<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0"
 xmlns:blogChannel="http://backend.userland.com/blogChannelModule"
>

<channel>
<title><![CDATA[Dobrica Pavlinušić's random unstructured stuff: IMAX B6]]></title>
<link>https://saturn.ffzg.hr/rot13/index.cgi?imax_b6</link>
<description></description>
<pubDate>Mon, 05 Jul 2021 19:09:27 -0000</pubDate>
<webMaster>root@saturn.ffzg.hr</webMaster>
<generator>Socialtext Workspace v2.19.0.2</generator>

<item>
<title><![CDATA[IMAX B6]]></title>
<link>https://saturn.ffzg.hr/rot13/index.cgi?imax_b6</link>
<description><![CDATA[<div>Creator: Dobrica Pavlinušić</div><hr/><div class="wiki">
<span class="nlw_phrase"><a href="https://saturn.ffzg.hr/rot13/index.cgi/RC-Power_BC6_Charger.pdf?action=attachments_download;page_name=imax_b6;id=20150202120557-0-26809">RC-Power_BC6_Charger.pdf</a><!-- wiki: {file: RC-=Power_BC6_Charger.pdf} --></span><br /><br /><div class="nlw_phrase"><table class="wafl_container">
  <tr>
    <td>
      <div class="wafl_box">
        
          <div class="wafl_titlebox">
            <div class="wafl_title">
              
                Contents: [Dobrica Pavlinušić's random unstructured stuff]
              
            </div>
          </div>
          <div class="wafl_items">
            
              <div class="wiki">
<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#mcu">Dobrica Pavlinušić's random unstructured stuff (MCU)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] MCU} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#open_source_firmware">Dobrica Pavlinušić's random unstructured stuff (Open source firmware)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Open source firmware} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#flashing">Dobrica Pavlinušić's random unstructured stuff (Flashing)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Flashing} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#update">Dobrica Pavlinušić's random unstructured stuff (Update)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Update} --></span></li>
</ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#serial_port">Dobrica Pavlinušić's random unstructured stuff (Serial port)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Serial port} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#logview">Dobrica Pavlinušić's random unstructured stuff (LogView)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] LogView} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#tsv">Dobrica Pavlinušić's random unstructured stuff (tsv)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] tsv} --></span></li>
</ul></ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#temperature_sensor">Dobrica Pavlinušić's random unstructured stuff (temperature sensor)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] temperature sensor} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#backup_calibration">Dobrica Pavlinušić's random unstructured stuff (backup calibration)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] backup calibration} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#memory_map">Dobrica Pavlinušić's random unstructured stuff (memory map)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] memory map} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#backup">Dobrica Pavlinušić's random unstructured stuff (backup)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] backup} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#create_calibration_for_compile_from_backup">Dobrica Pavlinušić's random unstructured stuff (create calibration for compile from backup)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] create calibration for compile from backup} --></span></li>
</ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#serial_tx_and_rx_on_chip_pins">Dobrica Pavlinušić's random unstructured stuff (serial tx and rx on chip pins)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] serial tx and rx on chip pins} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#openocd_upstream_support_for_nuvoton">Dobrica Pavlinušić's random unstructured stuff (openocd upstream support for nuvoton)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] openocd upstream support for nuvoton} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#openocd_0_10_changes">Dobrica Pavlinušić's random unstructured stuff (openocd 0.10 changes)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] openocd 0.10 changes} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#update_version">Dobrica Pavlinušić's random unstructured stuff (update version)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] update version} --></span></li>
</ul></ul>
</div>

            
            
          </div>
        
      </div>
    </td>
  </tr>
</table>
<!-- wiki: {toc: }
--></div><br /><br /><h1 id="mcu">MCU</h1>
<p>
Nuvoton M0517LBN ARM Cortex M0</p>
<p>
Nuvoton don’t guarantee the deviation of HIRC(22.1184MHz) for M0517.<br />
M0517 is a special part number of M051 series.</p>
<h1 id="open_source_firmware">Open source firmware</h1>
<ul>
<li><a target="_blank" title="(external link)" href="https://github.com/stawel/cheali-charger">https://github.com/stawel/cheali-charger</a></li>
<li><a target="_blank" title="(external link)" href="https://groups.google.com/forum/#!forum/cheali-charger">https://groups.google.com/forum/#!forum/cheali-charger</a></li>
<li><a target="_blank" title="(external link)" href="http://www.rcgroups.com/forums/showthread.php?t=1951734">http://www.rcgroups.com/forums/showthread.php?t=1951734</a></li>
</ul>
<h2 id="flashing">Flashing</h2>
<p>
<a target="_blank" title="(external link)" href="https://groups.google.com/forum/#!msg/cheali-charger/2Rz-dtwZ5Is/zUGr3PzX9bcJ">https://groups.google.com/forum/#!msg/cheali-charger/2Rz-dtwZ5Is/zUGr3PzX9bcJ</a></p>
<p>
pinout:</p>
<pre>
CHARGER -------------DONGLE
ICE_DATA &lt;---------&gt;    SWDIO
ICE_CLK  &lt;---------&gt;    SWCLK
ICE_RST  &lt;---------&gt;    RST (on SWIM header on my programmer)
GND      &lt;---------&gt;    GND
VCC      &lt;---------&gt;     5V
</pre>
<br /><span class="nlw_phrase"><img alt="isp_imaxB6_M0517.jpeg" src="https://saturn.ffzg.hr/rot13/index.cgi/isp_imaxB6_M0517.jpeg?action=attachments_download;page_name=imax_b6;id=20150618164148-0-8694" /><!-- wiki: {image: isp_imaxB6_M0517.jpeg} --></span><br /><br /><pre>
dpavlin@x200:/rest/cvs/cheali-charger$ cat .gitmodules 
[submodule &quot;utils/M0517_flash_tools&quot;]
        path = utils/M0517_flash_tools
        url = https://github.com/sasam/M0517_flash_tools.git


dpavlin@x200:/rest/cvs/cheali-charger/utils/M0517_flash_tools/tcl$ openocd \
 -f /usr/share/openocd/scripts/interface/stlink-v2.cfg \
 -f target_MO517_linux.cfg \
 -f M0517_flash.tcl -f M0517_unlock.tcl
</pre>
<br /><p>
If you get following error:</p>
<pre>
Error: init mode failed (unable to connect to the target)
</pre>
<br /><p>
Connect RST pin to GND while plugging in ST-Link v2 into computer. This will start M0517 in reset mode (you might see squares in first line of display).</p>
<p>
Then, unplug RST pin from GND and connect it to RST and restart openocd. Your IMAX B6 is probably protected, so follow instructions below to unlock it.</p>
<p>
Open telnet connection to openocd in other terminal:</p>
<pre>
dpavlin@x200:/rest/cvs/cheali-charger$ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
&gt; FlashAprom /rest/cvs/cheali-charger/hex/unstable/cheali-charger-imaxB6-clone_1.99-20150727_nuvoton-M0517.hex
</pre>
<br /><p>
Output from openocd after successful flash:</p>
<pre>
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
FlashAprom
EraseChip
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 : M0517.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : accepting 'telnet' connection on tcp/4444
Image: /rest/cvs/cheali-charger/./src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_1.00-20150617_nuvoton-M0517.bin; Size=34840; Sectors:69; FlashProces:(34840;3584,9;2584,1)
&gt;&gt;&gt;&gt;     Load FlashPgm to SRAM: NU_M051x.bin =&gt; 0x20000000
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0xfffffffe msp: 0xfffffffc
276 bytes written at address 0x20000000
downloaded 276 bytes in 0.008215s (32.810 KiB/s)
&gt;&gt;&gt;&gt;     FlashInit:
sp (/32): 0x20001000
pc (/32): 0x20000000
Error: timed out while waiting for target halted

Flash is locked!
Chip erase...
.
.
.
.
.
APROM: Erased!: (0x00000000):0xFFFFFFFF
LDROM: Erased!: (0x00100000):0xFFFFFFFF
Config: Erased!: (0x0030000):0xFFFFFFFF
Image: /rest/cvs/cheali-charger/./src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_1.00-20150617_nuvoton-M0517.bin; Size=34840; Sectors:69; FlashProces:(34840;3584,9;2584,1)
&gt;&gt;&gt;&gt;     Load FlashPgm to SRAM: NU_M051x.bin =&gt; 0x20000000
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0xfffffffe msp: 0xfffffffc
276 bytes written at address 0x20000000
downloaded 276 bytes in 0.008211s (32.826 KiB/s)
&gt;&gt;&gt;&gt;     FlashInit:
sp (/32): 0x20001000
pc (/32): 0x20000000
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x41000000 pc: 0x20000048 msp: 0x20001000
r0 (/32): 0x00000000
&gt;&gt;&gt;&gt;     FlashInit stop:
&gt;&gt;&gt;&gt;     EreaseFlash: start
     FLASH sector addr: 0x00000000
     sectors to erease: 0x00000045
r0 (/32): 0x00000000
r1 (/32): 0x00000045
sp (/32): 0x20001000
pc (/32): 0x20000058
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x200000a2 msp: 0x20000fec
r0 (/32): 0x00000000
&gt;&gt;&gt;&gt;    FlashErease: stop
&gt;&gt;&gt;&gt;   FLASH image: /rest/cvs/cheali-charger/./src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_1.00-20150617_nuvoton-M0517.bin to 0x00000000
&gt;&gt; Flash Sector: 0-6 =&gt; 0x00000000 (3584)
     SRAM load : tmp/fl.00 =&gt; 0x20000120
     FLASH addr: reg r0 0x00000000
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.069231s (50.555 KiB/s)
r0 (/32): 0x00000000
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
&gt;&gt; Flash Sector: 7-13 =&gt; 0x00000e00 (3584)
     SRAM load : tmp/fl.01 =&gt; 0x20000120
     FLASH addr: reg r0 0x00000e00
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.068563s (51.048 KiB/s)
r0 (/32): 0x00000E00
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
&gt;&gt; Flash Sector: 14-20 =&gt; 0x00001c00 (3584)
     SRAM load : tmp/fl.02 =&gt; 0x20000120
     FLASH addr: reg r0 0x00001c00
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.068231s (51.296 KiB/s)
r0 (/32): 0x00001C00
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
&gt;&gt; Flash Sector: 21-27 =&gt; 0x00002a00 (3584)
     SRAM load : tmp/fl.03 =&gt; 0x20000120
     FLASH addr: reg r0 0x00002a00
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.069227s (50.558 KiB/s)
r0 (/32): 0x00002A00
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
&gt;&gt; Flash Sector: 28-34 =&gt; 0x00003800 (3584)
     SRAM load : tmp/fl.04 =&gt; 0x20000120
     FLASH addr: reg r0 0x00003800
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.069238s (50.550 KiB/s)
r0 (/32): 0x00003800
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
&gt;&gt; Flash Sector: 35-41 =&gt; 0x00004600 (3584)
     SRAM load : tmp/fl.05 =&gt; 0x20000120
     FLASH addr: reg r0 0x00004600
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.069181s (50.592 KiB/s)
r0 (/32): 0x00004600
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
&gt;&gt; Flash Sector: 42-48 =&gt; 0x00005400 (3584)
     SRAM load : tmp/fl.06 =&gt; 0x20000120
     FLASH addr: reg r0 0x00005400
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.069107s (50.646 KiB/s)
r0 (/32): 0x00005400
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
&gt;&gt; Flash Sector: 49-55 =&gt; 0x00006200 (3584)
     SRAM load : tmp/fl.07 =&gt; 0x20000120
     FLASH addr: reg r0 0x00006200
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.069117s (50.639 KiB/s)
r0 (/32): 0x00006200
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
&gt;&gt; Flash Sector: 56-62 =&gt; 0x00007000 (3584)
     SRAM load : tmp/fl.08 =&gt; 0x20000120
     FLASH addr: reg r0 0x00007000
     SIZE  addr: reg r1 0x00000e00
     BUFFR addr: reg r2 0x20000120
3584 bytes written at address 0x20000120
downloaded 3584 bytes in 0.068143s (51.363 KiB/s)
r0 (/32): 0x00007000
r1 (/32): 0x00000E00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
&gt;&gt; Flash Sector: 63-68 =&gt; 0x00007e00 (2584)
     SRAM load : tmp/fl.09 =&gt; 0x20000120
     FLASH addr: reg r0 0x00007e00
     SIZE  addr: reg r1 0x00000c00
     BUFFR addr: reg r2 0x20000120
2584 bytes written at address 0x20000120
downloaded 2584 bytes in 0.050122s (50.346 KiB/s)
r0 (/32): 0x00007E00
r1 (/32): 0x00000C00
r2 (/32): 0x20000120
sp (/32): 0x20001000
pc (/32): 0x200000AE
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
r0 (/32): 0x00000000
&gt;&gt;&gt;&gt;   FLASH image: stop
&gt;&gt;&gt;&gt;    Verify: verify_image /rest/cvs/cheali-charger/./src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_1.00-20150617_nuvoton-M0517.bin 0
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x20000ff4
verified 34840 bytes in 0.226838s (149.990 KiB/s)
Trajanje init: 0 sec
Trajanje brisi: 2 sec
Trajanje pisi: 2 sec
Trajanje ukupno: 4 sec
</pre>
<br /><h2 id="update">Update</h2>
<pre>
dpavlin@x200:/rest/cvs/cheali-charger/utils/M0517_flash_tools/tcl$ openocd -f interface/stlink-v2.cfg -f target_MO517_linux.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.239563
Info : M0517.cpu: hardware has 4 breakpoints, 2 watchpoints


# in other terminal

dpavlin@x200:/rest/cvs/cheali-charger/utils/M0517_flash_tools$ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
&gt; source M0517_flash.tcl
FlashAprom

&gt; FlashAprom /rest/cvs/cheali-charger/hex/unstable/cheali-charger-imaxB6-clone_1.99-20150727_nuvoton-M0517.hex

</pre>
<br /><h1 id="serial_port">Serial port</h1>
<ul>
<li><a target="_blank" title="(external link)" href="http://www.rcgroups.com/forums/showthread.php?t=1046318">http://www.rcgroups.com/forums/showthread.php?t=1046318</a></li>
<li><a target="_blank" title="(external link)" href="https://groups.google.com/forum/#!topic/cheali-charger/VATJQ4-GpVE%5B1-25%5D">https://groups.google.com/forum/#!topic/cheali-charger/VATJQ4-GpVE%5B1-25%5D</a></li>
</ul>
<pre>
1 2 3

1 - +5V
2 - TTL TX serial / Vout of LM35
3 - GND
</pre>
<br /><h2 id="logview">LogView</h2>
<h3 id="tsv">tsv</h3>
<pre>
grep '$1' cheali.log | sed 's/;/\t/g' | xclip -selection clipboard -i
</pre>
<br /><h1 id="temperature_sensor">temperature sensor</h1>
<p>
cheali-charger version 1.99:</p>
<p>
The &quot;Hard way&quot; (any temp probe):<br />
1. connect external temp probe<br />
2. check if there is 5V on temp. connector (between pin 1 (GND) and pin 3)<br />
3. go to: &quot;options&quot;<del>&gt; &quot;calibrate&quot;</del>&gt;&quot;temp extern&quot;<br />
(first calibration point: point 0) <br />
&nbsp;&nbsp;4. set &quot;temp:&quot; to your room temperature (~20�C) <br />
(second calibration point: point 1) <br />
&nbsp;&nbsp;5. set &quot;calib. p.:&quot; to 1<br />
&nbsp;&nbsp;6. heat temp. sensor to 60�C<br />
&nbsp;&nbsp;7. set &quot;temp:&quot; to 60�C (the temperature sensor should be at 60�C at this moment)</p>
<p>
The &quot;easy way&quot; (LM35, LM35DZ):<br />
1. connect external temp probe<br />
2. check if there is 5V on temp. connector (between pin 1 (GND) and pin 3)<br />
2. check sensor output voltage, should be: ~0.20V (between pin 1 (GND) and pin 2)<br />
3. go to: &quot;options&quot;<del>&gt; &quot;calibrate&quot;</del>&gt;&quot;temp extern&quot;<br />
(first calibration point: point 0) <br />
&nbsp;&nbsp;4. set &quot;temp:&quot; to your room temperature (~20�C) <br />
(second calibration point: point 1) <br />
&nbsp;&nbsp;5. set &quot;calib. p.:&quot; to 1<br />
&nbsp;&nbsp;6. disconnect temperature probe<br />
&nbsp;&nbsp;7. make a shortcut between pin 1 (GND) and pin 2 on the temperature connector (simulate sensor output voltage = 0V)<br />
&nbsp;&nbsp;8. set &quot;temp:&quot; to 0�C</p>
<h1 id="backup_calibration">backup calibration</h1>
<h2 id="memory_map">memory map</h2>
<p>
Table 6.13-1 Memory Address Map</p>
<table style="border-collapse: collapse;" class="formatter_table">
<tr>
<td style="border: 1px solid black;padding: .2em;">Block Name</td>
<td style="border: 1px solid black;padding: .2em;">Size</td>
<td style="border: 1px solid black;padding: .2em;">Start Address</td>
<td style="border: 1px solid black;padding: .2em;">End Address</td>
</tr>
<tr>
<td style="border: 1px solid black;padding: .2em;">AP-ROM</td>
<td style="border: 1px solid black;padding: .2em;">8/16/32/64KB</td>
<td style="border: 1px solid black;padding: .2em;">0x0000_0000</td>
<td style="border: 1px solid black;padding: .2em;">0x0000_1FFF (8KB)</td>
</tr>
<tr>
<td style="border: 1px solid black;padding: .2em;"><span style="padding:.5em">&nbsp;</span></td>
<td style="border: 1px solid black;padding: .2em;"><span style="padding:.5em">&nbsp;</span></td>
<td style="border: 1px solid black;padding: .2em;"><span style="padding:.5em">&nbsp;</span></td>
<td style="border: 1px solid black;padding: .2em;">0x0000_3FFF (16KB)</td>
</tr>
<tr>
<td style="border: 1px solid black;padding: .2em;"><span style="padding:.5em">&nbsp;</span></td>
<td style="border: 1px solid black;padding: .2em;"><span style="padding:.5em">&nbsp;</span></td>
<td style="border: 1px solid black;padding: .2em;"><span style="padding:.5em">&nbsp;</span></td>
<td style="border: 1px solid black;padding: .2em;">0x0000_7FFF (32KB)</td>
</tr>
<tr>
<td style="border: 1px solid black;padding: .2em;"><span style="padding:.5em">&nbsp;</span></td>
<td style="border: 1px solid black;padding: .2em;"><span style="padding:.5em">&nbsp;</span></td>
<td style="border: 1px solid black;padding: .2em;"><span style="padding:.5em">&nbsp;</span></td>
<td style="border: 1px solid black;padding: .2em;">0x0000_FFFF (64KB)</td>
</tr>
<tr>
<td style="border: 1px solid black;padding: .2em;">Data Flash</td>
<td style="border: 1px solid black;padding: .2em;">4KB</td>
<td style="border: 1px solid black;padding: .2em;">0x0001_F000</td>
<td style="border: 1px solid black;padding: .2em;">0x0001_FFFF</td>
</tr>
<tr>
<td style="border: 1px solid black;padding: .2em;">LD-ROM</td>
<td style="border: 1px solid black;padding: .2em;">4KB</td>
<td style="border: 1px solid black;padding: .2em;">0x0010_0000</td>
<td style="border: 1px solid black;padding: .2em;">0x0010_0FFF</td>
</tr>
<tr>
<td style="border: 1px solid black;padding: .2em;">User Configuration</td>
<td style="border: 1px solid black;padding: .2em;">1 Words</td>
<td style="border: 1px solid black;padding: .2em;">0x0030_0000</td>
<td style="border: 1px solid black;padding: .2em;">0x0030_0000</td>
</tr>
</table>
<br /><h2 id="backup">backup</h2>
<pre>
&gt; init
&gt; dump_image aprom.bin 0x0 0x10000
dumped 65536 bytes in 0.638086s (100.300 KiB/s)

&gt; dump_image flash_data.bin 0x1f000 0x1000
dumped 4096 bytes in 0.042080s (95.057 KiB/s)

&gt; dump_image ldrom.bin  0x100000 0x1000
SWD DPIDR 0x0bb11477
Failed to read memory at 0x00100000

&gt; dump_image config.bin 0x300000 0x1000
SWD DPIDR 0x0bb11477
Failed to read memory at 0x00300000
</pre>
<br /><h2 id="create_calibration_for_compile_from_backup">create calibration for compile from backup</h2>
<p>
apply fix for python3 from <a target="_blank" title="(external link)" href="https://github.com/dpavlin/cheali-charger/tree/python3">https://github.com/dpavlin/cheali-charger/tree/python3</a></p>
<pre>
dpavlin@nuc:/nuc/cheali-charger/utils/eepromExtractor$ ls -al eeprom.bin
-r--r--r-- 1 dpavlin dpavlin 4096 Jul  5 10:54 eeprom.bin
dpavlin@nuc:/nuc/cheali-charger/utils/eepromExtractor$ ./eeprom.py
magic:  chli
version: 9.3.10
Data(
    magicString = (
        99,
        104,
        108,
        105,
    ),
    architecture = 16385,
    calibrationVersion = 9,
    programDataVersion = 3,
    settingVersion = 10,
    calibration = (
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 50,
                ),
                CalibrationPoint(
                    x = 17148,
                    y = 15976,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 50,
                ),
                CalibrationPoint(
                    x = 17148,
                    y = 15976,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 525,
                    y = 100,
                ),
                CalibrationPoint(
                    x = 5447,
                    y = 1000,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 1919,
                    y = 100,
                ),
                CalibrationPoint(
                    x = 5827,
                    y = 300,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 1,
                    y = 1,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 8000,
                    y = 5940,
                ),
                CalibrationPoint(
                    x = 8642,
                    y = 3479,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 21558,
                    y = 12728,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 52287,
                    y = 1910,
                ),
                CalibrationPoint(
                    x = 45432,
                    y = 0,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 25736,
                    y = 3995,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 25736,
                    y = 3995,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 51320,
                    y = 7985,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 26220,
                    y = 4002,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 26150,
                    y = 3989,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 25169,
                    y = 3916,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 0,
                    y = 0,
                ),
                CalibrationPoint(
                    x = 25405,
                    y = 3933,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 525,
                    y = 100,
                ),
                CalibrationPoint(
                    x = 5457,
                    y = 1000,
                ),
            ),
        ),
        Calibration(
            p = (
                CalibrationPoint(
                    x = 3013,
                    y = 100,
                ),
                CalibrationPoint(
                    x = 9187,
                    y = 300,
                ),
            ),
        ),
    ),
    calibrationCRC = 53014,
    battery = (
        Battery(
            type = 6,
            capacity = 2000,
            cells = 4,
            Ic = 1000,
            Id = 410,
            Vc_per_cell = 4200,
            Vd_per_cell = 3000,
            minIc = 100,
            minId = 55,
            time = 1000,
            enable_externT = 1,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73640&gt;,
        ),
        Battery(
            type = 6,
            capacity = 3000,
            cells = 1,
            Ic = 3000,
            Id = 1000,
            Vc_per_cell = 4200,
            Vd_per_cell = 3000,
            minIc = 300,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac735c0&gt;,
        ),
        Battery(
            type = 1,
            capacity = 2000,
            cells = 1,
            Ic = 2000,
            Id = 490,
            Vc_per_cell = 1800,
            Vd_per_cell = 850,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 1,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73740&gt;,
        ),
        Battery(
            type = 2,
            capacity = 3600,
            cells = 2,
            Ic = 3600,
            Id = 1000,
            Vc_per_cell = 1800,
            Vd_per_cell = 1000,
            minIc = 360,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73640&gt;,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac735c0&gt;,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73740&gt;,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73640&gt;,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac735c0&gt;,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73740&gt;,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73640&gt;,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac735c0&gt;,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73740&gt;,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73640&gt;,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac735c0&gt;,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73740&gt;,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73640&gt;,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac735c0&gt;,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73740&gt;,
        ),
        Battery(
            type = 0,
            capacity = 2000,
            cells = 3,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 1,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac73640&gt;,
        ),
        Battery(
            type = 11,
            capacity = 2000,
            cells = 1,
            Ic = 2000,
            Id = 1000,
            Vc_per_cell = 3000,
            Vd_per_cell = 1,
            minIc = 200,
            minId = 100,
            time = 1000,
            enable_externT = 0,
            externTCO = 6000,
            enable_adaptiveDischarge = 0,
            DCRestTime = 30,
            capCutoff = 120,
            _0 = &lt;v9_3_10.N11ProgramData7Battery3DOT_1E object at 0x7f3f4ac735c0&gt;,
        ),
    ),
    programDataCRC = 13555,
    settings = Settings(
        backlight = 70,
        fanOn = 3,
        fanTempOn = 5000,
        dischargeTempOff = 6000,
        audioBeep = 1,
        minIc = 50,
        minId = 50,
        inputVoltageLow = 10000,
        adcNoise = 0,
        UART = 3,
        UARTspeed = 3,
        UARToutput = 1,
        menuType = 1,
    ),
    settingsCRC = 15640,
)
dpavlin@nuc:/nuc/cheali-charger/utils/eepromExtractor$ cp defaultCalibration.cpp ../../src/hardware/nuvoton-M0517/targets/imaxB6-clone/
</pre>
<br /><h1 id="serial_tx_and_rx_on_chip_pins">serial tx and rx on chip pins</h1>
<ul>
<li>pin 5 - P3.0 RX</li>
<li>pin 7 - P3.1 TX</li>
</ul>
<span class="nlw_phrase"><a href="https://saturn.ffzg.hr/rot13/index.cgi/M051-LQFP-pins.png?action=attachments_download;page_name=imax_b6;id=20210703080122-1-22556">M051-LQFP-pins.png</a><!-- wiki: {file: M051-=LQFP-=pins.png} --></span><br /><br /><span class="nlw_phrase"><img alt="M051-LQFP-pins-800.png" src="https://saturn.ffzg.hr/rot13/index.cgi/M051-LQFP-pins-800.png?action=attachments_download;page_name=imax_b6;id=20210703080449-3-28017" /><!-- wiki: {image: M051-=LQFP-=pins-=800.png} --></span><br /><br /><h1 id="openocd_upstream_support_for_nuvoton">openocd upstream support for nuvoton</h1>
<pre>
pi@pihdmi:~/openocd-rpi2-stm32/imax_b6 $ openocd -f rpi2-swd.cfg -f target/numicro.cfg
Open On-Chip Debugger 0.10.0+dev-01489-g06c7a53f1-dirty (2020-11-14-15:21)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
swd
cortex_m reset_config sysresetreq

Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : clock speed 1001 kHz
Info : SWD DPIDR 0x0bb11477
Info : NuMicro.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for NuMicro.cpu on 3333
Info : Listening on port 3333 for gdb connections
</pre>
<br /><p>
Program new version</p>
<pre>
&gt; halt
target halted due to debug-request, current mode: Handler External Interrupt(6)
xPSR: 0x41000016 pc: 0x00000a70 msp: 0x20000f60
&gt; flash write_bank 0 /nuc/cheali-charger/src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_2.01-e10.3.12-20210623_nuvoton-M0517.bin
Nuvoton NuMicro: Flash Write ...
wrote 37776 bytes from file /nuc/cheali-charger/src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_2.01-e10.3.12-20210623_nuvoton-M0517.bin to flash bank 0 at offset 0x00000000 in 0.906262s (40.706 KiB/s)

&gt; reset
NuMicro.cpu -- clearing lockup after double fault
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x01000003 pc: 0xfffffffe msp: 0x20000eb0
Polling target NuMicro.cpu failed, trying to reexamine
NuMicro.cpu: hardware has 4 breakpoints, 2 watchpoints

</pre>
<br /><p>
This will brick mcu, so don't do it!</p>
<h1 id="openocd_0_10_changes">openocd 0.10 changes</h1>
<p>
<a target="_blank" title="(external link)" href="https://github.com/dpavlin/M0517_flash_tools/tree/fix_openocd_0.10">https://github.com/dpavlin/M0517_flash_tools/tree/fix_openocd_0.10</a></p>
<p>
Update cheali-charger/utils/M0517_flash_tools to branch fix_openocd_0.10</p>
<h2 id="update_version">update version</h2>
<p>
start openocd with raspberry pi configurtaion:</p>
<pre>
pi@pihdmi:~/openocd-rpi2-stm32/imax_b6 $ openocd -f target_M0517_rpi.cfg -s /nuc/cheali-charger/utils/M0517_flash_tools/tcl/ -f M0517_flash.tcl -f M0517_unlock.tcl
Open On-Chip Debugger 0.10.0+dev-01489-g06c7a53f1-dirty (2020-11-14-15:21)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
cortex_m reset_config sysresetreq

FlashAprom
EraseChip
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : clock speed 1001 kHz
Info : SWD DPIDR 0x0bb11477
Info : M0517.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for M0517.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'telnet' connection on tcp/4444
</pre>
<br /><p>
connect and flash latest version</p>
<pre>
pi@pihdmi:~/openocd-rpi2-stm32/imax_b6 $ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
&gt;
&gt; FlashAprom /nuc/cheali-charger/src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_2.01-e10.3.12-20210623_nuvoton-M0517.bin

&gt; FlashAprom /nuc/cheali-charger/src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_2.01-e10.3.12-20210705_nuvoton-M0517.bin

target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x00001000 msp: 0x20000ed0
target halted due to breakpoint, current mode: Thread
xPSR: 0x41000000 pc: 0x20000048 msp: 0x20001000
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x200000a2 msp: 0x20000fec
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
&gt; reset
</pre>
<br /><p>
output from openocd:</p>
<pre>
pi@pihdmi:~/openocd-rpi2-stm32/imax_b6 $ cat openocd.sh
openocd -s /nuc/cheali-charger/utils/M0517_flash_tools/tcl -f target_M0517_rpi.cfg -f M0517_flash.tcl -f M0517_unlock.tcl
pi@pihdmi:~/openocd-rpi2-stm32/imax_b6 $ ./openocd.sh
Open On-Chip Debugger 0.10.0+dev-01489-g06c7a53f1-dirty (2020-11-14-15:21)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
cortex_m reset_config sysresetreq

Flash
EraseChip
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : clock speed 1001 kHz
Info : SWD DPIDR 0x0bb11477
Info : M0517.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for M0517.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'telnet' connection on tcp/4444
Info : dropped 'telnet' connection
Info : accepting 'telnet' connection on tcp/4444
Image: /nuc/cheali-charger/src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_2.01-e10.3.12-20210705_nuvoton-M0517.bin, type: bin; Size=34660; Sectors:68; FlashProces:(34660;3584,9;2404,1)
&gt;&gt;&gt;&gt;     Load FlashPgm to SRAM: NU_M051x.bin =&gt; 0x20000000
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x00001144 msp: 0x20000fd8
&gt;&gt;&gt;&gt;     FlashInit:
target halted due to breakpoint, current mode: Thread
xPSR: 0x41000000 pc: 0x20000048 msp: 0x20001000
&gt;&gt;&gt;&gt;     FlashInit stop:
time init: 1 sec
&gt;&gt;&gt;&gt;     EreaseFlash: start
     FLASH sector addr: 0x00000000
     sectors to erease: 0x00000044
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x200000a2 msp: 0x20000fec
&gt;&gt;&gt;&gt;    FlashErease: stop
time erease: 1 sec
&gt;&gt;&gt;&gt;   FLASH image: /nuc/cheali-charger/src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_2.01-e10.3.12-20210705_nuvoton-M0517.bin to 0x00000000
&gt;&gt; Flash Sector: 0-6 =&gt; 0x00000000 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
&gt;&gt; Flash Sector: 7-13 =&gt; 0x00000e00 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
&gt;&gt; Flash Sector: 14-20 =&gt; 0x00001c00 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
&gt;&gt; Flash Sector: 21-27 =&gt; 0x00002a00 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
&gt;&gt; Flash Sector: 28-34 =&gt; 0x00003800 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
&gt;&gt; Flash Sector: 35-41 =&gt; 0x00004600 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
&gt;&gt; Flash Sector: 42-48 =&gt; 0x00005400 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
&gt;&gt; Flash Sector: 49-55 =&gt; 0x00006200 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
&gt;&gt; Flash Sector: 56-62 =&gt; 0x00007000 (3584)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
&gt;&gt; Flash Sector: 63-67 =&gt; 0x00007e00 (2404)
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000010c msp: 0x20000ff4
&gt;&gt;&gt;&gt;   FLASH image: stop
&gt;&gt;&gt;&gt;    Verify: verify_image /nuc/cheali-charger/src/hardware/nuvoton-M0517/targets/imaxB6-clone/cheali-charger-imaxB6-clone_2.01-e10.3.12-20210705_nuvoton-M0517.bin 0
time write: 1 sec
time summary: 3 sec
</pre>
</div>
<hr/><div>Attachments: isp_imaxB6_M0517.jpeg, M051-LQFP-pins-800.png, M051-LQFP-pins.png, RC-Power_BC6_Charger.pdf</div>]]></description>
<author>Dobrica Pavlinu&#x161;i&#x107;</author>
<category></category>
<guid isPermaLink="true">https://saturn.ffzg.hr/rot13/index.cgi?imax_b6</guid>
<pubDate>Mon, 05 Jul 2021 19:09:27 -0000</pubDate>
</item>
</channel>
</rss>