Testing VSPROG with Freedom board

I’m testing Freedom board with OpenOCD and VSProg following the instruction from this message:
http://tech.groups.yahoo.com/group/versaloon/message/347

# vsprog -skinetis -ms -I main.elf -o w
VSProg 1.0 svn:
CopyRight(c) 2008-2010 by SimonQian <SimonQian@SimonQian.com>

URL: http://www.SimonQian.com/en/Versaloon
mail: SimonQian@SimonQian.com

Info:   Chip name undefined, try auto-detecting.
Info:   Versaloon(0x33)by Simon(compiled on Oct 25 2011)
Info:   USB_TO_XXX abilities: 0x00000008:0x00000040:0xC0000006
Info:   SWDID = 0x0BC11477
Info:   AHB-AP_ID = 0x04770031
Info:   ROM_ADDRESS = 0xF0002003
Info:   CFG = 0x00000000, Little-endian
Info:   CORTEX-M0(+) r0p0 processor detected
Info:   CPUID = 0x410CC600
Info:   KINETIS series: KL family
Info:   KINETIS chip: KL25
Info:   KINETIS device die number: 09
Info:   KINETIS device revision number: 01
Info:   KINETIS sram size: 16384
Info:   KINETIS flash size: 128K
Info:   KINETIS pin number: 80
Info:   Chip-id read is 0x25151486.
Info:   Auto-detect signature is 0x25151486
Error:  kinetis auto-detect failed.
Error:  Fail to initialize target.
Error:  Fail to run command: prepare.

To fix this first issue just add this config to kinetis.xml:

<chip name="kl25z128frdm">
<chip_id>0x25151486</chip_id>
<program_mode>js</program_mode>
<app_default>0xFF</app_default>
<app_addr>0x00000000</app_addr>
<app_seg>0</app_seg>
<app_page_size>1024</app_page_size>
<sram_addr>0x20000000</sram_addr>
<uid init="0xFF" bytesize="12" mask="0xFFFFFFFF:0xFFFFFFFF:0xFFFFFFFF" format="%4x%4x%4x"></uid>
</chip>

Now it will report flash error:

# vsprog -skinetis -ms -I main.elf -o w
VSProg 1.0 svn:
CopyRight(c) 2008-2010 by SimonQian 

URL: http://www.SimonQian.com/en/Versaloon
mail: SimonQian@SimonQian.com

Info:   Chip name undefined, try auto-detecting.
Info:   Versaloon(0x33)by Simon(compiled on Oct 25 2011)
Info:   USB_TO_XXX abilities: 0x00000008:0x00000040:0xC0000006
Info:   SWDID = 0x0BC11477
Info:   AHB-AP_ID = 0x04770031
Info:   ROM_ADDRESS = 0xF0002003
Info:   CFG = 0x00000000, Little-endian
Info:   CORTEX-M0(+) r0p0 processor detected
Info:   CPUID = 0x410CC600
Info:   KINETIS series: KL family
Info:   KINETIS chip: KL25
Info:   KINETIS device die number: 09
Info:   KINETIS device revision number: 01
Info:   KINETIS sram size: 16384
Info:   KINETIS flash size: 128K
Info:   KINETIS pin number: 80
Info:   Chip-id read is 0x25151486.
Info:   Auto-detect signature is 0x25151486
Info:   kl25z128frdm found
Error:  flash is not defined, please define first.
Error:  Fail to check target defined content.
Error:  Fail to run command: prepare.

This error message “Error: flash is not defined, please define first.” is because I was using ELF instead of binary.
Just convert this ELF to Binary:

$ arm-none-eabi-objcopy -O binary main.elf main.bin

Let us to try again:

# vsprog -skinetis -ms -I main.bin -o w
VSProg 1.0 svn:
CopyRight(c) 2008-2010 by SimonQian 

URL: http://www.SimonQian.com/en/Versaloon
mail: SimonQian@SimonQian.com

