I have encountered a "strange" error - strange meaning that it worked before, but has stopped working recently.
I'm trying to activate the absolute maximum number of I2C buses on Raspberry Pi 4 - to create a "barcode scanning tunnel" with 10 "Tiny Code Reader" QR code scanners (produced by Useful Sensors) looking in from each side.
9 of the 10 scanners are working.
The scanner on I2C-0 worked when I had 8 scanners, but stopped working when I added 2 more. I did not alter its wiring or pins. Now it refuses to work even when I reduce the number of interfaces, which is puzzling.
I activate the interfaces for the scanners in "/boot/config.txt" (old distro, not "/boot/firmware" yet) like this:...where N increases from 4 to 11 (for various reasons I didn't risk claiming buses 2 and 3) while X and Y are like the attached schematic image shows.
Result: already before my application manages to run, by issuing "dmesg", I see the following stack trace:
...and my application reports:
Can anyone guess, what could be happning in the system to cause this?
I have tried to browse Linux sources (from https://elixir.bootlin.com/linux/v4.15. ... ore-base.c ), but I think I'm looking at the wrong version, because line 1588 says:
...so it doesn't look like runnable code, but a declaration. The previous and next functions are:
I'm more inclined to suspect that it happens in "add_numbered_adapter" which reads:
I'm trying to activate the absolute maximum number of I2C buses on Raspberry Pi 4 - to create a "barcode scanning tunnel" with 10 "Tiny Code Reader" QR code scanners (produced by Useful Sensors) looking in from each side.
9 of the 10 scanners are working.
The scanner on I2C-0 worked when I had 8 scanners, but stopped working when I added 2 more. I did not alter its wiring or pins. Now it refuses to work even when I reduce the number of interfaces, which is puzzling.
I activate the interfaces for the scanners in "/boot/config.txt" (old distro, not "/boot/firmware" yet) like this:
Code:
# this should give I2C-0dtparam=i2c_vc=ondtparam=i2c_vc_baudrate=100000# this gives I2C-1dtparam=i2c_arm=ondtparam=i2c_arm_baudrate=100000# these give 8 more interfacesdtoverlay=i2c-gpio,bus=N,i2c_gpio_sda=X,i2c_gpio_scl=YResult: already before my application manages to run, by issuing "dmesg", I see the following stack trace:
Code:
[ 5.022784] ------------[ cut here ]------------[ 5.022791] couldn't get idr[ 5.022850] WARNING: CPU: 3 PID: 173 at drivers/i2c/i2c-core-base.c:1588 __i2c_add_numbered_adapter+0x8c/0xc0[ 5.022887] Modules linked in: i2c_mux_pinctrl(+) drm_dma_helper raspberrypi_hwmon i2c_mux ecdh_generic drm_kms_helper i2c_brcmstb ecc rfkill libaes bcm2835_codec(C) snd_soc_core i2c_bcm2835 bcm2835_v4l2(C) bcm2835_isp(C) raspberrypi_gpiomem bcm2835_mmal_vchiq(C) videobuf2_vmalloc rpivid_hevc(C) v4l2_mem2mem videobuf2_dma_contig videobuf2_memops videobuf2_v4l2 videodev snd_compress vc_sm_cma(C) snd_pcm_dmaengine snd_bcm2835(C) snd_pcm videobuf2_common mc snd_timer snd uio_pdrv_genirq uio i2c_gpio i2c_algo_bit nvmem_rmem drm i2c_dev fuse drm_panel_orientation_quirks backlight ip_tables x_tables ipv6[ 5.023139] CPU: 3 PID: 173 Comm: systemd-udevd Tainted: G C 6.6.36-v8+ #1780[ 5.023154] Hardware name: Raspberry Pi 4 Model B Rev 1.5 (DT)[ 5.023162] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)[ 5.023176] pc : __i2c_add_numbered_adapter+0x8c/0xc0[ 5.023193] lr : __i2c_add_numbered_adapter+0x8c/0xc0[ 5.023209] sp : ffffffc08091b770[ 5.023216] x29: ffffffc08091b770 x28: 0000000000000000 x27: ffffff8005d3a300[ 5.023241] x26: ffffffdc1463c108 x25: ffffff8037e26700 x24: ffffff80042a8108[ 5.023263] x23: 0000000000000000 x22: 0000000000000001 x21: ffffffdc52fa9c38[ 5.023285] x20: ffffff8004e52000 x19: 00000000ffffffe4 x18: ffffffffffffffff[ 5.023307] x17: 0000000000000002 x16: ffffffdc521f4af8 x15: ffffff8004e52364[ 5.023329] x14: 0000000000000000 x13: 7264692074656720 x12: 74276e646c756f63[ 5.023350] x11: fffffffffffe0000 x10: ffffffdc52ea5c40 x9 : ffffffdc5190993c[ 5.023372] x8 : 00000000ffffefff x7 : ffffffdc52ea3708 x6 : 0000000000002538[ 5.023393] x5 : ffffff8037dc1d48 x4 : 0000000000000000 x3 : 0000000000000027[ 5.023415] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffffff8003b0bd80[ 5.023436] Call trace:[ 5.023445] __i2c_add_numbered_adapter+0x8c/0xc0[ 5.023462] i2c_add_adapter+0xac/0xe8[ 5.023477] i2c_mux_add_adapter+0x2a4/0x7e0 [i2c_mux][ 5.023512] i2c_mux_pinctrl_probe+0x32c/0x3d8 [i2c_mux_pinctrl][ 5.023543] platform_probe+0x70/0xf0[ 5.023562] really_probe+0x150/0x2c0[ 5.023574] __driver_probe_device+0x80/0x140[ 5.023587] driver_probe_device+0xe0/0x170[ 5.023600] __driver_attach+0x9c/0x1b0[ 5.023612] bus_for_each_dev+0x7c/0xe8[ 5.023624] driver_attach+0x2c/0x40[ 5.023635] bus_add_driver+0xec/0x218[ 5.023646] driver_register+0x68/0x138[ 5.023660] __platform_driver_register+0x30/0x48[ 5.023674] i2c_mux_pinctrl_driver_init+0x28/0xff8 [i2c_mux_pinctrl][ 5.023699] do_one_initcall+0x4c/0x298[ 5.023714] do_init_module+0x60/0x218[ 5.023731] load_module+0x1c04/0x1d30[ 5.023746] __do_sys_init_module+0x1a8/0x1e8[ 5.023762] __arm64_sys_init_module+0x24/0x38[ 5.023777] invoke_syscall+0x50/0x128[ 5.023794] el0_svc_common.constprop.0+0xd0/0xf8[ 5.023811] do_el0_svc_compat+0x28/0x48[ 5.023828] el0_svc_compat+0x30/0x88[ 5.023841] el0t_32_sync_handler+0x98/0x148[ 5.023851] el0t_32_sync+0x194/0x198[ 5.023863] ---[ end trace 0000000000000000 ]---[ 5.023875] i2c i2c-22: failed to add mux-adapter 1 (error=-16)[ 5.025180] i2c-mux-pinctrl: probe of soc:i2c0mux failed with error -16Code:
Initializing I2C handles.Failed opening I2C scanner 0, result code -74.OK opening I2C scanner 1.OK opening I2C scanner 4.OK opening I2C scanner 5.OK opening I2C scanner 6.OK opening I2C scanner 7.OK opening I2C scanner 8.OK opening I2C scanner 9.OK opening I2C scanner 10.OK opening I2C scanner 11.I have tried to browse Linux sources (from https://elixir.bootlin.com/linux/v4.15. ... ore-base.c ), but I think I'm looking at the wrong version, because line 1588 says:
Code:
EXPORT_SYMBOL_GPL(i2c_parse_fw_timings);Code:
void i2c_parse_fw_timings(struct device *dev, struct i2c_timings *t, bool use_defaults)Code:
int i2c_for_each_dev(void *data, int (*fn)(struct device *, void *))Code:
static int __i2c_add_numbered_adapter(struct i2c_adapter *adap){int id;mutex_lock(&core_lock);id = idr_alloc(&i2c_adapter_idr, adap, adap->nr, adap->nr + 1, GFP_KERNEL);mutex_unlock(&core_lock);if (WARN(id < 0, "couldn't get idr"))return id == -ENOSPC ? -EBUSY : id;return i2c_register_adapter(adap);}Statistics: Posted by diastrikos — Wed Jun 11, 2025 9:27 pm — Replies 3 — Views 137