Flashing an IMAX B6 clone (ATmega32A) with cheali-charger via USBASP
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.
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.
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.
After that the yellow exclamation mark in Device Manager is gone.
⚠ 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:
| Signal | USBASP header (10 pins) | ATmega32A pin (TQFP-44) |
|---|---|---|
| MOSI | 1 | 1 |
| MISO | 9 | 2 |
| SCK | 7 | 3 |
| RESET | 5 | 4 |
| VCC (5 V) | 2 | 5 |
| GND | 4, 6, 8, 10 | 6 |
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.
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.
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
| Date | What changed |
|---|---|
| 2026-11-07 | Article rewritten: ISP wiring table, avrdude commands, calibration, restoring the factory firmware; photos from the 2017 archive. |
| 2017-04-14 | First version on the old site. |