All of lore.kernel.org
 help / color / mirror / Atom feed
* SPI on Raspberry Pi (RPi) 4 + Ubuntu24.04 + EVL does not work
@ 2025-01-30 13:55 Gijs van Oort
  2025-01-30 18:00 ` Philippe Gerum
  0 siblings, 1 reply; 2+ messages in thread
From: Gijs van Oort @ 2025-01-30 13:55 UTC (permalink / raw)
  To: xenomai

I am trying to get SPI working on the EVL kernel on a Raspberry Pi 4 
with Ubuntu 24.04 Sever 64 bits. And I fail. Can anyone shine a light on 
the problem?

Basically what I tried is the following: straightforward 
cloning-configuring-building-installing (a little different though 
because I compiled inside an LXC container running Ubuntu 24 on my 
laptop since my main install is Ubuntu 22 and I don't want to mix up 
versions):

1. Get sources:
    `git clone --depth=1 --branch=v6.6.y-evl-rebase 
https://source.denx.de/Xenomai/xenomai4/linux-evl`
2. Create .config file:
    `make O=../linux-evl-build ARCH=arm64 
CROSS_COMPILE=aarch64-linux-gnu- defconfig`
3. Update .config file to make sure EVL is on (CONFIG_EVL=y) and all 
relevant SPI modules are included as module (CONFIG_SPI=y; 
CONFIG_SPI_SPIDEV=m; CONFIG_SPI_BCM2835=m; CONfIG_SPI_BCM28356AUX=m; I 
don't bother about SPI_OOB for the moment) with command line scripts 
(`scripts/config --module SPI_SPIDEV`)
4. Resolve dependencies in .config:
    `make O=../linux-evl-build ARCH=arm64 
CROSS_COMPILE=aarch64-linux-gnu- olddefconfig`
5. Compile:
    `make -j$(nproc) O=../linux-evl-build ARCH=arm64 
CROSS_COMPILE=aarch64-linux-gnu- Image modules dtbs`
6. Create Ubuntu24-Server-64-bits SD card for the Raspberry Pi with 
Raspberry Pi Imager
7. Install new kernel:
    `sudo env PATH=$PATH make O=../linux-evl-build ARCH=arm64 
CROSS_COMPILE=aarch64-linux-gnu- INSTALL_PATH=$FSBOOT install`
    `sudo env PATH=$PATH make O=../linux-evl-build ARCH=arm64 
CROSS_COMPILE=aarch64-linux-gnu- INSTALL_MOD_PATH=$FSROOT modules_install`
8. Copy the new device tree file and make sure that it is used:
    `cp 
../linux-evl-build/arch/arm64/boot/dts/broadcom/bcm2711-rpi-4-b.dtb 
$FSBOOT/bcm2711-rpi-4-b-evl.dtb`
    `echo "device_tree=bcm2711-rpi-4-b-evl.dtb" >> 
/media/$USER/$SD_BOOT/config.txt`
9. Boot the Raspberry Pi with the created Ubuntu image plus new kernel

I don't bother about evl-lib at this moment (installing that will be 
trivial once SPI is running).

What I get is a booting and working system (`uname -a` shows that I 
indeed run the created EVL kernel) but without working SPI. Some 
observations (all observed in the system with the new installed kernel, 
unless otherwise specified):
* When I just run a fresh Ubuntu 24 Server install on the Raspberry Pi 
(no EVL kernel), spi works as expected (e.g., `echo "hello" > 
/dev/spidev0.0` as root works and gives the expected signals on the SPI 
pins).
* In config.txt, SPI is enabled (`dtparam=spi=on`)
* No SPI-related entries in /dev (`ls -al /dev/sp* -d` gives no hits)
* SPI modules are loaded (`lsmod | grep spi` shows both spidev and 
spi_bcm3835)
* I do see SPI related items in /proc/device_tree : `cat 
/proc/device-tree/soc/spi@7e204000/status` yields 'okay', suggesting 
that at least something SPI related should be enabled (also, the address 
7e204000 is indeed related to the default SPI port).
* `cat /proc/devices | grep spi` shows "153 spi", indicating that there 
is indeed some SPI driver active with 153 as major device number.
* All in all everything seems to be okay, except the fact that there is 
no spi related entry in /dev. Using `sudo mknod /dev/spidev0.0 c 153 0` 
does create an entry but it is not working (`echo "hello" > 
/dev/spidev0.0` as root gives the error message "bash: /dev/spidev0.0: 
No such device or address").
* Contrary to a fresh Ubuntu24 install, the commands `dtparam` and 
`dtoverlay` do not work. (on a fresh Ubuntu24 they do work and I am able 
to enable and disable spi at runtime with both `dtparam spi=on`/`dtparam 
spi=off` and `dtoverlay spi0-2cs` as root. The spi entries in /dev 
appear and disappear accordingly). On the version with the EVL kernel I 
get the error message "mount: /config/device-tree: mount point does not 
exist." when I try either function. Could this be a hint that 
dtparam/dtoverlay could not work at boot time (i.e., when parsing 
config.txt) either?

Other things I tried (none of them had any noticeable effect; all showed 
the behavior listed above):
* Last year I had a similar struggle in getting SPI to work on an Ubuntu 
22.04 Server for Raspberry Pi. I ended up using the work of Deniz Ugur 
(https://github.com/DenizUgur/RPi4-EVL-4xSPI), which gave a working 
setup (with 4 SPI's even, if only I could borrow one of those for this 
year...). That setup used kernel 5.15.119. Apart from a small patch to 
tweak the bcm2711-rpi-4-b.dts device tree file, and a customized .config 
there was nothing much to it. Unfortunately, trying to do the same 
patches (tried both literally with `patch` and conceptually by applying 
similar changes to the .dts file manually) to the 6.6 kernel did not 
have any effect. Note that on this system, `dtparam` and `dtoverlay` did 
not work either; apparently it is possible to get SPI working without 
that having to work.
* Tried many different .config files. Always made sure that the SPI 
related modules were included as module (also tried once or twice to 
include them built-into the kernel (CONFIG_SPI_SPIDEV=y etc) without any 
positive effect). All .config files gave the same behavior (SPI-wise).
* Kept the bcm2711-rpi-4-b.dtb file from the fresh Ubuntu 24 image 
instead of replacing it by the newly generated .dtb file (i.e., skipped 
step 8). I could not spot any difference in behavior.
* Cloned the Raspberry Pi Linux kernel (`git clone --depth=1 
https://github.com/raspberrypi/linux linux-rpi`) next to the EVL kernel 
and copied all relevant device tree files from the Raspberry Pi kernel 
into the EVL kernel directory; then used that for the device tree 
generation (specifically: arch/arm*/boot/dts/broadcom, 
arch/arm*/boot/dts/overlays, arch/arm64/configs and two .h files that ar 
required for the dts files).
* Copied a (known working, for Ubuntu22-kernel 5.15.119) 
bcm2711-rpi-r-b.dtb device tree file to the new image and used that.
* Tried EVL kernel 6.12.y

Now I'm officially out of ideas, so hopefully someone can help me...

Kind regards,

Gijs van Oort
University of Twente
The Netherlands

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-30 18:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-30 13:55 SPI on Raspberry Pi (RPi) 4 + Ubuntu24.04 + EVL does not work Gijs van Oort
2025-01-30 18:00 ` Philippe Gerum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.