We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
I am using Phytec LPC3250 board for my design and I have a very important problem that I have been spending time on for days.
I want to modify my bootloader_NOR code so that I can send my application code image from the serial port.
However, when I define a global variable and use this variable in a function it gets wierd values. My code can be simplified as below:
#include "LPC318x.H" int m = 0; void MyFunction(int value) // do nothing function { } int main(void) { for(;;) { m++; // <- Breakpoint MyFunction(m); } }
When I debug the code, I see "m = 0xE0000420" at the breakpoint where I expect to see 0x00.
This ruins all my intention and I cannot proceed to modify the code.
I think the data in the RAM region is corrupted but I dont know why and I have no sensible solution for this.
Thanks for your helps in advance.
The problem is that the memory region is corrupted as soon as the bootloader program starts running. For example, the value at address 0x08000004 immediately becomes "0xE000032F". If my variable is located at that address then my variable is gone forever.
What exactly did you expect to happen? The bootloader, once called, owns the entire CPU, including all the RAM. It has to. And yes, that means you can not rely on any RAM contents being untouched after the bootloader has run unless the documentation of the bootloader explicitly stated that it's going to leave certain locations unmodified. Does this bootloader make that kind of promise about that particular memory region?
I have assumed the OP is talking about the 2-nd level bootloader and he is modifying that.
If those assumptions are correct then he can rely on the contents of RAM since his application is the bootloader - So long as they are within the bounds and knowledge of his modified bootloader.