Skip to content

Flashing

Andrej Tobola edited this page Sep 7, 2026 · 58 revisions

Warning

Unlocking the SAMD20 microcontroller for flashing removes security protection, which completely erases the original chip. There is (intentionally) no way to back up or restore the stock firmware—this is a one-way process!


Identifying and Preparing Connections

Option 1: Drilling Pin Holes (Without Opening Case)

You can access the programming pins through drilled holes without disassembling the housing (click any image to view full resolution).

Note

RST pin hole is needed when flashing by using RaspberryPi. WCH-LinkE does not need RST pin to be connected. However, this pin is important if battery freezes (see Warning below).

Caution

Be careful and do not touch BMS with drillbit!

Tip

During flashing, keep pressuse on probes with fingers to avoid loose connection.

Remember to wake up the battery by briefly pressing the trigger before updating the firmware.

Warning

DO NOT wake up battery while GND, SWDIO and SWCLK are connected with the flasher - battery can freeze and will not respond neither to trigger, nor the charger. If that happens, don't worry. Connect RESET/RST to GND through a 330 Ω to 1 kΩ resistor for 1 sec.

📸 View Drilling Guide Photos (Click to Expand)
IMG_1509 IMG_1510
IMG_1511 IMG_1512
IMG_1513 IMG_1514
IMG_1515 IMG_1516
IMG_1517 IMG_1518
IMG_1521

Option 2: Disassembling the Battery Case

After dismantling the battery, locate the pin header on the side of the circuit board (use the square pin to verify orientation):

BMS Wiring Pinout

The pads are covered in a protective lacquer layer (not all models). Gently scrape it off using a fiberglass abrasive pencil or fine wet-and-dry sandpaper before soldering/connecting wires.

Caution

Short Circuit Danger: These pins (and 18650 terminals) are live at all times! Ensure no tools or stray wires short any pads, or you will destroy the microcontroller.

3.3V Pin Warning: Only required if your programmer needs VSense (e.g., Atmel-ICE). Do not connect 3.3V if using a Raspberry Pi or WCH-LinkE!


Flashing with a Raspberry Pi (Recommended)

The Autoflash image supports all Raspberry Pi models (including Pi 4).

  1. Download the Raspberry Pi Autoflash image from Releases.
  2. Unzip and flash the image onto an SD card using BalenaEtcher.
  3. Connect the pack to the Pi's GPIO pins:

Raspberry Pi Wiring

  1. Insert the card, wake the battery pack by pressing the black lever/button, and power up the Pi.
  2. Boot and programming take several minutes. Completion is indicated by an LED sequence on the pack.

Flashing with an SWD Programmer (Microchip Studio)

  1. Install Microchip Studio (select SAMD20 architecture during installation).
  2. Connect programmer, open Microchip Studio, and wake the pack.
  3. Under Tools $\rightarrow$ Device Programming, set:
    • Tool: Your Programmer
    • Device: ATSAMD20E15
    • Interface: SWD $\rightarrow$ Click Apply.

Device Programming Menu

  1. Clicking Read will throw a security warning because the chip is locked:

Security Error

  1. Go to the Memories tab and click Erase now:

Erase Chip

  1. Once erased, read the Device Signature to verify:

Device Specs

  1. Compile and flash the project file by selecting Debug $\rightarrow$ Start without debugging (Ctrl+Alt+F5).

Flashing with OpenOCD & WCH-LinkE

Note

Flashing via OpenOCD with a WCH-LinkE adapter is only possible after the chip has already been unlocked via Raspberry Pi or Atmel-ICE (clone programmers cannot handle the internal RST pin reset sequence required for unlocking).

Flashing script is located in the Documents folder. WCH-LinkE Programmer Available Here.

Wiring: Connect only SWDIO, SWCLK, and GND.

WCH Link Programmer WCH Link Pinout