Stlink: STLink-v2 固件升级后 st-flash 不工作

创建于 2020-05-11  ·  21评论  ·  资料来源: stlink-org/stlink

你好,
不幸的是,ST-LINK/V2 板固件升级后 STlink 工具不起作用。
但是,该板可与 STM32CubeIDE 配合使用。

  • 编程器/开发板类型:stlink /v2-clone
  • 编程器固件版本:V2J37S7
  • 操作系统及版本:Ubuntu 20.04
  • Stlink 工具版本:st-flash 1.6.0-301-gd11e6f4
  • Stlink 命令行工具名称:st-flash、st-util
  • 目标芯片(和板如果适用): STM32F407VET6
$ st-flash write foo.bin 0x8000000 
st-flash 1.6.0-301-gd11e6f4
2020-05-12T00:20:24 WARN common.c: unknown chip id! 0x5fa0004
Failed to connect to target
$ st-util --verbose=99
st-util
2020-05-12T00:22:26 DEBUG common.c: *** looking up stlink version
2020-05-12T00:22:26 DEBUG common.c: st vid         = 0x0483 (expect 0x0483)
2020-05-12T00:22:26 DEBUG common.c: stlink pid     = 0x3748
2020-05-12T00:22:26 DEBUG common.c: stlink version = 0x2
2020-05-12T00:22:26 DEBUG common.c: jtag version   = 0x25
2020-05-12T00:22:26 DEBUG common.c: swim version   = 0x7
2020-05-12T00:22:26 DEBUG common.c: stlink current mode: debug (jtag or swd)
2020-05-12T00:22:26 DEBUG usb.c: JTAG/SWD freq set to 0
2020-05-12T00:22:26 DEBUG common.c: *** set_swdclk ***
2020-05-12T00:22:26 DEBUG common.c: stlink current mode: debug (jtag or swd)
2020-05-12T00:22:26 DEBUG common.c: *** stlink_jtag_reset ***
2020-05-12T00:22:26 DEBUG common.c: *** stlink_reset ***
2020-05-12T00:22:26 DEBUG common.c: *** stlink_write_debug32 5fa0004 to 0xe000ed0c
2020-05-12T00:22:26 DEBUG common.c: Loading device parameters....
2020-05-12T00:22:26 DEBUG common.c: *** stlink_core_id ***
2020-05-12T00:22:26 DEBUG common.c: core_id = 0x2ba01477
2020-05-12T00:22:26 DEBUG common.c: *** stlink_read_debug32 5fa0004 is 0xe0042000
2020-05-12T00:22:26 WARN common.c: unknown chip id! 0x5fa0004
2020-05-12T00:22:26 DEBUG common.c: *** stlink_reset ***
2020-05-12T00:22:26 DEBUG common.c: *** stlink_write_debug32 5fa0004 to 0xe000ed0c
2020-05-12T00:22:26 DEBUG gdb-server.c: Chip ID is 0x00000004, Core ID is 0x2ba01477.
2020-05-12T00:22:26 INFO gdb-server.c: Listening at *:4242...
^C2020-05-12T00:22:29 DEBUG common.c: *** stlink_run ***
2020-05-12T00:22:29 DEBUG common.c: *** stlink_exit_debug_mode ***
2020-05-12T00:22:29 DEBUG common.c: *** stlink_write_debug32 a05f0000 to 0xe000edf0
2020-05-12T00:22:29 DEBUG common.c: *** stlink_close ***

更新。 夜行者-87
我在这里回答,因为该线程关闭了 4 条评论。
最后更新是程序员固件版本:V2J37S7。
我确实降级了固件 V2J36S7 以使用 st-flash。
您的版本 FW V2.J29.S7 和 V2.J34.S7 太旧了。

componenst-flash componenst-util errounknown-chipid olinux programmestlinkv2-clone statuno-bug staturesolved-verified statuwont-fix targestm32f0 targestm32f4

最有用的评论

