Issue when setting Vector table register
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-04-30 8:56 AM
Hi
I have a booloader application that loads in new firmware in a different part of the flash. After updated I reset the processor and the newly uploaded application doesnt start. I think I must not be updating the vector table correctly because if I simply use the same vector table as the bootloader it works (the small uploaded test application doesnt use interupts). Here is my code in the bootloader.
#define APPLICATION_ADDRESS (uint32_t)0x08002030
typedef void (*pFunction)(void);
int boot_NewApp(void)
{pFunction JumpToApplication;
uint32_t JumpAddress;// Get the application stack pointer (First entry in the application vector table)
JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);// Get the application entry point (Second entry in the application vector table)
JumpToApplication = (pFunction) JumpAddress;// Reconfigure vector table offset register to match the application location
SCB->VTOR = APPLICATION_ADDRESS;// Set the application stack pointer
__set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);// Start the application
JumpToApplication();while(1);
}
If I comment out the 'SCB->VTOR = APPLICATION_ADDRESS;' line, it works as expected by using the bootloader vector table.
Can anyone please let me know what I am doing wrong?
Regards
Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-04-30 9:35 AM
>>Can anyone please let me know what I am doing wrong?
Got a bunch of random interrupts firing?
Stepped into with a debugger? Learned what?
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-04-30 9:37 AM
Hi
I added the line __disable_irq() at the start of the above function, and added __enable_irq() in my new application, and seemed to work okay until I added a serial interupt , and my bootloader vector table is used. Any idea why this is? I re added the SCB->VTOR = APPLICATION_ADDRESS; line in my bootloader..
Best Regards
Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-04-30 10:09 AM
#define APPLICATION_ADDRESS (uint32_t)0x08002030
[...]
// Reconfigure vector table offset register to match the application location
SCB->VTOR = APPLICATION_ADDRESS;
You didn't care to tell us what STM32, so I assumed Cortex-M4:
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-04-30 12:00 PM
,
,
Really the interrupts need to be culled at the peripheral level, especially when the app image doesn't support given interrupts, or statics haven't been initialized yet. Watch for SysTick in HAL implementations.
Have a proper Hard Fault Handler on both Loader and App, this should output to a USART ideally so death here can be quickly diagnosed.
Something in Default_Handler might also help if there is a disparity between IRQ Handlers provided by Loader and App
,Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-04-30 12:54 PM
Im using a STM32L073 chip.
Thanks
Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-04-30 4:11 PM
Im using a STM32L073 chip.
And then how hard is it to look it up in the respective Cortex-M0+ Programming Manual?
So, adjust the position of the table accordingly to the given granularity of 128 bytes.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-04-30 9:28 PM
Good catch, would expect it needs 256 byte alignment, the vector table is 192 bytes in size
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-01 3:40 AM
Thanks for that
I only had the data sheet and the reference manual (which I couldnt see any reference on the VTOR register), I never noticed the programmers manual.
I never enabled any interupts in the bootloader, just polled the serial port and now works great.
Thanks for the help.
Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-01 3:42 AM
Thanks Clive
Works good now , I now dont enable any interupts in the bootloader, just poll the serial port and changed my start location of my app to 256bit alignment and now works great.
Thanks for the help.
Scott
