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.
Hello, what I want to do in a new XC167 project is to program a boot routine which always resides in first sector of the internal flash. On power-up of the unit this routine will check if a memory stick is installed and if so it will also check if a new software version is available on the stick. If yes, the new version will be reprogrammed into flash, beginning at second sector (of course, flash file system and USB management is included in this boot routine). In older projects we used the in-system-flash programming described in appnote #138. Mostly this worked fine, but in some cases we had trouble when flash programming failed after updating via modem, or power loss - and everything was lost since flash was erased before...afterwards the on board AMD flash devices had to be programmed via eprommer by a service technician who had to go there....not very nice. Thats the reason why we prefere to have such a boot routine residing in internal flash to start a new update even when power gets lost during flash update. So again, this boot routine has to do this: - check if memory stick is installed - if not, set program counter to second sector of flash and start application program - if yes, check if new version is on stick - if so, overwrite new version into flash (starting at base adress of second sector), set program counter to start adress of second sector and so start aplication software.
Well, basically it seems not really hard work. Of course, the boot routine also must include routines to check if a valid application is already in flash, routines to compare actual version in flash with version in memory stick and so on. But I'm sure this will be possible.
What I do not know is, if it's possible to set the program counter to any location - in other words, is ist possible to jump to an explicit given adress, in this case jump to base adress of sector two ?
It would be nice to get help from you experts. And, if anybody has an appnote or link to examples where some or even all of the necessary boot routines are described, this would also be great !
Thank you in advance Harald
There are many ways to do this but something in C could look like.
Declare a function pointer
static void (far *myPC)(void);
Then in your code set the pointer to the address you want and then call it.
myPC = 0xC02000; /* set the address */ myPC(); /* jump to the address */
If you are using assembly then simply push the address you want onto the stack and then perform a "RET" of "RETS" instruction.
-Chris
Great assistance - Thanks a lot !
One further question concerning this topic, maybe you can help me once more: We are using µV3 with Ulink2 for debugging. I think, for running the application program from adress 0x0C02000 we have to make this by linker settings. But how does Ulink treat this when downloading into target ? Do we have to adjust the offset adress in ULINK settings ? If so, does ULINK erase the first sector too or does it remain unchanged ? In other words, we want to download the application to adress 0x0C02000, leaving the first flash sector unchanged - the bootloader must remain unaffected !
Thank you in advance, regards Harald