AT91SAM7S64 IAR port
Posted by
Jokke on September 20, 2005
I discovered a problem with crashing system. The cause showed up to be that IAR expects stack to be initiated to 0, but freeRTOS initates to 01010101, 02020202 ...
Therefore I have made a change to port.c, in "pxPortInitialiseStack":
---
*pxTopOfStack = ( portSTACK_TYPE ) 0xaaaaaaaa;/* R14 */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) pxOriginalTOS; /* Stack used when task starts goes in R13. */
pxTopOfStack--;
for (i = 0; i < 12; ++i) {
*pxTopOfStack = ( portSTACK_TYPE ) 0x0;/* R12...R1 */
pxTopOfStack--;
}
---
After that it works.
Regards
Jokke
RE: AT91SAM7S64 IAR port
Posted by
Richard on September 20, 2005
This is definitely not the case. When a task starts it does not make any assumptions as to the stack or register states.
I suspect you are calling main() in the wrong processor mode. main() must be called in supervisor mode. Are you using the startup code that came with the demo project?
RE: AT91SAM7S64 IAR port
Posted by
Jokke on September 20, 2005
This has nothing to do with main. In a normal task I discovered (looking at the assembler listing) that the compiler places a read in a vector, using an index that is in some cases still not initialized. This works fine as long as the index is 0 until it is used, but I got problems with reads out of defined memory, since, in this case, R5 was 0x05050505, as is initialised in port.c.
Maybe this is a compiler error, but my guess was that they made this assumption.
The code is a state machine, and it might not be obvious enough for the compiler that it starts in a state where the index is set, before moving to the state where it is used. On the other hand I do not get any warning of "used before set"(maybe IAR does not give such warnings?).
I am using the startup from the demo project, and I made a lot of versions of the software before this came up.
I guess I will have to send you the code and the assembler listing before we reach consensus on this...
Regards
Jokke
RE: AT91SAM7S64 IAR port
Posted by
Richard on September 20, 2005
If you could send me the smallest project possible that exhibits this behaviour I would be very grateful! Send it to the email address from the FreeRTOS WEB site Contacts page (r dot barry at fr.....org). Thanks.
RE: AT91SAM7S64 IAR port
Posted by
Richard on September 20, 2005
From the received code it looks as if there could be a compiler error - I will post the results but might take a while.
RE: AT91SAM7S64 IAR port
Posted by
Jokke on September 26, 2005
I upgraded the IAR tools to lates version (4.30), and there the compiler bug seems to be solved!
No problem with freeRTOS!
SOLVED