Skip to content
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

core_freq seems to affect I2C operation #212

Closed
fangfufu opened this issue Sep 11, 2013 · 16 comments
Closed

core_freq seems to affect I2C operation #212

fangfufu opened this issue Sep 11, 2013 · 16 comments

Comments

@fangfufu
Copy link

Hello,
My I2C device gives strange readings when the core_freq in /boot/config.txt is set to 450.
When core_freq=450:

fangfufu@snowden:~/Pi-Weather$ ./Pi-Sensors
Board Version: 1
Board Temperature: 35 C
Humidity: 27 %
Room Temperature: -3244.8 C
Outdoor Temperature: 28.3 C
Board Pressure: 3364.5

When core_freq is not set:

fangfufu@snowden:~/Pi-Weather$ ./Pi-Sensors
Board Version: 1
Board Temperature: 35 C
Humidity: 26 %
Room Temperature: 29.1 C
Outdoor Temperature: 28.2 C
Board Pressure: 100.4

I wonder if this is related to the SD card corruption when core_freq is overclocked. Is there a fix for this problem other than not overclocking?

In case you wonder, my I2C device is one of those Web4Robot Weather Station Board (http://www.web4robot.com/PiWeather.html).

@popcornmix
Copy link
Contributor

Yes, I believe I2C frequency is derived from core clock.
If you set the I2C frequency lower (i.e desired freq * 450/250) does it work?
I'd assume I2C would be happy with a lower than expected clock.

@fangfufu
Copy link
Author

How do I set I2C frequency? I am using the i2c-dev kernel module.

@cleverca22
Copy link

there is a file under /sys for that, it updates the speed the moment you write to it, let me boot my pi up and find it...

/sys/module/i2c_bcm2708/parameters/baudrate

mine is set to 100000 by default, giving 100khz, i think the bug is that corefreq comes into play, but the kernel isnt aware of that

you can reduce the speed to any value you want by just writting a number to that path

@cleverca22
Copy link

yep, 100khz with core_freq=300 becomes 120khz, (300/250)*100khz

clearly a bug within the linux driver

https://github.com/raspberrypi/linux/blob/b7c5c10f93a4f48609c3e8decaa37ab5aa04d830/drivers/i2c/busses/i2c-bcm2708.c#L148

somewhere in this region, but i dont know how to fetch core_freq from here

@fangfufu
Copy link
Author

Problem solved by manually setting I2C frequency to 55kHz. 55*450/250 = 99. So clearly this is some kind of bug.

@lurch
Copy link
Contributor

lurch commented Nov 5, 2013

If this is a kernel bug rather than a firmware bug, you should probably create an issue at https://github.com/raspberrypi/linux/issues

@popcornmix
Copy link
Contributor

@cleverca22
Can you change the 250 to your overclocked core freq (e.g. 300) here:
https://github.com/raspberrypi/linux/blob/rpi-3.6.y/arch/arm/mach-bcm2708/bcm2708.c#L226

and let me know if that is good. If so I'll look at populating that with the overclocked core frequency.

@cleverca22
Copy link

yep, if that clock matched core_freq, then the baudrate in /sys perfectly matches the SCL freq on the scope

@cleverca22
Copy link

any update?

@P33M
Copy link

P33M commented Jan 13, 2014

The correct calculation of the i2c divisor requires knowledge of the clock the block is supplied with.

Currently, there is no clock driver on the ARM side which would allow the proper use of clk_get_rate and friends. Only tangential references are made in the public datasheet to the clock distribution structure - a driver would have to know about this to implement the interface that allows clock querying.

Currently the implementation is a stub (with statically defined clocks).

@ghollingworth
Copy link
Contributor

Maybe we should add an interface from the ARM to the clock manager? Not sure it would actually be helpful though... Maybe one day we'll release the full spec for the manager and watch people's brains explode!

Gordon

@Ruffio
Copy link

Ruffio commented Jun 17, 2015

@popcornmix is this still an issue?

popcornmix added a commit that referenced this issue Dec 8, 2015
kernel: BCM270X_DT: Use clk_core for I2C interfaces
See: #212

kernel: SDIO-overlay: add poll_once-boolean parameter

kernel: dts: Added overlay for gpio_ir_recv driver
See: raspberrypi/linux#1199

kernel: Add FBUNSUPPORTED ioctl for bcm2708_fb
See: raspberrypi/linux#1200

kernel: config: Add FB_TFT_ILI9163 module
See: raspberrypi/linux#1177
popcornmix added a commit to Hexxeh/rpi-firmware that referenced this issue Dec 8, 2015
kernel: BCM270X_DT: Use clk_core for I2C interfaces
See: raspberrypi/firmware#212

kernel: SDIO-overlay: add poll_once-boolean parameter

kernel: dts: Added overlay for gpio_ir_recv driver
See: raspberrypi/linux#1199

kernel: Add FBUNSUPPORTED ioctl for bcm2708_fb
See: raspberrypi/linux#1200

kernel: config: Add FB_TFT_ILI9163 module
See: raspberrypi/linux#1177
@Ruffio
Copy link

Ruffio commented Jun 29, 2016

@fangfufu can this issue be closed?

@fangfufu
Copy link
Author

I sold my original Raspberry Pi. I left my weather station board in China.

I don't have the means to test this problem, please close the issue.

@Ruffio
Copy link

Ruffio commented Jun 29, 2016

@fangfufu you just press the 'Close' button to close this issue... Thanks.

@fangfufu
Copy link
Author

Thanks, issue closed.

neuschaefer pushed a commit to neuschaefer/raspi-binary-firmware that referenced this issue Feb 27, 2017
kernel: BCM270X_DT: Use clk_core for I2C interfaces
See: raspberrypi#212

kernel: SDIO-overlay: add poll_once-boolean parameter

kernel: dts: Added overlay for gpio_ir_recv driver
See: raspberrypi/linux#1199

kernel: Add FBUNSUPPORTED ioctl for bcm2708_fb
See: raspberrypi/linux#1200

kernel: config: Add FB_TFT_ILI9163 module
See: raspberrypi/linux#1177
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants