diff mbox series

Enable RaspberryPi arm64 to netboot a compressed kernel image

Message ID 4651700a-cfbc-093b-a351-a184ea8ed901@schorsch-tech.de
State Deferred
Delegated to: Tom Rini
Headers show
Series Enable RaspberryPi arm64 to netboot a compressed kernel image | expand

Commit Message

Georg Gast Jan. 8, 2022, 5:18 a.m. UTC
This changes add
  - kernel_comp_addr_r=0x0800000
  - kernel_comp_size=0x0800000
to the default environment of the raspberry pi. With these two options
u-boot can uncompress a received compressed kernel and boot it.

I could just test these changes on raspberry pi 4B with 8GB of ram.

See the attached logs.

U-Boot 2021.10-dirty (Jan 08 2022 - 05:57:42 +0100)

DRAM:  7.9 GiB
RPI 4 Model B (0xd03114)
MMC:   mmc@7e300000: 0, mmc@7e340000: 1
Loading Environment from FAT... Card did not respond to voltage select! 
: -110
In:    serial
Out:   vidconsole
Err:   vidconsole
Net:   eth0: ethernet@7d580000
PCIe BRCM: link up, 5.0 Gbps x1 (SSC)
starting USB...
Bus usb@7e980000: USB DWC2
Bus xhci_pci: Register 5000420 NbrPorts 5
Starting the controller
USB XHCI 1.00
scanning bus usb@7e980000 for devices... 1 USB Device(s) found
scanning bus xhci_pci for devices... Failed to get keyboard state from 
device 1997:2433
2 USB Device(s) found
        scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0
U-Boot> setenv boot_targets "dhcp pxe"
U-Boot> boot

georg@rpi64-test:~$ dmesg
[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd083]
[    0.000000] Linux version 5.15.10-rt24-v8 (georg@hammerhead) 
(aarch64-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU 
Binutils for Debian) 2.35.2) #1 SMP PREEMPT_RT Wed Jan 5 21:06:46 CET 2022
[    0.000000] Machine model: Raspberry Pi 4 Model B Rev 1.4
[    0.000000] efi: UEFI not found.
[    0.000000] Reserved memory: created CMA memory pool at 
0x0000000037400000, size 64 MiB
[    0.000000] OF: reserved mem: initialized node linux,cma, compatible 
id shared-dma-pool
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000000000000-0x000000003fffffff]
[    0.000000]   DMA32    [mem 0x0000000040000000-0x00000000ffffffff]
[    0.000000]   Normal   [mem 0x0000000100000000-0x00000001ffffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x000000003b3fffff]
[    0.000000]   node   0: [mem 0x0000000040000000-0x00000000fbffffff]
[    0.000000]   node   0: [mem 0x0000000100000000-0x00000001ffffffff]
[    0.000000] Initmem setup node 0 [mem 
0x0000000000000000-0x00000001ffffffff]
[    0.000000] percpu: Embedded 27 pages/cpu s73392 r8192 d29008 u110592
[    0.000000] pcpu-alloc: s73392 r8192 d29008 u110592 alloc=27*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3
[    0.000000] Detected PIPT I-cache on CPU0
[    0.000000] CPU features: detected: Spectre-v2
[    0.000000] CPU features: detected: Spectre-v4
[    0.000000] CPU features: detected: ARM errata 1165522, 1319367, or 
1530923
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 
2028848
[    0.000000] Kernel command line: rw console=ttyAMA0,115200u8 
console=tty1 earlyprintk root=/dev/nfs 
nfsroot=192.168.160.19:/srv/netboot/rpi64/rootfs 
ip=192.168.160.42:192.168.160.19:192.168.160.1::rpi64-test.schorsch-tech.de 
nfsrootdebug
[    0.000000] Unknown kernel command line parameters "earlyprintk 
nfsrootdebug", will be passed to user space.
diff mbox series

Patch

From 41099ae6902a3f48f66cd36b009a2847ec61a5ae Mon Sep 17 00:00:00 2001
From: Georg Gast <georg@schorsch-tech.de>
Date: Sat, 8 Jan 2022 06:01:19 +0100
Subject: [PATCH] Enable RaspberryPi arm64 to netboot a compressed kernel
 image.

This changes add
 - kernel_comp_addr_r=0x0800000
 - kernel_comp_size=0x0800000
