-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
smbus read_i2c_block_data Fails on Latest Kernel #828
Comments
Sorry, one more piece of info on this: If I roll back the kernel version to kernel 4.4.50-v7+ the python function begins to read properly again. |
In the second (broken) trace, the transfer diverges at the third Start bus state. The second transfer looks like it's doing a repeated start but terminating after a byte, whereas the first transfer does a stop then start and continues normally. What is the output of |
Can you try adding |
@P33M Re output of For 4.4.50-v7+
After an upgrade . . .
|
@pelwell to test this, I pasted When I do that I see:
|
@pelwell also just tried to change that line to Output of lsmod is:
|
Ah yes, that's because the overlay no longer does what you might think from its name. Download an updated overlay here that changes the compatible string - if you copy it into /boot/overlays and reboot you should find that the old driver (i2c_bcm2708) is loaded instead. You can then retry your test. My theory is that the I2C device you are trying to control does not support repeated starts. If you find that everything springs into life with the old driver, try repeating your test after turning on the "combined" module parameter:
|
@pelwell , thanks! I replaced i2c_bcm2708 (i2c1_bcm2708) and update config.txt. Unfortunately this did not seem to solve the problem. Could it be anything else? Is there a way to tell when the Kernel i2c was changed? |
|
@pelwell thanks for hanging in there with us!
|
Looks like there's a failure here: |
Just to see if I had entered in the config.txt info wrong, I changed the line to
|
Ah - although the module is called
|
@pelwell that worked! We're reading I2C again! Thanks! Just to repeat the entire process . . . .
Does that sound about right? Again, THANK YOU SO MUCH FOR YOUR HELP WITH THIS! |
Now that you have a workaround you can help to diagnose the real problem by trying with the
I am expecting your test to fail again, in which case we would need to find a way to disable combined (repeated start) transactions for i2c_bcm2835. |
@pelwell should this be run on a fresh Jessie Lite without the workaround on it, or on the one we've applied the workaround to? |
This test requires the workaround - you need the overlay to get the old driver loaded, and only the old driver has that parameter. |
Ok, so after applying the workaround, and then running the command
the example code does not work. However, after a reboot, the i2c readings returned to normal and gave expected readings. So what do you make of that? Strange or expected? |
It is what I was expecting - and hoping for, really. Now I'm sure what the problem is, finding a solution should just be a matter of having some time to work on it - either to find an existing way of disabling combined transaction, or to add one. |
By the way, rebooting should not be necessary to get back to a working system, just:
|
That's great to hear. Should I leave this open? |
Yes - until a proper fix is found, it's better to keep the history in a single thread. |
I've been looking at this for quite a while now, and I can't find a satisfactory solution. Linux expects to be able to use a repeated START when issuing a read from a device. If your device doesn't support that then I think it is broken - the I2C protocol seems pretty clear that a repeated start should be accepted. Fortunately there seem to be two workarounds:
Normally these flags are passed with each transfer using the I2C_RDWR ioctl. However, the SMBus API doesn't have these flags, and the Python SMBus module adds yet another abstraction layer. Preventing an entire I2C interface from using a repeated start just because a particular device doesn't support it is a kludge, but I can't see a better way while continuing to use the Python smbus module. I did find an alternative Python library using I2C_RDWR - https://github.com/quick2wire/quick2wire-python-api/blob/master/quick2wire/i2c.py - perhaps that might be worth a try. Otherwise, you're going to have to continue to use the modified i2c1_bcm2708 overlay. |
I think I answered this one when I said:
I'll post here when the updated overlay is available. |
Yes, you did. Thanks ! |
The i2c0-bcm2708 and i2c1-bcm2708 overlays allow the I2C pin usage to be changed. The names also suggest they revert to the old i2c_bcm2708 driver, but they don't. The newer i2c_bcm2835 driver forces transactions to be combined where possible, but this breaks some devices. Add an option to disable transaction combining, which is currently implemented by reverting to the old driver. See: raspberrypi/firmware#828 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The patched overlay (actually overlays - I changed i2c0-bcm2708 as well) is in the source tree and will be picked up by the next firmware build. Usage: |
kernel: BCM270X_DT: Add sdio_overclock parameter kernel: gpiolib: Don't prevent IRQ usage of output GPIOs See: raspberrypi/linux#2527 kernel: Driver for Allo Katana DAC See: raspberrypi/linux#2519 kernel: Prevent voltage low warnings from filling log See: raspberrypi/linux#2520 kernel: overlays: Add 'combine' option to i2c overlays See: #828 firmware: Extra reg writes to ensure the LCD display starts up at 800 wide firmware: platform: Lower temperature thresholds for extra pips to 50/60 firmware: video_encode: Add support for YVU420Planar and YVU420SemiPlanar firmware: video_decode: Support YV12, NV12, and NV21 output firmware: video_decode: Support reporting colour space firmware: IL rawcam: Fix copy/paste error on timing setup firmware: MMAL: Populate buffer header TYPE_SPECIFIC fields
kernel: BCM270X_DT: Add sdio_overclock parameter kernel: gpiolib: Don't prevent IRQ usage of output GPIOs See: raspberrypi/linux#2527 kernel: Driver for Allo Katana DAC See: raspberrypi/linux#2519 kernel: Prevent voltage low warnings from filling log See: raspberrypi/linux#2520 kernel: overlays: Add 'combine' option to i2c overlays See: raspberrypi/firmware#828 firmware: Extra reg writes to ensure the LCD display starts up at 800 wide firmware: platform: Lower temperature thresholds for extra pips to 50/60 firmware: video_encode: Add support for YVU420Planar and YVU420SemiPlanar firmware: video_decode: Support YV12, NV12, and NV21 output firmware: video_decode: Support reporting colour space firmware: IL rawcam: Fix copy/paste error on timing setup firmware: MMAL: Populate buffer header TYPE_SPECIFIC fields
kernel: BCM270X_DT: Add sdio_overclock parameter kernel: gpiolib: Don't prevent IRQ usage of output GPIOs See: raspberrypi/linux#2527 kernel: Driver for Allo Katana DAC See: raspberrypi/linux#2519 kernel: Prevent voltage low warnings from filling log See: raspberrypi/linux#2520 kernel: overlays: Add 'combine' option to i2c overlays See: #828 firmware: Extra reg writes to ensure the LCD display starts up at 800 wide firmware: platform: Lower temperature thresholds for extra pips to 50/60 firmware: video_encode: Add support for YVU420Planar and YVU420SemiPlanar firmware: video_decode: Support YV12, NV12, and NV21 output firmware: video_decode: Support reporting colour space firmware: IL rawcam: Fix copy/paste error on timing setup firmware: MMAL: Populate buffer header TYPE_SPECIFIC fields
kernel: BCM270X_DT: Add sdio_overclock parameter kernel: gpiolib: Don't prevent IRQ usage of output GPIOs See: raspberrypi/linux#2527 kernel: Driver for Allo Katana DAC See: raspberrypi/linux#2519 kernel: Prevent voltage low warnings from filling log See: raspberrypi/linux#2520 kernel: overlays: Add 'combine' option to i2c overlays See: raspberrypi/firmware#828 firmware: Extra reg writes to ensure the LCD display starts up at 800 wide firmware: platform: Lower temperature thresholds for extra pips to 50/60 firmware: video_encode: Add support for YVU420Planar and YVU420SemiPlanar firmware: video_decode: Support YV12, NV12, and NV21 output firmware: video_decode: Support reporting colour space firmware: IL rawcam: Fix copy/paste error on timing setup firmware: MMAL: Populate buffer header TYPE_SPECIFIC fields
The i2c0-bcm2708 and i2c1-bcm2708 overlays allow the I2C pin usage to be changed. The names also suggest they revert to the old i2c_bcm2708 driver, but they don't. The newer i2c_bcm2835 driver forces transactions to be combined where possible, but this breaks some devices. Add an option to disable transaction combining, which is currently implemented by reverting to the old driver. See: raspberrypi/firmware#828 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The i2c0-bcm2708 and i2c1-bcm2708 overlays allow the I2C pin usage to be changed. The names also suggest they revert to the old i2c_bcm2708 driver, but they don't. The newer i2c_bcm2835 driver forces transactions to be combined where possible, but this breaks some devices. Add an option to disable transaction combining, which is currently implemented by reverting to the old driver. See: raspberrypi/firmware#828 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The i2c0-bcm2708 and i2c1-bcm2708 overlays allow the I2C pin usage to be changed. The names also suggest they revert to the old i2c_bcm2708 driver, but they don't. The newer i2c_bcm2835 driver forces transactions to be combined where possible, but this breaks some devices. Add an option to disable transaction combining, which is currently implemented by reverting to the old driver. See: raspberrypi/firmware#828 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The i2c0-bcm2708 and i2c1-bcm2708 overlays allow the I2C pin usage to be changed. The names also suggest they revert to the old i2c_bcm2708 driver, but they don't. The newer i2c_bcm2835 driver forces transactions to be combined where possible, but this breaks some devices. Add an option to disable transaction combining, which is currently implemented by reverting to the old driver. See: raspberrypi/firmware#828 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The i2c0-bcm2708 and i2c1-bcm2708 overlays allow the I2C pin usage to be changed. The names also suggest they revert to the old i2c_bcm2708 driver, but they don't. The newer i2c_bcm2835 driver forces transactions to be combined where possible, but this breaks some devices. Add an option to disable transaction combining, which is currently implemented by reverting to the old driver. See: raspberrypi/firmware#828 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The i2c0-bcm2708 and i2c1-bcm2708 overlays allow the I2C pin usage to be changed. The names also suggest they revert to the old i2c_bcm2708 driver, but they don't. The newer i2c_bcm2835 driver forces transactions to be combined where possible, but this breaks some devices. Add an option to disable transaction combining, which is currently implemented by reverting to the old driver. See: raspberrypi/firmware#828 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The i2c0-bcm2708 and i2c1-bcm2708 overlays allow the I2C pin usage to be changed. The names also suggest they revert to the old i2c_bcm2708 driver, but they don't. The newer i2c_bcm2835 driver forces transactions to be combined where possible, but this breaks some devices. Add an option to disable transaction combining, which is currently implemented by reverting to the old driver. See: raspberrypi/firmware#828 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The i2c0-bcm2708 and i2c1-bcm2708 overlays allow the I2C pin usage to be changed. The names also suggest they revert to the old i2c_bcm2708 driver, but they don't. The newer i2c_bcm2835 driver forces transactions to be combined where possible, but this breaks some devices. Add an option to disable transaction combining, which is currently implemented by reverting to the old driver. See: raspberrypi/firmware#828 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The i2c0-bcm2708 and i2c1-bcm2708 overlays allow the I2C pin usage to be changed. The names also suggest they revert to the old i2c_bcm2708 driver, but they don't. The newer i2c_bcm2835 driver forces transactions to be combined where possible, but this breaks some devices. Add an option to disable transaction combining, which is currently implemented by reverting to the old driver. See: raspberrypi/firmware#828 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The i2c0-bcm2708 and i2c1-bcm2708 overlays allow the I2C pin usage to be changed. The names also suggest they revert to the old i2c_bcm2708 driver, but they don't. The newer i2c_bcm2835 driver forces transactions to be combined where possible, but this breaks some devices. Add an option to disable transaction combining, which is currently implemented by reverting to the old driver. See: raspberrypi/firmware#828 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The i2c0-bcm2708 and i2c1-bcm2708 overlays allow the I2C pin usage to be changed. The names also suggest they revert to the old i2c_bcm2708 driver, but they don't. The newer i2c_bcm2835 driver forces transactions to be combined where possible, but this breaks some devices. Add an option to disable transaction combining, which is currently implemented by reverting to the old driver. See: raspberrypi/firmware#828 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
Has the overlay thing been properly fixed in the last FW release? |
Yes, "combine" option was added in 4.14.37. |
Why this issue is still open? :) |
Well, we haven't had third party confirmation it's actually fixed, but reading back it does seem that it can be closed. @pelwell happy to close? |
Hey folks, noticed a problem when we went to update to the latest kernel on June 17 2017. I tried to isolate it as best I could with the following description. The smbus call
read_i2c_block_data
fails to do a block read. A couple of quick bulletI did the following to test and isolate the problem with the firmware, I created the following python script (pasted below). First, running on Jessi Lite 2017.01.11 I checked the kernel version, the updated Jessi Lite with the necessary support
Running with the older firmware, I get a healthy response from the function
read_i2c_block_data
.Then, updating to the latest firmware 4.9+ I run the same python script, and get a failure to read.
Below is the python code you can use to replicate the problem.
The text was updated successfully, but these errors were encountered: