diff options
-rwxr-xr-x | cores/arduino/Print.cpp | 7 | ||||
-rw-r--r-- | cores/arduino/WString.cpp | 4 | ||||
-rw-r--r-- | cores/arduino/WString.h | 1 | ||||
-rw-r--r-- | cores/arduino/wiring_analog.c | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | firmwares/wifishield/scripts/ArduinoWifiShield_upgrade.sh | 44 |
5 files changed, 41 insertions, 17 deletions
diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp index e087313..53961ec 100755 --- a/cores/arduino/Print.cpp +++ b/cores/arduino/Print.cpp @@ -53,8 +53,11 @@ size_t Print::print(const __FlashStringHelper *ifsh) size_t Print::print(const String &s) { - write((const uint8_t*)s.c_str(), s.length()); - return s.length(); + size_t n = 0; + for (uint16_t i = 0; i < s.length(); i++) { + n += write(s[i]); + } + return n; } size_t Print::print(const char str[]) diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp index d05037b..c6839fc 100644 --- a/cores/arduino/WString.cpp +++ b/cores/arduino/WString.cpp @@ -642,8 +642,4 @@ long String::toInt(void) const return 0; } -char* String::c_str() const -{ - return buffer; -} diff --git a/cores/arduino/WString.h b/cores/arduino/WString.h index ec6cead..947325e 100644 --- a/cores/arduino/WString.h +++ b/cores/arduino/WString.h @@ -169,7 +169,6 @@ public: // parsing/conversion long toInt(void) const; - char* c_str() const; protected: char *buffer; // the actual char array diff --git a/cores/arduino/wiring_analog.c b/cores/arduino/wiring_analog.c index 23b01c6..3f19c7f 100644 --- a/cores/arduino/wiring_analog.c +++ b/cores/arduino/wiring_analog.c @@ -47,6 +47,8 @@ int analogRead(uint8_t pin) if (pin >= 18) pin -= 18; // allow for channel or pin numbers #elif defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__) if (pin >= 24) pin -= 24; // allow for channel or pin numbers +#elif defined(analogPinToChannel) && (defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)) + pin = analogPinToChannel(pin); #else if (pin >= 14) pin -= 14; // allow for channel or pin numbers #endif diff --git a/firmwares/wifishield/scripts/ArduinoWifiShield_upgrade.sh b/firmwares/wifishield/scripts/ArduinoWifiShield_upgrade.sh index 5082392..d9a9e02 100644..100755 --- a/firmwares/wifishield/scripts/ArduinoWifiShield_upgrade.sh +++ b/firmwares/wifishield/scripts/ArduinoWifiShield_upgrade.sh @@ -1,8 +1,11 @@ #!/bin/sh -WIFI_FW_PATH="/hardware/arduino/firmwares/wifi-shield" +WIFI_FW_PATH="/hardware/arduino/firmwares/wifishield/binary" AVR_TOOLS_PATH="/hardware/tools/avr/bin" +TARGET_MICRO="at32uc3a1256" + + progname=$0 usage () { @@ -20,28 +23,49 @@ EOF upgradeHDmodule () { sleep 1 # Give time to the shield to end the boot echo "****Upgrade HD WiFi module firmware****\n" - dfu-programmer at32uc3a1256 erase - dfu-programmer at32uc3a1256 flash --suppress-bootloader-mem $WIFI_FW_PATH/wifi_dnld.hex - dfu-programmer at32uc3a1256 start - 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" + dfu-programmer $TARGET_MICRO erase + dfu-programmer $TARGET_MICRO flash --suppress-bootloader-mem $WIFI_FW_PATH/wifi_dnld.hex + dfu-programmer $TARGET_MICRO start + + if [ $? != 0 ] ; then + echo "\nError during device initialization, please close the J3 jumper and press the reset button.\nTry -h for help\n" + exit 1 # if the device is not recognized exit + fi + + echo -n "\nPress the RESET button on the shield then type [ENTER] to upgrade the firmware of the shield..\n" read readEnter } upgradeShield () { sleep 1 # Give time to the shield to end the boot echo "****Upgrade WiFi Shield firmware****\n" - dfu-programmer at32uc3a1256 erase - dfu-programmer at32uc3a1256 flash --suppress-bootloader-mem $WIFI_FW_PATH/wifiHD.hex - dfu-programmer at32uc3a1256 start + dfu-programmer $TARGET_MICRO erase + dfu-programmer $TARGET_MICRO flash --suppress-bootloader-mem $WIFI_FW_PATH/wifiHD.hex + dfu-programmer $TARGET_MICRO start + + if [ $? != 0 ] ; then + echo "\nError during device initialization, please close the J3 jumper and press the reset button.\nTry -h for help\n" + exit 1 # if the device is not recognized exit + fi + echo "\nDone. Remove the J3 jumper and press the RESET button on the shield." echo "Thank you!\n" } + cat <<EOF Arduino WiFi Shield upgrade ========================================= -Disclaimer: to access to the USB devices correctly, the dfu-programmer needs to be used as root. Run this script as root. +Instructions: + +To access to the USB devices correctly, the dfu-programmer needs to have the root permissions. + +You can upgrade the firmware of the antenna togheter with the shield firmware or only the shield firmware +if there aren't changes on the antenna firmware. + +Use the '-h' parameter for help +========================================= EOF @@ -90,7 +114,7 @@ if [ $USER = 'root' ] ; then #check if the current user is root esac done else - echo "You are not root!\n" + echo "Please retry running the script as root.\n" fi shift $(($OPTIND - 1)) |