Workshop: repairs and experiments

Flashing an IMAX B6 clone (ATmega32A) with cheali-charger via USBASP

Published 14.04.2017 · Updated 07.11.2026

A Chinese IMAX B6 clone charger built on an ATmega32A can be reflashed with the open cheali-charger firmware. All it takes is a one-dollar USBASP programmer. This is how we did it: the driver, the wiring, a backup of the factory firmware, writing the new one, and how to go back.

What we had

  • An IMAX B6 “Lipro Balance Charger” clone. In 2017 it cost about $15.
  • A USBASP programmer from AliExpress for $1.20.
  • A Windows 8.1 (64-bit) PC. On Linux USBASP needs no driver; the other steps are the same.
IMAX B6 clone charger with its leads
Our IMAX B6 clone with the leads it came with.

Check what your board is built on. Ours has an ATmega32A in a TQFP-44 package and a 16 MHz crystal, which is exactly the board cheali-charger targets. If your microcontroller is different, this guide does not apply.

The charger board with the case removed
The board out of the case: 16×2 display, converter inductor, balance connectors at the bottom.
The ATmega32A microcontroller on the board
The Atmel ATMEGA32A-AU microcontroller. The 16 MHz crystal is visible at the lower right.

Programmer and driver

USBASP is the cheapest AVR programmer. On Windows it needs a driver. We installed it with Zadig (zadig.akeo.ie): pick “USBasp” in the device list (USB ID 16C0:05DC), driver libusb-win32, then the install button.

Zadig: libusb-win32 driver for USBasp
Zadig: the USBasp device (16C0:05DC), libusb-win32 driver.

After that the yellow exclamation mark in Device Manager is gone.

USBASP programmer, top side
USBASP v2.0: the supply jumper (5 V / 3.3 V) is at the lower right.
USBASP programmer, bottom side
The back of the programmer.

⚠ Set the USBASP supply jumper to 5 V. The ATmega32A on this board runs at 5 V.

Wiring to the board

Next to the microcontroller the board has a row of programming (ISP) pads. Connect them to the USBASP header one to one, nothing crossed:

SignalUSBASP header (10 pins)ATmega32A pin (TQFP-44)
MOSI11
MISO92
SCK73
RESET54
VCC (5 V)25
GND4, 6, 8, 106

Pad labels differ between boards, so check every pad with a multimeter against the microcontroller pin in the table. It takes a minute and catches a mistake straight away.

Programmer wires soldered to the ISP pads
The USBASP ribbon and the wires soldered to the ISP pads on the board.

Step 1. Save the factory firmware

Without this copy there is no way back to the factory firmware. The tool is avrdude (we used 6.3; it ships with the Arduino IDE or can be taken from the project page). One command reads everything — flash, EEPROM and both fuse bytes:

avrdude -p atmega32 -c usbasp -U flash:r:flash.hex:i -U eeprom:r:eeprom.hex:i -U lfuse:r:lfuse.hex:h -U hfuse:r:hfuse.hex:h

What the output should show:

  • Device signature = 0x1e9502 (probably m32). That is an ATmega32 or ATmega32A: they share the signature. A different signature or zeros mean checking the wires and the supply.
  • At the end, Fuses OK (E:FF, H:C9, L:3F). We did not change the fuses and advise against it: cheali-charger works with the ones that are there.

Keep all four files. The EEPROM matters too: it holds the calibration of your particular charger.

Step 2. Write cheali-charger

The firmware comes from the project repository: github.com/stawel/cheali-charger; the flashing guide is docs/flashing.md. In 2017 we took the file from hex/unstable. There are separate files for different board variants, so take the one for yours.

avrdude -p atmega32 -c usbasp -U flash:w:cheali-charger.hex:a

avrdude erases the chip, writes and verifies by itself. We wrote 30,810 bytes: writing took about 16 seconds, verifying 9. It ends with 30810 bytes of flash verified.

Flashing: the programmer connected to the board
Flashing: USBASP connected to the board through the ribbon.

After a restart the charger showed the new cheali-charger menu.

Step 3. Calibration — a must

⚠ After the new firmware the charger must be calibrated. Without calibration it measures cell voltages inaccurately, and for lithium packs an error of even a few tens of millivolts means overcharging. The procedure is in the cheali-charger manual (in the project repository). You will need a multimeter you trust.

While the charger is open, check the thermal paste between the power transistors and the thermal pad. On clones it is often missing altogether.

Going back to the factory firmware

The same files from step 1, the other way round:

avrdude -p atmega32 -c usbasp -U flash:w:flash.hex:i -U eeprom:w:eeprom.hex:i

What next

We are planning our own firmware for this charger, with what we miss in the existing ones. That will be a separate article.

Article changelog

DateWhat changed
2026-11-07Article rewritten: ISP wiring table, avrdude commands, calibration, restoring the factory firmware; photos from the 2017 archive.
2017-04-14First version on the old site.