HOWTO: Flashing with ST-Link v2
Re: HOWTO: Flashing with ST-Link v2
post deleted
Huebner VCU controlling a Gen2 Prius Inverter powering an MGR
"Talent is equally distributed but opportunity is not." - Leila Janah
"Talent is equally distributed but opportunity is not." - Leila Janah
Re: HOWTO: Flashing with ST-Link v2
post deleted
Huebner VCU controlling a Gen2 Prius Inverter powering an MGR
"Talent is equally distributed but opportunity is not." - Leila Janah
"Talent is equally distributed but opportunity is not." - Leila Janah
-
- Posts: 861
- Joined: Tue Oct 29, 2019 2:48 pm
- Location: France
- Has thanked: 514 times
- Been thanked: 49 times
- Contact:
Re: HOWTO: Flashing with ST-Link v2
Well, it seems I am in your shoes Damian.io. I think my STM is blocked too.
Since it's the new adapter board for Gen2 , it's not exactly like the V3 boards, but connection is similar.
Ground, 3.3V, SWCLK and SWDIO
I tried .hex and .bin files with ST Nucleo, but I keep getting error messages when comparing after programming.
In LiveUpdates, I notice CoreState Blocked/Halted
Being my 2nd board, I would like to get to the bottom of this and not "replace STM" via programming..
When I execute the programming sequence, the connection is interupted and requires Restart before being able to re-connect.
Any ideas?
Since it's the new adapter board for Gen2 , it's not exactly like the V3 boards, but connection is similar.
Ground, 3.3V, SWCLK and SWDIO
I tried .hex and .bin files with ST Nucleo, but I keep getting error messages when comparing after programming.
In LiveUpdates, I notice CoreState Blocked/Halted
Being my 2nd board, I would like to get to the bottom of this and not "replace STM" via programming..
When I execute the programming sequence, the connection is interupted and requires Restart before being able to re-connect.
Any ideas?
- Kevin Sharpe
- Posts: 1345
- Joined: Fri Dec 14, 2018 9:24 pm
- Location: Ireland and US
- Been thanked: 8 times
Re: HOWTO: Flashing with ST-Link v2
Can I suggest you hire an electronics engineer for a few days? I don't want to minify your efforts but you seem to be stuck in a world of pain and maybe some expertise would help move your project forward?
This is a personal post and I disclaim all responsibility for any loss or damage which any person may suffer from reliance on the information and material in this post or any opinion, conclusion or recommendation in the information and material.
-
- Posts: 861
- Joined: Tue Oct 29, 2019 2:48 pm
- Location: France
- Has thanked: 514 times
- Been thanked: 49 times
- Contact:
Re: HOWTO: Flashing with ST-Link v2
Thanks Kevin, I didn't think it was this complicated. I had a motor spinning in manual mode before the very slippery slope downhill.
Might have to rethink my project..But will persist for now with trying to reprogramme the adapter board. Zookeeper is keeping the flame burning with his motor in FOC mode!!
I thought, 4 wires, a ST Link, how hard can it be?
Might have to rethink my project..But will persist for now with trying to reprogramme the adapter board. Zookeeper is keeping the flame burning with his motor in FOC mode!!
I thought, 4 wires, a ST Link, how hard can it be?
- Bassmobile
- Posts: 94
- Joined: Sat Apr 25, 2020 5:51 am
- Location: USA
- Has thanked: 7 times
- Been thanked: 1 time
Re: HOWTO: Flashing with ST-Link v2 and OpenOCD (Open On-Chip Debugger)
I find the most painless way to flash these boards is with an ST-LINK V2, and a few other open-source command line tools.
My personal preference is a macOS environment, but most any *nix / Linux distribution will work, even the Linux subsystem in Winblows will do.
First connect the hardware with 3.3v, GND, DIO and CLK to the appropriate 4 pins on on both your STLINK-v2 dongle and the V3 board.
On macOS, Homebrew is my package manager of choice. I will use it's `brew install` in the examples below for getting the software needed for the flashing procedures. All of these tools are available for other subsystems, this same processes will apply to many other GNU/Linux based systems such as Arch, Debian, etc.
The software I'm recommending you use is OpenOCD (Open On-Chip Debugger) and telnet. They need to be installed for this process.
or similar pattern on linux etc.
I make an alias `st-oocd` in my systems .profile for running the following command to make it quick and easier. The paths might differ slightly between different software system distributions, but it won't differ much!
you will be prompted for your password to perform the `sudo` operation
SUCCESS!
Now OpenOCD has initiated a debug session to the STM32, leave this shell session running and in another shell session connect to the debug server with telnet
OpenOCD will respond;
In the active telnet session issue this command
If you have some blue-pill variant, or ??? may report back;
In this case `Device Security Bit Set` requires the STM32 must first be unlocked to program. The device must be halted before you can issue the unlock commands, it is best to reset and immediatly halt the device, and OOCD supplies a simple way, issue the `reset halt` command over telnet:
Now issue command;
So, we need to once again, soft reset and halt the stm32;
Now we you can continue programming! You will need to know the full pathname to the firmware files you wish to write.
Hex files include the offset address information.
Alternatively you may specify; to write with .bin binaries, but it will require that you include memory location offsets.
Keep in mind that you need to give specific paths to the firmware file(s).
We will issue on more soft reset;
At this point if all went well, we will see the 'ALIVE' led flashing it's little heartbeat.
Issue one last command over telnet to shutdown the connection.

