#!/bin/sh #OpenOCD simple flasher script to use with "make program". #It generates temporary command script to the openocd in openocd.flash file, then runs openocd. #This script requires proper openocd.cfg file in the invokation path. #It converts hex file to bin format. Path to the *.hex file can be passed as an argument (eg. ../ ) #Any comments are welcome. CeDeROM 2008 ( http://www.tomek.cedro.info ) echo "Searching for *.elf object file in: $1" TARGET_NAME=`ls $1*.elf | awk '/elf/{split($0,filename,".elf"); print filename[1]}' -` if [ -z $TARGET_NAME ]; then echo "Cannot find *.elf object file. Exiting..."; exit -1; fi echo "Converting elf file to binary..." objcopy $TARGET_NAME".elf" -O binary $TARGET_NAME".bin" echo "Generating temporary flasher script for OpenOCD..." echo "wait_halt" > openocd.flash echo "sleep 10" >> openocd.flash echo "poll" >> openocd.flash echo "flash probe 0" >> openocd.flash echo "flash erase_sector 0 0 0" >> openocd.flash echo "flash write_image erase "$TARGET_NAME".bin 0x0" >> openocd.flash echo "reset run" >> openocd.flash echo "sleep 10" >> openocd.flash #echo "shutdown" >> openocd.flash echo "Programming $TARGET_NAME.bin with OpenOCD..." openocd rm openocd.flash #!/bin/sh #OpenOCD simple flasher script to use with "make program". #It generates temporary command script to the openocd in openocd.flash file, then runs openocd. #This script requires proper openocd.cfg file in the invokation path. #It converts hex file to bin format. Path to the *.hex file can be passed as an argument (eg. ../ ) #Any comments are welcome. CeDeROM 2008 ( http://www.tomek.cedro.info ) echo "Searching for *.elf object file in: $1" TARGET_NAME=`ls $1*.elf | awk '/elf/{split($0,filename,".elf"); print filename[1]}' -` if [ -z $TARGET_NAME ]; then echo "Cannot find *.elf object file. Exiting..."; exit -1; fi echo "Converting elf file to binary..." objcopy $TARGET_NAME".elf" -O binary $TARGET_NAME".bin" echo "Generating temporary flasher script for OpenOCD..." echo "wait_halt" > openocd.flash echo "sleep 10" >> openocd.flash echo "poll" >> openocd.flash echo "flash probe 0" >> openocd.flash echo "flash erase_sector 0 0 0" >> openocd.flash echo "flash write_image erase "$TARGET_NAME".bin 0x0" >> openocd.flash echo "reset run" >> openocd.flash echo "sleep 10" >> openocd.flash #echo "shutdown" >> openocd.flash echo "Programming $TARGET_NAME.bin with OpenOCD..." openocd rm openocd.flash