source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/hardware/arduino/avr/firmwares/wifishield/scripts/ArduinoWifiShield_upgrade.sh @ 4837

Last change on this file since 4837 was 4837, checked in by daduve, 2 years ago

Adding new version

  • Property svn:executable set to *
File size: 3.2 KB
Line 
1#!/bin/sh
2
3WIFI_FW_PATH="/hardware/arduino/avr/firmwares/wifishield/binary"
4AVR_TOOLS_PATH="/hardware/tools/avr/bin"
5
6TARGET_MICRO="at32uc3a1256"
7
8
9progname=$0
10
11usage () {
12cat <<EOF
13Usage: $progname [-a Arduino_path] [-f which_firmware] [-h]
14       -a set the path where the Arduino IDE is installed
15       -f the firmware you want to upload, valid parameters are:
16          shield  - to upgrade the WiFi shield firmware
17          all     - to upgrade both firmwares
18       -h help
19EOF
20  exit 0
21}
22
23upgradeHDmodule () {
24  sleep 1 # Give time to the shield to end the boot
25  echo "****Upgrade HD WiFi module firmware****\n"
26  dfu-programmer $TARGET_MICRO erase
27  dfu-programmer $TARGET_MICRO flash --suppress-bootloader-mem $WIFI_FW_PATH/wifi_dnld.hex
28  dfu-programmer $TARGET_MICRO start
29 
30  if [ $? != 0 ] ; then
31  echo "\nError during device initialization, please close the J3 jumper and press the reset button.\nTry -h for help\n"
32  exit 1 # if the device is not recognized exit
33  fi
34
35  echo -n "\nPress the RESET button on the shield then type [ENTER] to upgrade the firmware of the shield..\n"
36  read readEnter
37}
38
39upgradeShield () {
40  sleep 1 # Give time to the shield to end the boot
41  echo "****Upgrade WiFi Shield firmware****\n"
42  dfu-programmer $TARGET_MICRO erase
43  dfu-programmer $TARGET_MICRO flash --suppress-bootloader-mem $WIFI_FW_PATH/wifiHD.hex
44  dfu-programmer $TARGET_MICRO start
45
46  if [ $? != 0 ] ;  then
47  echo "\nError during device initialization, please close the J3 jumper and press the reset button.\nTry -h for help\n"
48  exit 1 # if the device is not recognized exit
49  fi
50
51  echo "\nDone. Remove the J3 jumper and press the RESET button on the shield."
52  echo "Thank you!\n"
53}
54
55
56cat <<EOF
57
58       Arduino WiFi Shield upgrade
59=========================================
60Instructions:
61
62To access to the USB devices correctly, the dfu-programmer needs to have the root permissions.
63
64You can upgrade the firmware of the antenna togheter with the shield firmware or only the shield firmware
65if there aren't changes on the antenna firmware.
66
67Use the '-h' parameter for help
68=========================================
69
70EOF
71
72if [ $USER = 'root' ] ; then  #check if the current user is root
73  while getopts ":a:f:h" opt; do
74    case $opt in
75        a)
76          ARDUINO_PATH=$OPTARG 
77          WIFI_FW_PATH=$ARDUINO_PATH$WIFI_FW_PATH
78          AVR_TOOLS_PATH=$ARDUINO_PATH$AVR_TOOLS_PATH
79          cd $AVR_TOOLS_PATH
80          ./avr-objcopy --output-target=ihex $WIFI_FW_PATH/wifi_dnld.elf  $WIFI_FW_PATH/wifi_dnld.hex   
81          ./avr-objcopy --output-target=ihex $WIFI_FW_PATH/wifiHD.elf  $WIFI_FW_PATH/wifiHD.hex
82          ;;
83        f)
84          if [ "$ARDUINO_PATH" != "" ] ; then
85            if [ "$OPTARG" = "all" ] ; then
86              upgradeHDmodule
87              upgradeShield
88              exit 0
89            else
90              if [ "$OPTARG" = "shield" ] ; then
91                upgradeShield
92                exit 0
93              else
94                echo "invalid parameter for the -f [firmware] option, please retry."
95                echo "Type -h for help\n"
96                exit 1
97              fi
98             fi
99          else
100            echo "Arduino Path not setted. Retry...\n"
101          fi
102          ;;
103        h)
104          usage ;;
105        \?)
106          echo "Invalid option: $OPTARG" >&2
107          usage
108          exit 1
109          ;;
110        :)
111          echo "Option -$OPTARG requires an argument." >&2
112          exit 1
113          ;;
114        esac
115  done
116else
117  echo "Please retry running the script as root.\n"
118fi
119
120shift $(($OPTIND - 1))
Note: See TracBrowser for help on using the repository browser.