CS32F103C8T6 blue-pill clone - cannot flash from AC6 SystemWorkbench
Asked Answered
I

4

5

I am trying to flash a blue-pill clone with a CS32F103C8T6 chip using the AC6 SystemWorkBench and a ST-LINK v2 device. It is a project built from STM32CubeMX - I am using a MacOS Mojave machine. Here is the output when trying to flash the device.

Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 8000 kHz
adapter_nsrst_delay: 100
Info : clock speed 8000 kHz
Info : STLINK v2 JTAG v31 API v2 SWIM v7 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.162004
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : Stlink adapter speed set to 4000 kHz
Warn : UNEXPECTED idcode: 0x2ba01477
Error: expected 1 of 1: 0x1ba01477
in procedure 'program' 
in procedure 'init' called at file "embedded:startup.tcl", line 495
in procedure 'ocd_bouncer'
** OpenOCD init failed **
shutdown command invoked

I have googled and found some similar posts about it, but have no luck solving it.

Does anyone have an idea ?

mvh Ole K Hornnes

Involuted answered 22/11, 2019 at 1:1 Comment(2)
Did you try flashing it with serial ?Louie
With STM32CubeIDE, I often had similar issues. You can try to use STLink GDB server instead of OpenOCD (if it is possible on this IDE).Lemley
L
8

In the OpenOCD config file, you need to add:

set CPUTAPID 0x2ba01477

I've never used AC6 SystemWorkbench and I don't now how you configure the board and the debug adapter in it. So I can't really tell where to look for the config file.

OpenOCD comes with an entire directory of board configurations, usually in a directory OpenOCD / scripts / board. It contains a script called stm32f103c8_blue_pill.cfg, which might be used in your case. Start there...

Lammers answered 22/11, 2019 at 10:1 Comment(1)
It was a bit hard to find this file, but when found this issue become solved. I found the file at: ``` /Applications/Ac6/SystemWorkbench.app/Contents/Eclipse/plugins/fr.ac6.mcu.debug_2.5.0.201904120827/resources/openocd/st_scripts/target/stm32f1x.cfg ```Involuted
A
9

set CPUTAPID 0x2ba01477 ; Will work for the clone but not for the genuine STM32…

Instead use: set CPUTAPID 0

The zero tells OpenOCD to ignore the id number, so any MCU will then work…

Information Source: OpenOCD TAPs

Audun answered 18/5, 2020 at 7:2 Comment(0)
L
8

In the OpenOCD config file, you need to add:

set CPUTAPID 0x2ba01477

I've never used AC6 SystemWorkbench and I don't now how you configure the board and the debug adapter in it. So I can't really tell where to look for the config file.

OpenOCD comes with an entire directory of board configurations, usually in a directory OpenOCD / scripts / board. It contains a script called stm32f103c8_blue_pill.cfg, which might be used in your case. Start there...

Lammers answered 22/11, 2019 at 10:1 Comment(1)
It was a bit hard to find this file, but when found this issue become solved. I found the file at: ``` /Applications/Ac6/SystemWorkbench.app/Contents/Eclipse/plugins/fr.ac6.mcu.debug_2.5.0.201904120827/resources/openocd/st_scripts/target/stm32f1x.cfg ```Involuted
R
2

C:\Ac6\SystemWorkbench\plugins\fr.ac6.mcu.debug_2.5.0.201904120827\resources\openocd\st_scripts\target\stm32f1x.cfg

add this line before first if statement

set CPUTAPID 0

it solves all openocd stlink id errors

Rightwards answered 14/8, 2020 at 11:41 Comment(0)
S
0

I'm running macOS on M1 and this was a bit of a pain but...

For anyone running this by invoking the openocd command manually like openocd -f ..., add a -d flag and run it like openocd -d -f .... Search the output for stm32f1x.cfg. For example for me I found it at:

Debug: 26 1 command.c:155 script_debug(): command - ocd_find target/stm32f1x.cfg
Debug: 27 1 configuration.c:88 find_file(): found /usr/local/bin/../share/openocd/scripts/target/stm32f1x.cfg

So I can add set CPUTAPID 0x2ba01477, or even better per Johan's answer - set CPUTAPID 0 to the top of the file at that file, specifically /usr/local/bin/../share/openocd/scripts/target/stm32f1x.cfg. I needed to use sudo to edit this file. Hope this generalizes the solution here.

Sadesadella answered 5/12, 2023 at 3:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.