2018-12-26 12:22 AM
Hi,
MCU version 20KB RAM, 128 KB FLASH category 5. I tried solutions on the web available for different STM32 MCU with no success. BOOT0 pin is fixed to GND in my custom PCB.
My final code flow is like below:
SCB -> VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector table relocation in Internal Flash*/
int main(){
HAL_RCC_DeInit();
Systick -> CTRL = 0;
Systick -> LOAD =0;
Systick -> VAL =0;
__disable_irq();
HAL_FLASH_Unlock();
void (*foo)(void) = 0x00000004;
__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
SCB -> VTOR = 0;
__set_MSP(0x20005000);
foo();
while(1);
}
When i debug, code jumps to the location 0x00000004 but after some instructions device jumps again to reset handler.
Can you correct me to make embedded USBDFU bootloader work ?
Thanks in advance,
2018-12-26 05:01 AM
Pretty sure there is no code at 4
And nothing on the other side enables the processor's IRQ again.
Unlocking the flash does not enable.the syscfg clock.
2018-12-26 05:50 AM
Please note that i remapped the system memory. So 0x1FF00004(AN2606 says system memory start address is 0x1FF00000) is mapped to 4 actually. I could see it from debugger's disassembly section. I tried to enable syscfg clock with __HAL_RCC_SYSCFG_CLK_ENABLE() also, No success. Please help with more detailed comments.
2018-12-26 08:22 AM
> So 0x1FF00004(AN2606 says system memory start address is 0x1FF00000) is mapped to 4 actually.
4 is not the address to jump to. It is address of address to jump to.
-- pa
2018-12-27 02:38 AM
((void (*)(void)) *((uint32_t*) 0x00000004))();
I observed same behavior with the above jump too. I mean, It jumps back to reset handler.
2018-12-27 03:57 AM
Also, don't forget to set the stack pointer. The value is *(NULL) :)
-- pa