stlink: stlink locks up when not connected to a device via JTAG / SWD
Problem If I run any command st-info, st-flash, without a device connected to the JTAG pins, every command after that fails until I remove the ST-Link V2 from USB and plug it back in.
Expected/description: I expect that when a device is not connected due to power loss, connection loss or plain absentmindedness, when I do actually connect a device I am still able to communicate with it when I finally connect it and run the command again
OS
pi@raspberrypi:~/stlink-repo/build/Release $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
Programmer: STLinkV2 F/W V2.J32.S7
commit hash: c3577b578ff24c2f5a9c2cb7430986a931c9afcd however it is happening on previous commits as well atleast as far back as d040db5585d33dc36bd8ae093c024583ef1b4f74
Target: STM32L071KZU6
pi@raspberrypi:~/stlink-repo/build/Release $ ./st-info --probe
Found 1 stlink programmers
serial: 563f7306513f52501639133f
openocd: "\x56\x3f\x73\x06\x51\x3f\x52\x50\x16\x39\x13\x3f"
flash: 196608 (pagesize: 128)
sram: 20480
chipid: 0x0447
descr: L0x Category 5 device
- [ x ] Programmer/board type: e.g Stlink/v1, Stlink/v2, Stlink/v2-onboard
- [ x ] Programmer firmware version: e.g STSW-LINK007 2.27.15
- [ X ] Operating system: e.g Linux, Mac OS X, Windows (with specific version)
- [ X ] Stlink tools version and/or git commit hash: e.g v1.1.0/git-c722056
- [ X ] Stlink commandline tool name: e.g
st-info,st-flash,st-util - [ X ] Target chip (and optional board): e.g STM32F402VG (STM32Fxxx Discovery)
Output:
// STM Device connected to JTAG
pi@raspberrypi:~/stlink-repo/build/Release $ ./st-flash --reset --format ihex write ~/Puck-1.4.1.hex
st-flash 1.5.1-38-gc3577b5
2019-09-19T14:19:39 INFO usb.c: -- exit_dfu_mode
2019-09-19T14:19:39 INFO common.c: Loading device parameters....
2019-09-19T14:19:39 INFO common.c: Device connected is: L0x Category 5 device, id 0x20086447
2019-09-19T14:19:39 INFO common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x30000 bytes (192 KiB) in pages of 128 bytes
2019-09-19T14:19:39 INFO common.c: Ignoring 20 bytes of 0x00 at end of file
2019-09-19T14:19:39 INFO common.c: Attempting to write 34996 (0x88b4) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08008880 erased
2019-09-19T14:19:44 INFO common.c: Finished erasing 274 pages of 128 (0x80) bytes
2019-09-19T14:19:44 INFO common.c: Starting Half page flash write for STM32L core id
2019-09-19T14:19:44 INFO flash_loader.c: Successfully loaded flash loader in sram
546/546 halfpages written
2019-09-19T14:19:52 INFO common.c: Starting verification of write complete
2019-09-19T14:19:52 INFO common.c: Flash written and verified! jolly good!
pi@raspberrypi:~/stlink-repo/build/Release $
-----------------------------------------------------------------------------------------
// STM Device not connected to JTAG
pi@raspberrypi:~/stlink-repo/build/Release $ ./st-flash --reset --debug --format ihex write ~/Puck-1.4.1.hex
st-flash 1.5.1-38-gc3577b5
2019-09-19T14:20:04 DEBUG common.c: stlink current mode: debug (jtag or swd)
2019-09-19T14:20:04 DEBUG common.c: stlink current mode: debug (jtag or swd)
2019-09-19T14:20:04 DEBUG common.c: *** looking up stlink version
2019-09-19T14:20:04 DEBUG common.c: st vid = 0x0483 (expect 0x0483)
2019-09-19T14:20:04 DEBUG common.c: stlink pid = 0x3748
2019-09-19T14:20:04 DEBUG common.c: stlink version = 0x2
2019-09-19T14:20:04 DEBUG common.c: jtag version = 0x20
2019-09-19T14:20:04 DEBUG common.c: swim version = 0x7
2019-09-19T14:20:04 DEBUG common.c: *** set_swdclk ***
2019-09-19T14:20:04 DEBUG common.c: *** stlink_jtag_reset ***
2019-09-19T14:20:04 DEBUG common.c: *** stlink_reset ***
2019-09-19T14:20:04 DEBUG common.c: *** stlink_write_debug32 5fa0004 to 0xe000ed0c
2019-09-19T14:20:04 INFO common.c: Loading device parameters....
2019-09-19T14:20:04 DEBUG common.c: *** stlink_core_id ***
2019-09-19T14:20:04 DEBUG common.c: core_id = 0x00000000
2019-09-19T14:20:04 DEBUG common.c: *** stlink_read_debug32 0 is 0xe0042000
2019-09-19T14:20:04 DEBUG common.c: *** stlink_read_debug32 0 is 0x40015800
2019-09-19T14:20:04 WARN common.c: Invalid flash type, please check device declaration
2019-09-19T14:20:04 DEBUG common.c: stlink current mode: debug (jtag or swd)
2019-09-19T14:20:04 DEBUG common.c: stlink current mode: debug (jtag or swd)
2019-09-19T14:20:04 DEBUG common.c: *** stlink_jtag_reset ***
2019-09-19T14:20:04 DEBUG common.c: *** stlink_reset ***
2019-09-19T14:20:04 DEBUG common.c: *** stlink_write_debug32 5fa0004 to 0xe000ed0c
2019-09-19T14:20:04 DEBUG common.c: *** stlink_force_debug_mode ***
2019-09-19T14:20:04 DEBUG common.c: *** stlink_status ***
core status: unknown
Unknown memory region
2019-09-19T14:20:04 DEBUG common.c: *** stlink_exit_debug_mode ***
2019-09-19T14:20:04 DEBUG common.c: *** stlink_write_debug32 a05f0000 to 0xe000edf0
2019-09-19T14:20:04 DEBUG common.c: *** stlink_close ***
-----------------------------------------------------------------------------------------
// STM Device connected to JTAG
pi@raspberrypi:~/stlink-repo/build/Release $ ./st-flash --reset --debug --format ihex write ~/Puck-1.4.1.hex
st-flash 1.5.1-38-gc3577b5
2019-09-19T14:20:12 DEBUG common.c: stlink current mode: debug (jtag or swd)
2019-09-19T14:20:12 DEBUG common.c: stlink current mode: debug (jtag or swd)
2019-09-19T14:20:12 DEBUG common.c: *** looking up stlink version
2019-09-19T14:20:12 DEBUG common.c: st vid = 0x0483 (expect 0x0483)
2019-09-19T14:20:12 DEBUG common.c: stlink pid = 0x3748
2019-09-19T14:20:12 DEBUG common.c: stlink version = 0x2
2019-09-19T14:20:12 DEBUG common.c: jtag version = 0x20
2019-09-19T14:20:12 DEBUG common.c: swim version = 0x7
2019-09-19T14:20:12 DEBUG common.c: *** set_swdclk ***
2019-09-19T14:20:12 DEBUG common.c: *** stlink_jtag_reset ***
2019-09-19T14:20:12 DEBUG common.c: *** stlink_reset ***
2019-09-19T14:20:12 DEBUG common.c: *** stlink_write_debug32 5fa0004 to 0xe000ed0c
2019-09-19T14:20:12 INFO common.c: Loading device parameters....
2019-09-19T14:20:12 DEBUG common.c: *** stlink_core_id ***
2019-09-19T14:20:12 DEBUG common.c: core_id = 0x00000000
2019-09-19T14:20:12 DEBUG common.c: *** stlink_read_debug32 0 is 0xe0042000
2019-09-19T14:20:12 DEBUG common.c: *** stlink_read_debug32 0 is 0x40015800
2019-09-19T14:20:12 WARN common.c: Invalid flash type, please check device declaration
2019-09-19T14:20:12 DEBUG common.c: stlink current mode: debug (jtag or swd)
2019-09-19T14:20:12 DEBUG common.c: stlink current mode: debug (jtag or swd)
2019-09-19T14:20:12 DEBUG common.c: *** stlink_jtag_reset ***
2019-09-19T14:20:12 DEBUG common.c: *** stlink_reset ***
2019-09-19T14:20:12 DEBUG common.c: *** stlink_write_debug32 5fa0004 to 0xe000ed0c
2019-09-19T14:20:12 DEBUG common.c: *** stlink_force_debug_mode ***
2019-09-19T14:20:12 DEBUG common.c: *** stlink_status ***
core status: unknown
Unknown memory region
2019-09-19T14:20:12 DEBUG common.c: *** stlink_exit_debug_mode ***
2019-09-19T14:20:12 DEBUG common.c: *** stlink_write_debug32 a05f0000 to 0xe000edf0
2019-09-19T14:20:12 DEBUG common.c: *** stlink_close ***
-----------------------------------------------------------------------------------------
// STM Device connected to JTAG
pi@raspberrypi:~/stlink-repo/build/Release $
pi@raspberrypi:~/stlink-repo/build/Release $ ./st-flash --reset --debug --format ihex write ~/Puck-1.4.1.hex
st-flash 1.5.1-38-gc3577b5
2019-09-19T14:20:14 DEBUG common.c: stlink current mode: debug (jtag or swd)
2019-09-19T14:20:14 DEBUG common.c: stlink current mode: debug (jtag or swd)
2019-09-19T14:20:14 DEBUG common.c: *** looking up stlink version
2019-09-19T14:20:14 DEBUG common.c: st vid = 0x0483 (expect 0x0483)
2019-09-19T14:20:14 DEBUG common.c: stlink pid = 0x3748
2019-09-19T14:20:14 DEBUG common.c: stlink version = 0x2
2019-09-19T14:20:14 DEBUG common.c: jtag version = 0x20
2019-09-19T14:20:14 DEBUG common.c: swim version = 0x7
2019-09-19T14:20:14 DEBUG common.c: *** set_swdclk ***
2019-09-19T14:20:14 DEBUG common.c: *** stlink_jtag_reset ***
2019-09-19T14:20:14 DEBUG common.c: *** stlink_reset ***
2019-09-19T14:20:14 DEBUG common.c: *** stlink_write_debug32 5fa0004 to 0xe000ed0c
2019-09-19T14:20:14 INFO common.c: Loading device parameters....
2019-09-19T14:20:14 DEBUG common.c: *** stlink_core_id ***
2019-09-19T14:20:14 DEBUG common.c: core_id = 0x00000000
2019-09-19T14:20:14 DEBUG common.c: *** stlink_read_debug32 0 is 0xe0042000
2019-09-19T14:20:14 DEBUG common.c: *** stlink_read_debug32 0 is 0x40015800
2019-09-19T14:20:14 WARN common.c: Invalid flash type, please check device declaration
2019-09-19T14:20:14 DEBUG common.c: stlink current mode: debug (jtag or swd)
2019-09-19T14:20:14 DEBUG common.c: stlink current mode: debug (jtag or swd)
2019-09-19T14:20:14 DEBUG common.c: *** stlink_jtag_reset ***
2019-09-19T14:20:14 DEBUG common.c: *** stlink_reset ***
2019-09-19T14:20:14 DEBUG common.c: *** stlink_write_debug32 5fa0004 to 0xe000ed0c
2019-09-19T14:20:14 DEBUG common.c: *** stlink_force_debug_mode ***
2019-09-19T14:20:14 DEBUG common.c: *** stlink_status ***
core status: unknown
Unknown memory region
2019-09-19T14:20:14 DEBUG common.c: *** stlink_exit_debug_mode ***
2019-09-19T14:20:14 DEBUG common.c: *** stlink_write_debug32 a05f0000 to 0xe000edf0
2019-09-19T14:20:14 DEBUG common.c: *** stlink_close ***
-----------------------------------------------------------------------------------------
// Remove USB and plug in again, STM device connected to JTAG
pi@raspberrypi:~/stlink-repo/build/Release $ ./st-flash --reset --format ihex write ~/Puck-1.4.1.hex
st-flash 1.5.1-38-gc3577b5
2019-09-19T14:20:26 INFO usb.c: -- exit_dfu_mode
2019-09-19T14:20:26 INFO common.c: Loading device parameters....
2019-09-19T14:20:26 INFO common.c: Device connected is: L0x Category 5 device, id 0x20086447
2019-09-19T14:20:26 INFO common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x30000 bytes (192 KiB) in pages of 128 bytes
2019-09-19T14:20:27 INFO common.c: Ignoring 20 bytes of 0x00 at end of file
2019-09-19T14:20:27 INFO common.c: Attempting to write 34996 (0x88b4) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08008880 erased
2019-09-19T14:20:32 INFO common.c: Finished erasing 274 pages of 128 (0x80) bytes
2019-09-19T14:20:32 INFO common.c: Starting Half page flash write for STM32L core id
2019-09-19T14:20:32 INFO flash_loader.c: Successfully loaded flash loader in sram
546/546 halfpages written
2019-09-19T14:20:39 INFO common.c: Starting verification of write complete
2019-09-19T14:20:40 INFO common.c: Flash written and verified! jolly good!
Nothing very interesting in here, but posting them for completeness… Output of dmesg:
pi@raspberrypi:~/stlink-repo/build/Release $ dmesg
[17512.033914] usb 1-1.3: new full-speed USB device number 18 using dwc_otg
[17512.167748] usb 1-1.3: New USB device found, idVendor=0483, idProduct=3748, bcdDevice= 1.00
[17512.167765] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[17512.167774] usb 1-1.3: Product: STM32 STLink
[17512.167784] usb 1-1.3: Manufacturer: STMicroelectronics
[17512.167793] usb 1-1.3: SerialNumber: VÿsQ\xc2\x82RP9\xc2\x87
[17553.721662] usb 1-1.3: USB disconnect, device number 18
[17555.044287] usb 1-1.3: new full-speed USB device number 19 using dwc_otg
[17555.177621] usb 1-1.3: New USB device found, idVendor=0483, idProduct=3748, bcdDevice= 1.00
[17555.177637] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[17555.177647] usb 1-1.3: Product: STM32 STLink
[17555.177656] usb 1-1.3: Manufacturer: STMicroelectronics
[17555.177666] usb 1-1.3: SerialNumber: VÿsQ\xc2\x82RP9\xc2\x87
syslog
Sep 19 14:19:35 raspberrypi kernel: [17512.033914] usb 1-1.3: new full-speed USB device number 18 using dwc_otg
Sep 19 14:19:35 raspberrypi kernel: [17512.167748] usb 1-1.3: New USB device found, idVendor=0483, idProduct=3748, bcdDevice= 1.00
Sep 19 14:19:35 raspberrypi kernel: [17512.167765] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Sep 19 14:19:35 raspberrypi kernel: [17512.167774] usb 1-1.3: Product: STM32 STLink
Sep 19 14:19:35 raspberrypi kernel: [17512.167784] usb 1-1.3: Manufacturer: STMicroelectronics
Sep 19 14:19:35 raspberrypi kernel: [17512.167793] usb 1-1.3: SerialNumber: VÿsQRP9
Sep 19 14:19:35 raspberrypi mtp-probe: checking bus 1, device 18: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3"
Sep 19 14:19:35 raspberrypi mtp-probe: bus: 1, device: 18 was not an MTP device
Sep 19 14:19:35 raspberrypi mtp-probe: checking bus 1, device 18: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3"
Sep 19 14:19:35 raspberrypi mtp-probe: bus: 1, device: 18 was not an MTP device
Sep 19 14:20:17 raspberrypi kernel: [17553.721662] usb 1-1.3: USB disconnect, device number 18
Sep 19 14:20:18 raspberrypi kernel: [17555.044287] usb 1-1.3: new full-speed USB device number 19 using dwc_otg
Sep 19 14:20:18 raspberrypi kernel: [17555.177621] usb 1-1.3: New USB device found, idVendor=0483, idProduct=3748, bcdDevice= 1.00
Sep 19 14:20:18 raspberrypi kernel: [17555.177637] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Sep 19 14:20:18 raspberrypi kernel: [17555.177647] usb 1-1.3: Product: STM32 STLink
Sep 19 14:20:18 raspberrypi kernel: [17555.177656] usb 1-1.3: Manufacturer: STMicroelectronics
Sep 19 14:20:18 raspberrypi kernel: [17555.177666] usb 1-1.3: SerialNumber: VÿsQRP9
Sep 19 14:20:18 raspberrypi mtp-probe: checking bus 1, device 19: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3"
Sep 19 14:20:18 raspberrypi mtp-probe: bus: 1, device: 19 was not an MTP device
Sep 19 14:20:18 raspberrypi mtp-probe: checking bus 1, device 19: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3"
Sep 19 14:20:18 raspberrypi mtp-probe: bus: 1, device: 19 was not an MTP device
kernal logs:
Sep 19 14:19:35 raspberrypi kernel: [17512.033914] usb 1-1.3: new full-speed USB device number 18 using dwc_otg
Sep 19 14:19:35 raspberrypi kernel: [17512.167748] usb 1-1.3: New USB device found, idVendor=0483, idProduct=3748, bcdDevice= 1.00
Sep 19 14:19:35 raspberrypi kernel: [17512.167765] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Sep 19 14:19:35 raspberrypi kernel: [17512.167774] usb 1-1.3: Product: STM32 STLink
Sep 19 14:19:35 raspberrypi kernel: [17512.167784] usb 1-1.3: Manufacturer: STMicroelectronics
Sep 19 14:19:35 raspberrypi kernel: [17512.167793] usb 1-1.3: SerialNumber: VÿsQRP9
Sep 19 14:20:17 raspberrypi kernel: [17553.721662] usb 1-1.3: USB disconnect, device number 18
Sep 19 14:20:18 raspberrypi kernel: [17555.044287] usb 1-1.3: new full-speed USB device number 19 using dwc_otg
Sep 19 14:20:18 raspberrypi kernel: [17555.177621] usb 1-1.3: New USB device found, idVendor=0483, idProduct=3748, bcdDevice= 1.00
Sep 19 14:20:18 raspberrypi kernel: [17555.177637] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Sep 19 14:20:18 raspberrypi kernel: [17555.177647] usb 1-1.3: Product: STM32 STLink
Sep 19 14:20:18 raspberrypi kernel: [17555.177656] usb 1-1.3: Manufacturer: STMicroelectronics
Sep 19 14:20:18 raspberrypi kernel: [17555.177666] usb 1-1.3: SerialNumber: VÿsQRP9
Thanks
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (12 by maintainers)
Hi @nzsmith1. Thx for your reply. That’s ok, we’ll leave this open anyway until a solution has been found. Possibly someone else may also show interest in the meanwhile.