所有21条评论

我在 Nucleo-64 STM32F030R8 板上将 ST-Link 固件更新到 2.37.26 后遇到了同样的问题。

那么我们可以添加一条评论,例如“如果您想使用此软件,请不要将 STLINK 固件更新到最新版本”?

对我来说,知道为什么这实际上失败会更有趣......
也许这些工具可以打补丁。
只有在不可能的情况下,建议的注释才是必要的。

不要更新 STLINK 固件

对我来说太晚了...我已经将固件降级到 st.com 上可用的最旧版本,但它没有帮助。 作为一种解决方法,我设法使用引导加载程序、USART 和stm32flash工具刷新我的代码,因此我知道目标设备正在工作。

那么我们可以添加一条评论,例如“如果您想使用此软件,请不要将 STLINK 固件更新到最新版本”?

我想是的。
我正在将我的 st-link 降级到 stsw-link007_V2-36-26。

谁能弄清楚哪个版本是最后一个已知的好版本?

不幸的是,这些旧固件只有 Windows 更新程序。 而且,正如人们可能猜到的,这个更新程序在 wine 下不起作用。

不幸的是,这些旧固件只有 Windows 更新程序。 而且,正如人们可能猜到的,这个更新程序在 wine 下不起作用。

如果我记得,我在 macOS 上使用 Java 版本的更新程序升级了我的 stlink v2 克隆。 升级后设备运行良好。 明天我会检查我的电脑上是否还有那个固件。

如果遇到任何问题,我会将我的 STLINKv2/clone 升级到最新固件并报告。

我已经用官方固件版本 V2.J29.S7 和 V2.J34.S7 和 Release v1.6.1 测试了原始方法:

$USER@$DEVICE:/$LOCAL_PATH/Blinker/Release$ st-flash write Blinker.bin 0x8000000
st-flash 1.6.1
2020-06-03T14:19:16 INFO common.c: F1xx Medium-density: 20 KiB SRAM, 64 KiB flash in at least 1 KiB pages.
file Blinker.bin md5 checksum: 16277ff2c027d497361dbae4255081a1, stlink checksum: 0x0004644a
2020-06-03T14:19:16 INFO common.c: Attempting to write 3520 (0xdc0) bytes to stm32 address: 134217728 (0x8000000)
2020-06-03T14:19:16 INFO common.c: Flash page at addr: 0x08000000 erased
2020-06-03T14:19:16 INFO common.c: Flash page at addr: 0x08000400 erased
2020-06-03T14:19:16 INFO common.c: Flash page at addr: 0x08000800 erased
2020-06-03T14:19:16 INFO common.c: Flash page at addr: 0x08000c00 erased
2020-06-03T14:19:16 INFO common.c: Finished erasing 4 pages of 1024 (0x400) bytes
2020-06-03T14:19:16 INFO common.c: Starting Flash write for VL/F0/F3/F1_XL core id
2020-06-03T14:19:16 INFO flash_loader.c: Successfully loaded flash loader in sram
  4/4 pages written
2020-06-03T14:19:16 INFO common.c: Starting verification of write complete
2020-06-03T14:19:16 INFO common.c: Flash written and verified! jolly good!

