AnsweredAssumed Answered

Bootloader, CodeWarrior 5 and P&E Multilink.

Question asked by Andre Goncalves on Jan 24, 2007
Latest reply on Jan 26, 2007 by Andre Goncalves
Hi there!

I am using a MC9S12E128, CodeWarrior 5 and a P&E Multilink.
My board has code that runs great. So what i decided to do was to make a bootloader that would check a MMC slot for a card, and if card was found, update the code. Let me walk you thru my idea.

On the main code, i changed the vector table to be created at 0x7F80. Then before any interrupt was enabled, i would move my RAM to be from 0xE000 to 0xFFFF and then copy my vector table to 0xFF80. The main code would reside anywhere besides from 0xC000 to 0xE000.

On the bootloader code, i fit the whole code from 0xC000 to 0xE000. The vector table for this code is normal (at 0xFF80). This code would check the MMC card using SPI, read the S19 file for the updated main code(generated by CodeWarrior), and copy it to flash (using the code i found on the freescale website on AN2720). After that was done and working, the program would just jump to the reset vector of the main program (at 0x7FFE) which in its turn would tell the code to go to the beginning of the main code (at 0x4001). Also, if there is no card present, it would just assume that there is already a main code programmed and jump to its reset vector right away. The bootloader won't update itself.

I hope i explained it right, here is the issue:

When i compile the code using CodeWarrior, program it using the Multilink and tell it to run on the debugger screen, the program runs, sees the card, copy the main code to flash, jump to the main code reset vector and runs main code. If i reset the board using the on screen debugger, it works too. But after that, if i just turn the board on, it wont jump to the main code! So it works if i have the debugger on, it wont if i have it in stand alone. The bootloader works, it finds the reset vector, the reset vector is pointing to the right location for the beginning of main code (0x4001) but it wont run main program.

What am i doing wrong?

Thank you,


P.S.: Sorry for long message....