Line 27... |
Line 27... |
#
|
#
|
# Author(s):
|
# Author(s):
|
# - Olivier Girard, olgirard@gmail.com
|
# - Olivier Girard, olgirard@gmail.com
|
#
|
#
|
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
# $Rev: 77 $
|
# $Rev: 89 $
|
# $LastChangedBy: olivier.girard $
|
# $LastChangedBy: olivier.girard $
|
# $LastChangedDate: 2010-11-21 20:50:55 +0100 (Sun, 21 Nov 2010) $
|
# $LastChangedDate: 2011-02-05 15:03:33 +0100 (Sat, 05 Feb 2011) $
|
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
|
|
global serial_baudrate
|
global serial_baudrate
|
global serial_device
|
global serial_device
|
|
|
Line 41... |
Line 41... |
# PARAMETER CHECK #
|
# PARAMETER CHECK #
|
###############################################################################
|
###############################################################################
|
|
|
proc help {} {
|
proc help {} {
|
puts ""
|
puts ""
|
puts "USAGE : openmsp430-loader.tcl \[-device <communication device>\] \[-baudrate <communication speed>\] <elf-file>"
|
puts "USAGE : openmsp430-loader.tcl \[-device <communication device>\] \[-baudrate <communication speed>\] <elf/ihex-file>"
|
puts ""
|
puts ""
|
puts "Examples: openmsp430-loader.tcl -device /dev/ttyUSB0 -baudrate 9600 leds.elf"
|
puts "Examples: openmsp430-loader.tcl -device /dev/ttyUSB0 -baudrate 9600 leds.elf"
|
puts " openmsp430-loader.tcl -device COM2: -baudrate 38400 ta_uart.elf"
|
puts " openmsp430-loader.tcl -device COM2: -baudrate 38400 ta_uart.ihex"
|
puts ""
|
puts ""
|
}
|
}
|
|
|
# Default values
|
# Default values
|
set serial_device /dev/ttyUSB0
|
set serial_device /dev/ttyUSB0
|
Line 65... |
Line 65... |
}
|
}
|
}
|
}
|
|
|
# Make sure arugments were specified
|
# Make sure arugments were specified
|
if {[string eq $elf_file -1]} {
|
if {[string eq $elf_file -1]} {
|
puts "ERROR: ELF file isn't specified"
|
puts "ERROR: ELF/IHEX file isn't specified"
|
help
|
help
|
exit 1
|
exit 1
|
}
|
}
|
|
|
# Make sure the elf file exists
|
# Make sure the elf file exists
|
if {![file exists $elf_file]} {
|
if {![file exists $elf_file]} {
|
puts "ERROR: Specified ELF file doesn't exist"
|
puts "ERROR: Specified ELF/IHEX file doesn't exist"
|
help
|
help
|
exit 1
|
exit 1
|
}
|
}
|
|
|
|
|
Line 97... |
Line 97... |
|
|
###############################################################################
|
###############################################################################
|
# CREATE AND READ BINARY EXECUTABLE FILE #
|
# CREATE AND READ BINARY EXECUTABLE FILE #
|
###############################################################################
|
###############################################################################
|
|
|
|
# Detect the file format depending on the fil extention
|
|
set fileType [file extension $elf_file]
|
|
set fileType [string tolower $fileType]
|
|
regsub {\.} $fileType {} fileType
|
|
if {![string eq $fileType "ihex"] & ![string eq $fileType "hex"] & ![string eq $fileType "elf"]} {
|
|
puts "ERROR: [string toupper $fileType] file format not supported"
|
|
return 0
|
|
}
|
|
if {[string eq $fileType "hex"]} {
|
|
set fileType "ihex"
|
|
}
|
|
if {[string eq $fileType "elf"]} {
|
|
set fileType "elf32-msp430"
|
|
}
|
|
|
# Generate binary file
|
# Generate binary file
|
if {[catch {exec msp430-objcopy -O binary $elf_file $bin_file} errMsg]} {
|
if {[catch {exec msp430-objcopy -I $fileType -O binary $elf_file $bin_file} errMsg]} {
|
puts $errMsg
|
puts $errMsg
|
exit 1
|
exit 1
|
}
|
}
|
|
|
# Wait until bin file is present on the filesystem
|
# Wait until bin file is present on the filesystem
|