AnsweredAssumed Answered

Merge Bootloader + Application

Question asked by sebasira on Dec 30, 2011
Latest reply on Jan 3, 2012 by sebasira

Setup: MC9S12A256 and CW 3.1


Hi guys!


I'm trying to merge my application with AN3275 bootloader. I want to do it with the HEXFILE instruction on .prm file. 

What I do is add HEXFILE bootloader.s19 at the biggining of that file, then reduce segmenet ROM_C000 definition so my app will not invade bootloader area. And also remove reset vector entry, because it's already capture inside the bootloader code. Everything compiles just perfectly, I can enter bootloader menu, but I cannot run the application.


The bootloader checks PAD0, if it is low, it enters bootloading mode, if not, it jumps to user application, my application. But it's not jumping to my app, it jumps to 0x0000.

The asm instruction is JMP [0xFF30, PC]  (where PC = F0CA). If I'm not wrong this is program-counter relative addressing mode. I didn't know about it.

But after the jump PC = 0x0000. If I manually change it (when debugging) to PC = 0xC000 application runs.


I don't understand why the bootloader uses PC-relative addressing. Why not just jump (for my app) to 0xC000?



One more thing, when bootloading the same application (updating firmware), The reset vector get erased, so after reset PC = 0x0000 and neither user code, nor bootloader works, unless i manually set it to bootloader startup address. [Note: the app I bootIoad is the same, without merging the bootloader, I mean no HEXFILE and with the reset vector entry]




I would like to add that bootloader does NOT use interrupts, so I don't have 2 vector tables. I just got the one from my application