Info:   Chip name undefined, try auto-detecting.
Info:   Versaloon(0x33)by Simon(compiled on Oct 25 2011)
Info:   USB_TO_XXX abilities: 0x00000008:0x00000040:0xC0000006
Info:   SWDID = 0x0BC11477
Info:   AHB-AP_ID = 0x04770031
Info:   ROM_ADDRESS = 0xF0002003
Info:   CFG = 0x00000000, Little-endian
Info:   CORTEX-M0(+) r0p0 processor detected
Info:   CPUID = 0x410CC600
Info:   KINETIS series: KL family
Info:   KINETIS chip: KL25
Info:   KINETIS device die number: 09
Info:   KINETIS device revision number: 01
Info:   KINETIS sram size: 16384
Info:   KINETIS flash size: 128K
Info:   KINETIS pin number: 80
Info:   Chip-id read is 0x25151486.
Info:   Auto-detect signature is 0x25151486
Info:   kl25z128frdm found
Error:  fuse is not defined, please define first.
Error:  Fail to check target defined content.
Error:  Fail to run command: prepare.

Hmm, now it says the fuse is not defined…

Let us to try to erase the chip:

# vsprog -skinetis -ms -I main.bin -o e
VSProg 1.0 svn:
CopyRight(c) 2008-2010 by SimonQian 

URL: http://www.SimonQian.com/en/Versaloon
mail: SimonQian@SimonQian.com

Info:   Chip name undefined, try auto-detecting.
Info:   Versaloon(0x33)by Simon(compiled on Oct 25 2011)
Info:   USB_TO_XXX abilities: 0x00000008:0x00000040:0xC0000006
Info:   SWDID = 0x0BC11477
Info:   AHB-AP_ID = 0x04770031
Info:   ROM_ADDRESS = 0xF0002003
Info:   CFG = 0x00000000, Little-endian
Info:   CORTEX-M0(+) r0p0 processor detected
Info:   CPUID = 0x410CC600
Info:   KINETIS series: KL family
Info:   KINETIS chip: KL25
Info:   KINETIS device die number: 09
Info:   KINETIS device revision number: 01
Info:   KINETIS sram size: 16384
Info:   KINETIS flash size: 128K
Info:   KINETIS pin number: 80
Info:   Chip-id read is 0x25151486.
Info:   Auto-detect signature is 0x25151486
Info:   kl25z128frdm found
Info:   SWDID = 0x0BC11477
Info:   AHB-AP_ID = 0x04770031
Info:   ROM_ADDRESS = 0xF0002003
Info:   CFG = 0x00000000, Little-endian
Info:   CORTEX-M0(+) r0p0 processor detected
Info:   CPUID = 0x410CC600
Info:   KINETIS series: KL family
Info:   KINETIS chip: KL25
Info:   KINETIS device die number: 09
Info:   KINETIS device revision number: 01
Info:   KINETIS sram size: 16384
Info:   KINETIS flash size: 128K
Info:   KINETIS pin number: 80
Info:   Chip-id read is 0x25151486.
Info:   erasing flash
erasing flash |========================================%100| 0.00s used
Info:   flash erased

Good, I hope! 🙂

Now, I will try to flash again:

# vsprog -skinetis -ms -I main.bin -o w
VSProg 1.0 svn:
CopyRight(c) 2008-2010 by SimonQian 

URL: http://www.SimonQian.com/en/Versaloon
mail: SimonQian@SimonQian.com

Info:   Chip name undefined, try auto-detecting.
Info:   Versaloon(0x33)by Simon(compiled on Oct 25 2011)
Info:   USB_TO_XXX abilities: 0x00000008:0x00000040:0xC0000006
Info:   SWDID = 0x0BC11477
Info:   AHB-AP_ID = 0x04770031
Info:   ROM_ADDRESS = 0xF0002003
Info:   CFG = 0x00000000, Little-endian
Error:  Stiky Error/Overrun.
Error:  Fail to initialize cm.
Error:  Maybe your last firmware disable the JTAG/SWD port, try using OpenOCD to erase the firmware.
Error:  Fail to enter program mode.
Error:  kinetis auto-detect failed.
Error:  Fail to initialize target.
Error:  Fail to run command: prepare.

