[SOLVED]Imposible to flash with STLink v2 key ( STM32F1xx and STM32F4xx)

ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Imposible to flash with STLink v2 key ( STM32F1xx and STM32F4xx)

Post by ag123 »

if your chinese blue pills uses one of these 'clone' chips e.g. cs32f103
https://www.aliexpress.com/wholesale?ca ... 32f103c8t6
there may be problem flashing using st-link
https://github.com/stlink-org/stlink/issues/756
if you still want to flash that you may need to build the st-flash binaries from source and patch the codes accordingly
https://github.com/stlink-org/stlink
jcbuntu
Posts: 27
Joined: Wed Jun 02, 2021 1:47 pm
Location: Andon 06 - France

Re: Imposible to flash with STLink v2 key ( STM32F1xx and STM32F4xx)

Post by jcbuntu »

Thank for yours answers.
Stevestrong -> libusb-1.0 was initially installed. I've re-installed before post my help message.
ag123 -> i'll see and etude your proposition. But i've a bad web ( low ADSL !) and no GSM around ... It's difficult to obtain information's !

But after others thinkings, i would return to basic remarks :
1- Is it correct that Arduino IDE with Arduino_STM32 don't use UART uploading method for STM32F4 ?
Mine have only uploading by ST Link or HID bootloader V2 - No serial via FTDI ( witch work fine with STM32F1xx) but USB-serial converter is recognize as ttyUSB0.

2 - Why my Arduino IDE don't see my ST Link v2 key ? Field "port" stay light grey. Idem when i want use them on STM32F1

I think that it's these two questions to solve before others ...
Are yours IDE works as mine ( and impossibility to upload STM32F4 with USB-serial converter ) ?

Nice to read you.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Imposible to flash with STLink v2 key ( STM32F1xx and STM32F4xx)

Post by ag123 »

if you are using MS windows i'd suggest using the stm32cube programmer.
the package is huge to install but that it is officially developed by ST and is a install tool used in the 'official' STM core.

do note that as this is ST developed, it'd likely not work if that is a 'clone' chip on the board, or possibly work incorrectly.
using libusb is mainly for the open sourced st-link installer which is pretty much 'you are on your own' premise.
open sourced tools like that in github are open sources, most of them work well, but that there is no support (and certainly no warranty).
they are good pieces of work done as a community gift / effort. they generally work well if you happen to be able to put all the necessary dependencies together. but that if it is broken 'you are on your own' i.e. it is for you to fix it on your system.

for stm32cube programmer mentioned. ST stated their terms it may include no warranties etc. but for one thing, it is more likely professionally developed especially on platforms such as windows and that large commercial product organizations are possibly using them. and for all it is worth, it may support new ST products that is not yet installable using the open sourced st-link flasher.

note that stm32cube programmer do not link directly with roger's (Libmaple) core. the way i install firmware more commonly is to build the binary and install it manually separately. the binary can be found in the arduino 'temp' folder or that you case use export > binary from the arduino IDE menu. then use ST's tool to install the firmware.
jcbuntu
Posts: 27
Joined: Wed Jun 02, 2021 1:47 pm
Location: Andon 06 - France

Re: Imposible to flash with STLink v2 key ( STM32F1xx and STM32F4xx)

Post by jcbuntu »

I use a linux OS and don't wish return to Windows. That's incontestable but, sometimes, have some disagreement !
Initially, i've thank that a majority of STM users works on linux and have the same problems. Because i think my problem is the link between OS/IDE Arduino/ Arduino_STM32/hardware.
Add multiple software layers isn't a good solution : OS + Java + Arduino IDE + STM32 over coat + specific libraries and drivers + exotic Chinese hardware as boards and tools ...
Things must stay simple and user must keep the control ! It's while i use a portable Arduino IDE on extern DD.
My OS installation is very clean and i don't want perturb her by multiples tests.

So, i think it's begin too complicate to have a global vision and prefer use another IDE specific to STM32 ... as you say.
Without new post before 10 days, i'll close this topic.

Thank you for help.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Imposible to flash with STLink v2 key ( STM32F1xx and STM32F4xx)

Post by ag123 »

for linux normally the open sourced st-link (including st-flash as an app within) normally works well, as mentioned, you could patch that if the 'tweak' for cs32f103 isn't there and that you happened to be using cs32f103 based bluepills.
the alternatives are to use openocd
http://openocd.org/doc/pdf/openocd.pdf
a google search turned these up
https://www.hackster.io/yusefkarim/uplo ... ocd-a3d4de
https://cycling-touring.net/2018/12/fla ... nder-linux

there is one other possibility that you get 'impossible to flash'. is that *debug ports is disabled* or the flash is write protected
a tactic is called 'connect under reset'
https://forum.sparkfun.com/viewtopic.php?t=35249
which is basically to press and hold the reset button while you attempt to erase the flash.
i did that in openocd pressing reset while flashing.

one of those things is to check in your sketch if you happen to have debug ports disabled. normally that's related to some defines which needs to be defined correctly. i think for stm32duino(s) normally at least swd pins is enabled.
jcbuntu
Posts: 27
Joined: Wed Jun 02, 2021 1:47 pm
Location: Andon 06 - France

Re: Imposible to flash with STLink v2 key ( STM32F1xx and STM32F4xx)

Post by jcbuntu »

OK, ag123. I'll see all of yours links later because i'll travel tomorrow for some days.
I'd checked the permanent reset button press when flashing ... but no effect.
I've no problem with the Chinese blue pill : USB-serial converter work fine with them.
Problems are only when i want use STM325F4xx, because Arduino-STM32 IDE want only upload with STLink key ... and don't see mine on a port ! Curious because Linux see my key and open a symbolic link.

Thank you for help.
jcbuntu
Posts: 27
Joined: Wed Jun 02, 2021 1:47 pm
Location: Andon 06 - France

Re: Imposible to flash with STLink v2 key ( STM32F1xx and STM32F4xx)

Post by jcbuntu »

... error ! it's not STM325F4xx but STM32F4xx where are my bugs !
If you use STLink key with STM32 Arduino IDE, what is the name of the key port which appear ?
fredbox
Posts: 125
Joined: Thu Dec 19, 2019 3:05 am
Answers: 2

Re: Imposible to flash with STLink v2 key ( STM32F1xx and STM32F4xx)

Post by fredbox »

ST-Link on Linux does not have a port assigned:

Code: Select all

[93510.859888] usb 5-2: new full-speed USB device number 2 using uhci_hcd
[93511.033906] usb 5-2: New USB device found, idVendor=0483, idProduct=3748, bcdDevice= 1.00
[93511.033914] usb 5-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[93511.033918] usb 5-2: Product: STM32 STLink
[93511.033920] usb 5-2: Manufacturer: STMicroelectronics
[93511.033923] usb 5-2: SerialNumber: Qÿi\x06I\xc2\x83QPH\x16\xc2\x87
The STM32CubeProgrammer mentioned has a Linux version. It is big at about 100 megabytes installed, but gets the job done. I don't have any board with clone chips, so I've not had any problems with STM32F407VE, STM32F401CC or the blue pill / maple mini boards.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Imposible to flash with STLink v2 key ( STM32F1xx and STM32F4xx)

Post by ag123 »

for a 'workaround' assuming that you are using a stm32f401/f411 black pill, stm32f4 has DFU built-in.
just that you'd need to set boot0. normally this is done with this finger dance. connect usb (just a usb cable would do, no dongles needed)
press both boot0 and reset.
release reset
release boot0 1 sec later
that should put it in dfu mode.
you need an updated version of dfu-util
http://dfu-util.sourceforge.net/

then normally check that dfu is connected

Code: Select all

dfu-util -l
if you can see it, usually the command to flash is

Code: Select all

dfu-util -a 0 -s 0x8000000 -RD sketch.bin
you'd need to find the sketch.bin in your Arduino IDE temp folders or use export binary from the menu.
after flashing press reset and the sketch should be running

as for st-link, normally you would see it in

Code: Select all

lsusb
if you are using the open sourced st-link (st-flash)
https://github.com/stlink-org/stlink
normally there is a command st-info

Code: Select all

st-info --probe
that should get you something about the st-link and the stm32 if it is properly connected
the command to flash normally is

Code: Select all

st-flash erase
st-flash write sketch.bin 0x8000000
the erase step is normally unnecessary, if it can't connect there would normally be error messages.
if ti did not say that the flash is write protected, it could be that the debug ports (e.g. swd) is disabled.
that can be bypassed using that 'connect under reset' technique when doing the erase or flashing (i.e. press/hold reset and run that command to erase)
or another way is to write a binary via usb DFU with a sketch that doesn't block out the debug ports, for that u'd need to check in your core/sketch or config settings (e.g. is some option selected to disable the debug ports in the menu?).
jcbuntu
Posts: 27
Joined: Wed Jun 02, 2021 1:47 pm
Location: Andon 06 - France

Re: Imposible to flash with STLink v2 key ( STM32F1xx and STM32F4xx)

Post by jcbuntu »

Thank you for your help ... and i progress step to step !
I'm always in travell, but i've token some hours for work a little ...

I've read all the previous links and install STM32CubeProgrammer ( witch is a nice tool).
Nothing better after link nor with STM32CubeProgrammer witch made one alarm Old STLink firmware version. I'll see this later.

I've connected a generic STLinkv2 key to PC and to STM32F407VET6 board ( black F407VE !).
During try to upload a sketch ( in boot mode or not) IDE Arduino -> STM32 master indicate :

Code: Select all

...arduino-1.8.13/hardware/Arduino_STM32-master/tools/linux/stlink/st-flash: error while loading shared libraries: libusb-1.0.so.0: cannot open shared object file: No such file or directory
Arduino_STM32-master use tools of linux directorate and not linux64.
With a terminal under linux directorate, i've launched :

Code: Select all

...arduino-1.8.13/hardware/Arduino_STM32-master/tools/linux/stlink$ ./st-info --probe
./st-info: error while loading shared libraries: libusb-1.0.so.0: cannot open shared object file: No such file or directory
Error message is the same that Arduino_STM32-master.

When i'm going in linux64 directorate, i obtain :

Code: Select all

...arduino-1.8.13/hardware/Arduino_STM32-master/tools/linux64/stlink$ ./st-info --probe
Found 1 stlink programmers
serial: 18310a002c135737334d4e00
openocd: "\x18\x31\x0a\x00\x2c\x13\x57\x37\x33\x4d\x4e\x00"
flash: 524288 (pagesize: 16384)
sram: 196608
chipid: 0x0413
descr: F4 device
YEEEESSSSSS ! it's better : my generic STLinkv2 key and STM32F407VET6 board are recognized. The board stop's program and begin upload mode. The STLink key blink blue/red and fix red.

Now, i've a simple (?) question ( if you're agree naturally !) : why, on my PC Linux 64, Arduino_STM32-master use linux tools and not linux64 tools ? Where is the file configuration ?
Post Reply

Return to “STLink”