question

Mike Dorsett avatar image
Mike Dorsett asked

Still on the trail to get SPI working on BBB

From https://community.victronenergy.com/questions/ask.html?space=31, describing the boot process:


The built-in environment in u-boot loads a default am335x-boneblack.dts to pass to the kernel at boot.

To override this default DTS, a uEnv.txt configuration file can be used to customize the u-boot environment. In the uEnv.txt you can explicitly specify a different DTS as well as the command line arguments to pass to the kernel.

There is no initrd used with the Venus BBB builds. U-boot goes directly to the final kernel.


So, to me this implies that there is a file "uEnv.txt" that should live in the boot folder. This file wasn't there after a clean install of the latest image. So I created the file with the following contents:

###U-Boot Overlays###
###Documentation: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#>
###Master Enable
enable_uboot_overlays=1
uboot_overlay_addr0=/dev/SPI0-00A0.dtbo

disable_uboot_overlay_video=1


I copied the .dtbo file into the dev directory as referenced. (ok so it should not normally be there..)

having rebooted the BBB, still no spi device listed in the dev folder.

Anyone have any pointers as to what is wrong? I suppose my next move is to add the debug terminal to watch the boot process to see if the uEnv.txt file is actually accessed.


Venus OSbeaglebone
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

2 Answers
Mike Dorsett avatar image
Mike Dorsett answered Ā·

Its been a while since I last visited this problem, and now have made some progress:

Notes: root@beaglebone is on the Venus OS

debian@beaglebone is from the Debian syatem

dt = device-tree

