Page 2 of 2

Re: HOWTO: Flashing with ST-Link v2

Posted: Mon Apr 06, 2020 7:36 pm
by ZooKeeper
post deleted

Re: HOWTO: Flashing with ST-Link v2

Posted: Tue Apr 07, 2020 12:16 am
by ZooKeeper
post deleted

Re: HOWTO: Flashing with ST-Link v2

Posted: Tue Aug 25, 2020 7:53 am
by RetroZero
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?

Re: HOWTO: Flashing with ST-Link v2

Posted: Tue Aug 25, 2020 8:04 am
by Kevin Sharpe
RetroZero wrote: Tue Aug 25, 2020 7:53 am Any ideas?
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?

Re: HOWTO: Flashing with ST-Link v2

Posted: Tue Aug 25, 2020 8:30 am
by RetroZero
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?

Re: HOWTO: Flashing with ST-Link v2 and OpenOCD (Open On-Chip Debugger)

Posted: Mon Apr 12, 2021 2:03 am
by Bassmobile
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.

Code: Select all

$ brew install openocd
$ brew install telnet  
or similar pattern

Code: Select all

`apt install`
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!

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
OpenOCD will respond;

Code: Select all

Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
In the active telnet session issue this command

Code: Select all

> flash probe 0
If you have some blue-pill variant, or ??? may report back;

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
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:

Code: Select all

> reset halt

Code: Select all

target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
Now issue command;

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.
So, we need to once again, soft reset and halt the stm32;

Code: Select all

> reset halt 
Now we you can continue programming! You will need to know the full pathname to the firmware files you wish to write.

Code: Select all

> flash write_image erase /path/to/files/stm32_loader.hex
> flash write_image /path/to/files/stm32_firmware.hex
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.

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
Keep in mind that you need to give specific paths to the firmware file(s).

We will issue on more soft reset;

Code: Select all

> 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.

Code: Select all

> shutdown 
8-)

Re: HOWTO: Flashing with ST-Link v2

Posted: Wed Jun 09, 2021 6:15 pm
by toastednow
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

Posted: Wed Sep 29, 2021 4:06 pm
by kay183
Hi,the new boards use a new SWD connector. What type of connector should I use?

Re: HOWTO: Flashing with ST-Link v2

Posted: Mon Oct 04, 2021 8:02 pm
by EV_Builder
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.

Re: HOWTO: Flashing with ST-Link v2

Posted: Thu Feb 03, 2022 5:18 pm
by chentron
flashed olimex from V2 board with android succesful with Zflash32 with arber instructions. Thanks