After updating OS on rpi4 from v6.1.21 to 6.3.38, Modbus & GPIO mappings were modified. Our service uses tty/AMA3 for RS485 Modbus, it got changed to tty/AMA5. Also, only one gpiochip is detected by the OS, so we lost the functionality from other gpiochip. Screenshots are attached.
I’m using EPC-CM4-070 (CS10600RA4070E) industrial RPi Compute Module 4.
Hi @mpous any update on this?
@Perzade do you have any link of this device?
UUID: bc9dcd4ff01c41f1a152859bf5e13765
Device link
no! i meant a link of the model to get the exact specifications of the device.
Sorry for not being clear!
No issue…here’s the link
Thanks @Perzade
I shared internally your issue with the OS team and we will get back to you!
Hello @Perzade
it looks like this is related the Linux Kernel update to 6.1.
Was kernel updated in v6.3 onwards? Our devices were working well on the previous v6.1.21 OS release.
@Perzade actually we bumped the kernel v6.1 in balenaOS version to v6.1.24+rev5
You can read more here https://github.com/balena-os/balena-raspberrypi/blob/master/CHANGELOG.md#v6124rev5
Let’s explore where how to change the GPIO mapping you are reporting as the access to the GPIO pins has been deprecated (sysfs
→ libgpio
) . Maybe we can find some ideas here?
Unlike standard CM4 GPIOs, this board (CS10600RA4070) uses an I2C driver for GPIOs, enabled via the following dtoverlay:
mcp23017,mcp23008,addr=0x20,noints
. So, we had gpiochip496 (IN) on the previous OS version which is not detected now.
Will libgpiod support I2C-based GPIO expansion or a different approach is required?
As we’re not using CPU GPIOs but optical isolated GPIOs through i2c driver, it seems like kernel update to v6.1 has issues in detecting the driver correctly. With previous kernel v5.5, config.txt settings were:
dtoverlay=mcp23017
dtparam=mcp23008
dtparam=addr=0x20
dtparam=noints
With these settings, gpiochip496 was detected and functional.
After the update, the following error appears in dmesg
:
[ 6.538782] mcp230xx 1-0020: prop pinctrl-0 index 0 invalid phandle
And i2cdetect -y 1
confirms that MCP23017 is detected at 0x20, but no GPIO chips are created:
I tried modifying
RESIN_HOST_CONFIG_dtoverlay
in multiple ways, including:
"mcp23017,mcp23008,addr=0x20,noints"
"mcp23017,addr=0x20,noints","mcp23008,addr=0x20,noints"
Neither approach restored the missing GPIOs.
@mpous can you check with the OS team:
- Has there been a change in how MCP23008 is handled in Kernel 6.1?
- Is there a new recommended way to configure MCP23017 & MCP23008 together in
config.txt
? - How can I ensure the GPIOs (previously
gpiochip496
) are correctly registered after boot?
Hi there,
A bit of googling around the dmesg
error you shared led me to this RPI forum thread: https://forums.raspberrypi.com/viewtopic.php?t=370907
In this thread, a user identified that there was an issue when using noints
with the mcp23017
overlay. They merged a fix in the 6.6 branch: dtoverlays: Fix noints mode of mcp23017 by 6by9 · Pull Request #6174 · raspberrypi/linux · GitHub
What you could try, to confirm this is the problem is swapping in the mcp23017.dtbo
from a 6.6 kernel, and seeing it it solves the issue. You can do that by inserting it into /mnt/boot/overlays
in the hostOS, then rebooting the device.
If it works, we know that this is the fix. Incidentally we have a PR open to bump the kernel to >6.6 for the Raspberry Pi device types: Add support for CM5 and RPi500 by mtoman · Pull Request #1201 · balena-os/balena-raspberrypi · GitHub which will include that fix natively - but there’s no ETA on when that will be merged and deployed at the moment.
Thanks for the input! I had compared dts files of Linux kernel v5.5 and v6.1. The major difference was pinctrl settings were missing in the old version. So, I commented out that settings in v6.1. GPIOs were detected & worked as expected. I’ll check with v6.6 dtbo now and see if it works.
A quick update, GPIOs work with v6.6 dtbo also. So, above PR can be a long-term fix for us as well. Thanks for the support @rcooke-warwick @mpous !
Thanks for confirming @Perzade