Forum : ST7/STM8
Original Post
Post Information | Post |
---|---|
July 24, 2009 - 11:37am
|
I've encountered an issue where the ZeroData routine used during startup will overwrite the whole ST7 stack, causing a crash when it tries to return. The issue seems to be related to initialising static variables to 0. The following code triggers the bug: char page0 a=0; void main(void) b = a++; // This is not important, just used it for a breakpoint void foo(void) } I believe I'm using the latest software version, this is what I have in About Ride7: Ride7 version 7.20.09.0162 At this point I'm just using global variables instead of statics. -- |
Hi
Can you let us know your target.
When I try your code with an ST7 I get a stack over flow error.
WHen does the crash appear?
Regards,
Matloub
I'm using ST72361AR6 as a target, but I think it will happen for any ST7 target. The crash is within the startup code generated by the compiler. Execution never reaches main().
I tried your little sample with your chip, but the link fails due to an address space overflow on ?ZD0?MAIN
Then I switched Default global memory class to Data and the sample links well and I'm able to debug in main.
I'm using the latest version (2.22.09.0203), but we haven't fixed anything in the ST7 startup.
Can you provided us more information or better a zipped project to:
Regards,
Stéphane
I've emailed the whole test project to .
I just downloaded the latest toolkit, and the problem is still there.
Maybe this will help you to trace the problem:
Normally ZeroData() loads BX with the start of the area to Zero, and CX with the length of the area. For my test code it loads BX with 0x00FE, and CX with 0x0103, which results in the stack being overwritten.
NOTE: The test code "works" if you exclude startup.asm from the project, as then ZeroData() is inlined, and there's nothing on the stack to damage.
The problem was within the linker of the latest release. A patch is available on the download page (for both a RLink issue with the verify command, and this linker issue).