[LPC553x]:How to Use Dual Image

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

[LPC553x]:How to Use Dual Image

[LPC553x]:How to Use Dual Image

1. Background

When an embedded device is being upgraded, due to external factors such as power outage and forced interruption, the new firmware cant be written completely into flash, which causes problems when the system is started. Or if the image file is damaged during device is currently running, the system will break down and the device cannot run. To solve these problems, you can use the dual image, which ensures that at least one image file can be started and works properly at any time. If anything goes wrong, the bootloader detects and uses the alternate image file.

2. Principle

LPC5536 ROM supports the dual image boot for internal flash, that means, in the flash region, two boot images can be placed there; ROM decides to boot which image based on the image version, boot the one with the newer image version first, if fail, boot the older one.

During power-on and startup, the ROM first detects the location and size of the relocated image file in the CMPA, and then detects the version number of the two images. Therefore, when the dual image is used,  mainly need configure the relocation address and version number of the image files.

The internal flash boot flow for dual image is as follows:

Alice_Yang_0-1686706853190.png

 

2.1 Relocating Image File

The LPC5536 internal flash supports remapping. When set the remap offset, Internal FLASH memory AHB access will change the access address adding the offset as the below figure shows. For example, when the offset is set to 128K(0x20000), the access to 0x0 will be remapped to 0x20000. Via this IP feature, ROM can implement a dual image boot with two images. The offset and the remap size of the image is set in CMPA region by the user.

This is an illustration of two image files stored in internal FLASH.

Alice_Yang_0-1686708852971.png

The offset and remap size of the second image is set by the user in the CMPA area to let ROM know the location of the second image.

Alice_Yang_2-1686706853225.png

 

2.2 Configuring Image Version

The image version is the image header offset 0x24; bit 10 shows whether the image contains the image version for not; if bit10 is 0, that means the image has no image version; ROM will take the image version as 0.

Alice_Yang_3-1686706853248.png

 

3Implementation

3.1 Configuring CMPA

1) Configure Data Values in the CMPA

Use blhost to write the modified bin file to CMPA to configure the image1 offset and remap size. The procedure is as follows:

First, open an all 0 cmpa.bin and change the data at 0x3E23C to 0x20000, as shown in the figure below:

Alice_Yang_4-1686706853288.png

 

Then, modify the remap size. The data at address 0x3E238 is changed to 0x1d800, as shown in the following figure:

Alice_Yang_5-1686706853314.png

 

Modify and save, rename as cmpa_new.bin, save as \blhost_2.6.7\blhost_2.6.7\bin\win.

2) Download cmpa_new.bin

Blhost 2.6.7 is a command-line tool, that use it to program cmpa_new.bin.

Check whether the communication between blhost and development board is successfully.

Firstly, check the port number for connecting between development board and computer from  device manager.

Alice_Yang_6-1686706853327.png

 

Secondly, short 3 and 4 of jumper J43 on lpc55s36-evk to enable ISP boot.

Thirdly, press the reset key to reset board, input connection test command “blhost-p com12 -- get-property 1”

Check whether communication is normal. If connection is successful, the message will be displayed as below:

Alice_Yang_7-1686706853350.png

 

Program modified bin file into CMPA.

Write CMPA by using command blhost-pcom12 -- write-memory 0x3e200 cmpa_new.binas shown below:

Alice_Yang_8-1686706853425.png

 

Read back CMPA data after writing.

To confirm the accuracy of the data, run command “blhost-pcom12 -- read-memory 0x3e200 512” to view the configured CMPA data, as shown in the following figure:

Alice_Yang_9-1686706853477.png

 

3.2 Setting Dual Image Version

To observe experimental effect, Image0 function is the RED light on LPC5536-evk development blinking, Image1 function is BLUDE light blinking.

In Image0 project, set version number to 1, in Image1 set version number to 2:

Open the project of red light blinking and change the header file to 0x10400 at offset 0x24.

Alice_Yang_10-1686706853627.png

 

Open the project of blue light blinking and change the header file to 0x20400 at offset 0x24.

Alice_Yang_11-1686706853767.png

 

3.3 Remap Flash

For users, LPC5536JBD100 has a total of 246K internal flash available, so Image0 is assigned to the address range 0x00000-0x1FFFF and Image1 is assigned to the address range 0x20000-0x3D7ff. If using MCUXpresso ID, the Settings are as follows:

Right-click Selected Project -> choose Properties ->MCU settings, set the Location (start address) and Size, click  Apply button when finished.

The red light blinking project are modified as follows:

Alice_Yang_12-1686706854023.png

 

 The blue light blinking project modified as follows:

Alice_Yang_13-1686706854173.png

 

Re-compile the project.

 3.4 Functional Testing

Test application is two lighting projects, namely red light blinking and blue light blinking. The red light blinking is image0, version 1, and the blue light blinking is image1, version 2. Therefore, if test result is blue light blinking, dual image function works successfully..

Download Images:

Using GUI Flash Tool in MCUXpresso IDE, download two image files to the development board:

Alice_Yang_14-1686706854179.png

 

Open, and the following view pops up. Select download File in "File to program", then click run button, image will be downloaded to flash.

Alice_Yang_15-1686706854287.png

 

When the download is complete, click OK.

Alice_Yang_16-1686706854306.png

 

Download another image in the same way. Note that "mass erase" cannot be checked when programing the second image. If you use other tools to program, also should disable the same function as "mass erase", avoid erasing the first image file.

Test result

After downloading the program and reset, the blue light blinking.

Further test:

Change the version number of red light blinking project to 3, that is, modify 0x10400 to 0x30400. Then downloading the image file again. The red light blinking.

4Summary

Dual image function increases the security for boot and firmware update of embedded devices. It is necessary to pay attention to the way of setting image offset, remapping size and configuring image version in the CMPA area when using it, and also pay attention to the flash configuration in the two projects.

 

Attachment is test application project.

Labels (1)
Tags (1)
Attachments
Comments
  •  
No ratings
Version history
Last update:
‎03-26-2024 09:47 PM
Updated by: