diff --git a/.gitignore b/.gitignore index ab80929..34be357 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ firmware/*.hex firmware/*.key firmware/*.counter +update/*.hex eeprom/*.eeprom # Byte-compiled / optimized / DLL files diff --git a/README.md b/README.md index bf6f456..d97d7b6 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,12 @@ sudo apt install python python-pip sudo pip install pyserial cryptography ``` +If you want to use the utility for firmware updating or flashing, you will also need avrdude: + +``` +sudo apt install avrdude +``` + ## Installation Just clone or download this repository, place wherever you'd like and run rnodeconf (remember to set executable permissions): diff --git a/rnodeconf b/rnodeconf index 04d747a..7b16abb 100755 --- a/rnodeconf +++ b/rnodeconf @@ -621,12 +621,31 @@ if __name__ == "__main__": exit() if args.port: + if args.update: + if os.path.isfile("./update/rnode_firmware.hex"): + try: + RNS.log("Updating RNode firmware for device on "+args.port) + from subprocess import call + flash_status = call(["avrdude", "-P", args.port, "-p", "m1284p", "-c", "arduino", "-b", "115200", "-U", "flash:w:update/rnode_firmware.hex"]) + if flash_status == 0: + RNS.log("Firmware updated") + args.info = True + else: + exit() + + except Exception as e: + RNS.log("Error while updating firmware") + RNS.log(str(e)) + else: + RNS.log("Firmware update file not found") + exit() + if args.flash: - if os.path.isfile("./firmware/firmware.hex"): + if os.path.isfile("./firmware/rnode_firmware.hex"): try: RNS.log("Flashing RNode firmware to device on "+args.port) from subprocess import call - flash_status = call(["avrdude", "-P", args.port, "-p", "m1284p", "-c", "arduino", "-b", "115200", "-U", "flash:w:firmware/firmware.hex"]) + flash_status = call(["avrdude", "-P", args.port, "-p", "m1284p", "-c", "arduino", "-b", "115200", "-U", "flash:w:firmware/rnode_firmware.hex"]) if flash_status == 0: RNS.log("Done flashing") args.rom = True