Added firmware hash readout

This commit is contained in:
Mark Qvist 2022-11-01 22:21:07 +01:00
parent 95970a54fe
commit 312e4ec2fe
5 changed files with 54 additions and 3 deletions

View File

@ -76,7 +76,6 @@ void device_load_signature() {
} }
void device_load_firmware_hash() { void device_load_firmware_hash() {
Serial.println("Loading hash from EEPROM");
for (uint8_t i = 0; i < DEV_HASH_LEN; i++) { for (uint8_t i = 0; i < DEV_HASH_LEN; i++) {
dev_firmware_hash_target[i] = EEPROM.read(dev_fwhash_addr(i)); dev_firmware_hash_target[i] = EEPROM.read(dev_fwhash_addr(i));
} }

View File

@ -46,6 +46,7 @@
#define CMD_DEV_HASH 0x56 #define CMD_DEV_HASH 0x56
#define CMD_DEV_SIG 0x57 #define CMD_DEV_SIG 0x57
#define CMD_FW_HASH 0x58 #define CMD_FW_HASH 0x58
#define CMD_HASHES 0x60
#define CMD_UNLOCK_ROM 0x59 #define CMD_UNLOCK_ROM 0x59
#define ROM_UNLOCK_BYTE 0xF8 #define ROM_UNLOCK_BYTE 0xF8
#define CMD_RESET 0x55 #define CMD_RESET 0x55

View File

@ -45,7 +45,6 @@ void measure_battery() {
battery_voltage = PMU.getBattVoltage()/1000.0; battery_voltage = PMU.getBattVoltage()/1000.0;
battery_percent = PMU.getBattPercentage()*1.0; battery_percent = PMU.getBattPercentage()*1.0;
battery_installed = PMU.isBatteryConnect(); battery_installed = PMU.isBatteryConnect();
// auxillary_temperature = PMU.getTemp();
external_power = PMU.isVBUSPlug(); external_power = PMU.isVBUSPlug();
float ext_voltage = PMU.getVbusVoltage()/1000.0; float ext_voltage = PMU.getVbusVoltage()/1000.0;
float ext_current = PMU.getVbusCurrent(); float ext_current = PMU.getVbusCurrent();

View File

@ -697,6 +697,18 @@ void serialCallback(uint8_t sbyte) {
device_save_signature(); device_save_signature();
} }
#endif #endif
} else if (command == CMD_HASHES) {
#if MCU_VARIANT == MCU_ESP32
if (sbyte == 0x01) {
kiss_indicate_target_fw_hash();
} else if (sbyte == 0x02) {
kiss_indicate_fw_hash();
} else if (sbyte == 0x03) {
kiss_indicate_bootloader_hash();
} else if (sbyte == 0x04) {
kiss_indicate_partition_table_hash();
}
#endif
} else if (command == CMD_FW_HASH) { } else if (command == CMD_FW_HASH) {
#if MCU_VARIANT == MCU_ESP32 #if MCU_VARIANT == MCU_ESP32
if (sbyte == FESC) { if (sbyte == FESC) {

View File

@ -43,7 +43,7 @@ uint8_t boot_vector = 0x00;
// TODO: Get ESP32 boot flags // TODO: Get ESP32 boot flags
#endif #endif
#if BOARD_MODEL == BOARD_RNODE_NG_20 #if BOARD_MODEL == BOARD_RNODE_NG_20 || BOARD_RNODE_NG_21
#include <Adafruit_NeoPixel.h> #include <Adafruit_NeoPixel.h>
#define NP_PIN 4 #define NP_PIN 4
#define NUMPIXELS 1 #define NUMPIXELS 1
@ -635,6 +635,46 @@ void kiss_indicate_fbstate() {
} }
serial_write(FEND); serial_write(FEND);
} }
void kiss_indicate_target_fw_hash() {
serial_write(FEND);
serial_write(CMD_DEV_HASH);
for (int i = 0; i < DEV_HASH_LEN; i++) {
uint8_t byte = dev_firmware_hash_target[i];
escaped_serial_write(byte);
}
serial_write(FEND);
}
void kiss_indicate_fw_hash() {
serial_write(FEND);
serial_write(CMD_DEV_HASH);
for (int i = 0; i < DEV_HASH_LEN; i++) {
uint8_t byte = dev_firmware_hash[i];
escaped_serial_write(byte);
}
serial_write(FEND);
}
void kiss_indicate_bootloader_hash() {
serial_write(FEND);
serial_write(CMD_DEV_HASH);
for (int i = 0; i < DEV_HASH_LEN; i++) {
uint8_t byte = dev_bootloader_hash[i];
escaped_serial_write(byte);
}
serial_write(FEND);
}
void kiss_indicate_partition_table_hash() {
serial_write(FEND);
serial_write(CMD_DEV_HASH);
for (int i = 0; i < DEV_HASH_LEN; i++) {
uint8_t byte = dev_partition_table_hash[i];
escaped_serial_write(byte);
}
serial_write(FEND);
}
#endif #endif
void kiss_indicate_fb() { void kiss_indicate_fb() {