Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] STLINK-V3 programmer support #820

Closed
6 tasks done
WRansohoff opened this issue Jul 25, 2019 · 70 comments
Closed
6 tasks done

[feature] STLINK-V3 programmer support #820

WRansohoff opened this issue Jul 25, 2019 · 70 comments

Comments

@WRansohoff
Copy link
Contributor

  • Programmer/board type: STlink/v3 (+on-board)
  • Programmer firmware version: V3.J2.M1 'STM32 Debug+Mass storage+VCP'
  • Operating system: Ubuntu 18.04
  • Stlink tools version: v1.5
  • Stlink commandline tool name: st-util, probably others as well.
  • Target chip (and optional board): STM32G431KB (STM32G431 'Nucleo-32')

Output:

[Time] WARN usb.c: Couldn't find any ST-Link/V2 devices

Expected/description:

The utility should connect to the device. I'm not sure how different these new ST-Link bridges are from the old ones, but hopefully things won't look too different. ST has a marketing blog post describing the new debuggers, but the technical information might be more spread out:

https://blog.st.com/stlink-v3set-in-circuit-debugger-programmer/

Sorry if this has already been added - I tried st-util -s 3, but I got: stlink version 3 unknown!

@unclebanjoman
Copy link

I also have a serious problem. I just bought a brand new STLINK-V3SET programmer / debugger original from StMicro.

  • Programmer type: STLINK-V3SET
  • Operating system: Debian 9 (stretch)
  • Stlink tools version: v1.5.1-31-g625f4cd
  • Stlink commandline tool name: st-info and all others
  • Target chip: STM32F746VG and/or STM32F469NI using original STLINK-V3SET programmer/debugger

The st-info utility discovers and manage my new STM32F746G-Discovery board without problems.
When I plug my new STLINK-V3SET programmer, executing the command:

./st-info --probe

I only obtain:

"Found 0 stlink programmers."

I've already put the appropriate file in /etc/udev/rules.d (filename: 49-stlinkv3.rules).
Issuing the lsusb -v command I get the following:

mmazza@linux9:~/ARMtoolchains/stlink-master/build/Release$ lsusb -v

Bus 005 Device 003: ID 0483:374f STMicroelectronics
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 ?
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x0483 STMicroelectronics
idProduct 0x374f
bcdDevice 1.00
iManufacturer 1 STMicroelectronics
iProduct 2 ST-LINK/V3
iSerial 3 005200363137510239383538

<more...>

Any ideas?
I'm really stuck.
Thanks in advance,

Max

@xkwy
Copy link

xkwy commented Aug 19, 2019

I have the same request.

Is there any one shall do something for support STLINK-V3SET? Please.

@mhnsn
Copy link

mhnsn commented Aug 23, 2019

Same as @unclebanjoman, on Ubuntu 18.04 LTS, my system detects the V3 probe, but st-info --probe returns 0 devices. I'll look into this some, but I can't promise anything.

@nife87
Copy link

nife87 commented Oct 9, 2019

I have the same request. I love using "make flash" in Makefiles, but I kinda also love the new v3.
My concrete error (Windows 10, Cygwin) with the STLINK-V3SET connected (and usable using STM32CubeProgrammer as well as using STLINK Utility):
st-flash --reset write bin/X.bin 0x8000000
st-flash 1.3.0
2019-10-09T22:56:02 WARN C:\Users\Jerry\Desktop\stlink-master\src\usb.c: Couldn't find any ST-Link/V2 devices

@Nightwalker-87 Nightwalker-87 added this to the General milestone Feb 19, 2020
@Nightwalker-87 Nightwalker-87 modified the milestones: General, v1.7.0 Feb 21, 2020
@martonmiklos
Copy link
Collaborator

martonmiklos commented Feb 24, 2020

Hey folks!

I have managed to patch the sources to get my STLink V3 mini recognised and initialised.

To be honest I remembered that it is just the matter of adding PIDs and configuring the proper endpoints. Well it was not that simple, but thanks to Antonio Borneo's great work on openOCD I managed to go through the differences easier.

My code lives here:
https://github.com/martonmiklos/stlink/pull/new/add_stlink_v3_support

