2010-12-08 05:55 PM
Self programming STM32
2011-05-17 05:17 AM
Thanks, Andrew. I assume you're talking about the interrupt vector table? I don't think I'll need any interrupts at all.
What I'm still not clear on is that with the AVR if the fuse is set, you always go to the bootloader section first which then sends you to ''normal'' code space if the external stimulus is there. Am I right in thinking it's the BOOT0 line which sends you to this bootloader space? If not, you jump to the standard program? Is there something to setup to tell which addresses to go to depending on the state of the BOOT0 line?2011-05-17 05:17 AM
''I assume you're talking about the interrupt vector table?''
I'm talking about The Vector Table: there is only one table for all vectors - including the start vector, the interrupt vectors, exception vectors, etc...''Am I right in thinking it's the BOOT0 line which sends you to this bootloader'' The BOOT pin can send you to ST's internal bootloader in ROM; otherwise, the start vector is fetched from the 1st entry in the vector table. When you write your own custom bootloader - as we're discussing here, and as illustrated in AN2557 - that has to be the destination of the start vector.
As far as the CPU is concerned, your custom bootloader is just a ''standard'' application.
2011-05-17 05:17 AM
''There is an application note describing this''
It is the AN2557 mentioned above!
2011-05-17 05:17 AM
Like Neil just said, your boot loader is just a standard appplication.
The binaries created contain the vector table, there's no need to care for anything. If compiled for flash, these vector tables are aligned to the flash start address. You can use any size of bootloader you want, just make sure your ''real'' application starts anywhere on a flash sector boundary. When you offset your application, to e.g. 0x08008000 (that's what I did, my bootloader got quite big ;-)), you will have to do multiple things: - correct the vector table addresses - jump from bootloader-application to ''real'' application - tell the processor to use the new vector table. There is an application note describing this, but I can't find it. 1) vector table offset: I changed my linker script to use the new base address. It depends on your toolchain how you do that, as I'm using Winarm, I had to align stm32_flash.ld, to align the line FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 256K to FLASH (rx) : ORIGIN = 0x8008000, LENGTH = 224K 2) jump to application code: You bootloader needs to call the application. This is simple: { /* Jump to user application */ JumpAddress = *(vu32*) (ApplicationAddress + 4); Jump_To_Application = (pFunction) JumpAddress; /* Initialize user application's Stack Pointer */ Jump_To_Application(); } So, your setting a function's address to the address of your application +4 (the first 32bit-value is the stack pointer, followed by the reset vector), and call that function. 3) align for the new vector table: NVIC_SetVectorTable(NVIC_VectTab_FLASH, FIRMWAREBASEADDRESS); That's all that is needed to jump from one application to another one. You can do whatever you want to the flash sectors that are not used by the currently running code, e.g. erase and reprogram the bootloader from your application and vice versa.2011-05-17 05:17 AM
2011-12-29 11:13 PM
I have bootloader - which programming application via CAN.
Application starts successfully from main function (after reset or power-on). But when I try to start application after flash programming from CAN-interrupt handler - application doesn't started. How can I start application from interrupt handler?