SPI node overlay causing kernel panic

Okay, here’s the thing, “rohm,dh2228fv” for some reason is not being recognized as a spidev node, so kernel doesn’t create a spidev pseudofile (i.e. /dev/spi0.0, dev/spi1.2, etc.)

Another thing here is that one of the GPIO CS lines are overlaid ontop of default mmc1 pins.
So the kernel panics only whenever I enable eMMC and include this SPIDEV overlay.

But from the dmesg printout it didn’t want to list the P8_04 for some reason.
Namely, I assume that P8_15 & P8_16 are being used as the default mmc1_d6 & mmc1_d7, so it complained that it cannot get these

So I should just remap the mmc1_dat6/7 to R9 and T7 balls

Actually it does..

voodoo@26-am335x-bbg:~$ uname -r ; sudo beagle-version | grep UBOOT
5.10.168-ti-r84
UBOOT: Booted Device-Tree:[am335x-boneblack-uboot.dts]
UBOOT: Loaded Overlay:[BB-ADC-00A0.kernel]
UBOOT: Loaded Overlay:[BB-BONE-eMMC1-01-00A0.kernel]
UBOOT: Loaded Overlay:[BB-SPIDEV0-00A0.kernel]
UBOOT: Loaded Overlay:[M-BB-BBG-00A0.kernel]
voodoo@26-am335x-bbg:/proc/device-tree/ocp/interconnect@48000000/segment@0/target-module@30000/spi@0/channel@0$ cat compatible 
rohm,dh2228fv
voodoo@26-am335x-bbg:~$ sudo modprobe spidev
voodoo@26-am335x-bbg:~$ ls /dev/spidev0.*
/dev/spidev0.0  /dev/spidev0.1
1 Like

Oh, so I should add spidev module to modules-load, since it’s no longer loaded by default?

