i2c hangs when reading just one byte
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: i2c hangs when reading just one byte
Previously you posted that the problems happen even before I2C is initialized so I assumed problems were unrelated.
I need a simple test application to try to reproduce the problem or there is not much I can do. Testing compiler options on the various F4 discovery demos yielded no results, all demos worked, it must be something specific of your setup.
Giovanni
I need a simple test application to try to reproduce the problem or there is not much I can do. Testing compiler options on the various F4 discovery demos yielded no results, all demos worked, it must be something specific of your setup.
Giovanni
-
mingthemad
- Posts: 12
- Joined: Wed Sep 26, 2012 4:33 am
Re: i2c hangs when reading just one byte
I think the problems are related.
My code was definitely crashing when I tried to receive only one byte.
When I changed to reading more bytes, the crashes stopped.
If you are getting crashes when trying to receive one byte, try using a
larger receive buffer - say 4 bytes - and leave the receive count at 1.
When I did this, I no longer got crashes.
Craig
My code was definitely crashing when I tried to receive only one byte.
When I changed to reading more bytes, the crashes stopped.
If you are getting crashes when trying to receive one byte, try using a
larger receive buffer - say 4 bytes - and leave the receive count at 1.
When I did this, I no longer got crashes.
Craig
Re: i2c hangs when reading just one byte
Hi Giovanny.
I have some new interesting bug:
http://rghost.net/41071059
My application use dedicated threads for each I2C device. All that threads
have same priority (NORMAL+5) except thread polling ITG3200 gyroscope,
it has priority NORMAL+7 (named PollGyro). Semaphores used for mutual
exclusion in drivers (I am not use mutexes at all).
All I2C threads synchronized with interrupts from I2C sensors using semaphores
signaled from EXTI ISRs. As you can see on screenshot "sp->s_queue" points
to 0x20009690, this is PollGyro thread. That error happens after 1-10 minutes
after program start. If I set priority of PollGyro thread same as other I2C threads
than my program able to run successfully whole night.
I think problem somewhere in priority handling inside chibios but I not familiar with it.
I have some new interesting bug:
http://rghost.net/41071059
My application use dedicated threads for each I2C device. All that threads
have same priority (NORMAL+5) except thread polling ITG3200 gyroscope,
it has priority NORMAL+7 (named PollGyro). Semaphores used for mutual
exclusion in drivers (I am not use mutexes at all).
All I2C threads synchronized with interrupts from I2C sensors using semaphores
signaled from EXTI ISRs. As you can see on screenshot "sp->s_queue" points
to 0x20009690, this is PollGyro thread. That error happens after 1-10 minutes
after program start. If I set priority of PollGyro thread same as other I2C threads
than my program able to run successfully whole night.
I think problem somewhere in priority handling inside chibios but I not familiar with it.
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: i2c hangs when reading just one byte
Hi,
This kind of random crashes are often caused by a race condition, not necessarily into the kernel. Apparently the semaphore gets corrupted, are you running with the state checker enabled?
Giovanni
This kind of random crashes are often caused by a race condition, not necessarily into the kernel. Apparently the semaphore gets corrupted, are you running with the state checker enabled?
Giovanni
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: i2c hangs when reading just one byte
Wait a moment,
Exactly why you think there is a problem with that state? is the assertion triggered?
Looking at the variable the semaphore state looks correct, the counter is -1 and there is a single thread in the list. The assertion should not be triggered.
Giovanni
Exactly why you think there is a problem with that state? is the assertion triggered?
Looking at the variable the semaphore state looks correct, the counter is -1 and there is a single thread in the list. The assertion should not be triggered.
Giovanni
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: i2c hangs when reading just one byte
Very strange, are you sure you don't have stack overflows or other kind of overflows?
Giovanni
Giovanni
Re: i2c hangs when reading just one byte
No stack overflows catches by assertions but after whole weekend debugging I am not sure at all.
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: i2c hangs when reading just one byte
That assertion can only be triggered if the fields p_prev and p_next of the thread pointer by the semaphore do not point back to the semaphore.
Anyway, try posting the code, all the places where you touch that semaphore.
Giovanni
Anyway, try posting the code, all the places where you touch that semaphore.
Giovanni