2

I'm trying to do a spi loopback test with a raspberry pi 3 model B+ with kernel patched with RT_PREEMPT.

This is the loopback test being attempted: Link

To run the test you must specify a path such as /dev/spidev0.0. I have no such file in /dev:

pi@raspberrypi:~ $ ls /dev | grep spi
pi@raspberrypi:~ $ 

The kernel version:

pi@raspberrypi:~ $ uname -r
4.9.80-rt62-v7+

I think the settings in /boot/config.txt are what they are supposed to be and I've rebooted a few times since setting it this way:

pi@raspberrypi:/boot $ cat config.txt | grep spi
dtparam=spi=on

There seems to be all sorts of spi stuff in the loaded device tree:

pi@raspberrypi:~ $ dtc -I fs /proc/device-tree | grep 'spi'
<stdout>: Warning (unit_address_vs_reg): Node /soc has a reg or ranges property, but no unit name
<stdout>: Warning (unit_address_vs_reg): Node /soc/vchiq has a reg or ranges property, but no unit name
<stdout>: Warning (unit_address_vs_reg): Node /soc/gpiomem has a reg or ranges property, but no unit name
<stdout>: Warning (unit_address_vs_reg): Node /soc/local_intc has a reg or ranges property, but no unit name
<stdout>: Warning (unit_address_vs_reg): Node /soc/axiperf has a reg or ranges property, but no unit name
<stdout>: Warning (unit_address_vs_reg): Node /memory has a reg or ranges property, but no unit name
<stdout>: Warning (unit_address_vs_reg): Node /axi/vc_mem has a reg or ranges property, but no unit name
<stdout>: Warning (avoid_default_addr_size): Relying on default #address-cells value for /axi/vc_mem
<stdout>: Warning (avoid_default_addr_size): Relying on default #size-cells value for /axi/vc_mem
        spi = "", "", "", "!status";
        spi2 = "/soc/spi@7e2150c0";
        spi0 = "/soc/spi@7e204000";
        spidev1 = "/soc/spi@7e204000/spidev@1";
        spi0_gpio35 = "/soc/gpio@7e200000/spi0_gpio35";
        spi = "/soc/spi@7e204000";
        spi0_pins = "/soc/gpio@7e200000/spi0_pins";
        spi0_gpio7 = "/soc/gpio@7e200000/spi0_gpio7";
        spi1 = "/soc/spi@7e215080";
        spi1_gpio16 = "/soc/gpio@7e200000/spi1_gpio16";
        spi2_gpio40 = "/soc/gpio@7e200000/spi2_gpio40";
        spi0_cs_pins = "/soc/gpio@7e200000/spi0_cs_pins";
        spidev0 = "/soc/spi@7e204000/spidev@0";
            spi0_gpio35 {
            spi0_pins {
            spi0_gpio7 {
            spi1_gpio16 {
            spi2_gpio40 {
            spi0_cs_pins {
        spi@7e204000 {
            compatible = "brcm,bcm2835-spi";
            spidev@1 {
                compatible = "spidev";
                spi-max-frequency = <0x7735940>;
            spidev@0 {
                compatible = "spidev";
                spi-max-frequency = <0x7735940>;
        spi@7e215080 {
            compatible = "brcm,bcm2835-aux-spi";
        spi@7e2150c0 {
            compatible = "brcm,bcm2835-aux-spi";
        spi2 = "/soc/spi@7e2150c0";
        spi0 = "/soc/spi@7e204000";
        spi1 = "/soc/spi@7e215080";

Any hints?

--Edit after some good hints in the comments --

I think I forgot to copy the /lib/modules/4.9.80-rt62-v7+/* files from the host where I built the kernel to the target.

adam@hostWhereKernelWasCrossCompiled:~/rtBuild_4_9$ find -iregex '.*spidev.*'
./lib/modules/4.9.80-rt62-v7+/kernel/drivers/spi/spidev.ko

pi@raspberrypi:/lib $ find -iregex '.spidev.' ./modules/4.14.34-v7+/kernel/drivers/spi/spidev.ko

No modules for 4.9.80-rt62-v7+ (the active kernel) are installed on the target.

Glorfindel
  • 620
  • 1
  • 8
  • 15
Adam
  • 41
  • 1
  • 4
  • look in the output of dmesg for references to SPI – Jaromanda X May 06 '18 at 23:02
  • dmesg | grep -i 'spi' returns nothing – Adam May 06 '18 at 23:09
  • how about lsmod | grep -i spi – Jaromanda X May 06 '18 at 23:12
  • lsmod returns nothing at all. Even without piping it into grep. – Adam May 06 '18 at 23:15
  • oh, well, that is odd - where did you get this kernel patched with RT_PREEMPT ... edit: never mind - found it – Jaromanda X May 06 '18 at 23:18
  • I built it :) I recall there was something about 'modularizing' stuff in the menuconfig tool and I didn't do it. – Adam May 06 '18 at 23:22
  • oh, so you've built a kernel without modules - have you included all the drivers you need inside the kernel? (e.g., spidev and another one whose name escapes me) – Jaromanda X May 06 '18 at 23:23
  • adam@hostWhereKernelWasBuilt:~/projects/raspberrypi/rtKernel/rtBuild_4_9$ find -iregex '.spidev.' ./lib/modules/4.9.80-rt62-v7+/kernel/drivers/spi/spidev.ko – Adam May 06 '18 at 23:31
  • the spi modules in the standard kernel are: spi-bcm2835 and spidev (these two are loaded when you change config.txt as you have done) - but then there's also spi-bcm2835aux ad714x-spi adxl34x-spi psxpad-spi bmp280-spi mmc_spi of_mmc_spi spi-nor arizona-spi cxd2880-spi - not sure if you'd need any of those as well – Jaromanda X May 06 '18 at 23:32
  • Hang on, you have a lib/modules/ folder - yet you say you didn't "modularize"? – Jaromanda X May 06 '18 at 23:33
  • Maybe somethings were modularized and others were not. You know what though, I think I copied the wrong modules or forgot to copy them into the target machine. I'm editing the question now to show my new findings. – Adam May 06 '18 at 23:36

1 Answers1

2

/dev/spidev wasn't showing up because files were missing in /lib/modules.

I cross compiled the rt kernel and when I was installing it on the target I forgot to copy the /lib/modules/4.9.80-rt62-v7+ and /lib/firmware.

After copying the contents of those directories onto the taget and rebooting /dev/spidev exists!

pi@raspberrypi:~ $ ls /dev | grep spi
spidev0.0
spidev0.1
Adam
  • 41
  • 1
  • 4