i2c hangs when reading just one byte

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

User avatar
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

Post by Giovanni »

Not sure, if the fault is immediate you should be able to step into it. Make sure to enable debug options, something could be trapped before the fault.

Giovanni
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: i2c hangs when reading just one byte

Post by barthess »

Debug options always on. I can not step in program before fault because it raise too early. All that I can is press "pause" in eclipse and look in stack:

Code: Select all

Thread [1] (Suspended: Signal 'SIGINT' received. Description: Interrupt.)   
   3 <symbol is not available> 0xffbaabe0   
   2 <symbol is not available> 0xfffffffc   
   1 <symbol is not available> 0xfffffffc   


Debugger also behaves strange

Code: Select all

thbreak main
Hardware assisted breakpoint 4 at 0x80c0192: file main.c, line 69.
continue
Note: automatically using hardware breakpoints for read-only addresses.

Program received signal SIGINT, Interrupt.
0xffbaabe0 in ?? ()


and OpenOCD

Code: Select all

Error: JTAG-DP STICKY ERROR
Error: MEM_AP_CSW 0x23000051, MEM_AP_TAR 0x280002ec
Error: stm32f4xxx.cpu -- clearing lockup after double fault
Polling target failed, GDB will be halted. Polling again in 100ms
Polling succeeded again
User avatar
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

Post by Giovanni »

So does it happens even before I2C is started?
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: i2c hangs when reading just one byte

Post by barthess »

Yes
User avatar
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

Post by Giovanni »

This is very strange, are you at least able to reach the main function?
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: i2c hangs when reading just one byte

Post by barthess »

Correct. I can not reach main()
User avatar
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

Post by Giovanni »

The only thing executed before the main is __early_init() that usually just does clock initialization, you should verify your clock settings.

Giovanni
User avatar
alex31
Posts: 445
Joined: Fri May 25, 2012 10:23 am
Has thanked: 57 times
Been thanked: 88 times

Re: i2c hangs when reading just one byte

Post by alex31 »

As i have said before, i have extracted my project so that it is no more included in chibios directory
and it compile with chibios from git.

now that i have done this, reading one byte just work ...
as previously, when my project was in chibios directory, chibios was uptodate,
i really don't understand where was the problem.

I have bought a book on git, perhaps i will find solution in it :-)

I have read post from barthess about problem when compiling with optimisation, and i have same
problem, but again, it's weird :

if i flash pgm compiled in O0, then flash pgm compiled in O2, pgm fail before entering main.
if i flash pgm compiled in O0, then flash pgm compiled in O1, then flash pgm compiled in O2, it's work in all the three mode, is it the same
for you barthess ?

Alexandre
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: i2c hangs when reading just one byte

Post by barthess »

alex31 wrote:if i flash pgm compiled in O0, then flash pgm compiled in O2, pgm fail before entering main.
if i flash pgm compiled in O0, then flash pgm compiled in O1, then flash pgm compiled in O2, it's work in all the three mode, is it the same
for you barthess ?

Looks very similar but not always the same.

Bug reproducible on testhal/STM32F4xx/I2C project when compiled with -Os
My own project reduced to blink + main threads now works with -O2 but failed with -Os.
-Os is the most buggy option.

I use

Code: Select all

gcc version 4.6.2 20120316 (release) [ARM/embedded-4_6-branch revision 185452] (GNU Tools for ARM Embedded Processors)
Open On-Chip Debugger 0.5.0 (v0.6.0-rc2 also tried with no differences)
Chibios trunk rev.4739

May it be bug in toolchain?
User avatar
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

Post by Giovanni »

Does manually erasing flash before reprogramming fix the problem?

Giovanni
Post Reply