2015-02-25 05:14 PM
Hello:
I need develop an SD card bootloader for STM32F407, mine also will include encrypted XTEA algorithm. I developed it already time ago for Microchip PIC32, and now need to do it sot STM32F4.I have donwload already a lot of information, even some examples about USB and Serial bootloaders, and started to develop mine for SD Card.But after read a lot, also some in this forum Im a bit confused about the named ''Vector Table'', do not know exactly what is it and how must config it properly in a Bootloader.I know about how config Linker Script for bootloader and for firmware programms, about the ROM ORIGIN.Please may somebody confirm if I must apply these config to bootloader ??:1.- Jump to user application must to be Application Address + 0x04. Why ??2.- In user application always must include in main.cNVIC_SetVectorTable(NVIC_VectTab_FLASH, Application address);
3.- In user Application, modify Linker script ROM ORIGIN to first address of user application.Thats right, need to apply some more to bootloader or firmware applications ???Thank you and kind regards.2015-02-25 05:35 PM
Yes, seems fair enough.
You know there are books and manuals that describe the function of the micro processor? example.lst file, the address stored in the second vector entry (+4) points to the ResetHandler routine....
56 00000200 ; Vector Table Mapped to Address 0 at Reset
57 00000200 AREA RESET, DATA, READONLY
58 00000000 EXPORT __Vectors
59 00000000 EXPORT __Vectors_End
60 00000000 EXPORT __Vectors_Size
61 00000000
62 00000000 00000000
__Vectors
DCD __initial_sp ; Top of Stack
63 00000004 00000000 DCD Reset_Handler ; Reset Handler
64 00000008 00000000 DCD NMI_Handler ; NMI Handler
65 0000000C 00000000 DCD HardFault_Handler ; Hard Fault
Handler
66 00000010 00000000 DCD MemManage_Handler
; MPU Fault Handler
67 00000014 00000000 DCD BusFault_Handler
; Bus Fault Handler
68 00000018 00000000 DCD UsageFault_Handler ; Usage Faul
t Handler
69 0000001C 00000000 DCD 0 ; Reserved
70 00000020 00000000 DCD 0 ; Reserved
71 00000024 00000000 DCD 0 ; Reserved
72 00000028 00000000 DCD 0 ; Reserved
73 0000002C 00000000 DCD SVC_Handler ; SVCall Handler
74 00000030 00000000 DCD DebugMon_Handler ; Debug Monito
r Handler
75 00000034 00000000 DCD 0 ; Reserved
76 00000038 00000000 DCD PendSV_Handler ; PendSV Handler
77 0000003C 00000000 DCD SysTick_Handler
; SysTick Handler
78 00000040
79 00000040 ; External Interrupts
80 00000040 00000000 DCD WWDG_IRQHandler ; Window WatchD
...
2015-02-25 06:21 PM
if ((sp & 0xFFFE7FFF) == 0x20000000)
?? Its not enough to check if the first Application Address is to 0xFFFFFFFF, if true then there is not User Application, and bootloader can not jump.bool checkUserCode (u32 usrAddr) {
u32 sp = *(vu32*) usrAddr;
if ((sp & 0xFFFE7FFF) == 0x20000000)
{
return (TRUE);
} else {
return (FALSE);
}
}