STM32F2 bootloader问题(STM32F2 bootloader issue)

编程入门 行业动态 更新时间:2024-10-18 22:31:50
STM32F2 bootloader问题(STM32F2 bootloader issue)

我写了一个bootloader来跳转到我的应用程序。 首先,我尝试使用一个简单的blinky-led应用程序=>我能够从引导程序中跳转到应用程序。

现在我想跳进我的真实应用程序。 该应用程序运行良好,但当我从我的引导程序跳转到它时,一旦中断启用,应用程序崩溃,我的跳转代码:

__disable_irq(); SCB->VTOR = (uint32_t)0x0800BA00; JumpAddress = *(__IO uint32_t*) (0X0800BA04); JumpToApplication = (pFunction) JumpAddress; __set_MSP(*(__IO uint32_t*) 0X0800BA00); JumpToApplication();

我不知道出了什么问题以及为什么激活中断会使应用程序崩溃。

感谢您的帮助

I have write a bootloader to jump into my app. First I have try with a simple blinky-led app => I am able to jump into the app from the bootloader.

Now I want to jump into my real app. The app is working well alone but when I jump into it from my bootloader the app crash as soon as the interrupts are enabled, my jumping code :

__disable_irq(); SCB->VTOR = (uint32_t)0x0800BA00; JumpAddress = *(__IO uint32_t*) (0X0800BA04); JumpToApplication = (pFunction) JumpAddress; __set_MSP(*(__IO uint32_t*) 0X0800BA00); JumpToApplication();

I don't know what is wrong and why the activation of interruptions crash the app.

Thank you for your help

最满意答案

在跳转到应用程序之前,您应该初始化在引导加载程序中初始化的所有内容。 如果引导加载程序使用带中断的USART,则应禁用此USART(例如,使用RCC->AHBxRST / RCC->APBxRST寄存器)并禁用其中断。 您还应该在启用中断的情况下跳转到您的应用程序。 您的应用程序应该像正常重置后一样获得芯片。

如果您的应用程序使用来自ST的称为SPL或HAL的废话代码,请确保此代码不会将SCB-> VTOR重置为0或0x8000000,因为通常它会在SystemInit() ,这是从Reset_Handler()调用的,在main()之前。

BTW - 您对应用程序的地址绝对肯定吗? 您通常将应用程序放在页面边界,而您的代码并不表示 - 0x800ba00 (46.5kB)距离最近的页面边界32kB和48kB ...

Before you jump to the application, you should deinitialize everything that you've initialized in the bootloader. If your bootloader uses USART with interrupts, you should disable this USART (for example using RCC->AHBxRST/RCC->APBxRST registers) and disable its interrupts. You should also jump to your application with interrupts enabled. Your application should get the chip just as it would be after a normal reset.

If your application uses this crap code from ST called SPL or HAL, then make sure that this code does NOT reset SCB->VTOR back to 0 or 0x8000000, because normally it does that in SystemInit(), which is called from Reset_Handler(), before main().

BTW - are you absolutely sure about the address of your application? You usually put the application at the page boundary, while your code does not indicate that - 0x800ba00 (46.5kB) is pretty far from the closest page boundaries 32kB and 48kB...

更多推荐

本文发布于:2023-08-01 00:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1351365.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:bootloader   issue

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!