Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Programming Kinetis With CodeWarrior from the DOS Shell

DZone's Guide to

Programming Kinetis With CodeWarrior from the DOS Shell

Dealing with your Kinetis device from the comfort of the command line.

· IoT Zone
Free Resource

In “CodeWarrior Flash Programming from a DOS Shell” I showed how to program a device from the DOS shell. Because that example was for ColdFire and CodeWarrior for MCU10.2, here is the same for a Kinetis (FRDM-KL25Z) and CodeWarrior for MCU10.6. In my workspace (c:\tmp\wsp_10.6) I have a project folder (FRDM-KL25Z).

I’m using the ‘Flash Programmer’ to sneak the needed commands:

Sneaking Commands from Flasher

Sneaking Commands from Flasher


I use these commands to build my TCL file (Standalone.tcl) with the launch configuration of my project (FRDM-KL25Z_FLASH_OpenSDA):

############################################################
# Standalone.tcl: a script file to flash my application
############################################################

# in any case, disconnect an existing debug connection
cmdwin::fl::disconnect

# set launch configuration:
cmdwin::fl::target -lc "FRDM-KL25Z_FLASH_OpenSDA"

# set Set the target RAM buffer for downloading image data:
cmdwin::fl::target -b 0x1ffff000 0x4000

# switch off verify and logging:
cmdwin::fl::target -v off -l off

# select flash device, organization and memory range:
cmdwin::fl::device -d "FTFA_PFlash128S1RAM16" -o "32Kx32x1" -a 0x0 0x1ffff

# specify target file, auto detect format, range settings on followed by the flash range, offset settings off
cmdwin::fl::image -f "C:\\tmp\\wsp_10.6\\FRDM-KL25Z\\FLASH\\FRDM-KL25Z.elf" -t "Auto Detect" -re on -r 0x0 0x1ffff -oe off

# now erase the flash...
cmdwin::fl::erase image

# ... followed by writing the application to flash:
cmdwin::fl::write

# disconnect connection
fl::disconnect

# exit Eclipse IDE
quitIDE

I recommend to run the .tcl file wither with the ‘source’ command in the Debugger Shell first (without the quitIDE at the end):

Successful command execution

Successful command execution

Here is the full Debugger Shell log:

CodeWarrior Debugger Shell v1.0
%>source c:\tmp\wsp_10.6\Standalone.tcl
cmdwin::fl::disconnect 
cmdwin::fl::target -lc FRDM-KL25Z_FLASH_OpenSDA 
cmdwin::fl::target -b 0x1ffff000 0x4000 
cmdwin::fl::target -v off -l off 
cmdwin::fl::device -d FTFA_PFlash128S1RAM16 -o 32Kx32x1 -a 0x0 0x1ffff 
cmdwin::fl::image -f C:\tmp\wsp_10.6\FRDM-KL25Z\FLASH\FRDM-KL25Z.elf -t Auto Detect -re on -r 0x0 0x1ffff -oe off 
cmdwin::fl::erase image 
 Beginning Operation ...    
------------------------- 
Auto-detection is successful.   
  File is of type Elf Format.   

Performing target initialization ...    
thread break: Stopped, 0x0, 0x0, cpuARMLittle, Unknown (state, tid, pid, cpu, target) 
thread set: Stopped, 0x0, 0x0, cpuARMLittle, Unknown (state, tid, pid, cpu, target) 
thread break: Stopped, 0x0, 0x0, cpuARMLittle, Unknown (state, tid, pid, cpu, target) 
source c:\\tmp\\wsp_10.6\\Standalone.tcl 
 Downloading Flash Device Driver ...   
Reading flash ID ...   
Erasing Sector 0x00000000 to 0x000003FF   
Erasing Sector 0x00000800 to 0x00000BFF   
Erasing Sector 0x00000C00 to 0x00000FFF   
Erasing Sector 0x00001000 to 0x000013FF   
Erasing Sector 0x00001400 to 0x000017FF   
Erasing Sector 0x00001800 to 0x00001BFF   
Erasing ...   
 Erase Command Succeeded    
cmdwin::fl::write 
 Beginning Operation ...    
------------------------- 
Using restricted address range 0x00000000 to 0x0001FFFF   
Programming file C:\tmp\wsp_10.6\FRDM-KL25Z\FLASH\FRDM-KL25Z.elf   
Auto-detection is successful.   
  File is of type Elf Format.   

 Downloading Flash Device Driver ...   
Reading flash ID ...   
Auto-detection is successful.   
  File is of type Elf Format.   

Downloading 0x000000C0 bytes to be programmed at 0x00000000   
Executing program ....   
 Program Command Succeeded    
Downloading 0x00001364 bytes to be programmed at 0x00000800   
Executing program ....   
 Program Command Succeeded    
cmdwin::fl::disconnect 
thread exit: Stopped, 0x0, 0x0, cpuARMLittle, Unknown (state, tid, pid, cpu, target) 

Finally, I can add/enable the quitIDE at the end of the TCL file to close the IDE at the end. From the DOS shell, I launch it like this:

"c:\Freescale\CW MCU v10.6\eclipse\cwide.exe" -data "c:\tmp\wsp_10.6" -vmargsplus -Dcw.script="c:\tmp\standalone.tcl"

flashing with CodeWarrior from DOS

Flashing with CodeWarrior from DOS

It will take a while to initialize the debugger engine. But above way is a convenient way to automate flashing several boards.

Happy DOSing :-)

Topics:
kinetis ,dos

Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}