Skip to content

Commit

Permalink
Update to support both MSPGCC and TI/RH GCC versions
Browse files Browse the repository at this point in the history
  • Loading branch information
olgirard committed Nov 16, 2015
1 parent 4becbec commit eda64c4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 43 deletions.
33 changes: 0 additions & 33 deletions tools/bin/README.TXT

This file was deleted.

16 changes: 14 additions & 2 deletions tools/bin/openmsp430-loader.tcl
Expand Up @@ -37,6 +37,18 @@
global omsp_conf
global omsp_info

# Detect toolchain
if {[catch {exec msp430-gcc --version} debug_info]} {
if {[catch {exec msp430-elf-gcc --version} debug_info]} {
puts "\nERROR: Could not detect MSP430 GCC toolchain"
exit 1
} else {
set TOOLCHAIN_PFX "msp430-elf"
}
} else {
set TOOLCHAIN_PFX "msp430"
}

###############################################################################
# SOURCE LIBRARIES #
###############################################################################
Expand Down Expand Up @@ -170,7 +182,7 @@ if {[string eq $fileType "elf"]} {
}

# Generate binary file
if {[catch {exec msp430-objcopy -I $fileType -O binary $elf_file $bin_file} errMsg]} {
if {[catch {exec ${TOOLCHAIN_PFX}-objcopy -I $fileType -O binary $elf_file $bin_file} errMsg]} {
puts $errMsg
exit 1
}
Expand All @@ -184,7 +196,7 @@ for {set i 0} {$i <= $timeout} {incr i} {
}
}
if {$i>=$timeout} {
puts "\nTimeout: ELF to BIN file conversion problem with \"msp430-objcopy\" executable"
puts "\nTimeout: ELF to BIN file conversion problem with \"${TOOLCHAIN_PFX}-objcopy\" executable"
puts "$errMsg"
exit 1
}
Expand Down
28 changes: 20 additions & 8 deletions tools/bin/openmsp430-minidebug.tcl
Expand Up @@ -82,6 +82,7 @@ global pmemIHEX
global isPmemRead
global brkpt
global color
global TOOLCHAIN_PFX

# Initialize to default values
set CpuNr 0
Expand Down Expand Up @@ -128,6 +129,15 @@ for {set i 0} {$i<3} {incr i} {
set backup($i,current_file_name) ""
}

# Detect toolchain
set TOOLCHAIN_PFX "msp430"
if {[catch {exec msp430-gcc --version} debug_info]} {
if {[catch {exec msp430-elf-gcc --version} debug_info]} {
} else {
set TOOLCHAIN_PFX "msp430-elf"
}
}


###############################################################################
# #
Expand Down Expand Up @@ -456,6 +466,7 @@ proc updateCodeView {} {
global pmemIHEX
global brkpt
global isPmemRead
global TOOLCHAIN_PFX

if {($binFileName!="") | ($isPmemRead==1)} {

Expand All @@ -479,12 +490,12 @@ proc updateCodeView {} {

set temp_elf_file "[clock clicks].elf"
set temp_ihex_file "[clock clicks].ihex"
if {[catch {exec msp430-objcopy -I $currentFileType -O elf32-msp430 $currentFileName $temp_elf_file} debug_info]} {
if {[catch {exec ${TOOLCHAIN_PFX}-objcopy -I $currentFileType -O elf32-msp430 $currentFileName $temp_elf_file} debug_info]} {
.ctrl.load.info.l configure -text "$debug_info" -fg red
return 0
}
if {![waitForFile $temp_elf_file]} {
.ctrl.load.info.l configure -text "Timeout: ELF file conversion problem with \"msp430-objcopy\" executable" -fg red
.ctrl.load.info.l configure -text "Timeout: ELF file conversion problem with \"${TOOLCHAIN_PFX}-objcopy\" executable" -fg red
return 0
}
if {[string eq $currentFileType "ihex"]} {
Expand All @@ -501,12 +512,12 @@ proc updateCodeView {} {
.ctrl.cpu.brkpt.chk$i configure -state disable
updateBreakpoint $i
}
if {[catch {exec msp430-objcopy -I $currentFileType -O ihex $temp_elf_file $temp_ihex_file} debug_info]} {
if {[catch {exec ${TOOLCHAIN_PFX}-objcopy -I $currentFileType -O ihex $temp_elf_file $temp_ihex_file} debug_info]} {
.ctrl.load.info.l configure -text "$debug_info" -fg red
return 0
}
if {![waitForFile $temp_ihex_file]} {
.ctrl.load.info.l configure -text "Timeout: IHEX file conversion problem with \"msp430-objcopy\" executable" -fg red
.ctrl.load.info.l configure -text "Timeout: IHEX file conversion problem with \"${TOOLCHAIN_PFX}-objcopy\" executable" -fg red
return 0
}
set fp [open $temp_ihex_file r]
Expand All @@ -519,15 +530,15 @@ proc updateCodeView {} {
for {set i 0} {$i<3} {incr i} {
.ctrl.cpu.brkpt.chk$i configure -state normal
}
if {[catch {exec msp430-objdump $dumpOpt $temp_elf_file} debug_info]} {
if {[catch {exec ${TOOLCHAIN_PFX}-objdump $dumpOpt $temp_elf_file} debug_info]} {
.ctrl.load.info.l configure -text "$debug_info" -fg red
return 0
}
} elseif {$codeSelect==3} {
for {set i 0} {$i<3} {incr i} {
.ctrl.cpu.brkpt.chk$i configure -state normal
}
if {[catch {exec msp430-objdump $dumpOpt\S $temp_elf_file} debug_info]} {
if {[catch {exec ${TOOLCHAIN_PFX}-objdump $dumpOpt\S $temp_elf_file} debug_info]} {
.ctrl.load.info.l configure -text "$debug_info" -fg red
return 0
}
Expand Down Expand Up @@ -626,6 +637,7 @@ proc loadProgram {load} {
global isPmemRead
global pmemIHEX
global backup
global TOOLCHAIN_PFX

# Check if the file exists
#----------------------------------------
Expand Down Expand Up @@ -682,14 +694,14 @@ proc loadProgram {load} {

# Generate binary file
set bin_file "[clock clicks].bin"
if {[catch {exec msp430-objcopy -I $binFileType -O binary $binFileName $bin_file} errMsg]} {
if {[catch {exec ${TOOLCHAIN_PFX}-objcopy -I $binFileType -O binary $binFileName $bin_file} errMsg]} {
.ctrl.load.info.l configure -text "$errMsg" -fg red
return 0
}

# Wait until bin file is present on the filesystem
if {![waitForFile $bin_file]} {
.ctrl.load.info.l configure -text "Timeout: ELF to BIN file conversion problem with \"msp430-objcopy\" executable" -fg red
.ctrl.load.info.l configure -text "Timeout: ELF to BIN file conversion problem with \"${TOOLCHAIN_PFX}-objcopy\" executable" -fg red
return 0
}

Expand Down

0 comments on commit eda64c4

Please sign in to comment.