Index | Thread | Search

From:
"Peter J. Philipp" <pjp@delphinusdns.org>
Subject:
bootriscv64.efi workaround
To:
tech@openbsd.org
Date:
Wed, 20 Mar 2024 17:32:46 +0100

Download raw body.

Thread
  • Peter J. Philipp:

    bootriscv64.efi workaround

Hi,

I'm working on the Ox64 which has only 64 MB of RAM.  There is still much to
do but the most important thing right now is just to get it to boot to 
userland.  The efiboot wants 64 MB and errors that it can't allocate memory
and this causes the boot process to crash, patch under the see-for-yourself
paste:


Hit any key to stop autoboot:  0                                                
=> fdt addr $fdtcontroladdr ; fdt move $fdtcontroladdr 50ffc000 ;  env set loada
ddr 50f00000 ; load mmc 0 $loadaddr efi/boot/bootriscv64.efi;bootefi $loadaddr 5
0ffc000                                                                         
Working FDT set to 53f3a4c0                                                     
Working FDT set to 50ffc000                                                     
148524 bytes read in 15 ms (9.4 MiB/s)                                          
No EFI system partition                                                         
No EFI system partition                                                         
Failed to persist EFI variables                                                 
Booting /efi\boot\bootriscv64.efi                                               
Can't allocate memory                                                           
disks: sd0*                                                                     
>> OpenBSD/riscv64 BOOTRISCV64 1.5                                              
boot> reboot                       

########################################################## next boot


U-Boot 2023.04-rc1 (Mar 10 2024 - 13:15:01 +0100)

DRAM:  64 MiB
Core:  38 devices, 17 uclasses, devicetree: board
MMC:   mmc@20060000: 0
Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1...
Loading Environment from nowhere... OK
In:    serial@2000a100
Out:   serial@2000a100
Err:   serial@2000a100
Net:
Warning: emac@20070000 (eth0) using random MAC address - f6:c4:6c:47:65:ac
eth0: emac@20070000
Hit any key to stop autoboot:  0
=> fdt addr $fdtcontroladdr ; fdt move $fdtcontroladdr 50ffc000 ;  env set loadaddr 50f00000 ; load mmc 0 $loadaddr efi/boot/bootriscv64.efi;bootefi $loadaddr 50ffc000
Working FDT set to 53f3a4c0
Working FDT set to 50ffc000
148636 bytes read in 16 ms (8.9 MiB/s)
No EFI system partition
No EFI system partition
Failed to persist EFI variables
Booting /efi\boot\bootriscv64.efi
disks: sd0*
>> OpenBSD/riscv64 BOOTRISCV64 1.5
boot> boot bsd.rd -c
NOTE: random seed is being reused.
booting sd0a:bsd.rd: 2035616+1000100+8460832+537648 [184296+122+349632+191418]=0xd463f8
bootargs: -c
all mapped
type 0x4 pa 0x3ef80000 va 0x3ef80000 pages 0x40 attr 0x8
type 0x2 pa 0x50000000 va 0x50000000 pages 0x800 attr 0x8
type 0x7 pa 0x50800000 va 0x50800000 pages 0x35e6 attr 0x8
type 0x2 pa 0x53de6000 va 0x53de6000 pages 0x4 attr 0x8
type 0x4 pa 0x53dea000 va 0x53dea000 pages 0x1 attr 0x8
type 0x7 pa 0x53deb000 va 0x53deb000 pages 0x1 attr 0x8
type 0x2 pa 0x53dec000 va 0x53dec000 pages 0x100 attr 0x8
type 0x1 pa 0x53eec000 va 0x53eec000 pages 0x25 attr 0x8
type 0x4 pa 0x53f11000 va 0x53f11000 pages 0x4 attr 0x8
type 0x9 pa 0x53f15000 va 0x53f15000 pages 0x7 attr 0x8
type 0x4 pa 0x53f1c000 va 0x53f1c000 pages 0x1 attr 0x8
type 0x6 pa 0x53f1d000 va 0x53f1d000 pages 0x1 attr 0x8000000000000008
type 0x4 pa 0x53f1e000 va 0x53f1e000 pages 0x3 attr 0x8
type 0x6 pa 0x53f21000 va 0x53f21000 pages 0x1 attr 0x8000000000000008
type 0x4 pa 0x53f22000 va 0x53f22000 pages 0x1 attr 0x8
type 0x6 pa 0x53f23000 va 0x53f23000 pages 0x6 attr 0x8000000000000008
type 0x4 pa 0x53f29000 va 0x53f29000 pages 0xd attr 0x8
type 0x3 pa 0x53f36000 va 0x53f36000 pages 0x47 attr 0x8
type 0x5 pa 0x53f7d000 va 0x53f7d000 pages 0x1 attr 0x8000000000000008
type 0x3 pa 0x53f7e000 va 0x53f7e000 pages 0x82 attr 0x8
Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2024 OpenBSD. All rights reserved.  https://www.OpenBSD.org

