Preserve Memory Ranges In CodeWarrior v10.6

Document created by jack Employee on Sep 4, 2014Last modified by Diana Torres on Feb 28, 2017
Version 2Show Document
  • View in full screen mode

This document shows a general way how to preserve memory range using target task in CW10.6.

 

I am using k64 freedom board and Segger J-link in my project as an example. K64 freedom board use MK64FN1M0 MCU which has 1 M size flash.  In my project I divide the flash into two areas in the link file as below:

 

/* Specify the memory areas */

MEMORY

{

m_interrupts       (rx) : ORIGIN = 0x00000000, LENGTH = 0x198

m_cfmprotrom       (rx) : ORIGIN = 0x00000400, LENGTH = 0x10

m_text             (rx) : ORIGIN = 0x00000800, LENGTH = 512K

m_text2            (rx) : ORIGIN = 0x00080800, LENGTH = 512K - 0x800

m_data         (rwx) : ORIGIN = 0x1FFF0000, LENGTH = 64K                  /* Lower SRAM */

m_data2        (rwx) : ORIGIN = 0x20000000, LENGTH = 192K                 /* Upper SRAM */

}


m_text2 is the memory area that I am trying to keep it from being erased while downloading the application to m_text memory area. Here are the steps to do this using target task in CW10.6.

  • Add a target task view by clicking Window -> Show View -> other from menu bar, then select Debug -> Target Tasks view in the popup window.
  • From the Target Tasks view, select “Import” from the context menu. Then select the flash (.xml) file for your target device. In this case I need to select MK64FN1M0.xml file. After that you will see a “MK64FN1M0” task in the list.

image001.png

  • Double click the task name, you will see there are two actions (“Erase” and “Program and Verify”) in the “Flash Programmer Actions” view.

  image003.png

  • The default Erase action will mass erase all flash, so I remove this action by unchecking the “Erase” action. I can add erase action in “Program and Verify” action later.
  • Double click the “Program and Verify” action. In the popup dialog, check “Erase sectors before program” option. Check “Restrict to Addresses in this Range” option, and then specify the address range you want to program. The data/code out of this range will be preserved (will not be erased or changed). Click “Update Program Action” button to update the settings of this action.

image005.png

image007.png

  • Move to Debug configurations window by clicking Run -> Debug configurations from Menu bar. Select a debug configuration, in this case I select the run configuration for Segger J-Link. Select Download tab which is under Debugger tab.
  • By default, Standard Download will be executed and all the flash will be erased. As I am going to execute target task in this case, so uncheck “Perform Standard Download” and then check “Execute Tasks”. Click “Add” button to add a task. In this case I add K64F1M0M12 task which I created in previous step in target task view.

image015.gif

  • Click “Debug” button, the application will be downloaded to flash but preserved area which was not specified in restrict flash range will not be erased. You can check this from memory view.

 

With the above steps, you can preserve a specified flash range while downloading application. I am using Segger J-link in my project as an example and the steps also work for other tools like P&E Multilink and USB Tap.

Attachments

    Outcomes