Hello,
I have not found instructions on how to enable SPI port on Orange Pi Zero board.
I am running balenaOS 2.53.9+rev1 on the board. Many thanks for any pointers.
Rostislav
Hi there, I’m not familiar with the Orange Pi Zero, but I believe it should be enabled by default since it’s a RPI based board. You can find more info about enabling various interfaces here: https://www.balena.io/docs/learn/develop/hardware/i2c-and-spi/, let us know if that helps.
Hi,
when I ssh into host OS, there is no /dev/spidev* interface.
root@3894a67:~# ls /dev/s*
/dev/snapshot /dev/stderr /dev/stdin /dev/stdout
/dev/shm:
root@3894a67:~#
It looks that it is not enabled by default.
Hi there Rostislav,
Have you already tried explicitly turning on the SPI interface via configuration variables (more information available here: https://www.balena.io/docs/reference/OS/advanced/#setting-device-tree-overlays-dtoverlay-and-parameters-dtparam)? Specifically, I think you’ll need to set something like RESIN_HOST_CONFIG_dtparam="spi=on"
as a device configuration variable. After that setting is applied, the device should reboot and come up with SPI enabled.
Hi,
yes, I have added RESIN_HOST_CONFIG_dtparam=“spi=on”, but when I reboot the device from cloud, device is being powered off. When I boot the device again no change in config file and no SPI interface present.
root@3894a67:~# cat /resin-boot/config.json
{
“deviceType”: “orange-pi-zero”,
“hostname”: “balena”,
“localMode”: true,
“persistentLogging”: false
}
root@3894a67:~# cat /mnt/boot/config.json
{“apiEndpoint”:“https://api.balena-cloud.com”,“appUpdatePollInterval”:900000,“applicationId”:“1763314”,“deltaEndpoint”:"https://delta.balena-cloud.com",“deviceApiKey”:“b28e361fada7fd0c5512cfff670603f0”,“deviceApiKeys”:{“api.balena-cloud.com”:“b28e361fada7fd0c5512cfff670603f0”},“deviceType”:“orange-pi-zero”,“listenPort”:“48484”,“mixpanelToken”:“9ef939ea64cb6cd8bbc96af72345d70d”,“registryEndpoint”:“registry2.balena-cloud.com”,“userId”:“10496”,“vpnEndpoint”:“vpn.balena-cloud.com”,“vpnPort”:“443”,“uuid”:“3894a677ca50e3feb08ee75d1e5abc7f”,“registered_at”:1605222683883,“deviceId”:4053816}root@3894a67:~#
Actually, hang on a moment, this device is an Orange Pi, not a Raspberry Pi, so those links about setting “spi-on” via Environment Variables might not work… I don’t have one of these boards to test on, but, can you ls -al
the /boot partition, and any subfolders, on the device, and share with us? I don’t know what files exist there on an Orange Pi. That may give us some hints of what to modify though.
root@3894a67:~# ls -al /resin-boot/
total 8751
drwxr-xr-x 5 root root 1024 Aug 10 13:47 .
drwxr-xr-x 1 root root 1024 Aug 10 13:48 …
-rw-r–r-- 1 root root 714 Aug 10 13:47 boot.scr
-rw-r–r-- 1 root root 112 Aug 10 13:47 config.json
-rw-r–r-- 1 root root 2131 Aug 10 13:47 device-type.json
drwxr-xr-x 3 root root 1024 Aug 10 13:47 dtb
-rw-r–r-- 1 root root 0 Aug 10 13:47 extra_uEnv.txt
-rw-r–r-- 1 root root 42 Aug 10 13:47 image-version-info
-rw-r–r-- 1 root root 206 Aug 10 13:47 os-release
-rw-r–r-- 1 root root 24 Aug 10 13:47 resin-image
-rw-r–r-- 1 root root 1976 Aug 10 13:47 resinos.fingerprint
drwxr-xr-x 2 root root 1024 Aug 10 13:47 splash
drwxr-xr-x 2 root root 1024 Aug 10 13:47 system-connections
-rw-r–r-- 1 root root 426063 Aug 10 13:47 u-boot-sunxi-with-spl.bin
-rw-r–r-- 1 root root 8525504 Aug 10 13:47 uImage
root@3894a67:~# ls -al /resin-boot/dtb/overlay/
total 27
drwxr-xr-x 2 root root 1024 Aug 10 13:47 .
drwxr-xr-x 3 root root 1024 Aug 10 13:47 …
-rw-r–r-- 1 root root 339 Aug 10 13:47 sun8i-h3-analog-codec.dtbo
-rw-r–r-- 1 root root 384 Aug 10 13:47 sun8i-h3-cir.dtbo
-rw-r–r-- 1 root root 4155 Aug 10 13:47 sun8i-h3-fixup.scr
-rw-r–r-- 1 root root 374 Aug 10 13:47 sun8i-h3-i2c0.dtbo
-rw-r–r-- 1 root root 374 Aug 10 13:47 sun8i-h3-i2c1.dtbo
-rw-r–r-- 1 root root 374 Aug 10 13:47 sun8i-h3-i2c2.dtbo
-rw-r–r-- 1 root root 778 Aug 10 13:47 sun8i-h3-pps-gpio.dtbo
-rw-r–r-- 1 root root 862 Aug 10 13:47 sun8i-h3-pwm.dtbo
-rw-r–r-- 1 root root 1040 Aug 10 13:47 sun8i-h3-spdif-out.dtbo
-rw-r–r-- 1 root root 1177 Aug 10 13:47 sun8i-h3-spi-add-cs1.dtbo
-rw-r–r-- 1 root root 804 Aug 10 13:47 sun8i-h3-spi-jedec-nor.dtbo
-rw-r–r-- 1 root root 788 Aug 10 13:47 sun8i-h3-spi-spidev.dtbo
-rw-r–r-- 1 root root 502 Aug 10 13:47 sun8i-h3-uart1.dtbo
-rw-r–r-- 1 root root 502 Aug 10 13:47 sun8i-h3-uart2.dtbo
-rw-r–r-- 1 root root 502 Aug 10 13:47 sun8i-h3-uart3.dtbo
-rw-r–r-- 1 root root 504 Aug 10 13:47 sun8i-h3-usbhost0.dtbo
-rw-r–r-- 1 root root 504 Aug 10 13:47 sun8i-h3-usbhost1.dtbo
-rw-r–r-- 1 root root 504 Aug 10 13:47 sun8i-h3-usbhost2.dtbo
-rw-r–r-- 1 root root 777 Aug 10 13:47 sun8i-h3-w1-gpio.dtbo
root@3894a67:~#
What is in that “extra_uEnv.txt” file? Can you cat
that and post it’s contents? Perhaps this is the place to set the overlays, which we can clearly see are sitting in that “dtb” folder.
File is empty.
Hmmmm, so, searching through the forums, I have found this: BalenaOS OrangePi One building custom balenaOS image with additional Kernel Devicetree
It seems that you need to inject the Overlay as described in Post 29: BalenaOS OrangePi One building custom balenaOS image with additional Kernel Devicetree
Many thanks for the pointers. Trying them:
$ mount -o remount,rw /
$ mkdir -p /sys/kernel/config/device-tree/overlays/spi
$ cd /mnt/boot/dtb/overlay
$ cat “sun8i-h3-spi-spidev.dtbo” > /sys/kernel/config/device-tree/overlays/spi/dtbo
But still SPI is not present.
I see from log:
[ 541.760992] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /aliases/spi0
[ 541.770209] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /aliases/spi1
Hi, unfortunately we don’t have this board as it’s community supported, but it might be the spidev dtbo using status=“disabled”. While we don’t know why it’s set like that by upstream, you can try:
- decompiling the spidev dtbo
- changing
status="disabled"
from “disabled” to “okay” - trying to load that on the board
the commands should be:
$ dtc -I dtb -O dts -o spidev.txt sun8i-h3-spi-spidev1.dtbo
$ vi spidev.txt # edit and switch from 'disabled' to 'okay'
$ dtc -I dts -O dtb -o sun8i-h3-spi-spidev1.dtbo spidev.txt
(and modprobe spidev
afterwards, if necessary)
tell us how it goes
At least on 2.46 you had to build the kernel module too (spidev.ko) before loading the device tree.
See here