stm32f030代碼升級(jí)總結(jié)
bootloader設(shè)置:
static void check_boot_mode(void)
{
uint32_t JumpAddress;
void(*Jump_To_Application)(void);
if (((*((__IO uint32_t*)(APP_SEGA_START_ADDRESS+8))) & 0x2FFE0000 ) == 0x20000000)
{
JumpAddress = *(__IO uint32_t*) (APP_SEGA_START_ADDRESS + 12);
Jump_To_Application = (void *)JumpAddress;
__set_MSP(*((__IO uint32_t*) (APP_SEGA_START_ADDRESS+8)));
Jump_To_Application();
}
}
application設(shè)置:
const uint8_t eh[8] __attribute__((at(0x08004000)));這個(gè)是使應(yīng)用代碼加載首地址向后推移8字節(jié);
下圖是應(yīng)用代碼加載地址和內(nèi)存設(shè)置:
下面是中斷向量表映射配置:
#define APPLICATION_ADDRESS (uint32_t)0x08004008
__IO uint32_t VectorTable[48] __attribute__((at(0x20000000)));
for(i = 0; i < 48; i++)
{
VectorTable[i] = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));
}