13

Using the other i2c bus hangs raspistill

 3 years ago
source link: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=46299&p=367237
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

rayjoh

Posts: 27 Joined: Thu May 23, 2013 11:48 am

Using the other i2c bus hangs raspistill

Thu Jun 06, 2013 12:47 pm

There is some conflict between the i2c buses.

The shell script can run for hours with no problem if I do not access the RTC clock http://www.adafruit.com/products/264. raspistill hangs if I run the command "hwclock -r" a few times. The camera LED is on.

raspistill also hangs if I run python scripts to access a Pi Plate http://www.adafruit.com/products/1115 or a TMP102 https://www.sparkfun.com/products/9418

I have been using one pi model A and one model B with two different power sources.
One 2A power supply connected to a USB hub. The pi is powered from the hub to the mikrousb port. TP1-TP2 is 4.9V. Also tested with a 12v car battery and LM2596
No keyboard and screen is connected, I login via ssh to them.

I did a fresh install of 2013-05-25-wheezy-raspbian on a second SD-card. No difference.

The script that I use to test raspistill

Code: Select all

while /bin/true ; do      
    date     
    raspistill -n -t 100 -e jpg -o - >  /dev/null
    sleep 1
done
-- Raymond

jamesh

Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum ModeratorPosts: 27553 Joined: Sat Jul 30, 2011 7:41 pm

Re: Using the other i2c bus hangs raspistill

Thu Jun 06, 2013 3:52 pm

Perhaps not related to the issue but you probably need to have a bigger delay between each invocation of raspistill - I doubt it can run up, capture then shutdown that fast and keep itself clean. I'd also use a longer -t value as well, I don't think 100 is enough for the exposure to have stabilised.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

rayjoh

Posts: 27 Joined: Thu May 23, 2013 11:48 am

Re: Using the other i2c bus hangs raspistill

Thu Jun 06, 2013 6:21 pm

jamesh wrote:Perhaps not related to the issue but you probably need to have a bigger delay between each invocation of raspistill - I doubt it can run up, capture then shutdown that fast and keep itself clean. I'd also use a longer -t value as well, I don't think 100 is enough for the exposure to have stabilised.
A new test.
I run this command in one terminal window

Code: Select all

for x in 1 2 3 4 5 6 7 8 9 ; do hwclock -r ; done
And this in another window

Code: Select all

raspistill -n -t 3000 -e jpg -o image.jpg
raspistill hangs forever in.

Code: Select all