OpenBSD 7.4-current (RAMDISK) #426: Tue Jan 30 07:46:45 MST 2024
    deraadt@riscv64.openbsd.org:/usr/src/sys/arch/riscv64/compile/RAMDISK
real mem  = 67108864 (64MB)
avail mem = 34902016 (33MB)
SBI: OpenSBI v1.2, SBI Specification Version 1.0
User Kernel Config
UKC> quit
Continuing...
random: boothowto does not indicate good seed
mainbus0 at root: Pine64 Ox64 (D0)
cpu0 at mainbus0: T-Head arch 0 imp 0 rv64imafdc
intc0 at cpu0
cpu0: 32KB 64b/line 128-way L1 I-cache, 32KB 64b/line 256-way L1 D-cache
plic0 at mainbus0
"clk-ext-xtal" at mainbus0 not configured
simplebus0 at mainbus0: "bus"
"syscon" at simplebus0 not configured
"gpip" at simplebus0 not configured
"clock-controller" at simplebus0 not configured
"serial" at simplebus0 not configured
"spi" at simplebus0 not configured
"i2c" at simplebus0 not configured
"pwm" at simplebus0 not configured
"timer" at simplebus0 not configured
"ir" at simplebus0 not configured
"i2c" at simplebus0 not configured
"serial" at simplebus0 not configured
"i2s" at simplebus0 not configured
"dma" at simplebus0 not configured
"syscon" at simplebus0 not configured
"syscon" at simplebus0 not configured
"audio" at simplebus0 not configured
"efuse" at simplebus0 not configured
"mmc" at simplebus0 not configured
"emac" at simplebus0 not configured
"dma" at simplebus0 not configured
"usb" at simplebus0 not configured
simplebus1 at mainbus0: "bus"
"syscon" at simplebus1 not configured
"dma" at simplebus1 not configured
"serial" at simplebus1 not configured
"i2c" at simplebus1 not configured
"i2c" at simplebus1 not configured
"clock-controller" at simplebus1 not configured
"spi" at simplebus1 not configured
"timer" at simplebus1 not configured
"memory-controller" at simplebus1 not configured
"timer" at mainbus0 not configured
softraid0 at root
scsibus0 at softraid0: 256 targets
root on rd0a swap on rd0b dump on rd0b
WARNING: CHECK AND RESET THE DATE!


Index: efiboot.c
===================================================================
RCS file: /cvs/src/sys/arch/riscv64/stand/efiboot/efiboot.c,v
retrieving revision 1.6
diff -u -p -u -r1.6 efiboot.c
--- efiboot.c	5 Jul 2023 09:25:55 -0000	1.6
+++ efiboot.c	20 Mar 2024 16:23:23 -0000
@@ -612,11 +612,19 @@ machdep(void)
 	/*
 	 * The kernel expects to be loaded into a block of memory aligned
 	 * on a 2MB boundary.  We allocate a block of 64MB of memory, which
-	 * gives us plenty of room for growth.
+	 * gives us plenty of room for growth.  Step down to 8MB if we can't
+	 * allocate.
 	 */
 	if (efi_memprobe_find(EFI_SIZE_TO_PAGES(64 * 1024 * 1024),
-	    0x200000, &addr) != EFI_SUCCESS)
-		printf("Can't allocate memory\n");
+	    0x200000, &addr) != EFI_SUCCESS) {
+		/* try again */
+		if (efi_memprobe_find(EFI_SIZE_TO_PAGES(8 * 1024 * 1024),
+			0x200000, &addr) != EFI_SUCCESS)
+			printf("Can't allocate memory\n");
+	}
+
+
+
 	efi_loadaddr = addr;
 
 	efi_timer_init();


Best Regards,
-pjp