2023-09-13 06:49 AM
Using both STM32CubeIDE and STM32CubeProgrammer; both fail to successfully program using the STLINK-V3MINIE. The part is IDs correctly and "Full chip erase" works without errors. I only get an error once I click the "Start Programming" button. Same board/programmer works correctly without error using openocd.
STM32CubeProgrammer:
09:35:53 : STM32CubeProgrammer API v2.14.0 | Windows-64Bits
09:36:10:208 : UR connection mode is defined with the HWrst reset mode
09:36:10:373 : ST-LINK SN : 0050003F3431511937393330
09:36:10:373 : ST-LINK FW : V3J13M4
09:36:10:374 : Board : STLINK-V3MINIE
09:36:10:374 : Voltage : 1.79V
09:36:10:374 : SWD freq : 50 KHz
09:36:10:374 : Connect mode: Under Reset
09:36:10:375 : Reset mode : Hardware reset
09:36:10:375 : Device ID : 0x460
09:36:10:375 : Revision ID : Rev B
09:36:10:375 : Reading data...
09:36:10:375 : r ap 0 @0x1FFF77DD 0x00000004 bytes Data 0xFFFFFFFF
09:36:10:376 : Database: Config 0 is active.
09:36:10:376 : flash loader C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin/FlashLoader/0x460.stldr is loaded
09:36:10:376 : halt ap 0
09:36:10:376 : r ap 0 @0x4002103C 0x00000004 bytes Data 0x00000000
09:36:10:376 : w ap 0 @0x4002103C 0x00000004 bytes Data 0x08000000
09:36:10:377 : Debug in Low Power mode enabled.
09:36:10:377 : r ap 0 @0x40015808 0x00000004 bytes Data 0x00000000
09:36:10:377 : w ap 0 @0x40015808 0x00000004 bytes Data 0x00001800
09:36:10:377 : r ap 0 @0x40015804 0x00000004 bytes Data 0x00000000
09:36:10:377 : w ap 0 @0x40015804 0x00000004 bytes Data 0x00000007
09:36:10:377 : Reading data...
09:36:10:377 : r ap 0 @0x1FFF75E0 0x00000004 bytes Data 0xFFFF0080
09:36:10:625 : UPLOADING OPTION BYTES DATA ...
09:36:10:625 : Bank : 0x00
09:36:10:625 : Address : 0x40022020
09:36:10:625 : Size : 112 Bytes
09:36:10:625 : Reading data...
09:36:10:625 : r ap 0 @0x40022020 0x00000070 bytes Data 0xFFFFF8AA
09:36:10:626 : UPLOADING OPTION BYTES DATA ...
09:36:10:626 : Bank : 0x00
09:36:10:626 : Address : 0x40022020
09:36:10:626 : Size : 112 Bytes
09:36:10:626 : Reading data...
09:36:10:626 : r ap 0 @0x40022020 0x00000070 bytes Data 0xFFFFF8AA
09:36:10:627 : UPLOADING ...
09:36:10:627 : Size : 1024 Bytes
09:36:10:627 : Address : 0x8000000
09:36:10:627 : Read progress:
09:36:10:627 : Reading data...
09:36:10:717 : r ap 0 @0x08000000 0x00000400 bytes Data 0x20009000
09:36:10:718 : Data read successfully
09:36:10:718 : Time elapsed during the read operation is: 00:00:00.126
09:36:29:286 : MASS ERASE ...
09:36:29:286 : Flash erase...
09:36:29:305 : halt ap 0
09:36:29:305 : w ap 0 reg 15 PC (0x20000000)
09:36:29:306 : w ap 0 reg 17 MSP (0x20000500)
09:36:29:320 : w ap 0 reg 16 xPSR (0x01000000)
09:36:29:386 : w ap 0 @0x20000B20 : 0x00000200 bytes, Data 0x00000000...
09:36:29:387 : w ap 0 @0x20000000 : 0x00000004 bytes, Data 0x0000BE00...
09:36:29:595 : w ap 0 @0x20000004 : 0x000006F4 bytes, Data 0x4891B580...
09:36:29:596 : Init flashloader...
09:36:29:614 : halt ap 0
09:36:29:616 : w ap 0 reg 0 R0 0x00000001
09:36:29:623 : w ap 0 reg 1 R1 0x00000000
09:36:29:636 : w ap 0 reg 2 R2 0x00000000
09:36:29:637 : w ap 0 reg 3 R3 0x00000000
09:36:29:653 : w ap 0 reg 4 R4 0x00000000
09:36:29:654 : w ap 0 reg 5 R5 0x00000000
09:36:29:671 : w ap 0 reg 6 R6 0x00000000
09:36:29:671 : w ap 0 reg 7 R7 0x00000000
09:36:29:687 : w ap 0 reg 8 R8 0x00000000
09:36:29:688 : w ap 0 reg 9 R9 0x00000000
09:36:29:704 : w ap 0 reg 10 R10 0x00000000
09:36:29:704 : w ap 0 reg 11 R11 0x00000000
09:36:29:720 : w ap 0 reg 12 R12 0x00000000
09:36:29:723 : w ap 0 reg 13 SP 0x00000000
09:36:29:738 : w ap 0 reg 14 LR 0x20000001
09:36:29:738 : w ap 0 reg 15 PC 0x20000005
09:36:29:754 : w ap 0 reg 16 xPSR 0x01000000
09:36:29:755 : w ap 0 reg 17 MSP 0x20000AF4
09:36:29:771 : w ap 0 reg 18 PSP 0x00000000
09:36:29:772 : run ap 0
09:36:29:772 : halt ap 0
09:36:29:788 : r ap 0 reg 0 R0 0x00000001
09:36:29:788 : Loader mass erase...
09:36:29:788 : w ap 0 reg 0 R0 0x00000000
09:36:29:808 : w ap 0 reg 1 R1 0x00000000
09:36:29:819 : w ap 0 reg 2 R2 0x00000000
09:36:29:823 : w ap 0 reg 3 R3 0x00000000
09:36:29:823 : w ap 0 reg 4 R4 0x00000000
09:36:29:829 : w ap 0 reg 5 R5 0x00000000
09:36:29:840 : w ap 0 reg 6 R6 0x00000000
09:36:29:846 : w ap 0 reg 7 R7 0x00000000
09:36:29:857 : w ap 0 reg 8 R8 0x00000000
09:36:29:862 : w ap 0 reg 9 R9 0x00000000
09:36:29:871 : w ap 0 reg 10 R10 0x00000000
09:36:29:879 : w ap 0 reg 11 R11 0x00000000
09:36:29:888 : w ap 0 reg 12 R12 0x00000000
09:36:29:896 : w ap 0 reg 13 SP 0x00000000
09:36:29:904 : w ap 0 reg 14 LR 0x20000001
09:36:29:913 : w ap 0 reg 15 PC 0x200002C5
09:36:29:921 : w ap 0 reg 16 xPSR 0x01000000
09:36:29:930 : w ap 0 reg 17 MSP 0x20000AF4
09:36:29:938 : w ap 0 reg 18 PSP 0x00000000
09:36:29:938 : run ap 0
09:36:29:970 : halt ap 0
09:36:29:976 : r ap 0 reg 0 R0 0x00000001
09:36:29:976 : Mass erase successfully achieved
09:36:30:143 : UPLOADING ...
09:36:30:143 : Size : 1024 Bytes
09:36:30:143 : Address : 0x8000000
09:36:30:144 : Read progress:
09:36:30:145 : Reading data...
09:36:30:259 : r ap 0 @0x08000000 0x00000400 bytes Data 0xFFFFFFFF
09:36:30:259 : Data read successfully
09:36:30:260 : Time elapsed during the read operation is: 00:00:00.126
09:36:38:678 : Memory Programming ...
09:36:38:678 : Opening and parsing file: v0.bin
09:36:38:696 : File : v0.bin
09:36:38:697 : Size : 70.36 KB
09:36:38:697 : Address : 0x80000000
09:36:38:697 : Erasing Segment <0> Address <0x80000000> Size <72052>Bytes
09:36:38:697 : Erasing memory corresponding to segment 0:
09:36:38:697 : Memory Erase via FlashLoader!
09:36:38:697 : Memory erase...
09:36:38:697 : erase: 0000ms
09:36:38:698 : Download in Progress:
09:36:38:698 : Size : 72052 Bytes
09:36:38:698 : Address : 0x80000000
09:36:38:698 : Buffer program...
09:36:38:699 : w ap 0 @0x80000000 : 0x00011974 bytes, Data 0x20009000...
09:36:38:699 : Error: failed to download Segment[0]
09:36:38:699 : Error: failed to download the File
09:36:38:732 : RUNNING Program ...
09:36:38:732 : Address: : 0x80000000
09:36:38:739 : STLink read from (0x80000000) returned: 0x00000020
09:36:38:740 : 2nd try fail!
09:36:38:740 : STLink read from (0x80000004) returned: 0x00000020
09:36:38:740 : 2nd try fail!
09:36:38:747 : w ap 0 reg 15 PC 0x00000018
09:36:38:753 : w ap 0 reg 17 MSP 0x00000018
09:36:38:757 : w ap 0 reg 16 xPSR 0x01000000
09:36:38:761 : Warning: The core is locked up
09:36:38:777 : Start operation achieved successfully
OpenOCD:
>.\openocd.exe -f interface/stlink.cfg -f target/stm32g0x.cfg -c 'flash init; init; reset halt; flash erase_sector 0 0 last'
Licensed under GNU GPL v2
libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : clock speed 2000 kHz
Info : STLINK V3J13M4 (API v3) VID:PID 0483:3754
Info : Target voltage: 1.790374
Info : [stm32g0x.cpu] Cortex-M0+ r0p1 processor detected
Info : [stm32g0x.cpu] target has 4 breakpoints, 2 watchpoints
Info : 'flash init' has already been called
Info : starting gdb server for stm32g0x.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : Unable to match requested speed 2000 kHz, using 1000 kHz
Info : Unable to match requested speed 2000 kHz, using 1000 kHz
[stm32g0x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0xfffffffe msp: 0xfffffffc
Info : device idcode = 0x20006460 (STM32G07/G08xx - Rev B : 0x2000)
Info : RDP level 0 (0xAA)
Info : flash size = 128 KiB
Info : flash mode : single-bank
erased sectors 0 through 63 on flash bank 0 in 1.502505s
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
shutdown command invoked
> .\openocd.exe -f interface/stlink.cfg -f target/stm32g0x.cfg -c 'program "abc.hex" verify reset exit'
Open On-Chip Debugger 0.12.0 (2023-07-12) [https://github.com/sysprogs/openocd]
Licensed under GNU GPL v2
libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : clock speed 2000 kHz
Info : STLINK V3J13M4 (API v3) VID:PID 0483:3754
Info : Target voltage: 1.790374
Info : [stm32g0x.cpu] Cortex-M0+ r0p1 processor detected
Info : [stm32g0x.cpu] target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for stm32g0x.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : Unable to match requested speed 2000 kHz, using 1000 kHz
Info : Unable to match requested speed 2000 kHz, using 1000 kHz
[stm32g0x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0xfffffffe msp: 0xfffffffc
Info : Unable to match requested speed 4000 kHz, using 3300 kHz
Info : Unable to match requested speed 4000 kHz, using 3300 kHz
** Programming Started **
Info : device idcode = 0x20006460 (STM32G07/G08xx - Rev B : 0x2000)
Info : RDP level 0 (0xAA)
Info : flash size = 128 KiB
Info : flash mode : single-bank
Info : Padding image section 0 at 0x0800e91c with 4 bytes
Info : Padding image section 1 at 0x08011974 with 4 bytes (bank write end alignment)
Warn : Adding extra erase range, 0x08011978 .. 0x08011fff
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
Info : Unable to match requested speed 2000 kHz, using 1000 kHz
Info : Unable to match requested speed 2000 kHz, using 1000 kHz
shutdown command invoked
Solved! Go to Solution.
2023-09-13 08:52 AM - edited 2023-09-13 08:53 AM
> 09:36:38:696 : File : v0.bin
> 09:36:38:697 : Size : 70.36 KB
> 09:36:38:697 : Address : 0x80000000
The address of flash is 0x08000000, not 0x80000000. You're specifying the wrong address.
2023-09-13 06:56 AM
2023-09-13 08:52 AM - edited 2023-09-13 08:53 AM
> 09:36:38:696 : File : v0.bin
> 09:36:38:697 : Size : 70.36 KB
> 09:36:38:697 : Address : 0x80000000
The address of flash is 0x08000000, not 0x80000000. You're specifying the wrong address.
2023-09-13 11:11 AM
Good catch, not sure how the extra 0 got there. I had Start address = "0x080000000" which made it hard for my brain to parse the typo.