I have not managed to test it (I have a mini at home but no device with 1.27 pitch JTAG conn).
Feel free to test it (it should work, since the most difference was in the initialisation) and report.

@Nightwalker-87
Copy link
Member

@WRansohoff: Are you interested in testing it by checking out the current develop branch?

@WRansohoff
Copy link
Contributor Author

I can take a look when I have access to one of the newer boards again. But that might be a couple of weeks from now, so maybe someone else can beat me to it :)

Thanks for patching this in!

@kioan
Copy link

kioan commented Feb 26, 2020

I have an stlink-v3 and I could help you with testing.
I compiled your code and connected my stlink-v3 programmer to a bluepill (stm32f103c8) board.

$ ./st-info --version
v1.6.0

$ ./st-info --probe
Found 1 stlink programmers

$ ./st-info --flash
0x10000

$ ./st-info --sram
0x5000

$ ./st-info --descr
F1 Medium-density device

$ ./st-info --pagesize
0x400

$ ./st-info --chipid
0x0410

$ ./st-info --serial
303034323030314633313337353130413339333833353338

$ ./st-info --hla-serial
"\x30\x30\x34\x32\x30\x30\x31\x46\x33\x31\x33\x37\x35\x31\x30\x41\x33\x39\x33\x38\x33\x35\x33\x38"

Runnning st-flash throws some errors as you can see bellow.

Erase seemed to succeed and it erased already running chip:

$ ./st-flash erase
st-flash 1.6.0
2020-02-26T11:27:37 INFO usb.c: Unable to match requested speed 1800 kHz, using 1000 kHz
2020-02-26T11:27:37 INFO common.c: Loading device parameters....
2020-02-26T11:27:37 INFO common.c: Device connected is: F1 Medium-density device, id 0x20036410
2020-02-26T11:27:37 INFO common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x10000 bytes (64 KiB) in pages of 1024 bytes
  core status: unknown
Mass erasing

I then reprogrammed the chip usint the STM32CubeProgrammer and tried reading and writing back using your stlink version.

Reading the chip throws errors:

$ ./st-flash read /tmp/saved.img 0x8000000 0x1000
st-flash 1.6.0
2020-02-26T11:24:35 INFO usb.c: Unable to match requested speed 1800 kHz, using 1000 kHz
2020-02-26T11:24:35 INFO common.c: Loading device parameters....
2020-02-26T11:24:35 INFO common.c: Device connected is: F1 Medium-density device, id 0x20036410
2020-02-26T11:24:35 INFO common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x10000 bytes (64 KiB) in pages of 1024 bytes
  core status: unknown

And also errors when trying to write back to the chip:

$ ./st-flash write /tmp/saved.bin 0x8000000
st-flash 1.6.0
2020-02-26T12:30:40 INFO usb.c: Unable to match requested speed 1800 kHz, using 1000 kHz
2020-02-26T12:30:40 INFO common.c: Loading device parameters....
2020-02-26T12:30:40 INFO common.c: Device connected is: F1 Medium-density device, id 0x20036410
2020-02-26T12:30:40 INFO common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x10000 bytes (64 KiB) in pages of 1024 bytes
  core status: unknown
2020-02-26T12:30:40 INFO common.c: Ignoring 3396 bytes of 0xff at end of file
2020-02-26T12:30:40 INFO common.c: Attempting to write 700 (0x2bc) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08000000 erased
2020-02-26T12:30:40 INFO common.c: Finished erasing 1 pages of 1024 (0x400) bytes
2020-02-26T12:30:40 INFO common.c: Starting Flash write for VL/F0/F3/F1_XL core id
2020-02-26T12:30:40 INFO flash_loader.c: Successfully loaded flash loader in sram
  core status: unknown
  core status: unknown
  core status: unknown
  core status: unknown
  core status: unknown
  core status: unknown
  core status: unknown

---- multiple lines trimmed ----

  core status: unknown
  core status: unknown
2020-02-26T12:30:41 ERROR flash_loader.c: flash loader run error
2020-02-26T12:30:41 ERROR common.c: stlink_flash_loader_run(0x8000000) failed! == -1
stlink_fwrite_flash() == -1

