Rev 410 | Blame | Compare with Previous | Last modification | View Log | Download
#!/bin/shprg="adude"#help(){echo "prg_fusebit_uc -- read and write fuse bits of the atmega8"echo ""echo "Usage: prg_fusebit_uc [-hu] -r|-w Freq"echo ""echo "OPTIONS: -h this help"echo " -r read fuse bytes"echo " -u use uisp instead of avrdude"echo " avrdude can automatically detect dapa or avrusb500."echo " uisp can only be used with the parallel port dapa."echo " -w write fuse bytes such that a given Freq is used"echo " a frequency of 0 means external crystal. Possible"echo " values are 0,1,2,4,8"echo ""echo "EXAMPLE: program the fuses to 4MHz internal"echo " prg_fusebit_uc -w 4"echo ""echo "Warning: you can not undo the setting \"external crystal\" unless"echo " you have a crystal that works."echo "This script can be easily adapted to different programmer types"exit 0}while [ -n "$1" ]; docase $1 in-h) help;shift 1;;-u) prg="uisp";shift 1;;-r) opt_r="1";shift 1;;-w) opt_w="1";freq="$2";shift 2;;-*) echo "error: no such option $1. -h for help";exit 1;;*) break;;esacdoneif [ -z "$opt_r" -a -z "$opt_w" ];then# one of those options is mandatoryhelpfihf=0xd9if [ "$opt_w" = "1" ]; thencase $freq in0) lf=0xee;echo "Make sure you have a crystal otherwise you can not change this!";sleep 2;;1) lf=0xe1;;2) lf=0xe2;;4) lf=0xe3;;8) lf=0xe4;;*) echo "error: no such frequency, -h for help";exit 1;;esacfiif [ "$prg" = "uisp" ]; thenif [ "$opt_r" = "1" ];thenset -xuisp -dlpt=/dev/parport0 -dprog=dapa --rd_fusesset +xecho "Explanation: Fuse Low Byte: 0xe1 (1MHz intern), 0xe3 (4MHz intern), "echo " 0xe4 (8MHz intern)"echo " Fuse High Byte should be 0xd9"exit 0fiif [ "$opt_w" = "1" ]; thenset -xuisp -dlpt=/dev/parport0 -dprog=dapa --wr_fuse_l=$lfuisp -dlpt=/dev/parport0 -dprog=dapa --wr_fuse_h=$hfset +xexit 0fifiif [ "$prg" = "adude" ]; thenif grep "Vendor=0403 ProdID=6001" /proc/bus/usb/devices > /dev/null ; thenprg="avrusb500"elseprg="dapa"fiif [ "$opt_r" = "1" ];thenset -xavrdude -p m8 -c $prg -v -qset +xecho "Explanation: Fuse Low Byte: 0xe1 (1MHz intern), 0xe3 (4MHz intern), "echo " 0xe4 (8MHz intern)"echo " Fuse High Byte should be 0xd9"exit 0fiif [ "$opt_w" = "1" ]; thenset -xavrdude -p m8 -c $prg -u -v -U lfuse:w:$lf:mavrdude -p m8 -c $prg -u -v -U hfuse:w:$hf:mset +xexit 0fifi