balenaOS ignores dtoverlay?

Hi,

I’m trying to change the chip select pins for SPI0 by applying a device tree overlay. However it looks like the configuration is not getting applied correctly. or being ignored. I’m using:

Device: Raspberry Pi 4 (using 64bit OS)
Host OS: balenaOS 2.85.2+rev3 (development)
Supervisor: 12.10.10
Local mode

Here are the steps I’ve taken:

  1. I flashed a new image, modified the config.txt, and then booted the device for the first time. When I ran cat /mnt/boot/config.txt, my changes could not be seen not. It looks like the default configuration from the fleet/application was used instead.

  2. Then I updated the device configuration using the dashboard. These changes do appear in /mnt/boot/config.txt after a reboot.

    Device configuration

    RESIN_HOST_CONFIG_dtparam="spi=on"
    RESIN_HOST_CONFIG_dtoverlay="spi0-2cs,cs0_pin=04,cs1_pin=27"
    

    /mnt/boot/config.txt

    disable_splash=0
    dtoverlay=spi0-2cs,cs0_pin=04,cs1_pin=27
    dtparam=spi=on
    enable_uart=1
    gpu_mem=396
    arm_64bit=1
    avoid_warnings=1
    
  3. In an application container, I used Python and pigpio to send some data on the main SPI bus, channel 0, SPI mode 3.

    import pigpio
    pi = pigpio.pi()
    
    h = pi.spi_open(0, 50000, 3)
    pi.spi_write(h, b'\x21\x00\x00\x00\x00')
    

    On a scope, it can be seen that the RPI is still using the default chip select pin (GPIO 8) and not the pin configured in the config.txt file (GPIO 4).

Do you know why this could be happening? Is there another way to test/print how SPI0 is configured on the RPI4?

Thanks!

Nevermind!

The issue is not with balenaOS. It was caused by the pigpio library – the SPI chip select lines have been hardcoded. Sorry about that!

I’ve opened an issue there regarding this.

2 Likes

Hey there and thanks for reporting back @gautam_io :slight_smile:
I would have been surprised, but good to know that it is not an issue with balenaOS.
The only real problems I witnessed in regards to Overlays, was that sometimes people try to load some which are not yet available in the boot/overlays folder - coming from Raspberry Pi OS and thinking that should work… But to be honest, that also has been way back :slight_smile:

Thanks again and I hope you get your project done in no time :slight_smile: !

1 Like

Thank you @gautam_io and welcome to the community. Let us know once the pigpio library solves this problem that everything is working fine :slight_smile:

Thank you @nmaas87 for your amazing support! you rock!

1 Like