If you want me to run specific tests, please guide me and I will do so.

@Nightwalker-87
Copy link
Member

Nightwalker-87 commented Feb 26, 2020

I would suggest to test common use cases and tasks which can be achieved with the stlink toolset, just as we expect these to work with the stlink-v2 programmer already supported. It seems not a problem if any additional feature may not yet be fully functional, but the main functions should turn out to be in a working state. @kioan @WRansohoff @martonmiklos: Maybe you can discuss some more specific tests with each other and also consult our documentation and "How-To" for some ideas. I'll jump into this in a few days as well.

@martonmiklos
Copy link
Collaborator

I will swipe together the necessary stuff to be able to debug during execution. It is going to be the most easier and efficient I think. Many thanks to @WRansohoff and @kioan for performing the tests.

@kioan
Copy link

kioan commented Feb 26, 2020

I am a little newbie to github etc, so if someone could give me some guidelines it would be really helpful.

My system is running Debian. Is there any way to create the debian package in order to install it?
This would allow me to test it using the environment I was already using (I have just started learning STM32 development using the Warren Gay book so I use his makefiles as a basic structure)

@Nightwalker-87
Copy link
Member

Nightwalker-87 commented Feb 26, 2020

@kioan: You may find it helpful to have a look in /doc/compiling as a first step and see how far you get. Unfortunately it's not completely up to date, but as I'm trying to do my very best - here is a "quick-and-dirty" update to it, to help you along:

  1. Fork the repo on the main project page: https://github.com/texane/stlink
  2. Clone/Download shows a git-link which you should copy to the clipboard.
  3. Create a new local folder for your git-Projects and make sure you have the package git installed, which I assume is already the case
  4. cd into the new folder via the terminal and then type git clone $pasted_link
  5. Make sure to have the following packages installed:
  • CMake (v2.8.7 or later)
  • C compiler (gcc, clang or mingw)
  • libusb 1.0 (v1.0.13 or later)
  • libusb-dev 1.0 (v1.0.13 or later)

... and then proceed with the instructions. Please let us know if you run into trouble. ;-)

@kioan
Copy link

kioan commented Feb 26, 2020

Thank you! In case someone else like me wants to follow this procedure, right after cloning (step 4) they should checkout the development branch and compile that instead of the main.
That can be done by running
git branch -a to show all branches followed by
git checkout remotes/origin/develop which is the branch with stlinkv3 support

I have created successfully the debian packages and installed them. I tried the makefiles that used to work with the stlinkv2 programmer but I get the same errors I mentioned before.
At least now I know that I can test your future patches.

@bdmihai
Copy link

bdmihai commented Mar 14, 2021

Hi. I did a test with the latest develop branch. Seems to work. STLink V3 SET

~/work/tools/stlink/build/Release/bin/st-flash --reset write bin/application.bin 0x08000000
st-flash 1.6.1-222-g1eaa638
2021-03-14T20:23:28 INFO usb.c: Unable to match requested speed 1800 kHz, using 1000 kHz
2021-03-14T20:23:28 WARN usb.c: NRST is not connected
2021-03-14T20:23:28 INFO common.c: stm32f411re: 128 KiB SRAM, 512 KiB flash in at least 16 KiB pages.
2021-03-14T20:23:28 WARN usb.c: NRST is not connected
file bin/application.bin md5 checksum: f247a2c4e817961e16c344e6e19d2c25, stlink checksum: 0x002725ff
2021-03-14T20:23:28 INFO common.c: Attempting to write 26100 (0x65f4) bytes to stm32 address: 134217728 (0x8000000)
EraseFlash - Sector:0x0 Size:0x4000 2021-03-14T20:23:28 INFO common.c: Flash page at addr: 0x08000000 erased
EraseFlash - Sector:0x1 Size:0x4000 2021-03-14T20:23:28 INFO common.c: Flash page at addr: 0x08004000 erased
2021-03-14T20:23:28 INFO common.c: Finished erasing 2 pages of 16384 (0x4000) bytes
2021-03-14T20:23:28 INFO common.c: Starting Flash write for F2/F4/F7/L4
2021-03-14T20:23:28 INFO flash_loader.c: Successfully loaded flash loader in sram
2021-03-14T20:23:28 INFO common.c: enabling 32-bit flash writes
2021-03-14T20:23:29 INFO common.c: Starting verification of write complete
2021-03-14T20:23:29 INFO common.c: Flash written and verified! jolly good!
2021-03-14T20:23:29 WARN usb.c: NRST is not connected