Hmm, I think it is necessary to disable some protection before to try writing something.

Let to test OpenOCD-CMSIS-DAP:

# ./src/openocd -f ./tcl/interface/vsllink.cfg
Open On-Chip Debugger 0.7.0-dev-g1d8f0c1 (2013-03-18-19:24)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.sourceforge.net/doc/doxygen/bugs.html
Error: The specified debug interface was not found (vsllink)
The following debug interfaces are available:
1: cmsis-dap
Runtime Error: ./tcl/interface/vsllink.cfg:7: 
in procedure 'script' 
at file "embedded:startup.tcl", line 58
in procedure 'interface' called at file "./tcl/interface/vsllink.cfg", line 7
root@bob:/comum/Projetos/Freedom/openocd/OpenOCD-CMSIS-DAP# ./src/openocd -f ./tcl/interface/vsllink.cfg^C
root@bob:/comum/Projetos/Freedom/openocd/OpenOCD-CMSIS-DAP# ./src/openocd -c "interface cmsis-dap" -f tcl/target/kl25.cfg
Open On-Chip Debugger 0.7.0-dev-g1d8f0c1 (2013-03-18-19:24)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'cmsis-dap'
Info : CMSIS-ADI: cmsis_dap_select
Info : CMSIS-DAP: cmsis_dap_swd_init
Info : kernel driver active
Info : kernel driver now detached.
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
cortex_m3 reset_config sysresetreq
adapter speed: 50 kHz
Info : CMSIS-DAP: cmsis_dap_init
Info : CMSIS-DAP: FW Version = 1.0
Info : CMSIS-DAP: Packet Size  = 64
Info : CMSIS-DAP: Packet Count = 32
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0 
Info : CMSIS-DAP: cmsis_dap_reset_link
Info : DAP_SWJ Sequence (reset: 50+ '1' followed by 0)
Info : DAP Read IDCODE
Info : CMSIS-DAP: Interface ready
Info : clock speed 50 kHz
Info : CMSIS-ADI: cmsis_dap_init
Info : CMSIS-ADI: cmsis_dap_queue_idcode_read
Info : CMSIS-ADI: cmsis_dap_queue_dp_read 00
Info :                              0bc11477
Info : IDCODE 0x0bc11477
Info : CMSIS-ADI: cmsis_dap_queue_ap_abort
START...
Info : CMSIS-ADI: cmsis_dap_queue_dp_read 04
Info :                              00000040
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 04 00000020
Info : CMSIS-ADI: cmsis_dap_queue_dp_read 04
Info :                              00000040
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 04 50000000
Info : CMSIS-ADI: cmsis_dap_queue_dp_read 04
Info :                              f0000040
Info : CMSIS-ADI: cmsis_dap_run
Info : CMSIS-ADI: cmsis_dap_queue_dp_read 04
Info :                              f0000040
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 00000000
Info : CMSIS-ADI: cmsis_dap_queue_ap_read 00
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 00000000
Info :                              03000000
Info : CMSIS-ADI: cmsis_dap_queue_ap_read 04
Info :                              ddfdffff
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 000000f0
Info : CMSIS-ADI: cmsis_dap_queue_ap_read f4
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 000000f0
Info :                              00000000
Info : CMSIS-ADI: cmsis_dap_queue_ap_read f8
Info :                              f0002003
Info : CMSIS-ADI: cmsis_dap_queue_ap_read fc
Info :                              04770031
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 00000000
Info : CMSIS-ADI: cmsis_dap_queue_ap_write 00 a2000012
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 00000000
Info : CMSIS-ADI: cmsis_dap_queue_ap_write 04 e000ed00
Info : CMSIS-ADI: cmsis_dap_queue_ap_read_block 01
Error: CMSIS-DAP: Block Read Error (04)
Info : CMSIS-ADI: cmsis_dap_queue_ap_abort

No way! I will need to modify MDM-AP Control register before trying to use SWD.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s