source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/hardware/arduino/avr/firmwares/wifishield/scripts/ArduinoWifiShield_upgrade_mac.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: 2.5 KB
Line 
1#!/bin/sh
2
3WIFI_FW_PATH="/hardware/arduino/avr/firmwares/wifishield/binary"
4AVR_TOOLS_PATH="/hardware/tools/avr/bin"
5
6progname=$0
7
8usage () {
9cat <<EOF
10Usage: $progname [-a Arduino_path] [-f which_firmware] [-h]
11       -a set the path where the Arduino IDE is installed
12       -f the firmware you want to upload, valid parameters are:
13          shield  - to upgrade the WiFi shield firmware
14          all     - to upgrade both firmwares
15       -h help
16EOF
17  exit 0
18}
19
20upgradeHDmodule () {
21  sleep 1 # Give time to the shield to end the boot
22  echo "****Upgrade HD WiFi module firmware****\n"
23  dfu-programmer at32uc3a1256 erase
24  dfu-programmer at32uc3a1256 flash --suppress-bootloader-mem $WIFI_FW_PATH/wifi_dnld.hex
25  dfu-programmer at32uc3a1256 start
26  echo -n "\nRemove the J3 jumper then press the RESET button on the shield then type [ENTER] to upgrade the firmware of the shield..\n"
27  read readEnter
28}
29
30upgradeShield () {
31  sleep 1 # Give time to the shield to end the boot
32  echo "****Upgrade WiFi Shield firmware****\n"
33  dfu-programmer at32uc3a1256 erase
34  dfu-programmer at32uc3a1256 flash --suppress-bootloader-mem $WIFI_FW_PATH/wifiHD.hex
35  dfu-programmer at32uc3a1256 start
36  echo "\nDone. Remove the J3 jumper and press the RESET button on the shield."
37  echo "Thank you!\n"
38}
39
40cat <<EOF
41
42       Arduino WiFi Shield upgrade
43=========================================
44Disclaimer: to access to the USB devices correctly, the dfu-programmer needs to be used as root. Run this script as root.
45
46EOF
47
48if [ $USER = 'root' ] ; then  #check if the current user is root
49  while getopts ":a:f:h" opt; do
50    case $opt in
51        a)
52          ARDUINO_PATH=$OPTARG 
53          WIFI_FW_PATH=$ARDUINO_PATH$WIFI_FW_PATH
54          AVR_TOOLS_PATH=$ARDUINO_PATH$AVR_TOOLS_PATH
55          cd $AVR_TOOLS_PATH
56          ./avr-objcopy --output-target=ihex $WIFI_FW_PATH/wifi_dnld.elf  $WIFI_FW_PATH/wifi_dnld.hex   
57          ./avr-objcopy --output-target=ihex $WIFI_FW_PATH/wifiHD.elf  $WIFI_FW_PATH/wifiHD.hex
58          ;;
59        f)
60          if [ "$ARDUINO_PATH" != "" ] ; then
61            if [ "$OPTARG" = "all" ] ; then
62              upgradeHDmodule
63              upgradeShield
64              exit 0
65            else
66              if [ "$OPTARG" = "shield" ] ; then
67                upgradeShield
68                exit 0
69              else
70                echo "invalid parameter for the -f [firmware] option, please retry."
71                echo "Type -h for help\n"
72                exit 1
73              fi
74             fi
75          else
76            echo "Arduino Path not setted. Retry...\n"
77          fi
78          ;;
79        h)
80          usage ;;
81        \?)
82          echo "Invalid option: $OPTARG" >&2
83          usage
84          exit 1
85          ;;
86        :)
87          echo "Option -$OPTARG requires an argument." >&2
88          exit 1
89          ;;
90        esac
91  done
92else
93  echo "You are not root!\n"
94fi
95
96shift $(($OPTIND - 1))
Note: See TracBrowser for help on using the repository browser.