My personal preference is a macOS environment, but most any *nix / Linux distribution will work, even the Linux subsystem in Winblows will do.
First connect the hardware with 3.3v, GND, DIO and CLK to the appropriate 4 pins on on both your STLINK-v2 dongle and the V3 board.
On macOS, Homebrew is my package manager of choice. I will use it's `brew install` in the examples below for getting the software needed for the flashing procedures. All of these tools are available for other subsystems, this same processes will apply to many other GNU/Linux based systems such as Arch, Debian, etc.
The software I'm recommending you use is OpenOCD (Open On-Chip Debugger) and telnet. They need to be installed for this process.
Code: Select all
$ brew install openocd
$ brew install telnet
Code: Select all
`apt install`
I make an alias `st-oocd` in my systems .profile for running the following command to make it quick and easier. The paths might differ slightly between different software system distributions, but it won't differ much!
Code: Select all
$ sudo /usr/local/bin/openocd -f /usr/local/share/openocd/scripts/interface/stlink-v2.cfg -f /usr/local/share/openocd/scripts/target/stm32f1x.cfg
you will be prompted for your password to perform the `sudo` operation
SUCCESS!
Code: Select all
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
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 : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 1000 kHz
Info : STLINK V2J17S4 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.225688
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f1x.cpu on 3333
Info : Listening on port 3333 for gdb connections
Now OpenOCD has initiated a debug session to the STM32, leave this shell session running and in another shell session connect to the debug server with telnet
Code: Select all
$ telnet localhost 4444
Code: Select all
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
Code: Select all
> flash probe 0
Code: Select all
device id = 0x20036410
STM32 flash size failed, probe inaccurate - assuming 128k flash
flash size = 128kbytes
Device Security Bit Set
flash 'stm32f1x' found at 0x08000000
Code: Select all
> reset halt
Code: Select all
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
Code: Select all
> stm32f1x unlock 0
Code: Select all
stm32x unlocked.
INFO: a reset or power cycle is required for the new settings to take effect.
Code: Select all
> reset halt
Code: Select all
> flash write_image erase /path/to/files/stm32_loader.hex
> flash write_image /path/to/files/stm32_firmware.hex
Alternatively you may specify; to write with .bin binaries, but it will require that you include memory location offsets.
Code: Select all
> flash write_image erase /path/to/files/stm32_loader.bin 0x08000000 bin
> flash write_image /path/to/files/stm32_firmware.bin 0x08001000 bin
We will issue on more soft reset;
Code: Select all
> reset
Issue one last command over telnet to shutdown the connection.
Code: Select all
> shutdown

-
- Posts: 4
- Joined: Wed Jun 09, 2021 6:10 pm
Re: HOWTO: Flashing with ST-Link v2
Hi! Latest mainboard has TC2030 programming interface and I bought TC2030-MCP-NL-10 for it but I am not sure about pinout for it. Could someone help me connect ST-link to it?
Re: HOWTO: Flashing with ST-Link v2
Hi,the new boards use a new SWD connector. What type of connector should I use?
- EV_Builder
- Posts: 1205
- Joined: Tue Apr 28, 2020 3:50 pm
- Location: The Netherlands
- Has thanked: 18 times
- Been thanked: 37 times
- Contact:
Re: HOWTO: Flashing with ST-Link v2
For the sake if it happens.
If you upload a empty project / overwrite the SWD pin config with something your chip/board can become in accesible.
To Solve:
- identify the reset pin on the device (chip)
- connect reset to GND
-Connect the ST-LINK and hit full erase in the application
- release the GND connection
The GUI will do a quick sweep and the chip is empty again.
If you upload a empty project / overwrite the SWD pin config with something your chip/board can become in accesible.
To Solve:
- identify the reset pin on the device (chip)
- connect reset to GND
-Connect the ST-LINK and hit full erase in the application
- release the GND connection
The GUI will do a quick sweep and the chip is empty again.
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
see http://www.wdrautomatisering.nl for bespoke BMS modules.
-
- Posts: 117
- Joined: Mon Feb 22, 2021 3:25 pm
- Location: Spain
- Has thanked: 42 times
- Been thanked: 10 times
Re: HOWTO: Flashing with ST-Link v2
flashed olimex from V2 board with android succesful with Zflash32 with arber instructions. Thanks
Re: HOWTO: Flashing with ST-Link v2
This push-pin SWD-connector is sort of proprietary. Its cheap to produce on PCB, but the connector is way too expensive. Please do not support this connector and just solder the wires on the pads. When done with flashing, unsolder the wires again when there is a risk of accidentally pulling on the soldered wires.