ZHDA045 January 2026 MSPM0G1518 , MSPM0G1519 , MSPM0G3518 , MSPM0G3519
#define BANK0_APP_START 0x00002000
#define BANK1_APP_START 0x00042000
uint32_t gVer_info_LB0, gVer_info_LB1;
bool gBankswap_conduct;
int main(void)
{
SYSCFG_DL_init();
/* Get version information */
gVer_info_LB0 = *((uint32_t*)BANK0_APP_START);
gVer_info_LB1 = *((uint32_t*)BANK1_APP_START);
/* Decide bank swap */
if (gVer_info_LB0 < gVer_info_LB1) {
uint32_t* ptr_version_info = (uint32_t*)BANK1_APP_START + 1; // 0x00042004
uint32_t* ptr_SP = (uint32_t*)BANK1_APP_START + 64; // 0x00042256
gBankswap_conduct = true;
/* Check App data format */
for(int i=0; i<63; i++) {
if(ptr_version_info[i] != 0xFFFFFFFF) {
gBankswap_conduct = false;
}
}
/* Check stack pointer, it depends on device */
/* MSPM0G3519 RAM 64kB - 0x20210000 */
if(*ptr_SP != 0x20210000) {
gBankswap_conduct = false;
}
}
if (DL_SYSCTL_isINITDONEIssued())
{
start_app((uint32_t *)VECTOR_ADDRESS_BANK0);
}
else //Init and SWAP
{
if (gBankswap_conduct){
DL_SYSCTL_executeFromUpperFlashBank(); // set flash bank swap bit
delay_cycles(160);
DL_SYSCTL_issueINITDONE(); // Issue INITDOEN to trigger System Reset -> swap to bank1
}else{
DL_SYSCTL_executeFromLowerFlashBank(); // still execute program from bank0
delay_cycles(160);
DL_SYSCTL_issueINITDONE(); // Issue INITDOEN to trigger System Reset -> jump to bank0 app program
}
}
}
客户安全代码 (CSC) 会检查组 0 和组 1 中的固件版本,以确定是否需要组交换。版本信息存储在每个闪存组的应用程序区域的起始位置。具体而言,组 0 应用程序版本位于地址 0x00002000,而组 1 应用程序版本位于地址 0x00042000。
检查版本信息后,如果闪存组 1 中的固件是最新版本,CSC 会先验证固件标头,再决定是否执行组交换。如果固件的标头不正确,或者组 0 已经包含最新版本,则不会执行组交换。