$USER@$DEVICE:/$LOCAL_PATH/git/stlink$ st-util --verbose=99
st-util
2020-06-03T13:13:44 DEBUG common.c: *** looking up stlink version
2020-06-03T13:13:44 DEBUG common.c: st vid         = 0x0483 (expect 0x0483)
2020-06-03T13:13:44 DEBUG common.c: stlink pid     = 0x3748
2020-06-03T13:13:44 DEBUG common.c: stlink version = 0x2
2020-06-03T13:13:44 DEBUG common.c: jtag version   = 0x22
2020-06-03T13:13:44 DEBUG common.c: swim version   = 0x7
2020-06-03T13:13:44 DEBUG common.c: *** looking up stlink version
2020-06-03T13:13:44 DEBUG common.c: st vid         = 0x0483 (expect 0x0483)
2020-06-03T13:13:44 DEBUG common.c: stlink pid     = 0x3748
2020-06-03T13:13:44 DEBUG common.c: stlink version = 0x2
2020-06-03T13:13:44 DEBUG common.c: jtag version   = 0x22
2020-06-03T13:13:44 DEBUG common.c: swim version   = 0x7
2020-06-03T13:13:44 DEBUG common.c: stlink current mode: mass
2020-06-03T13:13:44 DEBUG usb.c: JTAG/SWD freq set to 0
2020-06-03T13:13:44 DEBUG common.c: *** set_swdclk ***
2020-06-03T13:13:44 DEBUG common.c: stlink current mode: mass
2020-06-03T13:13:44 DEBUG common.c: *** stlink_enter_swd_mode ***
2020-06-03T13:13:44 DEBUG common.c: *** stlink_jtag_reset ***
2020-06-03T13:13:44 DEBUG common.c: *** stlink_reset ***
2020-06-03T13:13:44 DEBUG common.c: *** stlink_write_debug32 5fa0004 to 0xe000ed0c
2020-06-03T13:13:44 DEBUG common.c: Loading device parameters....
2020-06-03T13:13:44 DEBUG common.c: *** stlink_core_id ***
2020-06-03T13:13:44 DEBUG common.c: core_id = 0x2ba01477
2020-06-03T13:13:44 DEBUG common.c: *** stlink_read_debug32 20036410 is 0xe0042000
2020-06-03T13:13:44 DEBUG common.c: *** stlink_read_debug32 ffff0040 is 0x1ffff7e0
2020-06-03T13:13:44 INFO common.c: F1xx Medium-density: 20 KiB SRAM, 64 KiB flash in at least 1 KiB pages.
2020-06-03T13:13:44 DEBUG common.c: *** stlink_reset ***
2020-06-03T13:13:44 DEBUG common.c: *** stlink_write_debug32 5fa0004 to 0xe000ed0c
2020-06-03T13:13:44 DEBUG gdb-server.c: Chip ID is 0x00000410, Core ID is 0x2ba01477.
2020-06-03T13:13:44 INFO gdb-server.c: Listening at *:4242...
2020-06-03T14:07:48 DEBUG common.c: *** stlink_force_debug_mode ***
2020-06-03T14:07:48 DEBUG common.c: *** stlink_reset ***
2020-06-03T14:07:48 DEBUG common.c: *** stlink_write_debug32 5fa0004 to 0xe000ed0c
2020-06-03T14:07:48 DEBUG common.c: *** stlink_write_debug32 3 to 0xe0002000
2020-06-03T14:07:48 DEBUG common.c: *** stlink_read_debug32 261 is 0xe0002000
2020-06-03T14:07:48 INFO gdb-server.c: Found 6 hw breakpoint registers
2020-06-03T14:07:48 DEBUG common.c: *** stlink_write_debug32 0 to 0xe0002008
2020-06-03T14:07:48 DEBUG common.c: *** stlink_write_debug32 0 to 0xe000200c
2020-06-03T14:07:48 DEBUG common.c: *** stlink_write_debug32 0 to 0xe0002010
2020-06-03T14:07:48 DEBUG common.c: *** stlink_write_debug32 0 to 0xe0002014
2020-06-03T14:07:48 DEBUG common.c: *** stlink_write_debug32 0 to 0xe0002018
2020-06-03T14:07:48 DEBUG common.c: *** stlink_write_debug32 0 to 0xe000201c
2020-06-03T14:07:48 DEBUG gdb-server.c: init watchpoints
2020-06-03T14:07:48 DEBUG common.c: *** stlink_read_debug32 0 is 0xe000edfc
2020-06-03T14:07:48 DEBUG common.c: *** stlink_write_debug32 1000000 to 0xe000edfc
2020-06-03T14:07:48 DEBUG common.c: *** stlink_write_debug32 0 to 0xe0001028
2020-06-03T14:07:48 DEBUG common.c: *** stlink_write_debug32 0 to 0xe0001038
2020-06-03T14:07:48 DEBUG common.c: *** stlink_write_debug32 0 to 0xe0001048
2020-06-03T14:07:48 DEBUG common.c: *** stlink_write_debug32 0 to 0xe0001058
2020-06-03T14:07:48 INFO gdb-server.c: GDB connected.
2020-06-03T14:07:48 DEBUG gdb-server.c: recv: qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+;xmlRegisters=i386
2020-06-03T14:07:48 DEBUG gdb-server.c: query: Supported;multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+;xmlRegisters=i386
2020-06-03T14:07:48 DEBUG gdb-server.c: send: PacketSize=3fff;qXfer:memory-map:read+
2020-06-03T14:07:48 DEBUG gdb-server.c: recv: vMustReplyEmpty
2020-06-03T14:07:48 DEBUG gdb-server.c: send: 
2020-06-03T14:07:48 DEBUG gdb-server.c: recv: !
2020-06-03T14:07:48 DEBUG gdb-server.c: send: OK
2020-06-03T14:07:48 DEBUG gdb-server.c: recv: Hg0
2020-06-03T14:07:48 DEBUG gdb-server.c: send: 
2020-06-03T14:07:48 DEBUG gdb-server.c: recv: qTStatus
2020-06-03T14:07:48 DEBUG gdb-server.c: query: TStatus;
2020-06-03T14:07:48 DEBUG gdb-server.c: send: 
2020-06-03T14:07:48 DEBUG gdb-server.c: recv: ?
2020-06-03T14:07:48 DEBUG gdb-server.c: send: S05
2020-06-03T14:07:48 DEBUG gdb-server.c: recv: qfThreadInfo
2020-06-03T14:07:48 DEBUG gdb-server.c: query: fThreadInfo;
2020-06-03T14:07:48 DEBUG gdb-server.c: send: 
2020-06-03T14:07:48 DEBUG gdb-server.c: recv: qL1200000000000000000
2020-06-03T14:07:48 DEBUG gdb-server.c: send: 
2020-06-03T14:07:48 DEBUG gdb-server.c: recv: Hc-1
2020-06-03T14:07:48 DEBUG gdb-server.c: send: 
2020-06-03T14:07:48 DEBUG gdb-server.c: recv: qC
2020-06-03T14:07:48 DEBUG gdb-server.c: send: 
2020-06-03T14:07:48 DEBUG gdb-server.c: recv: qAttached
2020-06-03T14:07:48 DEBUG gdb-server.c: query: Attached;
2020-06-03T14:07:48 DEBUG gdb-server.c: send: 
2020-06-03T14:07:48 DEBUG gdb-server.c: recv: g
2020-06-03T14:07:48 DEBUG common.c: *** stlink_read_all_regs ***
2020-06-03T14:07:48 DEBUG gdb-server.c: send: 00000001fc7f000000d37f1f01f8dd32000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001
2020-06-03T14:07:48 DEBUG gdb-server.c: recv: qL1200000000000000000
2020-06-03T14:07:48 DEBUG gdb-server.c: send: 
2020-06-03T14:07:48 DEBUG gdb-server.c: recv: qXfer:memory-map:read::0,1000
2020-06-03T14:07:48 DEBUG gdb-server.c: query: Xfer;memory-map:read::0,1000
2020-06-03T14:07:48 DEBUG gdb-server.c: Xfer: type:memory-map;op:read;annex:;addr:0;length:4096
2020-06-03T14:07:48 DEBUG gdb-server.c: send: m<?xml version="1.0"?><!DOCTYPE memory-map PUBLIC "+//IDN gnu.org//DTD GDB Memory Map V1.0//EN"     "http://sourceware.org/gdb/gdb-memory-map.dtd"><memory-map>  <memory type="rom" start="0x00000000" length="0x10000"/>  <memory type="ram" start="0x20000000" length="0x5000"/>  <memory type="flash" start="0x08000000" length="0x10000">    <property name="blocksize">0x400</property>  </memory>  <memory type="ram" start="0x40000000" length="0x1fffffff"/>  <memory type="ram" start="0xe0000000" length="0x1fffffff"/>  <memory type="rom" start="0x1ffff000" length="0x800"/>  <memory type="rom" start="0x1ffff800" length="0x10"/></memory-map>
2020-06-03T14:07:48 DEBUG gdb-server.c: recv: qXfer:memory-map:read::27c,1000
2020-06-03T14:07:48 DEBUG gdb-server.c: query: Xfer;memory-map:read::27c,1000
2020-06-03T14:07:48 DEBUG gdb-server.c: Xfer: type:memory-map;op:read;annex:;addr:636;length:4096
2020-06-03T14:07:48 DEBUG gdb-server.c: send: l

