Hello,
We need to implement a secondary bootloader (SBL) on a 1051. The flashloader seems to be what we need. It would run at startup, wait for a few seconds to see if application need to be updated and if not, it jumps to our application. However, our application is partly in flash (XIP) and in OCRAM or DTCM for time critical functions.
Is this something flashloader can do? I don't see in flashloader code where it copies code from flash to RAM. It seems to only update external flash with new application and jump to it.
If not, could you advise on how to do this?
Thanks
Hugo
解決済! 解決策の投稿を見る。
Hi all,
Actually there no need for a modification of the bootloader for that. In the linker script of the application, you need to place your RAM function into RAM but also in flash. See this extract of our linker script:
/* MAIN TEXT SECTION */
.text : ALIGN(4)
{
__section_table_start = .;
__data_section_table = .;
LONG(LOADADDR(.data));
LONG( ADDR(.data));
LONG( SIZEOF(.data));
LONG(LOADADDR(.ram_func));
LONG( ADDR(.ram_func));
LONG( SIZEOF(.ram_func));
__data_section_table_end = .;
__bss_section_table = .;
LONG( ADDR(.bss));
LONG( SIZEOF(.bss));
__bss_section_table_end = .;
__section_table_end = . ;
/* End of Global Section Table */
*(.after_vectors*)
} > PROGRAM_FLASH
(...)
_etext = .;
/* RAM functions (SRAM_ITC) */
.ram_func : ALIGN(4)
{
FILL(0xff)
PROVIDE(__start_ram_func = .) ;
*(vtable)
*(.ramfunc*)
KEEP(*(CodeQuickAccess))
KEEP(*(DataQuickAccess))
*(RamFunction)
. = ALIGN(4) ;
PROVIDE(__end_ram_func = .) ;
} > SRAM_ITC AT>PROGRAM_FLASH
You can see that RAM functions are linked in ITC but place in flash. At startup, in ResetISR function, the application copies the code defined in __data_section_table into RAM. This table is defined in the linker script (see above).
// Load base address of Global Section Table
SectionTableAddr = &__data_section_table;
// Copy the data sections from flash to SRAM.
while (SectionTableAddr < &__data_section_table_end) {
LoadAddr = *SectionTableAddr++;
ExeAddr = *SectionTableAddr++;
SectionLen = *SectionTableAddr++;
data_init(LoadAddr, ExeAddr, SectionLen);
}
So there is almost nothing to do but modifying the linker script a little.
Hope this can help someone.
Hugo
Hi Gustavo,
Just got an idea, flashloader seems to be able to handle SB command. However, I think it's commands coming from the host. My idea it to create an SB section in my application that flashloader could read and execute the commands which would just be read/write memory commands that read part of the application in flash and copies them in RAM.
Could this be possible?
Thanks
Hugo
Hello Hugo,
You should be able to do it.
There are some posts on the communities with helpful information on using the flashloader like in the following community post.
https://community.nxp.com/t5/i-MX-RT/Flashloader-inside-application/m-p/951889
I hope that this information helps!
Regards,
Gustavo
Hello Hugo,
The Flashloader (available on the link below, you may need to login to download) does update the external Flash with the new application and then jumps to it. There are some more details on the documentation included.
https://www.nxp.com/webapp/Download?colCode=IMX-RT1050-FLASHLOADER&appType=license
The i.MXRT1150-EVK SDK contains a Flashloader example that may help you customize how the Flashloader works.
Just as an aside, AN12604 may also help as an example of an application with a secondary bootloader. As you see, there is a lot of flexibility on how you implement a bootloader.
https://www.nxp.com/docs/en/application-note/AN12604.pdf
I hope that this information helps!
Regards,
Gustavo
Hi Gustavo,
Thanks for your answer but this doesn't answer my question which was about Flashloader being able to copy time critical functions of our application into RAM.
The actual Flashloader application only manages the upgrade of the firmware (our application). However, could you tell me how or give me hints on how to modify it so it copies the part of our application that need to be run from RAM into OCRAM or TCM. Would I need to add some kind of table at a fix address in our application so the Flashloader could read this table and know what parts of the application need to be copied into RAM? Or do you have another solution?
Thanks,
Hugo
Hi all,
Actually there no need for a modification of the bootloader for that. In the linker script of the application, you need to place your RAM function into RAM but also in flash. See this extract of our linker script:
/* MAIN TEXT SECTION */
.text : ALIGN(4)
{
__section_table_start = .;
__data_section_table = .;
LONG(LOADADDR(.data));
LONG( ADDR(.data));
LONG( SIZEOF(.data));
LONG(LOADADDR(.ram_func));
LONG( ADDR(.ram_func));
LONG( SIZEOF(.ram_func));
__data_section_table_end = .;
__bss_section_table = .;
LONG( ADDR(.bss));
LONG( SIZEOF(.bss));
__bss_section_table_end = .;
__section_table_end = . ;
/* End of Global Section Table */
*(.after_vectors*)
} > PROGRAM_FLASH
(...)
_etext = .;
/* RAM functions (SRAM_ITC) */
.ram_func : ALIGN(4)
{
FILL(0xff)
PROVIDE(__start_ram_func = .) ;
*(vtable)
*(.ramfunc*)
KEEP(*(CodeQuickAccess))
KEEP(*(DataQuickAccess))
*(RamFunction)
. = ALIGN(4) ;
PROVIDE(__end_ram_func = .) ;
} > SRAM_ITC AT>PROGRAM_FLASH
You can see that RAM functions are linked in ITC but place in flash. At startup, in ResetISR function, the application copies the code defined in __data_section_table into RAM. This table is defined in the linker script (see above).
// Load base address of Global Section Table
SectionTableAddr = &__data_section_table;
// Copy the data sections from flash to SRAM.
while (SectionTableAddr < &__data_section_table_end) {
LoadAddr = *SectionTableAddr++;
ExeAddr = *SectionTableAddr++;
SectionLen = *SectionTableAddr++;
data_init(LoadAddr, ExeAddr, SectionLen);
}
So there is almost nothing to do but modifying the linker script a little.
Hope this can help someone.
Hugo