@Nightwalker-87 Nightwalker-87 changed the title [feature] STLINK-v3: Programmer support [feature] STLINK/V3 programmer support Mar 14, 2021
@Nightwalker-87
Copy link
Member

Nightwalker-87 commented Mar 14, 2021

Any STLINK-V3MODS around as well?

BTW: Our documentation will list all reported working dev-boards with on-board STLINK/V3, so any feedback is really valuable. ❤️
I'll leave this open for a few more days to give everybody enough time for testing and feedback.

@martonmiklos
Copy link
Collaborator

Any STLINK-V3MODS around as well?

FYI: V3MODS and V3MINI units are almost identical: the MINI has a pinheader populated, whilst the MODS does not. (You need to utilize the castellated holes at the edge of the board for connection).

@Nightwalker-87
Copy link
Member

Nightwalker-87 commented Mar 14, 2021

@martonmiklos: I know they are very similar from the docs and even share the same FW, but it doesn't hurt to see a success with both does it? The MODS has an extended set of functionality that may bring some side effects - you never know.

@martonmiklos
Copy link
Collaborator

martonmiklos commented Mar 14, 2021

but it doesn't hurt to see a success with both does it?

Of course testing never hurts :). I just mentioned it to not keep the MODS untested as blocker. (MODS should be less common in the wild due to it's intended board mount usage type)

@dieselburner
Copy link

Flashing a custom hardware with STM32F750Z8 using V3SET:

user@machine:~/nuttx$ st-info --probe
Found 1 stlink programmers
  version:    V3J7S1
  serial:     303032433030343933303338353130333334333333393030
  hla-serial: "\x30\x30\x32\x43\x30\x30\x34\x39\x33\x30\x33\x38\x35\x31\x30\x33\x33\x34\x33\x33\x33\x39\x30\x30"
  flash:      65536 (pagesize: 2048)
  sram:       327680
  chipid:     0x0449
  descr:      F7xx
user@machine:~/nuttx$ st-flash --reset write nuttx.bin 0x08000000
st-flash 1.6.1-224-g9956bde
2021-03-15T16:44:27 INFO usb.c: Unable to match requested speed 1800 kHz, using 1000 kHz
2021-03-15T16:44:27 WARN usb.c: NRST is not connected
2021-03-15T16:44:27 INFO common.c: F7xx: 320 KiB SRAM, 64 KiB flash in at least 2 KiB pages.
2021-03-15T16:44:27 WARN usb.c: NRST is not connected
file nuttx.bin md5 checksum: baa24dfb857177860e5982d3e6376ff, stlink checksum: 0x00678204
2021-03-15T16:44:27 INFO common.c: Attempting to write 63792 (0xf930) bytes to stm32 address: 134217728 (0x8000000)
EraseFlash - Sector:0x0 Size:0x8000 2021-03-15T16:44:28 INFO common.c: Flash page at addr: 0x08000000 erased
EraseFlash - Sector:0x1 Size:0x8000 2021-03-15T16:44:28 INFO common.c: Flash page at addr: 0x08008000 erased
2021-03-15T16:44:28 INFO common.c: Finished erasing 2 pages of 32768 (0x8000) bytes
2021-03-15T16:44:28 INFO common.c: Starting Flash write for F2/F4/F7/L4
2021-03-15T16:44:28 INFO flash_loader.c: Successfully loaded flash loader in sram
2021-03-15T16:44:28 INFO common.c: enabling 32-bit flash writes
2021-03-15T16:44:30 INFO common.c: Starting verification of write complete
2021-03-15T16:44:30 INFO common.c: Flash written and verified! jolly good!

@Nightwalker-87
Copy link
Member

@jdbruijn You appear to be the only one with a V3MINI so far...

@jdbruijn
Copy link
Contributor

Yeah, I still want to test (have it on my todo list) but I'm I'll at the moment.

@Nightwalker-87
Copy link
Member

Take your time. I wish you a speedy recovery. 👍

@jdbruijn
Copy link
Contributor

@Nightwalker-87 This is without any board connected since I don't have any actual hardware to program, unfortunately. Programmer is the STLINK-V3MINI. Let me know if you want me to run any other commands!

$ build/Release/bin/st-info --version
v1.6.1-225-g125cb2d
$ build/Release/bin/st-info --probe
Found 1 stlink programmers
  version:    V0S3
  serial:     303031413030343233353338353131373333333633373330
  hla-serial: "\x30\x30\x31\x41\x30\x30\x34\x32\x33\x35\x33\x38\x35\x31\x31\x37\x33\x33\x33\x36\x33\x37\x33\x30"
  flash:      0 (pagesize: 0)
  sram:       0
  chipid:     0x03e8

@Nightwalker-87
Copy link
Member

Without any target there would not be much else to see, I guess.

@Nightwalker-87 Nightwalker-87 changed the title [feature] STLINK/V3 programmer support [feature] STLINK-V3 programmer support Mar 20, 2021
Nightwalker-87 added a commit that referenced this issue Mar 20, 2021
- Updated CHANGELOG.md
- Updated README.md
- [doc] Official STLINK-V3 support
   (Closes #820, Closes #1022, Closes #1025)
- Updated list of contributors
- Updated info on version support
- Minor formatting fixes
@salyzyn
Copy link
Contributor

salyzyn commented Aug 26, 2021

debian package is behind the times? Installed v1.7.0 stlink tools from debian package as it indicated support for V3. My STLINK V3SET version V337M2B451 is not discovered, it mounts /dev/sda to /media/${USER}/STLINK_V3S and adds a /dev/ttyACM0 node when connected to Linux.

$ st-info --version
v1.7.0
$ st-info --probe
Found 0 stlink programmers

If I build it from git sources, it does discover:

~/src/stlink$ ./build/Release/bin/st-info --version
/etc/stlink/chips: No such file or directory
v1.7.0-105-gdb8f789
~/src/stlink$ ./build/Release/bin/st-info --probe
/etc/stlink/chips: No such file or directory
Found 1 stlink programmers
version: V3J7S1
serial: 004C00413438511134313939
flash: 1048576 (pagesize: 16384)
sram: 262144
chipid: 0x0419
descr: F42x/F43x

@huanglilong
Copy link

@salyzyn it works for me (ref: #1189)
$ sudo apt remove --purge stlink
$ sudo apt remove --purge libstlink1

solution from @mariobaldini
Syncing installed lib with the st-link bin solved the issue in my case:
Purged both the lib and installed bin: sudo apt remove --purge libstlink1 stlink
Reinstalled the bin again: sudo dpkg -i stlink_1.7.0-1_amd64.deb

@EngMarc
Copy link

EngMarc commented Dec 10, 2022

I just received my STLINK-V3SET today and am waiting on my STM32F411CEU6 which should be arriving end of Dec.
I'm pretty new to the Arduino/STM32 chipsets but have done a lot of programming in the past on unix, C/C++, Python, etc.

My goal is to get it set up to do some development and testing on a new automation project. I'll be in touch here as I'm quite a newbie for the STLINK-V3 and STM32 stuff.

@huanglilong
Copy link

@EngMarc you can try this https://github.com/huanglilong/stm32h7_fmu
using CMSIS-DAP for debugging
Nuttx as RTOS

@huanglilong
Copy link

huanglilong commented Dec 11, 2022

you can also use openocd to update frash
example:
openocd -f interface/cmsis-dap.cfg -f target/stm32h7x_dual_bank.cfg -c "program ./build/fmu_nuttx.bin 0x8000000 verify reset exit;"

@EngMarc
Copy link

EngMarc commented Dec 11, 2022

I need some pointers on the physical wiring/connections too.
I purchased the STM32F411CEU6 with 8 MB flash (https://www.aliexpress.us/item/3256801269871873.html?gatewayAdapt=glo2usa4itemAdapt&_randl_shipto=US).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

No branches or pull requests