我将对之前的版本进行第二次测试以进行调查。 但是,我们已经可以确认当前 STLINKv2 固件版本没有普遍问题,即使使用克隆的编程设备也是如此。

* Programmer firmware version: stsw-link007_V2-37-26

@busier :这是升级工具的版本,不是编程器的固件版本。 后者由升级工具决定,然后显示最新的可用版本。 请使用您的硬件重试,并且仅使用 ST 的官方工具和版本。

更新。 夜行者-87
我在这里回答,因为该线程关闭了 4 条评论。
最后更新是程序员固件版本:V2J37S7。
我确实降级了固件 V2J36S7 以使用 st-flash。
您的版本 FW V2.J29.S7 和 V2.J34.S7 太旧了。

线程再次打开。 这些是通过 ST 固件更新工具为 STLINK-v2 和 STLINK-v2 克隆编程器提供的最新版本。 我个人无法在任何其他硬件上进行测试,抱歉。
如果没有进一步的验证和贡献,我们恐怕也无能为力。

另一个测试版本 v1.6.1 和固件 V2.J36.S7(工具更新到 2.5.3):

$USER@$DEVICE:/$LOCAL_PATH:~/Schreibtisch/Blinker/Release$ st-flash write Blinker.bin 0x8000000
st-flash 1.6.1
2020-06-03T17:14:50 INFO common.c: F1xx Medium-density: 20 KiB SRAM, 64 KiB flash in at least 1 KiB pages.
file Blinker.bin md5 checksum: 16277ff2c027d497361dbae4255081a1, stlink checksum: 0x0004644a
2020-06-03T17:14:50 INFO common.c: Attempting to write 3520 (0xdc0) bytes to stm32 address: 134217728 (0x8000000)
2020-06-03T17:14:50 INFO common.c: Flash page at addr: 0x08000000 erased
2020-06-03T17:14:50 INFO common.c: Flash page at addr: 0x08000400 erased
2020-06-03T17:14:50 INFO common.c: Flash page at addr: 0x08000800 erased
2020-06-03T17:14:50 INFO common.c: Flash page at addr: 0x08000c00 erased
2020-06-03T17:14:50 INFO common.c: Finished erasing 4 pages of 1024 (0x400) bytes
2020-06-03T17:14:50 INFO common.c: Starting Flash write for VL/F0/F3/F1_XL core id
2020-06-03T17:14:50 INFO flash_loader.c: Successfully loaded flash loader in sram
  4/4 pages written
