Page 2 of 6

Re: i2c hangs when reading just one byte

Posted: Tue Oct 09, 2012 2:35 pm
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

Re: i2c hangs when reading just one byte

Posted: Tue Oct 09, 2012 2:44 pm
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

Re: i2c hangs when reading just one byte

Posted: Tue Oct 09, 2012 2:52 pm
by Giovanni
So does it happens even before I2C is started?

Re: i2c hangs when reading just one byte

Posted: Tue Oct 09, 2012 3:09 pm
by barthess
Yes

Re: i2c hangs when reading just one byte

Posted: Tue Oct 09, 2012 3:13 pm
by Giovanni
This is very strange, are you at least able to reach the main function?

Re: i2c hangs when reading just one byte

Posted: Tue Oct 09, 2012 3:19 pm
by barthess
Correct. I can not reach main()

Re: i2c hangs when reading just one byte

Posted: Tue Oct 09, 2012 3:31 pm
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

Re: i2c hangs when reading just one byte

Posted: Tue Oct 09, 2012 4:09 pm
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

Re: i2c hangs when reading just one byte

Posted: Wed Oct 10, 2012 9:39 am
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?

Re: i2c hangs when reading just one byte

Posted: Wed Oct 10, 2012 10:20 am
by Giovanni
Does manually erasing flash before reprogramming fix the problem?

Giovanni