I'm trying to use the CF Flasher to program the external Flash. The processor is MCF5272 and the external Flash is connected to CS0. There is also an external SDRAM connected at CS7, mapped to 0x00100000.
When I compiled the code to start from 0x00000000 and set the Flash base address to 0x00000000 in the CF Flasher, it seemed to work fine. Then I changed the start of the code to 0x00100000 so that I can copy everything to SDRAM after startup (a loader code also added). When I set the Flash base address to 0x00100000 in the CF Flasher and tried to program, only the vector table will be copied to the Flash when I looked at the memory window, all the rest of the Flash are "FF"'s.
Did I do anything wrong here? I turned on the echo and everything looked fine except that CF Flasher did work as expected. Thanks a lot for your inputs!!
I'm not exactly sure how CFFlasher modifies the memory map of the target device, but I believe that it downloads some code to SRAM and that code probably adjusts the various base addresses. However, that probably has nothing to do with your problem.
When you compiled and flashed your code to address 0x00000000 everything worked properly because the external flash is mapped to address 0x00000000 at reset. This is because you will have arranged for CS0 to be used to boot from the external flash. When the CPU resets, it loads the initial stack pointer from adress 0x00000000 and the initial PC from 0x00000004, therefore your external flash must start off at address 0x00000000.
The initial PC could be the start address of your boot loader, and the boot loader could change base addresses and relocate code as you wish, but it must be able to start executing with the flash at 0x00000000. It must either be compiled to run at this address or it must not use any absolute addresses.
What you could do is to compile your boot loader to start at 0x00000000. Compile your application to start at 0x00100000. Flash your boot loader to 0x00000000. Do not change your CFFlasher flash base address setting and then flash your application to an address after the end of the boot loader. When the boot loader starts, it should set up SDRAM to start at address 0x00100000, it then copies the application to that address and finally jumps to the entry point in the application.
The key point is that CFFlasher can only change the base address of flash when you are flashing it. It is your application that must do that, if neccessary, at run time.
Thanks. I actually gave up on tweaking the CFFlasher. Instead I compiled the code at 0x00100000 and treat it as a data block, then used a loader to copy the data block into RAM, just like what you suggested.