Dobrica Pavlinušić's random unstructured stuff
IMAX B6: Revision 9

RC-Power_BC6_Charger.pdf

Open source firmware

Flashing

https://groups.google.com/forum/#!msg/cheali-charger/2Rz-dtwZ5Is/zUGr3PzX9bcJ

pinout:

CHARGER -------------DONGLE
ICE_DATA <--------->    SWDIO
ICE_CLK  <--------->    SWCLK
ICE_RST  <--------->    RST (GND on my dongle)   
GND      <--------->    GND
VCC      <--------->     5V

isp_imaxB6_M0517.jpeg

Connect ST-Link to usb and start openocd

dpavlin@x200:/rest/cvs/cheali-charger/src/hardware/nuvoton-M0517/targets/imaxB6-clone$ openocd -f /usr/share/openocd/scripts/interface/stlink-v2.cfg -f /usr/share/openocd/scripts/target/m051.cfg 
Open On-Chip Debugger 0.9.0 (2015-05-28-17:08)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v17 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.432000
Error: init mode failed (unable to connect to the target)
in procedure 'init' 
in procedure 'ocd_bouncer'

Your chip is protected. Disconnect GND pin and start openocd again.

dpavlin@x200:/rest/cvs/openocd$ openocd -f /usr/share/openocd/scripts/interface/stlink-v2.cfg -f /usr/share/openocd/scripts/target/m051.cfg 
Open On-Chip Debugger 0.9.0 (2015-05-28-17:08)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v23 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.339130
Info : m051.cpu: hardware has 4 breakpoints, 2 watchpoints

In another terminal, connect to openocd and make backup:

dpavlin@x200:~$ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> init
> dump_image aprom.bin 0x0 0x10000
dumped 65536 bytes in 1.152825s (55.516 KiB/s)
> dump_image flash_data.bin 0x1f000 0x1000
dumped 4096 bytes in 0.071758s (55.743 KiB/s)
> dump_image ldrom.bin  0x100000 0x1000

> shutdown
shutdown command invoked
Connection closed by foreign host.



Serial port