-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with i2c-bcm2835 module with I2C devices? #3064
Comments
We're not aware of any major changes in the I2C block, although it has been mentioned that clock stretching should work now, however yours isn't the first report suggesting there may be a problem. Which devices does PiJuice use? Do you know if clock-stretching is involved? Can you get more detailed failure state than "COMMUNICATION ERROR"? |
copying in @tvoverbeek and @mmilann The communication error is in lines 94 and 110 of this script - https://github.com/PiSupply/PiJuice/blob/f571b4384aea02c75073204db5213538a9c02fbf/Software/Source/pijuice.py#L94 The I2C initialisation is here - https://github.com/PiSupply/PiJuice/blob/f571b4384aea02c75073204db5213538a9c02fbf/Software/Source/pijuice.py#L17 We are performing more testing on our side and will report back any further findings. Copying @ryanteck and @ChristopherRush also |
Could you retest with the latest |
@pelwell what's your address? Raspberry Pi office? |
All this on Pi4B with i2c_bcm2835
After rpi-update (Linux raspberrypi 4.19.57-v7l+ #1244 SMP Thu Jul 4 18:48:07 BST 2019 armv7l GNU/Linux) transactions still failing but different error code (ERR added on read transaction):
The PiJuice has a ST Micro STM32F030CCT6 MCU which handles the I2C traffic. |
@shawaj Yes, the new office on Cowley Road. |
@tvoverbeek Do you have an equivalent trace from a Pi3 showing what success looks like? |
Yes, will post that before testing the changed firmware |
Trace with successful transaction from a Pi3B, kernel (Linux rpi-pijuice-ref 4.19.57-v7+ #1244 SMP Thu Jul 4 18:45:25 BST 2019 armv7l GNU/Linux)
|
On Pi4B after apt-get update/upgrade now with kernel
So it seems we can solve it on our side. Still curious why it worked on Pi3B and not on a Pi4B with the i2c_bcm2835 module. Timing issue? |
The CLKT status flag indicates a clock-stretch timeout - the slave has held SCL low for too long. A mythical clock-stretch timeout was fixed for 2711, but apparently without requiring any driver changes. Another factor pointing towards the timeout is the fact that the old bcm2708 driver (which initialises the TOUT register to a value representing 35ms) works, while the bcm2835 driver (which doesn't change the value from the default of 40 clock cycles) fails. 40 clocks on a 1MHz bus is only 40us - what clock speed do you run at for PiJuice, and what is the maximum clock-stretch you might expect? At the very least the bcm2835 driver should also initialise the TOUT register to 35ms - I have no idea why it doesn't already. |
Ah - there's a minor bug in the old driver:
Can you spot it? Hint: the result is to disable timeouts completely. |
The |
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: raspberrypi#3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
There's a pull request here (#3068), in case any kernel builders have a spare moment test it with their devices before we merge it. |
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
There has been an attempt to upstream a similiar fix: Can anyone who is affected also test this patch? |
kernel: i2c: bcm2835: Set clock-stretch timeout to 35ms See: raspberrypi/linux#3064 kernel: xhci: add quirk for host controllers that don't update endpoint DCS See: raspberrypi/linux#3060 kernel: tty: amba-pl011: Make TX optimisation conditional See: #1017 kernel: overlays: Add real parameters to the rpi-poe overlay kernel: overlays: Correct gpio-fan gpio flags for 4.19 See: raspberrypi/linux#2715 kernel: overlays: i2c-gpio: Fix the bus parameter See: raspberrypi/linux#3062 kernel: overlays: Rename pi3- overlays to be less model-specific See: raspberrypi/linux#3052 firmware: dispmanx: Fix handling of disable_overscan to not disable it totally See: raspberrypi/linux#3059 firmware: power: Enable/disable H264 and ISP clocks with domain firmware: arm_loader: arm_64bit=0 should disable loading of kernel8.img firmware: dt-blob: CM has no activity LED
kernel: i2c: bcm2835: Set clock-stretch timeout to 35ms See: raspberrypi/linux#3064 kernel: xhci: add quirk for host controllers that don't update endpoint DCS See: raspberrypi/linux#3060 kernel: tty: amba-pl011: Make TX optimisation conditional See: raspberrypi/firmware#1017 kernel: overlays: Add real parameters to the rpi-poe overlay kernel: overlays: Correct gpio-fan gpio flags for 4.19 See: raspberrypi/linux#2715 kernel: overlays: i2c-gpio: Fix the bus parameter See: raspberrypi/linux#3062 kernel: overlays: Rename pi3- overlays to be less model-specific See: raspberrypi/linux#3052 firmware: dispmanx: Fix handling of disable_overscan to not disable it totally See: raspberrypi/linux#3059 firmware: power: Enable/disable H264 and ISP clocks with domain firmware: arm_loader: arm_64bit=0 should disable loading of kernel8.img firmware: dt-blob: CM has no activity LED
The PiJuice arrived - thanks - and I've installed the pijuice-gui package. Running on Pi4 with the latest |
@pelwell Phil. is that the 4.19.58 kernel from yesterday? It was definitely not OK on 4.19.57 |
Yes - you want the 4.19.58 kernel, because the clock-stretch timeout patch was in the same update. |
Just ran rpi-update. So with the 4.19.58 kernel and the PiJuice 1.3 firmware I get no errors in the kernel log, but the received data from the PiJucie is corrupted. (There is a checksum as the last byte in each message)
I understand the new SoC has the clock stretch bug fixed. Did you check the PiJuice GUI or only the debug output of the i2c-bcm2835 module? |
I used the GUI enough to convince me it was working - I could see the battery charge increasing, for example. However, on the first attempt on a Pi 4 I could see that all the responses from the device were 0xFF, at if the bus was stuck high. It was only after trying on a 3B+ and switching back to the 4 that it worked, so I don't know what changed. |
I happen to have 3 RPi4B (1, 2 and 4GB, Thanks PiSupply) and tried with all of them. |
@tvoverbeek yes I sent @pelwell one of the units that arrived this week |
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
[ Upstream commit 9495b9b31abe525ebd93da58de2c88b9f66d3a0e ] The CLKT register contains at poweron 0x40, which at our typical 100kHz bus rate means .64ms. But there is no specified limit to how long devices should be able to stretch the clocks, so just disable the timeout. We still have a timeout wrapping the entire transfer. Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> BugLink: raspberrypi/linux#3064 Signed-off-by: Wolfram Sang <wsa@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Santhosh <santhosh.user.why.red@gmail.com>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
[ Upstream commit 9495b9b31abe525ebd93da58de2c88b9f66d3a0e ] The CLKT register contains at poweron 0x40, which at our typical 100kHz bus rate means .64ms. But there is no specified limit to how long devices should be able to stretch the clocks, so just disable the timeout. We still have a timeout wrapping the entire transfer. Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> BugLink: raspberrypi/linux#3064 Signed-off-by: Wolfram Sang <wsa@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: #3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
[ Upstream commit 9495b9b31abe525ebd93da58de2c88b9f66d3a0e ] The CLKT register contains at poweron 0x40, which at our typical 100kHz bus rate means .64ms. But there is no specified limit to how long devices should be able to stretch the clocks, so just disable the timeout. We still have a timeout wrapping the entire transfer. Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> BugLink: raspberrypi/linux#3064 Signed-off-by: Wolfram Sang <wsa@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
When trying the PiJuice on Pi 4B using Raspbian Buster out of the box we get a COMMUNICATION ERROR in the PiJuice software although i2cdetect reported the usual addresses (0x14 and 0x68).
Turned out we had to use the older i2c-bcm2708 module instead of the default i2c-bcm2835 module.
With 'dtoverlay=i2c-bcm2708' in /boot/config.txt both the PiJuice HAT and Zero work.
On the Pi 3B+ the PiJuice works fine with the default i2c-bcm2835 module.
Do not know what the differences are in the new BCM2711 SoC w.r.t. I2C hardware.
Is there any known issues that might be causing this?
The text was updated successfully, but these errors were encountered: