简体   繁体   English

如何通过串口闪存STM32

[英]How to flash STM32 via Serial Port

I have an STM32F102 microcontroller and I want to program it via the Serial Port. 我有一个STM32F102微控制器,我想通过串口编程。

While there is a flasher available for windows, I want to do it on a Linux Machine. 虽然有一个可用于Windows的闪存,但我想在Linux机器上进行。 I tried doing it with this script 我尝试用这个脚本来做

I have set BOOT0 = 1 and BOOT1 = 0, restarted the microcontroller. 我已设置BOOT0 = 1且BOOT1 = 0,重启微控制器。 But it does not work. 但它不起作用。 I get the following output 我得到以下输出

Can't init. Ensure BOOT0=1, BOOT1=0, and reset device
Traceback (most recent call last):
  File "stm32loader.py", line 552, in <module>
    bootversion = cmd.cmdGet()
  File "stm32loader.py", line 140, in cmdGet
    if self.cmdGeneric(0x00):
  File "stm32loader.py", line 137, in cmdGeneric
    return self._wait_for_ack(hex(cmd))
  File "stm32loader.py", line 88, in _wait_for_ack
    raise CmdException("No response to %s" % info)
__main__.CmdException: No response to 0x0

Here are a few tips: 以下是一些提示:

  • Connect serial cable before resetting / powering up the board. 在重置/加电电路板之前连接串行电缆。 Otherwise some transients can mess the serial bootloader up. 否则一些瞬态可能会破坏串行引导加载程序。

  • Make sure you are using a TTL level USB-to-serial converter instead of a RS-232 cable. 确保使用的是TTL级USB转串口转换器而不是RS-232电缆。 RS-232 has inverted level, and worse still, its -15V to 15V voltage range can burn your STM32. RS-232具有反转电平,更糟糕的是,其-15V至15V的电压范围可以烧毁您的STM32。

  • Make sure RX and TX are connected correctly. 确保RX和TX正确连接。

  • Try using stm32flash instead. 请尝试使用stm32flash

  • Most STM32's serial bootloader does not support baud rate higher than 115200 as I remember. 我记得大多数STM32的串行引导加载程序不支持高于115200的波特率。 The bootloader can detect baud rate automatically, the one I usually use is 57600. 引导加载程序可以自动检测波特率,我通常使用的是57600。

Some of these chips are being shipped with locked bootloaders. 其中一些芯片与锁定的引导加载程序一起发货。 You will need to use STM32 Flash loader demonstrator to remove the protection. 您将需要使用STM32 Flash加载器演示器来删除保护。 Windows only unfortunately but once it is unlocked you can use any machine. 不幸的是Windows,但一旦解锁,你可以使用任何机器。

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

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