mirror of
https://github.com/liberatedsystems/RNode_Firmware_CE.git
synced 2024-07-02 14:34:13 +02:00
Added boot diagnostics
This commit is contained in:
parent
af794fc882
commit
b319e2b0e8
8
Config.h
8
Config.h
@ -4,7 +4,7 @@
|
|||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
#define MAJ_VERS 0x01
|
#define MAJ_VERS 0x01
|
||||||
#define MIN_VERS 0x11
|
#define MIN_VERS 0x12
|
||||||
|
|
||||||
#define MCU_1284P 0x91
|
#define MCU_1284P 0x91
|
||||||
|
|
||||||
@ -107,4 +107,10 @@
|
|||||||
const uint8_t SIG_SYNCED = 0x02;
|
const uint8_t SIG_SYNCED = 0x02;
|
||||||
const uint8_t RX_ONGOING = 0x04;
|
const uint8_t RX_ONGOING = 0x04;
|
||||||
|
|
||||||
|
// Boot flags
|
||||||
|
#define START_FROM_BOOTLOADER 0x01
|
||||||
|
#define START_FROM_POWERON 0x02
|
||||||
|
#define START_FROM_BROWNOUT 0x03
|
||||||
|
#define START_FROM_JTAG 0x04
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -562,22 +562,39 @@ void checkModemStatus() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void validateStatus() {
|
void validateStatus() {
|
||||||
if (eeprom_lock_set()) {
|
if (OPTIBOOT_MCUSR & (1<<PORF)) {
|
||||||
if (eeprom_product_valid() && eeprom_model_valid() && eeprom_hwrev_valid()) {
|
boot_vector = START_FROM_POWERON;
|
||||||
if (eeprom_checksum_valid()) {
|
} else if (OPTIBOOT_MCUSR & (1<<BORF)) {
|
||||||
hw_ready = true;
|
boot_vector = START_FROM_BROWNOUT;
|
||||||
|
} else if (OPTIBOOT_MCUSR & (1<<WDRF)) {
|
||||||
|
boot_vector = START_FROM_BOOTLOADER;
|
||||||
|
} else {
|
||||||
|
Serial.write("Error, indeterminate boot vector\r\n");
|
||||||
|
led_indicate_boot_error();
|
||||||
|
}
|
||||||
|
|
||||||
if (eeprom_have_conf()) {
|
if (boot_vector == START_FROM_BOOTLOADER) {
|
||||||
eeprom_conf_load();
|
if (eeprom_lock_set()) {
|
||||||
op_mode = MODE_TNC;
|
if (eeprom_product_valid() && eeprom_model_valid() && eeprom_hwrev_valid()) {
|
||||||
startRadio();
|
if (eeprom_checksum_valid()) {
|
||||||
|
hw_ready = true;
|
||||||
|
|
||||||
|
if (eeprom_have_conf()) {
|
||||||
|
eeprom_conf_load();
|
||||||
|
op_mode = MODE_TNC;
|
||||||
|
startRadio();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
hw_ready = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hw_ready = false;
|
hw_ready = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hw_ready = false;
|
hw_ready = false;
|
||||||
|
Serial.write("Error, incorrect boot vector\r\n");
|
||||||
|
led_indicate_boot_error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
Utilities.h
18
Utilities.h
@ -7,6 +7,13 @@
|
|||||||
#include "Framing.h"
|
#include "Framing.h"
|
||||||
#include "MD5.h"
|
#include "MD5.h"
|
||||||
|
|
||||||
|
uint8_t boot_vector = 0x00;
|
||||||
|
uint8_t OPTIBOOT_MCUSR __attribute__ ((section(".noinit")));
|
||||||
|
void resetFlagsInit(void) __attribute__ ((naked)) __attribute__ ((used)) __attribute__ ((section (".init0")));
|
||||||
|
void resetFlagsInit(void) {
|
||||||
|
__asm__ __volatile__ ("sts %0, r2\n" : "=m" (OPTIBOOT_MCUSR) :);
|
||||||
|
}
|
||||||
|
|
||||||
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
|
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
|
||||||
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
|
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
|
||||||
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
|
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
|
||||||
@ -28,6 +35,17 @@ void led_indicate_error(int cycles) {
|
|||||||
digitalWrite(pin_led_tx, LOW);
|
digitalWrite(pin_led_tx, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void led_indicate_boot_error() {
|
||||||
|
while (true) {
|
||||||
|
led_tx_on();
|
||||||
|
led_rx_off();
|
||||||
|
delay(10);
|
||||||
|
led_rx_on();
|
||||||
|
led_tx_off();
|
||||||
|
delay(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void led_indicate_warning(int cycles) {
|
void led_indicate_warning(int cycles) {
|
||||||
bool forever = (cycles == 0) ? true : false;
|
bool forever = (cycles == 0) ? true : false;
|
||||||
cycles = forever ? 1 : cycles;
|
cycles = forever ? 1 : cycles;
|
||||||
|
Loading…
Reference in New Issue
Block a user