mirror of
https://github.com/markqvist/RNode_Firmware.git
synced 2025-03-12 17:26:34 -04:00
Set firmware hashes on nRF
This commit is contained in:
parent
c1b3b4f416
commit
95895f3756
6
Makefile
6
Makefile
@ -238,9 +238,13 @@ upload-featheresp32:
|
|||||||
|
|
||||||
upload-rak4631:
|
upload-rak4631:
|
||||||
arduino-cli upload -p /dev/ttyACM0 --fqbn rakwireless:nrf52:WisCoreRAK4631Board
|
arduino-cli upload -p /dev/ttyACM0 --fqbn rakwireless:nrf52:WisCoreRAK4631Board
|
||||||
|
@sleep 1
|
||||||
|
rnodeconf /dev/ttyACM0 --firmware-hash $$(./partition_hashes from_device /dev/ttyACM0)
|
||||||
|
|
||||||
upload-heltec_t114:
|
upload-heltec_t114:
|
||||||
arduino-cli upload -p /dev/cu.usbmodem14401 --fqbn heltec:Heltec_nRF52:HT-n5262
|
arduino-cli upload -p /dev/ttyACM0 --fqbn Heltec_nRF52:Heltec_nRF52:HT-n5262
|
||||||
|
@sleep 1
|
||||||
|
rnodeconf /dev/ttyACM0 --firmware-hash $$(./partition_hashes from_device /dev/ttyACM0)
|
||||||
|
|
||||||
release: release-all
|
release: release-all
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import sys
|
|||||||
import RNS
|
import RNS
|
||||||
import json
|
import json
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import subprocess
|
||||||
|
|
||||||
major_version = None
|
major_version = None
|
||||||
minor_version = None
|
minor_version = None
|
||||||
@ -27,9 +28,23 @@ target_version = None
|
|||||||
|
|
||||||
target_file = os.path.join(sys.argv[1])
|
target_file = os.path.join(sys.argv[1])
|
||||||
|
|
||||||
firmware_data = open(target_file, "rb").read()
|
if sys.argv[1] == "from_device":
|
||||||
calc_hash = hashlib.sha256(firmware_data[0:-32]).digest()
|
from_device = True
|
||||||
part_hash = firmware_data[-32:]
|
else:
|
||||||
|
from_device = False
|
||||||
|
|
||||||
if calc_hash == part_hash:
|
if not from_device:
|
||||||
print(RNS.hexrep(part_hash, delimit=False))
|
firmware_data = open(target_file, "rb").read()
|
||||||
|
calc_hash = hashlib.sha256(firmware_data[0:-32]).digest()
|
||||||
|
part_hash = firmware_data[-32:]
|
||||||
|
|
||||||
|
if calc_hash == part_hash:
|
||||||
|
print(RNS.hexrep(part_hash, delimit=False))
|
||||||
|
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
cmdresult = subprocess.run(["rnodeconf", sys.argv[2], "-L"], stdout=subprocess.PIPE).stdout.decode('utf-8')
|
||||||
|
part_hash = cmdresult.split("The actual firmware hash is: ")[1].replace("\n", "")
|
||||||
|
print(part_hash)
|
||||||
|
except Exception as e:
|
||||||
|
print("Could not get partition hash from device: "+str(e))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user