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 0×4800. 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






Pingback: Flashing with a Button (and a Magic Wand) | MCU on Eclipse
Pingback: Page not found | MCU on Eclipse
Thanks a lot for the very useful hint.
I followed the steps described here and achieved preservation of a range of flash memory on my K60DN512 but it was painfully slow compared with no range preservation.
A bit of background: I have CW 10.2.4 and a P&E micro multilink FX. Without range preservation writing a image (of about 50Kb) in flash takes a few seconds (about 15s) but with range preservation (only memory range 1, from 0×40000 to 0x7FFFF) writing the same image takes more than 5 minutes! (320s average in several of my tests). I try to keep the multilink FX up-to-date (current firm. is 705) so I suspect it’s a codewarrior problem.
Any thoughts on this issue will be really useful.
I think the P&E ‘preservation’ algorithm really loads all the preserved bytes, then does a full erase and then programs the whole thing again. Which needs time.
Have you considered to use a Target Task instead? At least I see that here I could erase on a block level, and that way would avoid the whole backup thing.
Pingback: How (not) to Secure my Microcontroller | MCU on Eclipse
Pingback: Adding Symbols to the CodeWarrior Debugger | MCU on Eclipse
Hello,
I just saw this great option. Does the configuration is saved in project file or in worksapace?
For example: I have two projects on same workspace: Application and Bootloader.
I want to set memory preservation range for each of the project. Of course each project should have its own preservation range.
Thanks.
Yes, the settings are stored in the .launch file (typically located inside the Project_Settings\Debugger project folder).
That way you can have two different (Eclipse) launch files: one for the application and one for the bootloader.