Skip to content

Flashing a Board

adrianblakey edited this page Sep 14, 2026 · 21 revisions

If you have manufactured a board you'll need to install firmware on it by flashing it. This page describes how to do that. There is also a new LibreOffice document in git that describes how to do this too.

The simplest way to understand this is to watch the video which describes how to flash a Remora1 using Windows and PowerWriter.

To flash a board you need:

To use the PWLINK2 USB dongle you'll either need a Windows computer on which to run the PowerWriter software, or a Linux/macOS machine to run the OpenOCD software.

The PowerWriter software and the PWLINK2 dongle have the capability to flash the Artery F421 MCU as well as several other types of MCU. The ESCape32 WiKi also mentions using the STLINK device, however it's only useful for flashing STM MCU's and we are using the Artery. There is more information on the ESCape32 WiKi about flashing.

You could also try the Artery AT-LINK device and their UM_ICP_Programmer. There's more info in the F421 getting started document. The AT-LINK is available here. If you use this, please tell us how it went.

We have tried some different solutions to connect the PWLINK2 to the board. All of them employ very fine spring loaded "pogo" pins which touch down on the single wire debug pads on the board. These are the pads marked 'I' and 'C' on the top side of the board. To locate them look at the picture in the test document in the docs directory, or open up KiCad and use the PCB editor to find them.

Pogo pins are expensive (over priced?) especially the good quality ones. The following are good quality ones. They are available in packs of five and you'll need about 11 pins and springs in total if you want to connect to all the pads and the power pads.

