Tool/software: Code Composer Studio
When using rm48 series processor to upgrade, flash API is needed to erase, read and write.
The overall process of upgrading is: when the program starts, it runs app directly. When communication command comes, it jumps to boot program, erases flash and writes new code.
The boot program is a separate project. The compiled binary code is placed in app in the form of an array, fixing the address of some functions, calling the function of boot from app through the function pointer, and realizing flash erasing, reading, writing and other functions.
If the flash operation in boot is executed in RAM, the binary code call in app that runs in RAM during code compilation does not run normally. Therefore, flash operation is not in RAM, that is, put boot in bank1 and app in bank0, so that the flash in boot can operate on the address in bank0. The specific address allocation is as follows:
The CMD file of bootloader:
MEMORY
{
VECTORS (X) : origin=0x00180000 length=0x00000020
FLASH0 (RX) : origin=0x00180020 length=0x000fffff
SRAM (RW) : origin=0x08002000 length=0x0002D000
STACK (RW) : origin=0x08000000 length=0x00002000
}
SECTIONS
{
.intvecs : {} > VECTORS
.text > FLASH0
.
const
> FLASH0
.cinit > FLASH0
.pinit > FLASH0
.data > SRAM
.bss > SRAM
}
App application CMD file:
MEMORY
{
VECTORS (X) : origin=0x00000000 length=0x00000020
FLASH1 (RX) : origin=0x00000020 length=0x0017ffe0
STACKS (RW) : origin=0x08000000 length=0x00001500
RAM (RW) : origin=0x08001500 length=0x0003EB00
}
/*----------------------------------------------------------------------------*/
/* Section Configuration */
SECTIONS
{
.intvecs : {} > VECTORS
.text : {} > FLASH1
.
const
: {} > FLASH1
.cinit : {} > FLASH1
.pinit : {} > FLASH1
.bss : {} > RAM
.data : {} > RAM
.sysmem : {} > RAM
}
However, during the debugging process, it is found that running boot program separately in bank1 can erase the specified bank0 address, read and write operations are normal, and the results are correct after running for many times.
However, in the way described above, when calling the function in boot through function pointer from app, an error will be reported when calling several times in succession, which will directly result in flash ECC error, and the nerror indicator light will be on, which cannot be recovered.
Please help to see, what is the problem? What's the solution? Thank you!