root@pi4:~# strace -p 3546
Process 3546 attached - interrupt to quit
futex(0xb6f01390, FUTEX_WAIT_PRIVATE, 0, NULL
-- Raymond

jamesh

Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum ModeratorPosts: 27553 Joined: Sat Jul 30, 2011 7:41 pm

Re: Using the other i2c bus hangs raspistill

Thu Jun 06, 2013 7:48 pm

Wasn't really expecting it to help, but worth a punt. This one needs to go to Dom I think. There should be no interference between the two AFAIK.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

jamesh

Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum ModeratorPosts: 27553 Joined: Sat Jul 30, 2011 7:41 pm

Re: Using the other i2c bus hangs raspistill

Fri Jun 07, 2013 7:54 am

Consensus is maybe a fault in the Arm side I2C driver that its may be reseting the peripheral, or maybe bad clocking somwhere. Someone who knows more about it will have to look at it I think! Hopefully Dom will be able to comment.

My own thoughts are perhaps that the Arm side driver has no idea the I2C is being used by the GPU, so happily does a reset since its thinks its the only user. No idea how to test that though.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

jamesh

Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum ModeratorPosts: 27553 Joined: Sat Jul 30, 2011 7:41 pm

Re: Using the other i2c bus hangs raspistill

Fri Jun 07, 2013 10:36 am

Dom's taken a quick look and the driver doesn't seem to be doing the wrong thing.

Anyone know if the source to hwclock is available anywhere? That might be the culprit.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

Gert van Loo

Posts: 2487 Joined: Tue Aug 02, 2011 7:27 am Contact: Website

Re: Using the other i2c bus hangs raspistill

Fri Jun 07, 2013 10:43 am

This has gone up the chain of people who might know and landed on my desk.
I will have to look into this but I can't do that right now as I have a few other more important issues to resolve.
I CAN say that all the I2C channel are hardware-independent. That is: the chip has three totally individual instantiated I2C blocks.
AFAIK the source of the I2C clock is the system bus clock, not the general clock manager.

tasanakorn

Posts: 18 Joined: Thu May 16, 2013 3:53 pm

Re: Using the other i2c bus hangs raspistill

Mon Jun 10, 2013 11:23 am

Hi,
Good news. Finally, I can work around this problems (at least in my case).

Just unbind i2c bus 0 from linux i2c driver.

Code: Select all

sudo -s
echo bcm2708_i2c.0 > /sys/bus/platform/drivers/bcm2708_i2c/unbind

Now, I can mad pulling I2C and Camera simultaneously.


IMHO, conflict between Camera Driver (I2C-0 from GPU) and I2C linux kernel.


dom

Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum ModeratorPosts: 5673 Joined: Wed Aug 17, 2011 7:41 pm Location: Cambridge

Re: Using the other i2c bus hangs raspistill

Tue Jun 11, 2013 4:15 pm

Gert's given me a hwclock module. I can see the problem.

Basically there is a common I2C interrupt between the channels, and both I2C bus' handlers get called.
Because GPU is talking to camera on the "other" I2C bus, the arm eventually sees the "DONE" bit from a transaction and thinks it ought to respond.

This response results in either a panic when a null message pointer is dereferenced, or if it gets past that, then the resulting I2C responses will likely upset the camera.

I think @tasanakorn's unbind solution is actually the techically correct one.

I've also got a patch that makes I2C driver ignore interrupts if it has no outstanding messages, which also seems to fix it.

If anyone has an I2C device and ability to rebuild kernel, can you test this patch:
http://pastebin.com/z7G6tnHy

Firstly, does it break your current I2C usage?
Secondly does it continue to work when camera is active?

rayjoh

Posts: 27 Joined: Thu May 23, 2013 11:48 am

Re: Using the other i2c bus hangs raspistill

Wed Jun 12, 2013 5:45 am

I have successfully built a new kernel and modules. raspistill survived my hwclock test.

Without the patch, I could run raspistill and pi plate for maximum 5 minutes. I am running a test with raspistill, Pi plate and tmp102 at the moment. Still running after 40 minutes.

Added: I aborted the test after 8 hours. The patch is OK for me.
-- Raymond

dom

Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum ModeratorPosts: 5673 Joined: Wed Aug 17, 2011 7:41 pm Location: Cambridge

Re: Using the other i2c bus hangs raspistill

Wed Jun 12, 2013 8:33 pm

rayjoh wrote:Added: I aborted the test after 8 hours. The patch is OK for me.

Thanks for report. I'll add the patch to kernel source.


johntucker

Posts: 1 Joined: Wed Aug 14, 2013 10:48 pm

Re: Using the other i2c bus hangs raspistill

Wed Aug 14, 2013 10:58 pm

I to have this problem. I would like to know which of the two solutions in this chain is best. I would rather not have to rebuild the kernel so the unbind seems better but a better explanation would be helpful.

Thanks.

jamesh

Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum ModeratorPosts: 27553 Joined: Sat Jul 30, 2011 7:41 pm

Re: Using the other i2c bus hangs raspistill

Thu Aug 15, 2013 7:47 am

johntucker wrote:I to have this problem. I would like to know which of the two solutions in this chain is best. I would rather not have to rebuild the kernel so the unbind seems better but a better explanation would be helpful.

Thanks.

You could try rpi-update - that may pull in the fix.

Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

johny

Posts: 58 Joined: Tue Apr 24, 2012 10:00 am Location: Australia

Re: Using the other i2c bus hangs raspistill

Fri Sep 13, 2013 7:48 am

Thanks for this thread - I had a fun time trying to work out why my Pi B rev 1 was hanging intermittently.

Since it's not explicitly stated here yet: Don't use other devices on i2c-0 while you're using the camera - it won't always work... The CSI has a control channel (CCI) which is on i2c-0.

On the newer revision boards this is much harder to do by accident since the i2c-0 pins got moved to P5.

Display posts from previous:Sort by

Return to “Camera board”


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK