Is widgetlords compatible with BalenaOS + raspberry?

Hello, thanks for the great platform first of all.

I am working with the widgetlords.com boards and libraries to read and write from raspberry 3b+ through SPI with a series of 7 boards: 2 x 2DAO, 2 x 8DI, 2 x 8DO, 1 x KO.

I have tested the widgetlords libraries for the SPI IO boards with Raspbian, and everything is ok. I am getting 5 SPI devices to show up (spidev0.0 up to spidev0.5, it looks like the widgetlords library emulates the devices not based on numbers but on type) and i can read from and write to each of them. in order to do it, i had to install the python libraries as described in the " Getting Started with PI-SPI Libraries" section on the web site of the maker.

in order to get the widgetlords libraries to work, there are a few steps, among which:

  1. in raspbian, to add the widgetlords library, do the following:
    a. sudo raspi-config
    b. Select “5 Interfacing Options”.
    c. Select “P6 Serial”
    d. Answer no for a serial-accessible login shell.
    e. Answer yes for enabling serial hardware.

  2. add the dtoverlay to the /boot/config.txt file
    a .sudo nano /boot/config.txt
    b. Scroll to the bottom of the file.
    c. For the PI-SPI series add the following line:
    d. dtoverlay=pi-spi

in order to do the above in balenaOS, i have changed the dtoverlay fleet environment variables in such a way that, when i start the docker container, I get the following:

Applying boot config: {“dtoverlay”:[“pi-spi,pi3-miniuart-bt”],“dtparam”:[“i2c_arm=on”,“spi=on”,“audio=on”],“avoid_warnings”:“1”,“disable_splash”:“1”,“enable_uart”:“1”,“gpu_mem”:“16”}

In theory, it should be the same, but when i try to list the devices, i only get the first two SPI devices. All the others have disappeared. What am i doing wrong?

Hi tommaso

your problem might be due to the value of dtoverlay being “pi-spi,pi3-miniuart-bt” rather than “pi-spi”. If you want to specify both values for dtoverlay you have to separate them using double quotes, for example: “pi-spi”,“pi3-miniuart-bt”

You can find additional examples in this doc: https://www.balena.io/docs/reference/OS/advanced/#setting-device-tree-overlays-dtoverlay-and-parameters-dtparam

Best regards

federico

1 Like

Hey Fede,
thanks for the reply. I tried changing the overlay as you mentioned, and now this is what the logs are showing.

02.12.19 16:52:19 (+0100) Applied boot config: {“dtoverlay”:[“pi-spi”],“dtparam”:[“i2c_arm=on”,“spi=on”,“audio=on”],“enable_uart”:“1”,“avoid_warnings”:“1”,“disable_splash”:“1”,“gpu_mem”:“16”}

still no luck though :frowning: . The interesting thing is that it looks like devices are being picked up, but just two of them, not all of them. Does this mean some of the GPIOs are being taken up by another resource? How does balena handle serial login shell?

Hi tommaso
Thanks for updating us on your progress. Are you by chance running a development build of balenaOS? If so the serial console is enabled. If that is the case you can disable it using systemctl disable serial-getty or install a production build instead.

To permanently disable the serial console on balenaOS development builds do:

  1. First disable read-only rootfs:
    # mount -o remount,rw /
  2. Then mask the serial getty service:
    # systemctl mask serial-getty@serial0.service
  3. reboot.

Do you still have the raspbian image? If so it might be useful to compare it’s config.txt with the balenaOS version.

Thanks,
James.

Hi James,
thank you for the support.
I am using a production build, since I had read about the serial console issues that you are mentioning in the dev build in the documentation. The one below is the content of the /boot/config.txt file in raspbian.

# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d
enable_uart=1
dtoverlay=pi-spi

Something i have noticed is that the image file of the raspbian image has 6 spidev0.X dtbo files in the overlay container, while the balena os only has 3. Does that mean that BalenaOS cannot support more than 3 devices?

Thanks for the info @tgirotto. What are the overlay names you see in raspbian?

We’d like to compare them with what you see on balenaOS.

that’s what i see from the overlays folder. It’s really just the raspbian buster image i got from the raspberry web site, nothing special :slight_smile:

Hi @tgirotto, it looks like we need to update the SPI overlays on balenaOS for the Pi’s. We created an issue to address this, you can keep track of the progress here. You will also get notified on this forum thread once the issue is closed.

thanks a lot. Will keep checking!

Hey @tgirotto,

We have updated the SPI overlays and it has been merged. It will be available for download in the next release of the os.
Thanks,
Rahul

Thanks!

We will let you know you once the os is available for download in the dashboard.
Regards,
Rahul