You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Issue with i2c-bcm2835 module with I2C devices? #3064
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?
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"?
Could you retest with the latest rpi-update kernel + firmware (and without your overlay workaround)? There have been some clocking changes which may have solved the problem. If not, I'll need to get hold of a PiJuice.
All this on Pi4B with i2c_bcm2835
I turned on debugging of i2c_bcm2835 (debug=3).
This is the output of a failing transaction with the official kernel (Linux raspberrypi 4.19.50-v7l+ #895 SMP Thu Jun 20 16:03:42 BST 2019 armv7l GNU/Linux);
The PiJuice has a ST Micro STM32F030CCT6 MCU which handles the I2C traffic.
In the meantime we also have a changed firmware for the PiJuice with changed I2C timing.
Will test that too and report later.
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)
Note: same kernel as after rpi-update on Pi4B, but this was after a normal apt-get update/upgrade yesterday.
On Pi4B after apt-get update/upgrade now with kernel Linux raspberrypi 4.19.57-v7l+ #1244 SMP Thu Jul 4 18:48:07 BST 2019 armv7l GNU/Linux and i2c_bcm2835 and updated PiJuice firmware PiJuice-V1.4_2019_07_11.elf.binary success:
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.
Activity
pelwell commentedon Jul 10, 2019
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"?
shawaj commentedon Jul 10, 2019
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
pelwell commentedon Jul 12, 2019
Could you retest with the latest
rpi-updatekernel + firmware (and without your overlay workaround)? There have been some clocking changes which may have solved the problem. If not, I'll need to get hold of a PiJuice.shawaj commentedon Jul 12, 2019
@pelwell what's your address? Raspberry Pi office?
tvoverbeek commentedon Jul 12, 2019
All this on Pi4B with i2c_bcm2835
I turned on debugging of i2c_bcm2835 (debug=3).
This is the output of a failing transaction with the official kernel (Linux raspberrypi 4.19.50-v7l+ #895 SMP Thu Jun 20 16:03:42 BST 2019 armv7l GNU/Linux);
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.
In the meantime we also have a changed firmware for the PiJuice with changed I2C timing.
Will test that too and report later.
pelwell commentedon Jul 12, 2019
@shawaj Yes, the new office on Cowley Road.
pelwell commentedon Jul 12, 2019
@tvoverbeek Do you have an equivalent trace from a Pi3 showing what success looks like?
tvoverbeek commentedon Jul 12, 2019
Yes, will post that before testing the changed firmware
tvoverbeek commentedon Jul 12, 2019
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)
Note: same kernel as after rpi-update on Pi4B, but this was after a normal apt-get update/upgrade yesterday.
tvoverbeek commentedon Jul 12, 2019
On Pi4B after apt-get update/upgrade now with kernel
Linux raspberrypi 4.19.57-v7l+ #1244 SMP Thu Jul 4 18:48:07 BST 2019 armv7l GNU/Linuxand i2c_bcm2835 and updated PiJuice firmwarePiJuice-V1.4_2019_07_11.elf.binarysuccess: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?
pelwell commentedon Jul 12, 2019
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.
pelwell commentedon Jul 12, 2019
Ah - there's a minor bug in the old driver:
Can you spot it?
Hint: the result is to disable timeouts completely.
tvoverbeek commentedon Jul 12, 2019
The
clk_tout = 35/1000*baud; //35ms timeout as per SMBus specs.will result in a clk_tout of 0 (integer division)i2c: bcm2835: Set clock-stretch timeout to 35ms
pelwell commentedon Jul 12, 2019
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.
286 remaining items
i2c: bcm2835: Set clock-stretch timeout to 35ms
i2c: bcm2835: Set clock-stretch timeout to 35ms
i2c: bcm2835: Set clock-stretch timeout to 35ms
i2c: bcm2835: Set clock-stretch timeout to 35ms
i2c: bcm2835: Set clock-stretch timeout to 35ms
i2c: bcm2835: Set clock-stretch timeout to 35ms
i2c: bcm2835: Set clock-stretch timeout to 35ms
i2c: bcm2835: Set clock-stretch timeout to 35ms
i2c: bcm2835: Set clock-stretch timeout to 35ms
i2c: bcm2835: Set clock-stretch timeout to 35ms
i2c: bcm2835: Set clock-stretch timeout to 35ms
i2c: bcm2835: Set clock-stretch timeout to 35ms
i2c: bcm2835: Set clock-stretch timeout to 35ms
i2c: bcm2835: Set clock-stretch timeout to 35ms
i2c: bcm2835: Set clock-stretch timeout to 35ms