spi present in device- tree, but naming conveention differs:
Venus:
ocp{
interconnect@48000000 {
segment@0 {
target-module@30000 {
compatible = "ti,sysc-omap2\0ti,sysc";
reg = <0x30000 0x04 0x30110 0x04 0x30114 0x04>;
reg-names = "rev\0sysc\0syss";
ti,sysc-mask = <0x303>;
ti,sysc-sidle = <0x00 0x01 0x02>;
ti,syss-mask = <0x01>;
clocks = <0x2f 0x14 0x00>;
clock-names = "fck";
#address-cells = <0x01>;
#size-cells = <0x01>;
ranges = <0x00 0x30000 0x1000>;

Debian BBB:
ocp{
spi@48030000 {
compatible = "ti,omap4-mcspi";
#address-cells = <0x01>;
#size-cells = <0x00>;
reg = <0x48030000 0x400>;
interrupts = <0x41>;
ti,spi-num-cs = <0x02>;
ti,hwmods = "spi0";
dmas = <0x27 0x10 0x00 0x27 0x11 0x00 0x27 0x12 0x00 0x27 0x13 0x00>;
dma-names = "tx0\0rx0\0tx1\0rx1";
status = "disabled";
phandle = <0xc6>;
};
resulting in differences in /proc/device-tree/ocp directory:
Venus:
root@beaglebone:~# ls /proc/device-tree/ocp
#address-cells interconnect@47c00000 ranges target-module@49900000
#size-cells interconnect@48000000 sram@40300000 target-module@49a00000
compatible interconnect@4a000000 target-module@47400000 target-module@53100000
emif@4c000000 interconnect@4b140000 target-module@47810000 target-module@53500000
gpmc@50000000 interrupt-controller@48200000 target-module@49000000 target-module@56000000
interconnect@44c00000 name target-module@49800000 ti,hwmods

root@beaglebone:~# ls /proc/device-tree/ocp/interconnect@48000000
#address-cells compatible ranges reg-names segment@100000 segment@300000
#size-cells name reg segment@0 segment@200000

root@beaglebone:~# ls /proc/device-tree/ocp/interconnect@48000000/segment@0
#address-cells target-module@14000 target-module@30000 target-module@44000 target-module@50000 target-module@c8000
#size-cells target-module@16000 target-module@38000 target-module@46000 target-module@60000 target-module@ca000
compatible target-module@22000 target-module@3c000 target-module@48000 target-module@8000 target-module@cc000
name target-module@24000 target-module@40000 target-module@4a000 target-module@80000
ranges target-module@2a000 target-module@42000 target-module@4c000 target-module@a0000

root@beaglebone:~# ls /proc/device-tree/ocp/interconnect@48000000/segment@0/target-module@30000
#address-cells clock-names compatible ranges reg-names ti,sysc-mask ti,syss-mask
#size-cells clocks name reg spi@0 ti,sysc-sidle

root@beaglebone:~# ls /proc/device-tree/ocp/interconnect@48000000/segment@0/target-module@30000/spi@0
#address-cells compatible dmas name status
#size-cells dma-names interrupts reg ti,spi-num-cs


Debian:
debian@beaglebone:/var/lib/cloud9$ ls /proc/device-tree/ocp
A15_pinmux epwmss@48304000 lcdc@4830e000 P8_06_pinmux P8_18_pinmux P8_30_pinmux P8_42_pinmux P9_18_pinmux P9_30_pinmux serial@48022000 timer@44e31000 wdt@44e35000
'#address-cells' ethernet@4a100000 mailbox@480c8000 P8_07_pinmux P8_19_pinmux P8_31_pinmux P8_43_pinmux P9_19_pinmux P9_31_pinmux serial@48024000 timer@48040000
aes@53500000 gpio@44e07000 mcasp@48038000 P8_08_pinmux P8_20_pinmux P8_32_pinmux P8_44_pinmux P9_20_pinmux P9_41_pinmux serial@481a6000 timer@48042000
can@481cc000 gpio@4804c000 mcasp@4803c000 P8_09_pinmux P8_21_pinmux P8_33_pinmux P8_45_pinmux P9_21_pinmux P9_42_pinmux serial@481a8000 timer@48044000
can@481d0000 gpio@481ac000 mmc@47810000 P8_10_pinmux P8_22_pinmux P8_34_pinmux P8_46_pinmux P9_22_pinmux P9_91_pinmux serial@481aa000 timer@48046000
cape-universal gpio@481ae000 mmc@48060000 P8_11_pinmux P8_23_pinmux P8_35_pinmux P9_11_pinmux P9_23_pinmux P9_92_pinmux sgx@56000000 timer@48048000
compatible gpmc@50000000 mmc@481d8000 P8_12_pinmux P8_24_pinmux P8_36_pinmux P9_12_pinmux P9_24_pinmux phandle sham@53100000 timer@4804a000
edma@49000000 i2c@44e0b000 name P8_13_pinmux P8_25_pinmux P8_37_pinmux P9_13_pinmux P9_25_pinmux pruss-soc-bus@4a326004 '#size-cells' tptc@49800000
elm@48080000 i2c@4802a000 ocmcram@40300000 P8_14_pinmux P8_26_pinmux P8_38_pinmux P9_14_pinmux P9_26_pinmux ranges spi@48030000 tptc@49900000
emif@4c000000 i2c@4819c000 P8_03_pinmux P8_15_pinmux P8_27_pinmux P8_39_pinmux P9_15_pinmux P9_27_pinmux rng@48310000 spi@481a0000 tptc@49a00000
epwmss@48300000 interrupt-controller@48200000 P8_04_pinmux P8_16_pinmux P8_28_pinmux P8_40_pinmux P9_16_pinmux P9_28_pinmux rtc@44e3e000 spinlock@480ca000 tscadc@44e0d000
epwmss@48302000 l4_wkup@44c00000 P8_05_pinmux P8_17_pinmux P8_29_pinmux P8_41_pinmux P9_17_pinmux P9_29_pinmux serial@44e09000 ti,hwmods usb@47400000

debian@beaglebone:/var/lib/cloud9$ ls /proc/device-tree/ocp/spi@48030000
'#address-cells' channel@0 channel@1 compatible dma-names dmas interrupts name phandle pinctrl-0 pinctrl-names reg '#size-cells' status ti,hwmods ti,spi-num-cs

showing the much longer, convoluted path in Venus. ? Does this save much space? it certainly makes the DT file less readable.
Venus:root@beaglebone:~# cat /proc/device-tree/ocp/interconnect@48000000/segment@0/target-module@30000/spi@0/status
disabled
Debian:debian@beaglebone:/var/lib/cloud9$ cat /proc/device-tree/ocp/spi@48030000/status
okay
so: while all of the ocp tags in the DT are "disabled" as default, something else loads on top "The Device Driver" -refered to in the linux Device tree manual, but with no other references. Reluctant to change this in the DTS file and re-compile, as there are duplicate address warnings!!(and others).
Booting of the Kernel is supposed to sort out access to ocp's, but something is missing for the spi in venus.
Venus does not appear to have systemctl?
root@beaglebone:~# ls /sys/module
8250 can_raw ecdh_generic ipt_REJECT mmcblk omap_rng sdhci usbcore
block cfg80211 firmware_class iptable_filter musb_hdrc overlay spurious vt
bluetooth configfs industrialio ipv6 nf_conntrack printk sysrq watchdog
c_can cpufreq ip6_tables kernel nf_defrag_ipv4 random tcp_cubic workqueue
c_can_platform cpuidle ip6t_REJECT keyboard nf_defrag_ipv6 rcupdate ti_am335x_adc x_tables
can cryptomgr ip6table_filter kfifo_buf nf_reject_ipv4 rfkill ti_am335x_tscadc xt_conntrack
can_dev ecc ip_tables libcrc32c nf_reject_ipv6 rng_core ti_cpsw xt_tcpudp
(56 modules)
root@beaglebone:~# lsmod
Module Size Used by
cfg80211 557056 0
can_raw 20480 2
can 20480 1 can_raw
ip6t_REJECT 16384 3
nf_reject_ipv6 16384 1 ip6t_REJECT
ipt_REJECT 16384 3
nf_reject_ipv4 16384 1 ipt_REJECT
xt_tcpudp 16384 8
bluetooth 327680 4
ecdh_generic 16384 1 bluetooth
ecc 32768 1 ecdh_generic
rfkill 20480 4 bluetooth,cfg80211
ip6table_filter 16384 1
ip6_tables 28672 1 ip6table_filter
xt_conntrack 16384 2
nf_conntrack 77824 1 xt_conntrack
nf_defrag_ipv6 16384 1 nf_conntrack
libcrc32c 16384 1 nf_conntrack
nf_defrag_ipv4 16384 1 nf_conntrack
iptable_filter 16384 1
ip_tables 28672 1 iptable_filter
x_tables 24576 8 ipt_REJECT,ip_tables,iptable_filter,xt_tcpudp,ip6t_REJECT,ip6table_filter,xt_conntrack,ip6_tables
ti_am335x_adc 16384 0
kfifo_buf 16384 1 ti_am335x_adc
industrialio 49152 2 ti_am335x_adc,kfifo_buf
omap_rng 16384 0
rng_core 20480 1 omap_rng
c_can_platform 16384 0
c_can 20480 1 c_can_platform
can_dev 24576 1 c_can
ti_am335x_tscadc 16384 1 ti_am335x_adc
(31 loaded).

Debian:debian@beaglebone:/var/lib/cloud9$ ls /sys/module
8021q cec drm_kms_helper ftdi_sio ipv6 lockd nfs_layout_nfsv41_files printk remoteproc snd sunrpc ubifs usb_f_mass_storage vt zswap
8250 ch341 dynamic_debug fuse irq_pruss_intc mmcblk nfsv4 pru_rproc rfkill snd_pcm suspend u_ether usb_f_rndis watchdog
apparmor configfs ehci_hcd garp kernel module omapdrm pruss rng_core snd_timer sysrq uio usbserial wkup_m3_ipc
auth_rpcgss cpufreq etnaviv hid keyboard mrp omap_mailbox pruss_soc_bus scsi_mod soundcore tcp_cubic uio_pdrv_genirq usb_storage wkup_m3_rproc
blk_cgroup cryptomgr fb hid_logitech libahci netpoll onenand random sdhci spidev ti_cpsw usbcore u_serial workqueue
block dns_resolver firmware_class hid_logitech_hidpp libata nf_conntrack overlay rcupdate sg spurious tpm usb_f_acm virtio xhci_hcd
can drm fscrypto i2c_algo_bit libcomposite nfs pm33xx rcutree smsc95xx srcutree ubi usb_f_ecm virtio_ring xz_dec
(98 modules)

debian@beaglebone:/var/lib/cloud9$ lsmod
Module Size Used by
pru_rproc 28672 0
irq_pruss_intc 20480 1 pru_rproc
pruss 16384 1 pru_rproc
pm33xx 16384 0
wkup_m3_ipc 16384 1 pm33xx
wkup_m3_rproc 16384 1
remoteproc 57344 3 pru_rproc,wkup_m3_rproc,wkup_m3_ipc
virtio 16384 1 remoteproc
virtio_ring 28672 1 remoteproc
pruss_soc_bus 16384 0
ftdi_sio 49152 2
ch341 16384 1
usbserial 49152 8 ftdi_sio,ch341
usb_f_acm 16384 2
u_serial 20480 3 usb_f_acm
usb_f_ecm 20480 2
usb_f_mass_storage 53248 2
usb_f_rndis 32768 4
uio_pdrv_genirq 16384 0
u_ether 20480 2 usb_f_ecm,usb_f_rndis
uio 20480 1 uio_pdrv_genirq
libcomposite 65536 18 usb_f_ecm,usb_f_acm,usb_f_mass_storage,usb_f_rndis
spidev 20480 2

(23 loaded).
Note that in Debian there is an spidev module, which is loaded, in Venus there is not.
from opkg - list:
kernel-module-rtlwifi-5.10.109-venus-12 - 5.10.109-venus-12-r0
kernel-module-scsi-mod-5.10.109-venus-12 - 5.10.109-venus-12-r0
kernel-module-sd-mod-5.10.109-venus-12 - 5.10.109-venus-12-r0
kernel-module-sha256-generic-5.10.109-venus-12 - 5.10.109-venus-12-r0
kernel-module-slcan-5.10.109-venus-12 - 5.10.109-venus-12-r0
kernel-module-slhc-5.10.109-venus-12 - 5.10.109-venus-12-r0
kernel-module-smsc-5.10.109-venus-12 - 5.10.109-venus-12-r0
kernel-module-smsc75xx-5.10.109-venus-12 - 5.10.109-venus-12-r0
kernel-module-smsc95xx-5.10.109-venus-12 - 5.10.109-venus-12-r0
kernel-module-ssu100-5.10.109-venus-12 - 5.10.109-venus-12-r0
kernel-module-st-drv-5.10.109-venus-12 - 5.10.109-venus-12-r0
kernel-module-ti-am335x-adc-5.10.109-venus-12 - 5.10.109-venus-12-r0

so no kernel module spidev is listed....

So the conclusion is that Victron has not compiled the kernel-module for the spi port .




2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Mike Dorsett avatar image
Mike Dorsett answered Ā·

@mvader (Victron Energy) The problem appears to be that the SPI kernel module option has been missed out of the Venus makefile configuration.

I tried to copy the spidev.ko files from a beaglebone/Debian system to

ls /lib/modules/5.10.109-venus-11/kernel/drivers/spi

and load the module with:

insmod /lib/modules/5.10.109-venus-11/kernel/drivers/spi/spidev.ko

but got the error:
insmod: ERROR: could not insert module /lib/modules/5.10.109-venus-11/kernel/drivers/spi/spidev.ko: Invalid module format

This now appears to be a dead end, without a recompile of the whole os - but apparently one needs to have access to some Victron private repositories to do this..

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources

Victron Venus OS Open Source intro page

Venus OS GitHub (please do not post to this)

Additional resources still need to be added for this topic