to the default environment of the raspberry pi. With these two options
u-boot can uncompress a received compressed kernel and boot it.

I could just test these changes on raspberry pi 4B with 8GB of ram.

See the attached logs.

U-Boot 2021.10-dirty (Jan 08 2022 - 05:57:42 +0100)

DRAM:  7.9 GiB
RPI 4 Model B (0xd03114)
MMC:   mmc@7e300000: 0, mmc@7e340000: 1
Loading Environment from FAT... Card did not respond to voltage select! : -110
In:    serial
Out:   vidconsole
Err:   vidconsole
Net:   eth0: ethernet@7d580000
PCIe BRCM: link up, 5.0 Gbps x1 (SSC)
starting USB...
Bus usb@7e980000: USB DWC2
Bus xhci_pci: Register 5000420 NbrPorts 5
Starting the controller
USB XHCI 1.00
scanning bus usb@7e980000 for devices... 1 USB Device(s) found
scanning bus xhci_pci for devices... Failed to get keyboard state from device 1997:2433
2 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0
U-Boot> setenv boot_targets "dhcp pxe"
U-Boot> boot

georg@rpi64-test:~$ dmesg
[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd083]
[    0.000000] Linux version 5.15.10-rt24-v8 (georg@hammerhead) (aarch64-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2) #1 SMP PREEMPT_RT Wed Jan 5 21:06:46 CET 2022
[    0.000000] Machine model: Raspberry Pi 4 Model B Rev 1.4
[    0.000000] efi: UEFI not found.
[    0.000000] Reserved memory: created CMA memory pool at 0x0000000037400000, size 64 MiB
[    0.000000] OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000000000000-0x000000003fffffff]
[    0.000000]   DMA32    [mem 0x0000000040000000-0x00000000ffffffff]
[    0.000000]   Normal   [mem 0x0000000100000000-0x00000001ffffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x000000003b3fffff]
[    0.000000]   node   0: [mem 0x0000000040000000-0x00000000fbffffff]
[    0.000000]   node   0: [mem 0x0000000100000000-0x00000001ffffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x00000001ffffffff]
[    0.000000] percpu: Embedded 27 pages/cpu s73392 r8192 d29008 u110592
[    0.000000] pcpu-alloc: s73392 r8192 d29008 u110592 alloc=27*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3
[    0.000000] Detected PIPT I-cache on CPU0
[    0.000000] CPU features: detected: Spectre-v2
[    0.000000] CPU features: detected: Spectre-v4
[    0.000000] CPU features: detected: ARM errata 1165522, 1319367, or 1530923
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 2028848
[    0.000000] Kernel command line: rw console=ttyAMA0,115200u8 console=tty1 earlyprintk root=/dev/nfs nfsroot=192.168.160.19:/srv/netboot/rpi64/rootfs ip=192.168.160.42:192.168.160.19:192.168.160.1::rpi64-test.schorsch-tech.de nfsrootdebug
[    0.000000] Unknown kernel command line parameters "earlyprintk nfsrootdebug", will be passed to user space.
---
 include/configs/rpi.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/configs/rpi.h b/include/configs/rpi.h
index 522b41c02d..4f106643ac 100644
--- a/include/configs/rpi.h
+++ b/include/configs/rpi.h
@@ -151,6 +151,9 @@ 
  * Even with the smallest possible CPU-GPU memory split of the CPU getting
  * only 64M, the remaining 25M starting at 0x02700000 should allow quite
  * large initrds before they start colliding with U-Boot.
+ *
+ * The kernel uncompression area is placed at 0x0800000 with 0x0800000 bytes.
+ * Even the first rpi had just 256M of RAM. This should be still work on it.
  */
 #define ENV_MEM_LAYOUT_SETTINGS \
 	"fdt_high=" FDT_HIGH "\0" \
@@ -159,7 +162,9 @@ 
 	"scriptaddr=0x02400000\0" \
 	"pxefile_addr_r=0x02500000\0" \
 	"fdt_addr_r=0x02600000\0" \
-	"ramdisk_addr_r=0x02700000\0"
+	"ramdisk_addr_r=0x02700000\0" \
+	"kernel_comp_addr_r=0x0800000\0" \
+	"kernel_comp_size=0x0800000\0"
 
 #if CONFIG_IS_ENABLED(CMD_MMC)
 	#define BOOT_TARGET_MMC(func) \
-- 
2.30.2