[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to enable spi on Raspberry Pi 4 (bookworm)?



Am Sun, 30 Oct 2022 19:32:17 +0100
schrieb Diederik de Haas <didi.debian@cknow.org>:

> On Sunday, 30 October 2022 18:04:28 CET Sebastian Kuzminsky wrote:
> > The Raspbian Buster armhf binaries can be made to run on Debian
> > Bookworm arm64 with a little bit of coaxing, but they rely on
> > kernel features that are not in Bookworm's arm64 kernel  
> 
> Do you know which kernel features?
> I can then create a MR to get those enabled in Debian's Bookworm
> kernel.

I got this working some time ago. I used a mainline kernel with PREEMPT
RT and a CAN driver over SPI. 

https://forums.raspberrypi.com/viewtopic.php?t=329789
and
https://forums.raspberrypi.com/viewtopic.php?t=338859

I use uboot to apply the overlay. It is important that the DTCs are
compiled with the "-@" option. I compile the kernel on my amd64 machine
with 

time ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- DTC_FLAGS="-@" make
deb-pkg -j16

With u-boot i use the extlinux boot configuration with a custom patch
that got sadly not accepted (or maybe igored) from u-boot upstream. With
that patch i can apply the overlays on raspi. The patch is based on
u-boot 2021.07. set the distro_bootcmd to your partition. This can be
tricky if you are not expierenced with u-boot. In my case it looks like

setenv distro_bootcmd="sysboot mmc 0:3 any 0x02400000
/boot/extlinux/extlinux.conf"
saveenv
reset

over the uart at the bootup.

0x02400000 is explained by the other vars. As far as i remember it is
the load address for the extlinux.conf file.

mmc 0:3 = first mmc thired partition. My layout is:
1: firmware (u-boot and the basic fdts also the u-boot environment)
2: swap
3: root

The default debian kernel works but the device tree is not compiled
with "-@". So you cant apply any overlays.

ovmerge, i downloaded from the raspi Site
https://github.com/raspberrypi/utils/blob/master/ovmerge/ovmerge

Hope that helps :)

Best regards
Georg


Attachment: merged.dts
Description: audio/vnd.dts

Attachment: make-merged.sh
Description: application/shellscript

Attachment: rtc.dts
Description: audio/vnd.dts

Attachment: spidev3.dts
Description: audio/vnd.dts

>From cc3c2d4ee591414c368b667b33b4b24b36f6fbb8 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 | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/configs/rpi.h b/include/configs/rpi.h
index 522b41c02d..41cd721f6e 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,10 @@
 	"scriptaddr=0x02400000\0" \
 	"pxefile_addr_r=0x02500000\0" \
 	"fdt_addr_r=0x02600000\0" \
-	"ramdisk_addr_r=0x02700000\0"
+	"fdtoverlay_addr_r=0x026A0000\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

Attachment: config-2021.07
Description: Binary data

Attachment: extlinux.conf
Description: Binary data


Reply to: