Repository navigation
Description
Describe the bug
If I configure the device tree with 5 chip selects for SPI0, I am able to observe the chip selects go low (as expected) when I transfer a message to each of them. If I try to issue a transfer to the 5th configured chip select, I observe the chip-select pin going low--but stays low for much longer than expected eventually resulting in a TimeoutError: [Errno 110] Connection timed out.
I downloaded the kernel with hash 1e53604087930e7cf42eee3d42572d0d6f54c86a and loaded it onto the sd card. I believe this has the fix #6044 for #6020, #5858 and #5865 but I still have this issue.
Steps to reproduce the behaviour
- Set up device tree for five chip-selects for SPI0 using two default SPI CS pins and three GPIOs
- error reproducing example. The same issue also occurs with the C++ spidev implementation, but provided is python:
import spidev spi = spidev.SpiDev() spi.open(0, 4) to_send = [0x1, 0x2, 0x3] spi.xfer(to_send) - Configuring the fifth GPIO pin to another hardware pin results in the same problem.
Device (s)
Raspberry Pi 5
System
system information
raspberry pi 5 model b rev 1.0
pretty_name="debian gnu/linux 12 (bookworm)"
name="debian gnu/linux"
version_id="12"
version="12 (bookworm)"
raspberry pi reference 2024-03-15
generated using pi-gen, https://github.com/rpi-distro/pi-gen, f19ee211ddafcae300827f953d143de92a5c6624, stage2
linux piedpiper 6.6.30-v8-16k+ #1762 smp preempt thu may 9 15:18:59 bst 2024 aarch64 gnu/linux
revision : c04170
serial : 022f76c8c8c62e9a
model : raspberry pi 5 model b rev 1.0
throttled flag : throttled=0x0
camera : vc_gencmd_read_response returned -1 error=1 error_msg="command not registered"
videocore information
2024/04/20 11:53:30
copyright (c) 2012 broadcom
version d1744d21 (release) (embedded)
vc_gencmd_read_response returned -1
error=1 error_msg="command not registered"
filesystem information
filesystem 1k-blocks used available use% mounted on
udev 1899136 0 1899136 0% /dev
tmpfs 414240 5232 409008 2% /run
/dev/mmcblk0p2 60819080 4481464 53229288 8% /
tmpfs 2071136 0 2071136 0% /dev/shm
tmpfs 5120 48 5072 1% /run/lock
/dev/mmcblk0p1 522230 90424 431806 18% /boot/firmware
tmpfs 414224 0 414224 0% /run/user/1000
filename type size used priority
/var/swap file 102368 0 -2
package version information
raspberrypi-ui-mods:
installed: (none)
raspberrypi-sys-mods:
installed: 20240129
openbox:
installed: (none)
lxpanel:
installed: (none)
pcmanfm:
installed: (none)
rpd-plym-splash:
installed: (none)
networking information
eth0: flags=4163<up,broadcast,running,multicast> mtu 1500
inet x.x.x.x netmask x.x.x.x broadcast x.x.x.x
inet6 y::y.y.y.y prefixlen 64 scopeid 0x20
ether m.m.m.m txqueuelen 1000 (ethernet)
rx packets 48 bytes 8359 (8.1 kib)
rx errors 0 dropped 0 overruns 0 frame 0
tx packets 59 bytes 10287 (10.0 kib)
tx errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 107
lo: flags=73<up,loopback,running> mtu 65536
inet x.x.x.x netmask x.x.x.x
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (local loopback)
rx packets 10 bytes 1588 (1.5 kib)
rx errors 0 dropped 0 overruns 0 frame 0
tx packets 10 bytes 1588 (1.5 kib)
tx errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4099<up,broadcast,multicast> mtu 1500
ether m.m.m.m txqueuelen 1000 (ethernet)
rx packets 0 bytes 0 (0.0 b)
rx errors 0 dropped 0 overruns 0 frame 0
tx packets 0 bytes 0 (0.0 b)
tx errors 0 dropped 0 overruns 0 carrier 0 collisions 0
usb information
/: bus 04.port 1: dev 1, class=root_hub, driver=xhci-hcd/1p, 5000m
/: bus 03.port 1: dev 1, class=root_hub, driver=xhci-hcd/2p, 480m
/: bus 02.port 1: dev 1, class=root_hub, driver=xhci-hcd/1p, 5000m
/: bus 01.port 1: dev 1, class=root_hub, driver=xhci-hcd/2p, 480m
display information
running (f)kms, console
/sys/class/drm/card1-hdmi-a-1
/sys/class/drm/card1-hdmi-a-2
/sys/class/drm/card1-writeback-1
/sys/class/drm/card1-writeback-2
connector 0 (32) hdmi-a-1 (disconnected)
encoder 0 (31) tmds
connector 1 (41) hdmi-a-2 (disconnected)
encoder 1 (40) tmds
hdmi0: hdmi_hotplug = 0x00000000
hdmi1: hdmi_hotplug = 0x00000000
/sys/kernel/debug/dri/1/state:
plane[45]: plane-0
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=0
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[62]: plane-1
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=0
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[76]: plane-2
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=0
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[87]: plane-3
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=0
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[98]: plane-4
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=1
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[108]: plane-5
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=2
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[118]: plane-6
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=3
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[128]: plane-7
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=4
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[138]: plane-8
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=5
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[148]: plane-9
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=6
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[158]: plane-10
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=7
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[168]: plane-11
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=8
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[178]: plane-12
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=9
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[188]: plane-13
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=a
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[198]: plane-14
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=b
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[208]: plane-15
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=c
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[218]: plane-16
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=d
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[228]: plane-17
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=e
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[238]: plane-18
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=f
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[248]: plane-19
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=10
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[258]: plane-20
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=11
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[268]: plane-21
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=11
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[278]: plane-22
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=11
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
plane[288]: plane-23
crtc=(null)
fb=0
crtc-pos=0x0+0+0
src-pos=0.000000x0.000000+0.000000+0.000000
rotation=1
normalized-zpos=11
color-encoding=itu-r bt.709 ycbcr
color-range=ycbcr limited range
crtc[55]: mop
enable=0
active=0
self_refresh_active=0
planes_changed=0
mode_changed=0
active_changed=0
connectors_changed=0
color_mgmt_changed=0
plane_mask=0
connector_mask=0
encoder_mask=0
mode: "": 0 0 0 0 0 0 0 0 0 0 0x0 0x0
crtc[72]: moplet
enable=0
active=0
self_refresh_active=0
planes_changed=0
mode_changed=0
active_changed=0
connectors_changed=0
color_mgmt_changed=0
plane_mask=0
connector_mask=0
encoder_mask=0
mode: "": 0 0 0 0 0 0 0 0 0 0 0x0 0x0
crtc[86]: crtc-2
enable=0
active=0
self_refresh_active=0
planes_changed=0
mode_changed=0
active_changed=0
connectors_changed=0
color_mgmt_changed=0
plane_mask=0
connector_mask=0
encoder_mask=0
mode: "": 0 0 0 0 0 0 0 0 0 0 0x0 0x0
crtc[97]: crtc-3
enable=0
active=0
self_refresh_active=0
planes_changed=0
mode_changed=0
active_changed=0
connectors_changed=0
color_mgmt_changed=0
plane_mask=0
connector_mask=0
encoder_mask=0
mode: "": 0 0 0 0 0 0 0 0 0 0 0x0 0x0
connector[32]: hdmi-a-1
crtc=(null)
self_refresh_aware=0
max_requested_bpc=8
colorspace=default
connector[41]: hdmi-a-2
crtc=(null)
self_refresh_aware=0
max_requested_bpc=8
colorspace=default
connector[61]: writeback-1
crtc=(null)
self_refresh_aware=0
max_requested_bpc=0
colorspace=default
connector[75]: writeback-2
crtc=(null)
self_refresh_aware=0
max_requested_bpc=0
colorspace=default
config.txt
arm_64bit=1
arm_boost=1
arm_freq=2400
arm_freq_min=1500
arm_peri_high=1
audio_pwm_mode=2
auto_initramfs=1
avs_temp=57614
camera_auto_detect=1
core_freq=910
core_freq_min=500
disable_commandline_tags=2
disable_fw_kms_setup=1
disable_l2cache=1
disable_overscan=1
display_auto_detect=1
display_default_lcd=-1
display_hdmi_rotate=-1
display_lcd_rotate=-1
dvfs=4
enable_gic=1
enable_uart=-1
force_eeprom_read=1
force_pwm_open=1
framebuffer_depth=16
framebuffer_ignore_alpha=1
framebuffer_swap=1
gpu_freq_min=500
hdmi_enable_4kp60=1
hevc_freq=910
hevc_freq_min=500
ignore_lcd=-1
init_uart_clock=0x2dc6c00
isp_freq=910
isp_freq_min=500
mask_gpu_interrupt1=16418
max_framebuffers=2
over_voltage_avs=0x2e568
pause_burst_frames=1
pciex4_reset=1
pmic_turbo_threshold=600
program_serial_random=1
total_mem=4096
v3d_freq=960
v3d_freq_min=500
vpred=9498
vpred_max=9498
hdmi_force_cec_address:0=65535
hdmi_force_cec_address:1=65535
device_tree=-
overlay_prefix=overlays/
hdmi_cvt:0=
hdmi_cvt:1=
hdmi_edid_filename:0=
hdmi_edid_filename:1=
hdmi_timings:0=
hdmi_timings:1=
cmdline.txt
reboot=w coherent_pool=1m 8250.nr_uarts=1 pci=pcie_bus_safe smsc95xx.macaddr=d8:3a:dd:bd:e5:f8 vc_mem.mem_base=0x3fc00000 vc_mem.mem_size=0x40000000 console=ttyama10,115200 console=tty1 root=partuuid=e28bd33a-02 rootfstype=ext4 fsck.repair=yes rootwait
Logs
[ 145.448526] spidev spi0.4: SPI transfer timed out
[ 145.448541] spi_master spi0: failed to transfer one message from queue
[ 145.448544] spi_master spi0: noqueue transfer failed
Additional context
device tree overlay:
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target = <&spi0_cs_pins>;
frag0: __overlay__ {
brcm,pins = <8 7 5 6 13>;
};
};
fragment@1 {
target = <&spi0>;
frag1: __overlay__ {
#address-cells = <1>;
#size-cells = <0>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>, <&gpio 5 1>, <&gpio 6 1>, <&gpio 13 1>;
status = "okay";
spidev0_2: spidev@2 {
compatible = "spidev";
reg = <2>;
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev0_3: spidev@3 {
compatible = "spidev";
reg = <3>;
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
spidev0_4: spidev@4 {
compatible = "spidev";
reg = <4>;
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};
};
};
Activity
pelwell commentedon May 13, 2024
This issue appears to be Pi 5-specific - which is interesting considering that the CS lines are managed by the SPI framework as regular GPIOs. It's also worth saying explicitly that the problem seems to be with the 5th configured CS GPIO, whatever the order of the CS GPIOs.
spi: dw: Handle any number of gpiod CS lines
pelwell commentedon May 13, 2024
This behaviour is caused by a quirk of the RP1 SPI interface, and a deficiency in the driver to handle it. #6161 should be a fix for it. Wait about 45 minutes from now for the build checks on the PR to complete, then run
sudo rpi-update pulls/6161to install a trial 6.6 kernel with the fix. Back up any valuable data beforehand, just in case.itsarune commentedon May 14, 2024
Awesome, updated as you suggested and I can successfully transfer to the 5th chip-select as expected!
spi: dw: Handle any number of gpiod CS lines
pelwell commentedon May 14, 2024
Thanks for the feedback. The fix has been merged, and will be included in future kernel releases.
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
284 remaining items
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines
spi: dw: Handle any number of gpiod CS lines