Nuvoton...easy flashing with ST-Link V2 and other SWD flashers (openocd = Error: init mode failed)

2,694 views
Skip to first unread message

priv...@gmail.com

unread,
Feb 12, 2015, 7:42:18 AM2/12/15
to cheali-...@googlegroups.com
i was trying to flash a clone with M0517LBN arm and could'n't get the cpu  into debug mode for SWD flashing.
the solution after 1 day reading PDFs and general searching for how ARM using SWD turned out to be easy but hidden into datasheets......
when the M)517LBN is locked we have to force it into halt state manually just after hardware reset (HW RESET).

the problem:

bin>openocd-0.8.0.exe -interface/stlink-v2.cfg -f target_M0517_win.tcl
Open On-Chip Debugger 0.8.0 (2014-04-28-08:39)
Licensed under GNU GPL v2
For bug reports, read
        http
://openocd.sourceforge.net/doc/doxygen/bugs.html
0
Info : This adapter doesn't support configurable speed
Info : STLINK v2 JTAG v23 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.471484
Error: init mode failed
in procedure '
transport'
in procedure '
init'


the solution:

on SWD pinouts force into manual hardware reset by jumper on RST pin (cpu side) to GND (STLink v2 side)
then plug the STLink v2 into USB 
use 5V Vcc on STLink v2 side
then run openocd and do not unplug from USB
try 3-4 times by re-running openocd and plug-unplug the RST-on-GND (STLink v2 side)
that's it

charger             -          st-link
ICE_DATA <--------->    SWDIO
ICE_CLK    <--------->    SWCLK
ICE_RST    <-------->-    GND           <---------------- plun-unplug to manually reset the cpu
GND -         <--------->    GND
VCC           <--------->    5V Vcc

progs used: openocd to halt and erase chip and CoFlash to prog , using Windows 7

jarno83

unread,
Feb 17, 2015, 2:53:09 PM2/17/15
to cheali-...@googlegroups.com
Hi, I got it unlocked but I have problems with flashing:
Same text starts running on telnet window also.
And my charger is not booting right now.

Any toughs?

Thanks. 

jarno83

unread,
Feb 17, 2015, 3:23:08 PM2/17/15
to cheali-...@googlegroups.com
Ok, got it working...
Answer - Remove power plug from charger power input. It seams to drain st-link programmer and won't have enough juice to keep the jtag connection up.

jarno83

unread,
Feb 18, 2015, 4:47:41 AM2/18/15
to cheali-...@googlegroups.com
I had a problem with calibrating and flashed hex from unstable - cheali-charger-imaxB6-clone_0.99-20150211_nuvoton-M0517.hex
The flash was unsuccessful like the problem I had before when jtag connection lost.
Pic added.

It halts on line 50 in M0517_flash.tcl with command -  wait_halt

What am I doing wrong?

Thanks.



timeout.png

jarno83

unread,
Feb 18, 2015, 8:05:49 AM2/18/15
to cheali-...@googlegroups.com
Used debug_level 3 before flashing and maybe that means something to someone smarter :)
debug.png

Paweł Si

unread,
Feb 18, 2015, 9:36:19 AM2/18/15
to cheali-...@googlegroups.com

2015-02-18 14:05 GMT+01:00 jarno83 <jarnoo...@gmail.com>:
Used debug_level 3 before flashing and maybe that means something to someone smarter :)

hmm...
what the M0517_flash.tcl code is doing (based on http://openocd.sourceforge.net/doc/html/General-Commands.html):
1. reset init   <- "Immediately halt the target, and execute the reset-init script"
2. load_image NU_M051x.bin 0x20000000    <- load NU_M051x.bin  file into cpu ram at address ...
3. reg sp 0x20001000  <- set stack pointer
    reg pc 0x20000000  <- set program counter (to NU_M051x.bin:FlashInit())
    resume  <- start program
4. wait_halt <- wait until program halts: in 3. we are executing FlashInit, witch ends with a breakpoint
5.....

so... I have no idea where the problem is :D
are you sure you have unlock the CPU flash? 

you could also try to connect to openOCD through telnet:4444 and try to execute each line manually

Reply all
Reply to author
Forward
0 new messages