Added firmware updating

pull/1/head
Mark Qvist 2018-06-27 10:34:01 +02:00
parent ddf2248f0b
commit 515f589e5a
3 changed files with 28 additions and 2 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
firmware/*.hex
firmware/*.key
firmware/*.counter
update/*.hex
eeprom/*.eeprom
# Byte-compiled / optimized / DLL files

View File

@ -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):

View File

@ -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