How can the pyboard be reprogrammed with a new C project using ST-Link/v2?

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
johnthagen
Posts: 3
Joined: Wed Feb 27, 2019 1:00 pm

How can the pyboard be reprogrammed with a new C project using ST-Link/v2?

Post by johnthagen » Wed Feb 27, 2019 1:10 pm

Hello,

I'd like to reprogram and debug the STM32F4 on the pyboard using an external ST-Link/v2 with a C project that I have generated and compiled from STM32CubeMX.

I've done this with the STM32F4DISCOVERY board before using these instructions: https://electronics.stackexchange.com/a/410840

I tried using these instructions as a reference: https://github.com/micropython/micropyt ... -for-STM32

The connections from the ST-Link/v2 are connected as follows:

PIN1 (VAPP) -> 3V3
PIN7 (TMS_SWDIO) -> PA13 (X21-2)
PIN9 (TCK_SWCLK) -> PA14 (X20-2)
PIN15 (NRST) -> NRST (RST)
PIN20 (GND) -> GND

The ST-Link Manual is here: https://www.st.com/resource/en/user_man ... 026748.pdf

I'm thinking that perhaps because the SWDIO and SWCLK lines are shared with LEDs, the default pyboard firmware may be holding these lines high or low?

When I try to push the program using OpenOCD:

Open On-Chip Debugger 0.10.0+dev-00608-g68f09deb (2018-12-06-12:24)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : clock speed 2000 kHz
Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.252840
Error: init mode failed (unable to connect to the target)
in procedure 'program'
in procedure 'init' called at file "embedded:startup.tcl", line 496
in procedure 'ocd_bouncer'
** OpenOCD init failed **
shutdown command invoked

Thanks.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: How can the pyboard be reprogrammed with a new C project using ST-Link/v2?

Post by dhylands » Wed Feb 27, 2019 4:22 pm

You probably need to remove the current limiting resistors on the LEDs.

The firmware can only interfere with the STLINK once the firmware starts running, so until you can load and run the firmware you're trying to test, there can't be any interference from that side.

johnthagen
Posts: 3
Joined: Wed Feb 27, 2019 1:00 pm

Re: How can the pyboard be reprogrammed with a new C project using ST-Link/v2?

Post by johnthagen » Wed Feb 27, 2019 11:12 pm

@dhylands Thanks for the reply! I messed around with this for a while and got it working! Needed to "connect the 3V3 pin to the P1/DFU pin with a wire" per the README.

I think the existing firmware must have been holding down those LEDs or something?

I'd like to contribute my experiences with this for others. Would the wiki be the right place? The RST docs? Somewhere else?

johnthagen
Posts: 3
Joined: Wed Feb 27, 2019 1:00 pm

Re: How can the pyboard be reprogrammed with a new C project using ST-Link/v2?

Post by johnthagen » Tue Mar 05, 2019 4:11 pm

@dhylands I've created a wiki page on this: https://github.com/micropython/micropyt ... ST-Link-v2

Hope this is helpful to others in the future.

sim222
Posts: 20
Joined: Wed Nov 27, 2019 12:04 am

Re: How can the pyboard be reprogrammed with a new C project using ST-Link/v2?

Post by sim222 » Tue Oct 26, 2021 3:31 am

johnthagen wrote:
Tue Mar 05, 2019 4:11 pm
@dhylands I've created a wiki page on this: https://github.com/micropython/micropyt ... ST-Link-v2

Hope this is helpful to others in the future.
Thanks a lot!!
I am looking for a solution to it.

Post Reply