Date:2011-05-21 16:08:46 (8 years 27 days ago)
Author:Werner Almesberger
Commit:e9d65fbfd3a1d1b3c22dc93c97d92a4287e243bf
Message: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
Files: prod/Common (4 diffs)
prod/Makefile (2 diffs)
prod/atusb-flash (1 diff)

Change Details

prod/Common
1818LOG=_log
1919>$LOG
2020
21if [ ${REF#net:} = $REF ]; then
22    REF_EXEC=
23else
24    REF_EXEC="ssh `echo $REF | sed 's/^net://;s/,.*$//'`"
25fi
26
2127if [ ${DUT#net:} = $DUT ]; then
2228    LOCAL_EXEC=
2329    LOCAL_DUT=$DUT
...... 
9298##### Evaluation ############################################################
9399
94100
95expect()
101_doit()
96102{
97103    eval "$cmd" >_out 2>&1 || { echo "exit code $?" | fail; exit 1; }
104}
105
106
107doit()
108{
109    _doit
110    pass
111}
112
113
114expect()
115{
116    _doit
98117    fgrep -q "$@" _out || { echo "expected $*" | fail; exit 1; }
99118    pass
100119}
...... 
102121
103122expect_re()
104123{
105    eval "$cmd" >_out 2>&1 || { echo "exit code $?" | fail; exit 1; }
124    _doit
106125    grep -q "$@" _out || { echo "expected $*" | fail; exit 1; }
107126    pass
108127}
...... 
113132
114133begin()
115134{
116    if [ -z "$1" ]; then
117        echo "usage: begin profile [clock-ref]" 1>&2
118        exit 1
119    fi
120    PROFILE=$1
121    if [ ! -r $PROFILE ]; then
122        echo "$PROFILE not found" 1>&2
123        exit 1
135    if [ "$1" ]; then
136        PROFILE=$1
137        if [ ! -r $PROFILE ]; then
138            echo "$PROFILE not found" 1>&2
139            exit 1
140        fi
124141    fi
125142    if [ "$2" ]; then
126143        CLKREF=$2
prod/Makefile
33#
44
55
6.PHONY: all ben usb
6.PHONY: all ben usb flash
77
88all: ben
99
...... 
1313usb: usb.profile
1414    ./atusb net:ben usb
1515
16flash:
17    ./atusb-flash net:ben usb
18
1619ben.profile:
1720    cp ../tools/atrf-path/profile.example $@
1821
prod/atusb-flash
1#!/bin/sh
2
3. ./Common
4
5
6USB_ID=20b7:1540
7FW_BOOT_FILE=boot.hex
8FW_APP_FILE=atusb.bin
9
10
11#
12# This invocation of avrdude is derived from ben-wpan/atusb/fw/Makefile,
13# target "prog".
14#
15
16flash()
17{
18    step "Flash boot loader"
19    cmd "$REF_EXEC avrdude -F -p atmega32u2 -c nanonote_atusb -e \
20                  -U flash:w:$FW_BOOT_FILE:i \
21                  -U lfuse:w:0x60:m \
22                  -U hfuse:w:0xd8:m \
23                  -U lock:w:0x2f:m"
24    expect "lock verified"
25}
26
27
28enumerate()
29{
30    step "Enumeration"
31    cmd "$LOCAL_EXEC usbwait -i 0.1 -t 30 $USB_ID"
32    doit
33}
34
35
36dfu()
37{
38    step "DFU application"
39    cmd "$LOCAL_EXEC dfu-util -d $USB_ID -D $FW_APP_FILE"
40    expect "No error"
41}
42
43
44begin
45flash
46enumerate
47dfu

Archive Download the corresponding diff file



interactive