Setting I2C Clock Stretch Timeout and Baudrate with i2c-dev
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- c, linux
- Domain
- embedded-iot, operating-systems
Research direction
Start by reading i2c-bcm2835.c and the i2c-dev interface, then inspect how the BSC.CLKT register and TOUT value currently control clock stretching. Consider how the proposed I2C_CLOCK_TIMEOUT and I2C_BAUDRATE ioctls would fit the existing interfaces and update the driver. Done means both settings can be changed at application level with the requested ranges and behavior.
Written by the indexing model from the issue text.
Description
This idea came to my mind after spending several days fighting against an I2C clock stretch timeout issue.
Currently the I2C Clock Stretch Timeout is set to 35ms in i2c-bcm2835.c which is not sufficient for applications requiring a very long processing time (e.g. several seconds). Besides even the max value (65535 i2c clock cycles) is not sufficient in some cases, as it's "only" 655ms @ 100kbits : in that case the only workaround is to disable it by setting it to 0.
I found a way to fix it (by directly addressing the BSC.CLKT register and setting TOUT to 0 to disable the clock stretch timeout), but thought it would be much simpler to do it at higher level using ioctl commands.
In the same idea, it would be nice to set the I2C baudrate at application level using ioctl , instead of doing it in boot/config.txt
Here is my proposal:
- add 1 new parameter I2C_CLOCK_TIMEOUT in i2c-dev to set the clock stretch timeout - value between 0 to 65535
- add 1 new parameter I2C_BAUDRATE in i2c-dev to set the I2C baudrate
- update i2c-bcm2835 accordingly
What do you think?
Please note I'm discovering the raspberry (and linux in general) so I may be missed some obvious reasons that prevent to do these changes.
- Dominant language
- C
- Stars
- 13.2k
- Forks
- 5.5k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 21
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from raspberrypi/linux
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
raspberrypi/linux#7415 · 2 comments · 1 reaction ·
-
rp1-cfe doesn't forward V4L2_EVENT_SOURCE_CHANGE event from csi-2 sensor driver to userspace app Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
raspberrypi/linux#7399 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
raspberrypi/linux#7357 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
raspberrypi/linux#7054 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
raspberrypi/linux#7634 · 8 comments · 1 reaction ·
All issues in raspberrypi/linux
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
zephyrproject-rtos/zephyr#119726 ·
-
[Bounty proposal] fix(web): memory insights count an evening memory on the next day ($25 proposed) Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
BasedHardware/omi#15320 ·
-
[adam] AdamNet network read doesn't cap to MAX_ADAM_PACKET_LEN, overflows client receive buffers Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
FujiNetWIFI/fujinet-firmware#1649 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
HarbourMasters/Shipwright#7229 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
riscv-software-src/riscv-isa-sim#2435 · 1 comment ·