Skip to content

Programming (Flashing) the Board

adrianblakey edited this page Sep 14, 2026 · 3 revisions

To flash the board yourself you'll need:

a computer running Windows or Linux. a USB serial interface or "dongle" (different from the WiFi dongle to change the operating parameters) - we use the PWLINK2.. Do a search to find them. You can pck one up from EBay for about $12. connectors to connect the dongle to the board - we use spring loaded pin connectors (pictures and links to come). These probably come from Farnell in the UK. computer software to flash the board using the dongle - for Windows use Power Writer or the OpenOCD fork for Artery MCU's To use the PWLINK2 you'll either need a Windows computer on which to run the Powerwriter software, or a Linux/macOS machine to run the OpenOCD software.

Power Writer PWLINK2 that has the capability to flash the Artery F421 MCU as well as several other types of MCU. The ESCape32 WiKi mentions 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

To connect the PWLINK2 to the board we have some connectors that have very fine spring loaded pins on the ends to touch down on the single wire debug pads on the board (look at the picture in the test document in the docs directory to find these on the board). They are fiddly to use and I don't yet have a link to where to obtain them. If you find a link to buy them - please file a defect and tell us :-). Obviously a better flashing solution is needed.

Power Writer 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 Power Writer. You can obtain Power Writer 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 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.
  • 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.
    • Hit 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 red/black 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.
  • 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_FAST-rev2.bin - this is a custom build target and not a default binary - it's in the bin directory of this repo.
  • Accept the default memory location 08000000.
  • Click OK
  • Again - click on + Add firmware.
  • Locate the motor commutator binary - _SLOTCAR_rev8.bin.
  • 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 takes about 2 secs.
  • Hit "Write" - again takes about 2 sec.
  • Power off the eCom.
  • Attach a motor.
  • Power on at say 4v - restraining the motor.
  • 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 ...

Clone this wiki locally