[https://uk.rs-online.com/web/p/test-pins/2615250](https://uk.rs-online.com/web/p/test-pins/2615250?searchId=8d6a018a-920d-4670-9edf-c3fc3913bc35&gb=s).   
[https://uk.rs-online.com/web/p/test-pins/2615193](https://uk.rs-online.com/web/p/test-pins/2615193?searchId=65eaa4c7-bd3a-4835-be49-b4e54abaab4e&gb=s)

There are some much cheaper ones on EBay but you might end up getting what you pay for.

The simple approach to attaching the pins is to solder some connector wire to a couple of the pins and use connector leads with crocodile clips to wire them to the pins on the PWLINK2.

To mount the pogo pins for the SWD pads we have had success holding the pogo pins in a binder clip with some insulation on its jaws and then just teasing out the distance between the pins to correspond to the distance between the pads on the board. Then you can hold the clip carefully between two fingers and press it down onto the pads to make a connection while you operate PowerWriter from the computer keyboard.

A good way to apply power to the board is to use a couple of small crocodile clips with one side insulated and the other bent over slightly so the board can be pincered by each clip, but with only one side of the clip connecting to the power pad on the bottom side of the board. These are soldered to leads with banana plugs for the power supply on the other ends.

We improved the above flashing solution using a 3D-printed jig to support the pogo pins in locations corresponding to their locations on the board. These weren't very robust but looked a bit like these clamps you can buy on AliExpress. The design files are not (yet) checked in.

Our latest solution is a couple of pcb's - one for the top another for the bottom, that have pin locations corresponding to the pin locations on the board. These are checked in to git. Our plan is to put these in a clamp. These designs can be sent to JLCPCB and made at very low cost. The gerbers for them are here:

https://github.com/aartech-dev/slot-car-ecom/blob/main/PogoPower_KiCad8/production/PogoPower_KiCad8.zip   
https://github.com/aartech-dev/slot-car-ecom/blob/main/PogoSignal_KiCad8/production/PogoSignal_KiCad8.zip  

We are planning on improving the board layout to make flashing simpler. :-)

PowerWriter has options to flash a board that has existing software on it. If you are flashing for the first time and do not need to reset the option bytes OpenOCD is a good solution. The official OpenOCD fork for Artery MCU's is in github. I haven't tried using it yet therefore if you do please file a defect and provide some explicit instructions.

Since we built our prototype from an existing drone ESC we used PowerWriter. You can obtain PowerWriter from this link If you run it from Chrome it'll offer to translate from Chinese to English - useful I'd say.

Here's the process we used:

  • Run the software, accept the "Yes" to run in admin mode to access the devices.
  • Plug in the PWLINK2 dongle, and run any driver installs and updates.
  • If PowerWriter offers an update - accept the offer, and wait a bit until it provides the update.
  • Click on the Writer Setting tab.
  • You can either load the settings from the pkg file or enter them manually.
  • To load them select open, and navigate to the file at32f421x8.pkg that you downloaded from git. Open it by using the password: remora1
  • To enter the settings manually - in Chip Select:
  • Click on MCU model:
  • For the Artery - use the menus to select AT32F421x8
  • Set the following:
    Erase type: Don't erase
    Interface level 3.3v
    Speed: 10M hz
    OptionByte: Factory=>Custom
    Note: Don't change the Write function configuration
  • Optionally - click the Save button at the top and save the configuration as a pkg file - it'll save you time later to reload this configuration instead of setting everything again next time you run the program. It asks for a password - (why?) ...
  • In Communication configuration:
  • Click on Refresh
  • It'll update the Device dropdown - on my machine I see COM6 and COM7 - with the dongle on COM7
  • Hit Connect - the log window on the right should show you that it has successfully connected to the PWLINK2 dongle
  • Select the Option bytes tab
  • Only if you are flashing an ESC/MCU for the first time, you need to disable the RDP read protection, otherwise it's not possible to update the firmware.
  • Click on the RDP line and ensure it says read protection off
  • Wire up the dongle to the "stab pins" (or connectors you are using to connect the dongle to the board - you could solder some wires on but ...) to connect the dongle to the swdio/clk pins.
  • Connect a ground wire from the 2 dongle gnd pins to -ve on your power supply (psu).
  • Connect the psu to the +ve and -ve pads on the bottom of the eCom.
  • If the eCom has already been flashed with firmware, you might want to disconnect the motor from the eCom otherwise the motor might run when you turn power on. (not the case if you use the default firmware)
  • Power on - give it about 8VDC (It will beep if it's a drone esc with a buzzer running Beliheli32)
  • If it's running the ESCape32 default binaries - no beep.
  • Old Note: If you are flashing the prototype (HAKRC) drone eCom and the shunt is in place on the HAKRC and it's running the default ESCape32 binary, you can connect a serial terminal to the white and black control cable of the esc - see the ESCap32 wiki. https://github.com/neoxic/ESCape32/wiki
  • Load up the binaries into PowerWriter.
  • Select the Program Memory tab
  • Click on + Add firmware
  • Locate the bootstrap binary BOOT3_PA2_FE-rev4.bin on your computer that you should have previously downloaded from github
  • Accept the default memory location 08000000
  • Click OK
  • Again - click on + Add firmware
  • Locate the motor commutator binary - AART1-rev17.2.bin - that you have previously downloaded from github.
  • Give it the location 08001000 - there is a bug in PowerWriter that truncates a zero from the end of the address, just add it.
  • Hit the checkmark Apply button
  • You are now ready to flash
  • Touch the SWD pins from the dongle on to the pads on the eCom.
  • Just for good measure, go into the writer settings and hit disconnect/connect - check the log
  • If this is a new mcu - select: Option byte
  • Hit the "Write" button - this should disable the write protection on the mcu
  • Select the Program Memory tab
  • If this has already been flashed - you must first erase the current flash before writing the new flash
  • With the swd pins connected, hit erase - it take about 2 secs
  • Hit "Write" - again takes about 2 sec
  • Power off the eCom
  • Attach a motor
  • Power on at say 4V - which restraining the motor - it will run.
  • This is where it's useful to have a command line or a WiFi dongle attached to enable you to change any compiled-in settings ...

Troubleshooting

BE PATIENT

Use magnifying glasses so you can see the pads and ensure the pins are touching the pads. Flashing the boards is fiddly and you won't get it right first time.

Make sure the SWDIO and SWDCOM connections from the PWLINK2 and made to the correct pads on the baord.

If the board does not consume a very small amount of power (about .1A) on startup, assume the power connections are not made. It might be a good idea to solder on the power leads.

The most common mistake is not attaching the GND connections on the PWLINK2 to the -ve power supply.

The pads are very small and the pogo pins delicate and imprecise. It's sometimes hard to get a good electrical connection. Try delicately "scratching" the tip of the pogo pin on the pad.

If you suspect bad hardware (which we have found to be extremely rare if you've used JLCPCB) run the hardware tests that are specified in the testing document.

Clone this wiki locally