SparkFun Forums 

Where electronics enthusiasts find answers.

Open source ARM Debugger
By Sawe
#186028
Hallo guys,
I'm new in this Forum.

I have a problem with flashing my Freescale, Openocd does not complete the inti-command.
Openocd failt by reading or writing in the memory for Private Peripheral Bus.
At each try it's an other adress, but some adresses are read- oder writeable.

The error-message look like this error:
Code: Select all
Open On-Chip Debugger 0.9.0-rc1 (2015-04-24-22:05)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : FTDI SWD mode enabled
Info : add flash_bank kinetis MKL16Z128VFM4.flash
adapter speed: 1000 kHz
none separate
cortex_m reset_config sysresetreq
Info : clock speed 1000 kHz
Info : SWD IDCODE 0x0bc11477
Info : SWD IDCODE 0x0bc11477
Error: Failed to read memory at 0xe000ed00
Polling target MKL16Z128VFM4.cpu failed, trying to reexamine
Info : SWD IDCODE 0x0bc11477
Info : SWD IDCODE 0x0bc11477
Error: Failed to write memory at 0xe0001028
Info : MKL16Z128VFM4.cpu: hardware has 2 breakpoints, 2 watchpoints
Error: The 'check_security' command must be used after 'init'.
in procedure 'init' called at file "D:\Eclipse\Workspace\We******Samuel\Demozuspieler\MKL16Z4.cfg", line 86
in procedure 'ocd_bouncer' 
in procedure 'nand' 
in procedure 'ocd_bouncer'

Polling target MKL16Z128VFM4.cpu failed, trying to reexamine
Info : SWD IDCODE 0x0bc11477
Info : SWD IDCODE 0x0bc11477
Error: Failed to read memory at 0xe000edfc
Info : MKL16Z128VFM4.cpu: hardware has 0 breakpoints, 2 watchpoints
Error: The 'check_security' command must be used after 'init'.
in procedure 'init' called at file "D:\Eclipse\Workspace\We******Samuel\Demozuspieler\MKL16Z4.cfg", line 86
in procedure 'ocd_bouncer' 
in procedure 'pld' 
in procedure 'ocd_bouncer'

Polling target MKL16Z128VFM4.cpu failed, trying to reexamine
Info : SWD IDCODE 0x0bc11477
Info : MKL16Z128VFM4.cpu: hardware has 2 breakpoints, 2 watchpoints
Warn : *********** ATTENTION! ATTENTION! ATTENTION! ATTENTION! **********
Warn : ****                                                          ****
Warn : **** Your Kinetis MCU is in secured state, which means that,  ****
Warn : **** with exception for very basic communication, JTAG/SWD    ****
Warn : **** interface will NOT work. In order to restore its         ****
Warn : **** functionality please issue 'kinetis mdm mass_erase'      ****
Warn : **** command, power cycle the MCU and restart OpenOCD.        ****
Warn : ****                                                          ****
Warn : *********** ATTENTION! ATTENTION! ATTENTION! ATTENTION! **********
shutdown command invoked

Here my Config-File:
Code: Select all
#
# Freescale Kinetis KL series devices
#

interface ftdi
ftdi_device_desc "FT2232H MiniModule"
ftdi_vid_pid 0x0403 0x6010

ftdi_layout_init 0x0028 0x00eb
#ftdi_layout_init 0x00a8 0x00eb
#ftdi_layout_signal nSRST -noe 0x0020
ftdi_layout_signal SWD_EN -ndata 0x0080
ftdi_layout_signal SWDIO_OE -data 0x0008

set ENDIAN little
set _CHIPNAME MKL16Z128VFM4

transport select swd
source [find target/swj-dp.tcl]

# Work-area is a space in RAM used for flash programming
# By default use 4kB
if { [info exists WORKAREASIZE] } {
   set _WORKAREASIZE $WORKAREASIZE
} else {
   set _WORKAREASIZE 0x1000
}

if { [info exists CPUTAPID] } {
    set _CPUTAPID $CPUTAPID
} else {
    set _CPUTAPID 0x0bc11477
}




swj_newdap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID

set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME cortex_m -chain-position $_CHIPNAME.cpu -endian little

# It is important that "kinetis mdm check_security" is called for
# 'examine-end' event and not 'eximine-start'. Calling it in 'examine-start'
# causes "kinetis mdm check_security" to fail the first time openocd
# calls it when it tries to connect after the CPU has been power-cycled.
$_CHIPNAME.cpu configure -event examine-end {
	kinetis mdm check_security
}

$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE

set _FLASHNAME $_CHIPNAME.flash
#flash bank $_FLASHNAME kinetis 0 131072 0 0 $_TARGETNAME
flash bank $_FLASHNAME kinetis 0 0x08000000 0 0 $_TARGETNAME
#flash banks

# Table 5-1. Clock Summary of KL25 Sub-Family Reference Manual
# specifies up to 1MHz for VLPR mode.
adapter_khz 1000

#debug_level 3

#reset_config srst_nogate
#reset_config srst_only
reset_config none
cortex_m reset_config sysresetreq

#targets

#if {![using_hla]} {
   # if srst is not fitted use SYSRESETREQ to
   # perform a soft reset
   # cortex_m reset_config sysresetreq
#}

$_TARGETNAME configure -event reset-init {
    # Table 5-1. Clock Summary of KL25 Sub-Family Reference Manual
    # specifies up to 24MHz for run mode; Table 17 of Sub-Family Data
    # Sheet rev4 lists 25MHz as the maximum frequency.
     adapter_khz 24000
}

#commands for flashing

init
#reset halt
#kinetis mdm test_securing
#kinetis mdm check_security

#kinetis mdm check_security
#flash probe 0
#kinetis mdm mass_erase
#flash write_image D:/Eclipse/Workspace/We******Samuel/Demozuspieler/Debug/Demozuspieler.hex 0 ihex
#reset run
shutdown
I hope someone here can help me :)

EDIT: Sometimes the init finished without errors

Regards,
Samuel
By Sawe
#186112
Hallo,

I think I have the reason for the problem, but no solution ...
I think the watchdog resets the MCU every second and so the init can not be completed.
And if the timing is good, the init finished.
The watchdog is enabled by default. (COP timeout is after 1024 cycles, and the clocksource is the internal 1 kHz clock)
My idee: reset the target before execute the init, but I can not reset the target before init ...
other idee: disable Wdog before execute the init, but I can not write registers before init ...

I hope someone can help

Regards,
Samuel