Repository navigation
Description
Describe the bug
I have 2 MUX installed, as follows:
dtoverlay=i2c-mux,pca9548,addr=0x74,base=40 dtoverlay=i2c-mux,pca9548,addr=0x70,base=30
(note base=xx is a beta provided by PhilE, but the problem was there before this).
When I type i2cdetect -y 3x the first time, it correctly looks for all the available devices on bus 3x (MUX1). But, when I then type i2cdetect -y 4y to show devices on bus 4y (MUX2), it superimposes what it found on bus 3x to what it finds on 4y. If my interpretation is correct, it holds onto the buffer from MUX1 when displaying MUX2.
It doesn't do this, when you stick to MUX1 addresses. Only superimposes MUX1 onto MUX2. I tested the reverse, with MUX2 first and MUX1 second. Same behavior.
Example:
Helios@HeliosRPi4:~ $ i2cdetect -y 30
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- 57 -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: UU -- -- -- UU -- -- --
Helios@HeliosRPi4:~ $ i2cdetect -y 40
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- 28 -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- 57 -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: UU -- -- -- UU -- -- --
Helios@HeliosRPi4:~ $
57 and 68 do not exist on bus 40...
Steps to reproduce the behaviour
1- install 2 identical MUX via dtoverlay:
dtoverlay=i2c-mux,pca9548,addr=0x74
dtoverlay=i2c-mux,pca9548,addr=0x70
2- install a few i2c devices on each MUX, ideally different I2C addresses
3- reboot
4- type 'i2cdetect -y xx' (MUX1) and note the devices shown on monitor
5- type 'i2cdetect -y yy' (MUX2) and note that the devices shown from the previous step (port XX) are still visible, in addition to the actual devices on port YY.
Device (s)
Raspberry Pi 4 Mod. B
System
Helios@HeliosRPi4:~ $ cat /etc/rpi-issue Raspberry Pi reference 2023-12-05 Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 70cd6f2a1e34d07f5cba7047aea5b92457372e05, stage4
Helios@HeliosRPi4:~ $ vcgencmd version Oct 17 2023 15:39:16 Copyright (c) 2012 Broadcom version 30f0c5e4d076da3ab4f341d88e7d505760b93ad7 (clean) (release) (start)
Helios@HeliosRPi4:~ $ uname -a Linux HeliosRPi4 6.6.21-v8+ #1 SMP PREEMPT Thu Mar 14 10:53:16 UTC 2024 aarch64 GNU/Linux
Logs
No response
Additional context
No response
Activity
pelwell commentedon Mar 14, 2024
I think it's worse than you describe, because aren't the
UUs in70: UU -- -- -- UU -- -- --the PCF9548s themselves?6by9 commentedon Mar 14, 2024
MUX1 knows nothing about MUX2.
By default the mux is left selected to the last used output in the hope that it saves reselecting the same output for the next transaction.
So your observation is correct - activating a 3x output and then a 4x output will see the combination of the two mux output buses.
Reading the bindings, there is the
i2c-mux-idle-disconnectoridle-stateproperties that allow control of the idle state of any mux.Adding either
or
to the pca95x nodes should cause it to always disconnect when idle, at the expense of an extra I2C write to the mux after every transaction (this will add up for something like an
i2cdetect).Addresses used on the parent bus will also be reserved on all child buses.
Trilife commentedon Mar 14, 2024
pelwell commentedon Mar 14, 2024
I guess that is required, otherwise there would be no way to say "I want to talk to the parent bus now".
That's already covered by #6037
6by9 commentedon Mar 14, 2024
#6040 adds an override
disconnect_on_idlethat addsidle-state = <MUX_IDLE_DISCONNECT>;to the relevant nodes.pelwell commentedon Mar 14, 2024
I've merged #6040 and rebased #6038 on top of it. As usual, it will take about 45 minutes for the auto-builds to complete, then
sudo rpi-update pulls/6038again. (If you installed pulls/6040 instead you would lose thebase=parameter support)Trilife commentedon Mar 14, 2024
6by9 commentedon Mar 14, 2024
What are your complete dtoverlay lines now?
Have you added the
disconnect_on_idleoverride to both of them?xxd /proc/device-tree/soc/i2c@7e804000/mux@70/idle-stateshould return(aka -2) if correctly configured.
pelwell commentedon Mar 14, 2024
In other words:
Trilife commentedon Mar 14, 2024
6by9 commentedon Mar 14, 2024
I can't find my PCA9548 at present, but I've done a quick hack to the driver to ignore I2C errors, and used I2C event logging (see https://riptutorial.com/linux-kernel/example/11983/tracing-i2c-events for how)
My log (plus annotations) gives me this as a fragment from an i2cdetect -y 29 (8th bus on the mux as I haven't got the base_nr patches).
So that is doing exactly what I'd expect it to.
rpi-update normally caches the build that it last installed. I don't know whether it does so with pulls, but it's possible that it didn't update to the new build.
If that has happened, then
sudo vclog -mwill report the fact it has been ignored, eg fromdtoverlay=i2c-mux,pca9548,wibbleMemory says it is delete /boot/firmware/.firmware_revision to force rpi-update to download the files again.
Trilife commentedon Mar 22, 2024
popcornmix commentedon Mar 22, 2024
The fix is merged into source tree and is in current rpi-update kernel.
It will be in subsequent updates to apt kernel.
You won't get overwritten unless there is an update (or you request
install --reinstall).So it shouldn't be an issue going forward.
Trilife commentedon Apr 5, 2024
Trilife commentedon Apr 5, 2024
9 remaining items
Trilife commentedon Apr 8, 2024
Trilife commentedon Apr 9, 2024
Trilife commentedon Apr 13, 2024
Trilife commentedon Apr 13, 2024
dtoverlay: Convert u32s to unsigned strings
dtoverlay: Convert u32s to unsigned strings
pieeprom-2024-04-17: 2712: 2711: Build Pi4 and Pi5 firmware from the …
pieeprom-2024-04-17: 2712: 2711: Build Pi4 and Pi5 firmware from the …
firmware: arm_dt: On 2711, force otg_mode=1 if xhci is enabled
firmware: arm_dt: On 2711, force otg_mode=1 if xhci is enabled
Trilife commentedon Apr 23, 2024
pelwell commentedon Apr 23, 2024
You shouldn't need to install it any more - just install the latest stable firmware:
sudo rpi-update stableTrilife commentedon Apr 24, 2024
pelwell commentedon Apr 24, 2024
Hmm, that's a new failure - I'll try and find out what's going wrong. You should be OK with updating to the latest instead -
sudo rpi-update.pelwell commentedon Apr 24, 2024
My advice was showing its age - the preferred syntax is now
sudo rpi-update stable, which works. The BRANCH=stable version is equivalent tosudo rpi-update stable stable, which means "stable software, stable eeprom", and the eeprom has no "stable" branch.