1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-12-23 14:18:58 +02:00

prod/: added atusb-flash script and adapted infrastructure

- atusb-flash: flash boot loader and application
- Makefile (PHONY, flash): invoke atusb-flash
- Common (REF_EXEC): execute a command on the host with the reference
  device
- Common (_doit, expect, expect_re): moved command execution to separate
  function, for better sharing
- Common (doit): new function for executing a command without grepping
  through its output
- Common (begin): make profile argument optional
This commit is contained in:
Werner Almesberger 2011-05-21 11:08:46 -03:00
parent 21c70eb6c2
commit e9d65fbfd3
3 changed files with 78 additions and 11 deletions

View File

@ -18,6 +18,12 @@ DUT=$2
LOG=_log
>$LOG
if [ ${REF#net:} = $REF ]; then
REF_EXEC=
else
REF_EXEC="ssh `echo $REF | sed 's/^net://;s/,.*$//'`"
fi
if [ ${DUT#net:} = $DUT ]; then
LOCAL_EXEC=
LOCAL_DUT=$DUT
@ -92,9 +98,22 @@ cmd()
##### Evaluation ############################################################
expect()
_doit()
{
eval "$cmd" >_out 2>&1 || { echo "exit code $?" | fail; exit 1; }
}
doit()
{
_doit
pass
}
expect()
{
_doit
fgrep -q "$@" _out || { echo "expected $*" | fail; exit 1; }
pass
}
@ -102,7 +121,7 @@ expect()
expect_re()
{
eval "$cmd" >_out 2>&1 || { echo "exit code $?" | fail; exit 1; }
_doit
grep -q "$@" _out || { echo "expected $*" | fail; exit 1; }
pass
}
@ -113,14 +132,12 @@ expect_re()
begin()
{
if [ -z "$1" ]; then
echo "usage: begin profile [clock-ref]" 1>&2
exit 1
fi
PROFILE=$1
if [ ! -r $PROFILE ]; then
echo "$PROFILE not found" 1>&2
exit 1
if [ "$1" ]; then
PROFILE=$1
if [ ! -r $PROFILE ]; then
echo "$PROFILE not found" 1>&2
exit 1
fi
fi
if [ "$2" ]; then
CLKREF=$2

View File

@ -3,7 +3,7 @@
#
.PHONY: all ben usb
.PHONY: all ben usb flash
all: ben
@ -13,6 +13,9 @@ ben: ben.profile
usb: usb.profile
./atusb net:ben usb
flash:
./atusb-flash net:ben usb
ben.profile:
cp ../tools/atrf-path/profile.example $@

47
prod/atusb-flash Executable file
View File

@ -0,0 +1,47 @@
#!/bin/sh
. ./Common
USB_ID=20b7:1540
FW_BOOT_FILE=boot.hex
FW_APP_FILE=atusb.bin
#
# This invocation of avrdude is derived from ben-wpan/atusb/fw/Makefile,
# target "prog".
#
flash()
{
step "Flash boot loader"
cmd "$REF_EXEC avrdude -F -p atmega32u2 -c nanonote_atusb -e \
-U flash:w:$FW_BOOT_FILE:i \
-U lfuse:w:0x60:m \
-U hfuse:w:0xd8:m \
-U lock:w:0x2f:m"
expect "lock verified"
}
enumerate()
{
step "Enumeration"
cmd "$LOCAL_EXEC usbwait -i 0.1 -t 30 $USB_ID"
doit
}
dfu()
{
step "DFU application"
cmd "$LOCAL_EXEC dfu-util -d $USB_ID -D $FW_APP_FILE"
expect "No error"
}
begin
flash
enumerate
dfu