In many cases I do a full erase-flash-debug cycle: I get my embedded microcontroller flash completely erased and then programmed with my application. Well, that does not work that way if I program with a bootloader. Yes, I can flash the bootloader and then load my target application with the bootloader, but that’s not the scenario I want to use in the development phase. I want to flash my application and keep the bootloader on the target. This means: I need to do erase and program a part of the memory. But how to do this?
Background: My application runs on the TWR-LCD board. The ColdFire MCF51JM128 enumerates as MSD (Mass Storage Device) on the USB bus in booloader mode. That way I can simply copy an S19 file from the PC to the target and it will flash that file. The bootloader is implemented with Processor Expert components and is available here.
The following picture shows the memory map and shared areas between the bootloader and the application:
So flashing the application on top of the bootloader means that I should not erase the flash below 0x4800. I need to tell the debugger this. The solution is to use the P&E Multilink with the ‘Advanced Programming Option’:
This gives me the option I need to preserve one or multiple memory ranges:
There are other powerful options too. If use ‘Enable Flash Programming Dialog’ then get the following dialog during programming:
The good thing is: it shows that my flash protection works: the Debugger and P&E Multilink are preserving my data range, erasing things and then restore the content again: that way the preservation is not limited to the physical device flash block boundaries. Really, really cool!
The only not-so-good thing with this dialog is: it is visible only during the script execution, and closes right afterwards. So it might go so fast that you do not have any chance to read what is going on. But there is rescue: I need to have logging enabled (see as well Debugging rules):
With logging enabled, I get the messages as well in the Console view:
With that, I do not need to have the ‘Enable Flash Programming Dialog’ enabled. I get the full information to the Console View anyway with logging. And this is what I need to see. And with the Advanced Programming Option I can program only part of my flash
Happy flashing in parts 🙂