From 56d9bdd39ed36c36e9a61411b86c76d5228b2133 Mon Sep 17 00:00:00 2001 From: sicarius Date: Sun, 11 Feb 2007 18:32:03 +0000 Subject: Added lot's of code-files used during work --- source/ct-Bot/contrib/flash_n_fuse/flash.sh | 55 +++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 source/ct-Bot/contrib/flash_n_fuse/flash.sh (limited to 'source/ct-Bot/contrib/flash_n_fuse/flash.sh') diff --git a/source/ct-Bot/contrib/flash_n_fuse/flash.sh b/source/ct-Bot/contrib/flash_n_fuse/flash.sh new file mode 100644 index 0000000..3a386e3 --- /dev/null +++ b/source/ct-Bot/contrib/flash_n_fuse/flash.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# echo program C't-Bot with avrdude and mySmartUSB +# +# echo Usage: flash.sh +# +if [ $# != 1 ]; then + echo "Usage: flash.sh " + exit 1; +fi +# now check if the fuses are set correctly +# use temporary file names in /tmp for it +lowtemp="$(mktemp /tmp/lfuse.XXXXX)" +hightemp="$(mktemp /tmp/hfuse.XXXXX)" +locktemp="$(mktemp /tmp/lock.XXXXX)" + +# read fuses +avrdude -p m32 -c avr910 -P /dev/ttyUSB0 -U lfuse:r:$lowtemp:i \ + -U hfuse:r:$hightemp:i -U lock:r:$locktemp:i >/dev/null 2>&1 +if [ $? != "0" ]; then + echo "Error while reading fuses!" + exit 1 +fi + +fuses_ok=1 +# now compare the values with the correspondent .hex file +cmp -n 13 lfuse.hex $lowtemp >/dev/null 2>&1 +if [ $? != "0" ]; then + echo "low fuse doesn't fit!" + fuses_ok=0; +fi +cmp -n 13 hfuse.hex $hightemp >/dev/null 2>&1 +if [ $? != "0" ]; then + echo "high fuse doesn't fit!" + fuses_ok=0; +fi +cmp -n 13 lock.hex $locktemp >/dev/null 2>&1 +if [ $? != "0" ]; then + echo "lock byte doesn't fit!" + fuses_ok=0; +fi + + +# clean up temp files +rm $lowtemp +rm $hightemp +rm $locktemp + +# if some or all fuses were wrong, give hint and bail out +if [ $fuses_ok != "1" ]; then + echo "Please correct your fuses with setfuses.sh, else you'll probably get locked out from your MCU!" + exit 2; +fi + +# all fuses ok, now program flash +avrdude -p m32 -c avr910 -P /dev/ttyUSB0 -e -U flash:w:$1:i -- cgit v1.2.3