2020-06-03T17:14:50 INFO common.c: Starting verification of write complete
2020-06-03T17:14:50 INFO common.c: Flash written and verified! jolly good!

我们越来越近了——同时还有另一个更新可用,它部署了 V2J37S7——所以你是对的。 我也用相同的结果测试了后者。
在闪烁之前,您可能需要st-flash erase 。 反正我还是不能重现。

好消息:
最新固件 V2.J37.S7(fw-tool-更新至 2.5.4)甚至适用于 Release v1.6.0。

$USER@$DEVICE:/$LOCAL_PATH:/$LOCAL_PATH/git/stlink$ /$LOCAL_PATH/git/stlink/build/Release/st-info --version
v1.6.0
$USER@$DEVICE:/$LOCAL_PATH:/$LOCAL_PATH/git/stlink$ /$LOCAL_PATH/git/stlink/build/Release/st-flash erase
st-flash 1.6.0
2020-06-03T17:53:24 INFO common.c: Loading device parameters....
2020-06-03T17:53:24 INFO common.c: Device connected is: F1 Medium-density device, id 0x20036410
2020-06-03T17:53:24 INFO common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x10000 bytes (64 KiB) in pages of 1024 bytes
Mass erasing
$USER@$DEVICE:/$LOCAL_PATH:/$LOCAL_PATH/git/stlink$ /$LOCAL_PATH/git/stlink/build/Release/st-flash write /$LOCAL_PATH/Blinker/Release/Blinker.bin 0x8000000
st-flash 1.6.0
2020-06-03T17:54:22 INFO common.c: Loading device parameters....
2020-06-03T17:54:22 INFO common.c: Device connected is: F1 Medium-density device, id 0x20036410
2020-06-03T17:54:22 INFO common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x10000 bytes (64 KiB) in pages of 1024 bytes
2020-06-03T17:54:22 INFO common.c: Attempting to write 3520 (0xdc0) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08000c00 erased
2020-06-03T17:54:22 INFO common.c: Finished erasing 4 pages of 1024 (0x400) bytes
2020-06-03T17:54:22 INFO common.c: Starting Flash write for VL/F0/F3/F1_XL core id
2020-06-03T17:54:22 INFO flash_loader.c: Successfully loaded flash loader in sram
  4/4 pages written
