mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-12-23 17:59:53 +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:
parent
21c70eb6c2
commit
e9d65fbfd3
37
prod/Common
37
prod/Common
@ -18,6 +18,12 @@ DUT=$2
|
|||||||
LOG=_log
|
LOG=_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
|
if [ ${DUT#net:} = $DUT ]; then
|
||||||
LOCAL_EXEC=
|
LOCAL_EXEC=
|
||||||
LOCAL_DUT=$DUT
|
LOCAL_DUT=$DUT
|
||||||
@ -92,9 +98,22 @@ cmd()
|
|||||||
##### Evaluation ############################################################
|
##### Evaluation ############################################################
|
||||||
|
|
||||||
|
|
||||||
expect()
|
_doit()
|
||||||
{
|
{
|
||||||
eval "$cmd" >_out 2>&1 || { echo "exit code $?" | fail; exit 1; }
|
eval "$cmd" >_out 2>&1 || { echo "exit code $?" | fail; exit 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
doit()
|
||||||
|
{
|
||||||
|
_doit
|
||||||
|
pass
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
expect()
|
||||||
|
{
|
||||||
|
_doit
|
||||||
fgrep -q "$@" _out || { echo "expected $*" | fail; exit 1; }
|
fgrep -q "$@" _out || { echo "expected $*" | fail; exit 1; }
|
||||||
pass
|
pass
|
||||||
}
|
}
|
||||||
@ -102,7 +121,7 @@ expect()
|
|||||||
|
|
||||||
expect_re()
|
expect_re()
|
||||||
{
|
{
|
||||||
eval "$cmd" >_out 2>&1 || { echo "exit code $?" | fail; exit 1; }
|
_doit
|
||||||
grep -q "$@" _out || { echo "expected $*" | fail; exit 1; }
|
grep -q "$@" _out || { echo "expected $*" | fail; exit 1; }
|
||||||
pass
|
pass
|
||||||
}
|
}
|
||||||
@ -113,14 +132,12 @@ expect_re()
|
|||||||
|
|
||||||
begin()
|
begin()
|
||||||
{
|
{
|
||||||
if [ -z "$1" ]; then
|
if [ "$1" ]; then
|
||||||
echo "usage: begin profile [clock-ref]" 1>&2
|
PROFILE=$1
|
||||||
exit 1
|
if [ ! -r $PROFILE ]; then
|
||||||
fi
|
echo "$PROFILE not found" 1>&2
|
||||||
PROFILE=$1
|
exit 1
|
||||||
if [ ! -r $PROFILE ]; then
|
fi
|
||||||
echo "$PROFILE not found" 1>&2
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
if [ "$2" ]; then
|
if [ "$2" ]; then
|
||||||
CLKREF=$2
|
CLKREF=$2
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
.PHONY: all ben usb
|
.PHONY: all ben usb flash
|
||||||
|
|
||||||
all: ben
|
all: ben
|
||||||
|
|
||||||
@ -13,6 +13,9 @@ ben: ben.profile
|
|||||||
usb: usb.profile
|
usb: usb.profile
|
||||||
./atusb net:ben usb
|
./atusb net:ben usb
|
||||||
|
|
||||||
|
flash:
|
||||||
|
./atusb-flash net:ben usb
|
||||||
|
|
||||||
ben.profile:
|
ben.profile:
|
||||||
cp ../tools/atrf-path/profile.example $@
|
cp ../tools/atrf-path/profile.example $@
|
||||||
|
|
||||||
|
47
prod/atusb-flash
Executable file
47
prod/atusb-flash
Executable 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
|
Loading…
Reference in New Issue
Block a user