AnsweredAssumed Answered

Flashloader inside application

Question asked by Daniele Pagani on Aug 5, 2019
Latest reply on Aug 19, 2019 by jeremyzhou

   Dear sirs,

we're working with i.MX RT1060 EVK board and we're wondering about best practices for In-Application Programming.

We can correctly use Sdphost and Blhost utility, according to: Flash loader i.MXRT1060https://cache.nxp.com/secured/assets/downloads/en/programmers/FLASHLOADER-RT106x-1-GA.zip?__gda__=1565027429_41912c0a860b0aec6a744589f0269b4f&fileExt=.zip

However, we can not use boot pin mode for hardware's constraints.

So, we're using Rom Apis to set device programmatically into serial download mode:

void bl_serial_downloader(void)
{
run_bootloader_ctx_t boot_para;

boot_para.B.imageIndex = 0;
boot_para.B.serialBootInterface = kEnterBootloader_SerialInterface_USB;
boot_para.B.bootMode = kEnterBootloader_Mode_SerialDownloader;
boot_para.B.tag = kEnterBootloader_Tag;
g_bootloaderTree->runBootloader( (void *)&boot_para );
}

 

However, according to ROM APIs this feature is not available for all i.MX RT processors and our project can require usage of other processors.

So, we guess to load Flashloader application inside main application and then run it if required.

We define an array flashloader of bytes with Flashloader bin file and then we call a jump to application:

 

 .data.flashloader

                0x0000000020000000    0x161a1 ./source/led_blinky.o

                0x0000000020000000                flashloader

 *fill*         0x00000000200161a1        0x3 ff

 

JumpApplication(*(uint32_t*)0x20000400, *(uint32_t*)0x20000404);

 

__STATIC_FORCEINLINE void JumpApplication(uint32_t topOfMainStack, uint32_t AppAddr)
{
    __ASM volatile ("mov SP, %0" : : "r" (topOfMainStack) : );
    __ASM volatile ("mov PC, %0" : : "r" (AppAddr) : );
}

 

This solution doesn't work, so, can you suggest something about the matter?

 

BR,

Daniele

Outcomes