How do I stop MIMXRT1050 debug from erasing unused sectors?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I stop MIMXRT1050 debug from erasing unused sectors?

697 Views
michaelwhite
Contributor II

I have a 27 kB "bootloader" project I place in the beginning of XIP flash (0x60000000); this image boots and run as expected.  I have a "runtime" image I place at 0x60008000 (flash start + 32 kB) that is to be copied to RAM by the bootloader project.  If I create a binary file containing both the bootloader and runtime images and manually flash the binary image, XIP flash looks correct - the bootloader image is present at 0x60000000 and the runtime image is present at 0x60008000.

However, if I debug bootloader with MCUExpresso (v10.1.1) both the bootloader flash area (0x60000000 - 0x60007fff) and the runtime flash area (0x60008000 - ?) are overwritten - bootloader flash area is overwritten with the bootloader image (expected) and the runtime flash area is erased (all 0xff's, unexpected).

I've tried reducing the flash memory size seen by the bootloader project to 32 kB in "Properties --> C/C++ Build --> MCU settings" but that causes errors accessing the flash when attempting to load the image via Debug.

How do I prevent debug of the bootloader image from erasing flash blocks not needed by the bootloader image?

Thanks.

Tags (2)
1 Reply

559 Views
lpcxpresso_supp
NXP Employee
NXP Employee

As you may well know, these devices must first be erased before they can be programmed. Typically the erase size (sector/block) supported by the flash device is significantly larger than the program size (page). Hence the programming operation is s sequence of erases, program, program program ... Our flash drivers may concatenate the required erase operations at the start of the programming sequence, before streaming the data to be programmed to the driver.

The Hyperflash flash driver used by LinkServer is optimised for programming performance. A consequence of this is that the largest erase size (256KB) is used as part of the programming operations. This erase size represents 1/256 th (<1/2 %) of the device. If you wish to program two separate images (or binaries) into this flash, then each must start on a 256KB boundary. So if there is code programmed at the start of flash, the next address available for use is 0x60040000.

Note: when a LinkServer/CMSIS-DAP debug operation is performed, the debug log contains the sector/block erase size (as used by the driver), as well as the total flash size, as shown in the log fragment shown below.

...

Opening flash driver MIMXRT1050-EVK_S26KS512S.cfx
Sending VECTRESET to run flash driver
flash variant 'S26KS512S' detected (64MB = 256*256K at 0x60000000)
Closing flash driver MIMXRT1050-EVK_S26KS512S.cfx

...

Yours,

MCUXpresso IDE Support