Up till now, I wrote a small bootloader, that essentially just calls the main program that is 0x2000 off:
Code: Select all
#define APPLICATION_OFFSET 0x2000
typedef void (*pFunction)(void);
void startApp(void)
{
u32 ApplicationAddress=FLASH_BASE+APPLICATION_OFFSET;
/* Jump to user application */
pFunction Jump_To_Application = (pFunction) (*(__IO uint32_t*) (ApplicationAddress + 4));
/* Initialize user application's Stack Pointer */
u32 stack=*(__IO uint32_t*) ApplicationAddress;
__set_MSP(stack);
Jump_To_Application();
}
Then the main code have custom ld that contains
Code: Select all
MEMORY
{
flash : org = 0x08002000, len = 124k
ram : org = 0x20000000, len = 16k
}
and in the main
Code: Select all
void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset)
{
/* Check the parameters */
assert_param(IS_NVIC_VECTTAB(NVIC_VectTab));
assert_param(IS_NVIC_OFFSET(Offset));
SCB->VTOR = NVIC_VectTab | (Offset & (uint32_t)0x1FFFFF80);
}
int main(void)
{
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x2000);
So it was working good on 3454, but not on 3589, SIGTRAP inside chSysInit() (it can't step in chThdCreateStatic, guess some interrupt comes at the time and kills it) with pc=0x08000200, which is weird I think. If I change the program to run without the offset it goes okay, removing the chSysEnable() makes it run further until it freezes in some communication later. I have 3454 saved, so went back, recompiled and it is working again. Giovanni, can you think of anything that have changed recently that forbids me to move the code, like some interrupt handler at specific offset or something?