2020-06-03T17:54:22 INFO common.c: Starting verification of write complete
2020-06-03T17:54:22 INFO common.c: Flash written and verified! jolly good!

我在 Nucleo-64 STM32F030R8 板上将 ST-Link 固件更新到 2.37.26 后遇到了同样的问题。

@grzegorz-kraszewski:您的电路板使用不同的编程器硬件:STLINK-v2-1。
如果仍然相关,请为此打开一个单独的问题。 此票证仅与 STLINK-v2 相关。 谢谢。

@chenguokai :我认为我们现在应该关闭它,因为原来的问题显然与stlink工具集无关。

不要改变:

:~/stlink/build/Release/bin$ ./st-flash write ~/Downloads/monitor_lmi.bin 0x8000000
st-flash 1.6.0-364-g60f8461
2020-06-03T19:18:40 WARN common.c: unknown chip id! 0x5fa0004
Failed to connect to target

@busier :如图所示,这不是stlink工具集本身的问题。 固件由 ST Microelectronics 作为商业专有产品提供。 因此,您需要参考官方 ST-Link 支持论坛。 我们不能提供固件支持,因为它不是这个项目的一部分,我们也没有开发人员访问它。

我使用 ST Link v2 克隆的本地测试对于 FW 版本V2J37S7似乎也很好。

是否有一些特定于板载 ST Link 的问题?

我们还不知道,但这就是为什么我建议 @grzegorz-kraszewski 打开单独的票,如果问题仍然存在于板载 V2-1 模块上。

对于 Ubuntu 20.04 和 Ubuntu 18.04。
STM32CubeProgrammer 与 STM32F103C8T6 (bluepill)
STM32CubeProgrammer 与 STM32F407VET6
但是 st-flash out 没有任何变化:

st-flash 1.6.0-364-g60f8461
2020-06-03T19:18:40 WARN common.c: unknown chip id! 0x5fa0004
Failed to connect to target

@busier :此票已关闭,不会重新打开。 请不要回收。

此页面是否有帮助?
0 / 5 - 0 等级