Correct, as it’s a module, just add it to /etc/modules-load.d/*.conf

Regards,

1 Like

is there a way to instruct uboot overlay for emmc (#disable_uboot_overlay_emmc=1 in uEnv.txt) which loads the /boot/dtbs/5.10.168-ti-r84/overlays/BB-BONE-eMMC1-01-00A0.dtbo
it to load before any of the uboot_overlay_addr.

Found 0 extension board(s). 
uboot_overlays: \[fdt_buffer=0x200000\] ... 
uboot_overlays: uboot loading of \[BB-ADC-00A0.dtbo\] disabled by /boot/uEnv.txt \[disable_uboot_overlay_adc=1\]... 
uboot_overlays: loading /lib/firmware/BB-I2C1-00A0.dtbo ... 
1102 bytes read in 7 ms (153.3 KiB/s) 
uboot_overlays: loading /lib/firmware/VERBATIM-SPIDEV1-GEN2.dtbo ... 
2234 bytes read in 33 ms (65.4 KiB/s) 
uboot_overlays: loading /boot/dtbs/5.10.168-ti-r83/overlays/BB-BONE-eMMC1-01-00A0.dtbo ... 
1605 bytes read in 7 ms (223.6 KiB/s) 
uboot_overlays: uboot loading of \[BB-HDMI-TDA998x-00A0.dtbo\] disabled by /boot/uEnv.txt \[disable_uboot_overlay_video=1\]... 
loading /boot/initrd.img-5.10.168-ti-r83 ...

to switch SPIDEV overlay in front of eMMC1:

Found 0 extension board(s). 
uboot_overlays: \[fdt_buffer=0x200000\] ... 
uboot_overlays: uboot loading of \[BB-ADC-00A0.dtbo\] disabled by /boot/uEnv.txt \[disable_uboot_overlay_adc=1\]... 
uboot_overlays: loading /lib/firmware/BB-I2C1-00A0.dtbo ... 
1102 bytes read in 7 ms (153.3 KiB/s) 
uboot_overlays: loading /boot/dtbs/5.10.168-ti-r83/overlays/BB-BONE-eMMC1-01-00A0.dtbo ... 
1605 bytes read in 7 ms (223.6 KiB/s) 
uboot_overlays: loading /lib/firmware/VERBATIM-SPIDEV1-GEN2.dtbo ... 
2234 bytes read in 33 ms (65.4 KiB/s) 
uboot_overlays: uboot loading of \[BB-HDMI-TDA998x-00A0.dtbo\] disabled by /boot/uEnv.txt \[disable_uboot_overlay_video=1\]... 
loading /boot/initrd.img-5.10.168-ti-r83 ...

I guess I just need to order them like so in the uEnv.txt …

Or just combine them into one overlay.. If your spidev is using pins used by eMMC, it’s best to disable eMMC.. On one of the early lcd design’s it shared pins with the eMMC, this condition led up to eMMC file system corruption…

Regards,

Sure, I’d like to have the eMMC and the spidev chipselects though. No luck with reordering with uEnv.txt, so I’ll hedge my bets with simply combining them under one overlay (which was my initial idea)

When I used uboot_overlay_addr1 for eMMC1 and uboot_overlay_addr4 for SPIDEV I got this

U-Boot 2022.04-ge0d31da5 (Aug 04 2023 - 18:48:26 +0000)

CPU  : AM335X-GP rev 2.1
Model: TI AM335x BeagleBone Black
DRAM:  512 MiB
Reset Source: Global warm SW reset has occurred.
Reset Source: Power-on reset has occurred.
RTC 32KCLK Source: External.
Core:  150 devices, 14 uclasses, devicetree: separate
WDT:   Started wdt@44e35000 with servicing (60s timeout)
MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
Loading Environment from EXT4... ** File not found /boot/uboot.env **

** Unable to read "/boot/uboot.env" from mmc0:1 **
Board: BeagleBone Black
<ethaddr> not set. Validating first E-fuse MAC
BeagleBone Black:
BeagleBone Cape EEPROM: no EEPROM at address: 0x54
BeagleBone Cape EEPROM: no EEPROM at address: 0x55
BeagleBone Cape EEPROM: no EEPROM at address: 0x56
BeagleBone Cape EEPROM: no EEPROM at address: 0x57
Net:   eth2: ethernet@4a100000, eth3: usb_ether
Press SPACE to abort autoboot in 0 seconds
board_name=[A335BNLT] ...
board_rev=[EID0] ...
switch to partitions #0, OK
mmc0 is current device
SD/MMC found on device 0
Couldn't find partition 0:2 0x82000000
Can't set block device
Couldn't find partition 0:2 0x82000000
Can't set block device
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
Scanning disk mmc@48060000.blk...
Scanning disk mmc@481d8000.blk...
Found 3 disks
No EFI system partition
BootOrder not defined
EFI boot manager: Cannot load any image
gpio: pin 56 (gpio 56) value is 0
gpio: pin 55 (gpio 55) value is 0
gpio: pin 54 (gpio 54) value is 0
gpio: pin 53 (gpio 53) value is 1
switch to partitions #0, OK
mmc0 is current device
gpio: pin 54 (gpio 54) value is 1
Checking for: /uEnv.txt ...
Checking for: /boot/uEnv.txt ...
gpio: pin 55 (gpio 55) value is 1
2017 bytes read in 3 ms (656.3 KiB/s)
Loaded environment from /boot/uEnv.txt
Checking if uname_r is set in /boot/uEnv.txt...
gpio: pin 56 (gpio 56) value is 1
Running uname_boot ...
loading /boot/vmlinuz-5.10.168-ti-r83 ...
6656512 bytes read in 421 ms (15.1 MiB/s)
debug: [enable_uboot_overlays=1] ...
debug: [enable_uboot_cape_universal=1] ...
debug: [uboot_base_dtb_univ=am335x-boneblack-uboot-univ.dtb] ...
uboot_overlays: [uboot_base_dtb=am335x-boneblack-uboot-univ.dtb] ...
uboot_overlays: Switching too: dtb=am335x-boneblack-uboot-univ.dtb ...
loading /boot/dtbs/5.10.168-ti-r83/am335x-boneblack-uboot-univ.dtb ...
210706 bytes read in 21 ms (9.6 MiB/s)
Found 0 extension board(s).
uboot_overlays: [fdt_buffer=0x200000] ...
uboot_overlays: uboot loading of [BB-ADC-00A0.dtbo] disabled by /boot/uEnv.txt [disable_uboot_overlay_adc=1]...
uboot_overlays: loading /lib/firmware/BB-I2C1-00A0.dtbo ...
1102 bytes read in 7 ms (153.3 KiB/s)
uboot_overlays: loading /lib/firmware/BB-BONE-eMMC1-01-00A0.dtbo ...
1605 bytes read in 7 ms (223.6 KiB/s)
failed on fdt_overlay_apply(): FDT_ERR_NOTFOUND
uboot_overlays: loading /lib/firmware/VERBATIM-SPIDEV1-GEN2.dtbo ...
2234 bytes read in 32 ms (67.4 KiB/s)
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
failed on fdt_overlay_apply(): FDT_ERR_BADMAGIC
base fdt does did not have a /__symbols__ node
make sure you've compiled with -@
uboot_overlays: uboot loading of [BB-BONE-eMMC1-01-00A0.dtbo] disabled by /boot/uEnv.txt [disable_uboot_overlay_emmc=1]...
uboot_overlays: uboot loading of [BB-HDMI-TDA998x-00A0.dtbo] disabled by /boot/uEnv.txt [disable_uboot_overlay_video=1]...
loading /boot/initrd.img-5.10.168-ti-r83 ...
8806096 bytes read in 562 ms (14.9 MiB/s)
debug: [console=ttyS0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100] ...
debug: [bootz 0x82000000 0x88080000:865ed0 88000000] ...
Kernel image @ 0x82000000 [ 0x000000 - 0x659200 ]
ERROR: Did not find a cmdline Flattened Device Tree
Could not find a valid device tree
** Invalid partition 2 **
Couldn't find partition mmc 0:2
** Invalid partition 3 **
Couldn't find partition mmc 0:3
** Invalid partition 4 **
Couldn't find partition mmc 0:4
** Invalid partition 5 **
Couldn't find partition mmc 0:5
** Invalid partition 6 **
Couldn't find partition mmc 0:6
** Invalid partition 7 **
Couldn't find partition mmc 0:7
switch to partitions #0, OK
mmc1(part 0) is current device
** No partition table - mmc 1 **
Couldn't find partition mmc 1:1
gpio: pin 56 (gpio 56) value is 0
gpio: pin 55 (gpio 55) value is 0
gpio: pin 54 (gpio 54) value is 0
gpio: pin 53 (gpio 53) value is 1
switch to partitions #0, OK
mmc1(part 0) is current device
gpio: pin 54 (gpio 54) value is 1
** No partition table - mmc 1 **
Couldn't find partition mmc 1:1
Checking for: /uEnv.txt ...
** No partition table - mmc 1 **
Couldn't find partition mmc 1:1
Checking for: /boot/uEnv.txt ...
** No partition table - mmc 1 **
Couldn't find partition mmc 1:1
** No partition table - mmc 1 **
Couldn't find partition mmc 1:2
** No partition table - mmc 1 **
Couldn't find partition mmc 1:3
** No partition table - mmc 1 **
Couldn't find partition mmc 1:4
** No partition table - mmc 1 **
Couldn't find partition mmc 1:5
** No partition table - mmc 1 **
Couldn't find partition mmc 1:6
** No partition table - mmc 1 **
Couldn't find partition mmc 1:7
starting USB...
Bus usb@47401800: Port not available.
USB is stopped. Please issue 'usb start' first.
starting USB...
Bus usb@47401800: Port not available.
link up on port 0, speed 100, full duplex
BOOTP broadcast 1
DHCP client bound to address 10.42.0.234 (5 ms)
Using ethernet@4a100000 device
TFTP from server 10.42.0.1; our IP address is 10.42.0.234
Filename 'vmlinuz-5.10.168-ti-r83'.
Load address: 0x82000000
Loading: T 

should probably go with the dts fragments instead?

side note, get rid of this.. “it’s useful” for new users, but gets in the way for everything you try to do..

Regards,

1 Like

BTW… once “FDT_ERR_NOTFOUND” occurs, the memory u-boot used to apply the overlay is now corrupt and anything after is completely invalid.. (aka don’t spend time debugging anything after)

1 Like

Yes, I’ve used some other development image (that is less secured) on which I’ve built dtbos natively via BeaglBone-DeviceTrees. However it’s kernel was r83, while the device tree’s one was probably building for r84.

Anyway, defaulting back to my regular bulid system with everything aligned seems to work. So I’m going to batch automate a bunch of trial runs.

Still not sure if the FDT_ERR_BADMAGIC is cursing me here ...


I’ll try with a newer kernel 5.12 (than 5.10), or rather with 6.1x some time later

Although I don’t see any symbols from the backtrace that were touched there …

FWIW, I might even try just disabling DMA for SPI and go with PIO
Or delayed spidev driver load

Switching the order so that BB-BONE-eMMC1-01-00A0 overlay loads before my custom one, seems to increase number of times I get the kernel crash.

For now I highly suspect that issue could be resolved with

Was able to do it

Decided to drop cs-gpios, instead using userspace managed gpio switching