Erwin School

MCF52221 - Bootloader question

Discussion created by Erwin School on Apr 18, 2008
Latest reply on Apr 21, 2008 by Erwin School

I am currently developing a bootloader for the MCF52221 which can program new firmware (S-Record file) into the microcontroller's internal flash. The programming of the flash works perfectly, but i'm having trouble getting the new firmware to run.

The start address of the firmware flash (FIRMWARE_BASE) is 0x00001200 (directly after the bootloader code)

To start the firmware i use the following code:
    move.l  #FIRMWARE_BASE,a0           
    move.l  (a0),sp                       
    move.l  #(FIRMWARE_BASE + 4),a0   
    move.l  (a0),a0                       
    jmp (a0)                          
When this code is executed the microcontroller just hangs. Because the microcontroller hangs i think the firmware is not correct. I have tryed a jump to the address 0  and then the microcontroller restarts the bootloader, so the code above seems to work correct.

The firmware is a simple program which turns on a led when it is executed (based on a standard Codewarrior project).
Because it is a standard CodeWarrior project the Vectors are being copyed into the RAM by the following routine:
    if (__VECTOR_RAM != (unsigned long*)_vect)
        for (n = 0; n < 256; n++)
            __VECTOR_RAM[n] = (unsigned long)_vect[n];
    mcf5xxx_wr_vbr((unsigned long)__VECTOR_RAM);

I have adjusted the memory map in the linker command file (.lcf) to start from a address offset of 0x1200
   vectorrom   (RX)  : ORIGIN = 0x00001200, LENGTH = 0x00000400
   cfmprotrom  (RX)  : ORIGIN = 0x00001600, LENGTH = 0x00000020  
   code        (RX)  : ORIGIN = 0x00001700, LENGTH = 0x00018300
   vectorram   (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000400
   userram     (RWX) : ORIGIN = 0x20000400, LENGTH = 0x00003C00

So my question is: Am i forgetting something? Does anyone have an idea wat goes wrong, and how should i fix it? Any help would be greatly appreciated.

Thanks and greetings,