RT1170 SBL ISP download app for remap function

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

RT1170 SBL ISP download app for remap function

RT1170 SBL ISP download app for remap function

RT1170 SBL ISP download app for remap function

1. Abstract

Previously wrote a post about using the official SBL ISP method to download the APP:

RT1170 SBL ISP download SDRAM APP

Recently, a customer also needs to use RT1170 SBL ISP to download code, but the code app that needs to be downloaded is based on MCUXpresso IDE, which generates a bin file and can be programmed to different locations in the flash, and then use remap to run the corresponding app.

Regarding remap, we can know from the SBL documentation that RT1170 can directly support it:

1.jpg

Fig 1

Usually, if combined with SFW for SD card, cloud and other app updates, the remap function can be directly supported. Because SFW currently only supports two IDEs: IAR and MDK, and does not support MCUXPresso IDE, it is not particularly convenient for customers to use MCUXPresso to develop apps. Moreover, customers do not need to use an SD card or network cloud to update the code. SBL's ISP Updates are enough. So how to use SBL to implement the remap function of two MCUXpresso apps? For MCUXpresso App, you can use one project, so you only need to modify the content to identify different apps and burn them to different flash addresses. The specific implementation methods and steps are given below.

The spatial structure of SBL, APP1, and APP2 codes is as follows:

2.jpg

Fig 2

2. SBL operation and modification

2.1 SBL configuration and downloading

Refer to the doc chapter 2.1:

RT1170 SBL ISP download SDRAM APP

Generate the related sbl_iar project.

2.2 SBL add remap code

Opern sbl project file: sbl-master\boot\sbl_boot.c

int sbl_boot_main(void) code modified like this:

int sbl_boot_main(void)
{
  char ch = 0;
	struct image_header br_hdr1 = {
		.ih_hdr_size = 0x2000
	};
	struct boot_rsp rsp = {
		.br_hdr = &br_hdr1,
		.br_flash_dev_id = 1,
		.br_image_off = 0x80000
	};
	int rc = 0;

#ifdef CONFIG_BOOT_SIGNATURE
#if defined(SOC_IMXRTYYYY_SERIES) || defined(SOC_LPC55S69_SERIES)
	CRYPTO_InitHardware();
#endif
#endif
	sbl_flash_init();
#ifdef TEST_FUNCTION
    enable_image(Permanent_mode);
#endif	
	BOOT_LOG_INF("Bootloader Version %s", BOOTLOADER_VERSION);
	os_heap_init();    
        BOOT_LOG_INF("remap or not:Y/N\r\n\r\n");
        ch = GETCHAR();
        BOOT_LOG_INF("input=%c,\r\n\r\n",ch);
        if((ch == 'Y') || (ch == 'y'))
        {
            BOOT_LOG_INF("With remap!\r\n\r\n");
            SBL_EnableRemap(BOOT_FLASH_ACT_APP, BOOT_FLASH_ACT_APP+FLASH_AREA_IMAGE_1_SIZE, FLASH_AREA_IMAGE_1_SIZE);
        }  
        else if((ch == 'N') || ((ch == 'n') ))
        {
	    BOOT_LOG_INF("Without remap!\r\n\r\n");
            SBL_DisableRemap();
        }
        else
        {
            BOOT_LOG_INF("Without remap!\r\n\r\n");
        }
#ifdef SINGLE_IMAGE
    rc = boot_single_go(&rsp);
#else
#ifdef SOC_REMAP_ENABLE
    rc = boot_remap_go(&rsp);
#else
	rc = boot_go(&rsp);
#endif
#endif /* SINGLE_IMAGE*/
	if (rc != 0) {
        while (1)
        {
            BOOT_LOG_ERR("Unable to find bootable image");
            SDK_DelayAtLeastUs(3000000, BOARD_BOOTCLOCKRUN_CORE_CLOCK);
        }
    }
    
	BOOT_LOG_INF("Bootloader chainload address offset: 0x%x", rsp.br_image_off);
	BOOT_LOG_INF("Reset_Handler address offset: 0x%x", rsp.br_image_off + rsp.br_hdr->ih_hdr_size);
	BOOT_LOG_INF("Jumping to the image\r\n\r\n");      
	do_boot(&rsp);
	BOOT_LOG_ERR("Never should get here");
    for (;;);
}

After modification, build the IAR SBL project, then use the debugger download the sbl to the MIMXRT1170-EVK board.

3. APP prepare

Refer to doc chapter 2.2:

RT1170 SBL ISP download SDRAM APP

In order to know the detail app, we can use the hello_world project, and modify the code like the following:

int main(void)
{
    char ch;

    /* Init board hardware. */
    BOARD_ConfigMPU();
    BOARD_InitPins();
    BOARD_BootClockRUN();
    BOARD_InitDebugConsole();
    PRINTF("hello world1->real addr is 0X30100000\r\n"); //app1
    //  PRINTF("hello world2->real addr is 0X30200000\r\n");//app2

    while (1)
    {
        ch = GETCHAR();
        PUTCHAR(ch);
    }
}

Use app1 printf code, to generate the hello_world1.bin,then add the secure header which match to the SBL, generate the hello_app1.bin.

Use app2 printf code, to generate the hello_world2.bin,then add the secure header which match to the SBL, generate the hello_app2.bin.

Now, give the details how to generate the related secure app:

Open sbl-master\target\evkmimxrt1170\env.bat:

Change the path to:

cd ..\..\component\secure\mcuboot\scripts

copy the mcuxpresso project generated bin file:hello_world1.bin and hello_world2.bin

to:

sbl-master\component\secure\mcuboot\scripts

Use the following commander:

python imgtool.py sign --key xxxx_priv.pem --align 4 --version "1.1" --header-size 0x400 --pad-header --slot-size 0x100000 --max-sectors 32 hello_world1.bin hello_app1.bin

python imgtool.py sign --key xxxx_priv.pem --align 4 --version "1.1" --header-size 0x400 --pad-header --slot-size 0x100000 --max-sectors 32 hello_world2.bin hello_app2.bin

to generate the hello_app1.bin, hello_app2.bin.

3.jpg

Fig 3

3. Test result

Use the MCUbootutility SBL OTA run mode, after board reset, in 5 seconds to connect the board, then burn:

hello_app1.bin to 0X30100000

hello_app2.bin to 0X30200000

4.jpg

Fig 4

5.jpg

Fig 5

After downloading, exit MCUBootutility.

Reset the board, in the console wait the log appear, then input ‘Y’ or ‘N’ to select which app boots:

‘Y’: remap, APP2 boot

‘N’: without remap, APP1 boot

Test result is:

 6.jpg

Fig 6

From the test result, we can see the remap function already works OK.

 

添付
評価なし
バージョン履歴
最終更新日:
‎01-03-2024 03:42 AM
更新者: