Repository navigation
Flashing
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!
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.
After dismantling the battery, locate the pin header on the side of the circuit board (use the square pin to verify orientation):

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!
The Autoflash image supports all Raspberry Pi models (including Pi 4).
- Download the Raspberry Pi Autoflash image from Releases.
- Unzip and flash the image onto an SD card using BalenaEtcher.
- Connect the pack to the Pi's GPIO pins:

- Insert the card, wake the battery pack by pressing the black lever/button, and power up the Pi.
- Boot and programming take several minutes. Completion is indicated by an LED sequence on the pack.
- Install Microchip Studio (select SAMD20 architecture during installation).
- Connect programmer, open Microchip Studio, and wake the pack.
- Under Tools
$\rightarrow$ Device Programming, set:- Tool: Your Programmer
-
Device:
ATSAMD20E15 -
Interface:
SWD$\rightarrow$ Click Apply.

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

- Go to the Memories tab and click Erase now:

- Once erased, read the Device Signature to verify:

- Compile and flash the project file by selecting Debug
$\rightarrow$ Start without debugging (Ctrl+Alt+F5).
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.











