简体   繁体   English

STM32 Factory Bootloader如何实现随时刷机?

[英]How Does STM32 Factory Bootloader Allow for Reflashing at any Time?

I'm aware that on some STM32 boards, they come with a built in bootloader in their ROM.我知道在某些 STM32 板上,它们的 ROM 中带有内置引导加载程序。 Quoting from STM32 Application Note引用自STM32 应用笔记

The bootloader is stored in the internal boot ROM (system memory) of STM32 devices, and is programmed by ST during production. Bootloader存储在STM32器件的内部引导ROM(系统内存)中,由ST在生产时进行编程。 Its main task is to download the application program to the internal Flash memory through one of the available serial peripherals (such as USART, CAN, USB, I2C, SPI).它的主要任务是通过可用的串行外设之一(如USART、CAN、USB、I2C、SPI)将应用程序下载到内部Flash memory。

However the ability to reflash at any time, ie trigger a reflash when your board is a running a program confuses me.然而,随时刷新的能力,即当您的电路板正在运行程序时触发刷新让我感到困惑。 My understanding is that a bootloader is the first piece of code to execute and then launches your user program.我的理解是引导加载程序是要执行的第一段代码,然后启动您的用户程序。 However, to facilitate this flashing at any time, won't the bootloader have to constantly poll for a request to reflash?但是,为了方便随时刷写,引导加载程序是否必须不断轮询刷新请求?

Your understanding is right.你的理解是对的。 Almost.几乎。

In case of STM32, you need to set up the chip to run the bootloader, typically using BOOT pins.对于 STM32,您需要设置芯片以运行引导加载程序,通常使用 BOOT 引脚。 When the bootloader runs, it checks if the programming is necessary by monitoring the specific peripherals.当引导加载程序运行时,它会通过监视特定外设来检查是否需要编程。 If the programming is not triggered, it jumps to the user program.如果没有触发编程,则跳转到用户程序。

Therefore, you cannot reprogram at any time, only at boot time.因此,您不能随时重新编程,只能在启动时重新编程。

Here is an example bootloader flowchart for programming over UART or I2C.以下是通过 UART 或 I2C 编程的示例引导加载程序流程图。

See this application note on STM32 bootloader for more details.有关更多详细信息,请参阅有关 STM32 引导加载程序的应用笔记

The bootloader only polls for an update on start-up/reset.引导加载程序仅在启动/重置时轮询更新。 So not "anytime" in the sense of "spontaneously" - you do have to trigger it.所以不是“自发地”意义上的“任何时候”——你必须触发它。 If the programmer has access to the reset pin or control of power, it can of course invoke a restart.如果程序员可以访问复位引脚或控制电源,则当然可以调用重启。

Moreover the ROM bootloader only runs at all if the BOOT pins are set appropriatlely.此外,只有在 BOOT 引脚设置得当的情况下,ROM 引导加载程序才会运行。 The boot modes are Flash, SRAM or ROM.引导方式为Flash、SRAM或ROM。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM