通过机应用跳转到bootloader的STM32即使用Boot 0和引导1引脚在启动模式下,从用户闪存 [英] Jump to Bootloader in STM32 through appliction i.e using Boot 0 and Boot 1 Pins in Boot mode from User flash

查看:2286
本文介绍了通过机应用跳转到bootloader的STM32即使用Boot 0和引导1引脚在启动模式下,从用户闪存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有固件升级的要求。我打算使用USB DFU类。但对于固件升级的命令将来自于我而言PC应用程序。所以我需要切换到引导程序是存在于系统内存。由于最初我运行应用程序,它正从用户闪存引导即我有BOOT0和引导1引脚配置用户闪存。由于DFU引导程序是在有系统的闪存,现在该BOOT0和BOOT1引脚设置需要改变。有没有像引导0和引导的方式1设置保持一致的用户闪存,并在应用中,我们跳转到系统内存?

I have a requirement for firmware upgrade. I am planning to use USB DFU class. But command for firmware upgrade will come from PC application in my case . so i need to switch to bootloader which is there in System Memory. As initially i am running application so it is getting booted from User flash i.e i have Boot0 and Boot 1 pins configured for User flash. As DFU bootloader is there in System flash ,now for that Boot0 and Boot1 pins settings need to be changed . is there a way like Boot 0 and Boot 1 settings remain same as User Flash memory and in the application we jump to System Memory?

推荐答案

BOOT0 / 1引脚仅当处理器开始,以检查它是否应该从内存中加载用户code或采样是否应加载引导程序。
这些引脚的状态没有引导装载程序之后的效果。

Boot0/1 pins are sampled only when the processor starts, in order to check if it should load the user code from memory or if it should load the bootloader. The state of these pins has no effect of the bootloader afterwards.

我已经面对了类似的请求,并发现2种方式来加载点播的引导程序。

I've been faced to a similar request, and found 2 ways to load the bootloader on-demand.

首先,你可以在JUMP从用户自code到bootloader。例如,您可以跳转到引导程序当按钮为pressed。

First, you can "JUMP" from user-code to the bootloader. For example, you could jump to the bootloader when a button is pressed.

不过......这不仅仅是一个简单的指令JUMP复杂得多:一些寄存器和设备必须正确地重新配置与引导加载程序的工作,你必须确保没有IRQ将跳转过程中引发的,......在事实上,你必须重新配置的处理器,如果它是复位后刚刚开始。
您可以找到有关此工艺的一些信息:从ST 该视频

But... this is far more complicated than a simple JUMP instruction : some registers and devices must be reconfigured correctly to work with the bootloader, you have to ensure that no IRQ will be triggered during the JUMP,... In fact, you have to reconfigure the processor as if it was just started after reset. You can find some information about this technic : on this video from ST.

我设法做这种对项目STM32F1xx之事。
然而,基于STM32F4一个更复杂的项目,这将成为真的很难......我将不得不停止所有设备(定时器,通信接口,ADC,DAC,...),确保没有IRQ被触发,重新配置所有的时钟,...

I managed to do this kind of things on STM32F1xx project. However, on a more complex project based on STM32F4, this would become really difficult... I would have to stop all devices (timers, communication interface, ADC, DAC,...), ensure that no IRQ would be triggered, reconfigure all the clocks,...

相反,我决定实施第二个解决方案:当我想跳到引导程序,我在备份寄存器的一个写字节,然后发出一个软复位。然后,当处理器将重新启动,在该程序的开始,它会读取该寄存器。该寄存器包含表明它应该bootloader模式重新启动值。然后,跳转到引导程序是非常容易,因为$ P $在的YouTube视频

Instead, I decided to implement this second solution: When I want to jump to the bootloader, I write a byte in one of the backup register and then issue a soft-reset. Then, when the processor will restart, at the very beginning of the program, it will read this register. This register contains the value indicating that it should reboot in bootloader mode. Then, the jump to the bootloader is much easier, as presented in the youtube video.

这篇关于通过机应用跳转到bootloader的STM32即使用Boot 0和引导1引脚在启动模式下,从用户闪存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