Updated start sequence, added boot graphics

This commit is contained in:
Mark Qvist 2022-11-02 19:02:22 +01:00
parent 8e64bc2aa6
commit 21e040eb97
6 changed files with 155 additions and 124 deletions

View File

@ -71,33 +71,16 @@ char bt_devname[11];
}
}
bool bt_early_init_done = false;
bool bt_early_init() {
if (!bt_early_init_done) {
bool bt_setup_hw() {
if (!bt_ready) {
if (EEPROM.read(eeprom_addr(ADDR_CONF_BT)) == BT_ENABLE_BYTE) {
bt_enabled = true;
} else {
bt_enabled = false;
}
if (btStart()) {
if (esp_bluedroid_init() == ESP_OK) {
if (esp_bluedroid_enable() == ESP_OK) {
const uint8_t* bda_ptr = esp_bt_dev_get_address();
memcpy(dev_bt_mac, bda_ptr, BT_DEV_HASH_LEN);
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
} else {
return true;
}
}
bool bt_setup_hw() {
if (!bt_ready) {
if (EEPROM.read(eeprom_addr(ADDR_CONF_BT)) == BT_ENABLE_BYTE) { bt_enabled = true; } else { bt_enabled = false; }
if (bt_early_init()) {
const uint8_t* bda_ptr = esp_bt_dev_get_address();
char *data = (char*)malloc(BT_DEV_ADDR_LEN+1);
for (int i = 0; i < BT_DEV_ADDR_LEN; i++) {
@ -118,6 +101,8 @@ char bt_devname[11];
return true;
} else { return false; }
} else { return false; }
} else { return false; }
}
}

View File

@ -113,7 +113,7 @@ bool device_firmware_ok() {
}
bool device_init() {
if (bt_early_init()) {
if (bt_ready) {
for (uint8_t i=0; i<EEPROM_SIG_LEN; i++){dev_eeprom_signature[i]=EEPROM.read(eeprom_addr(ADDR_SIGNATURE+i));}
mbedtls_md_context_t ctx;
mbedtls_md_type_t md_type = MBEDTLS_MD_SHA256;

View File

@ -253,6 +253,7 @@ void draw_waterfall(int px, int py) {
bool stat_area_intialised = false;
void draw_stat_area() {
if (device_init_done) {
if (!stat_area_intialised) {
stat_area.drawBitmap(0, 0, bm_frame, 64, 64, SSD1306_WHITE, SSD1306_BLACK);
stat_area_intialised = true;
@ -268,6 +269,7 @@ void draw_stat_area() {
draw_signal_bars(44, 56);
draw_waterfall(27, 4);
}
}
}
void update_stat_area() {
@ -284,6 +286,9 @@ void update_stat_area() {
const uint8_t pages = 3;
uint8_t disp_page = START_PAGE;
void draw_disp_area() {
if (!device_init_done) {
disp_area.drawBitmap(0, 37, bm_boot, disp_area.width(), 27, SSD1306_WHITE, SSD1306_BLACK);
} else {
if (!disp_ext_fb or bt_ssp_pin != 0) {
if (device_signatures_ok()) {
disp_area.drawBitmap(0, 0, bm_def_lc, disp_area.width(), 37, SSD1306_WHITE, SSD1306_BLACK);
@ -353,6 +358,7 @@ void draw_disp_area() {
} else {
disp_area.drawBitmap(0, 0, fb, disp_area.width(), disp_area.height(), SSD1306_WHITE, SSD1306_BLACK);
}
}
}
void update_disp_area() {

View File

@ -27,6 +27,23 @@ const unsigned char bm_bt [] PROGMEM = {
0x29, 0x94, 0x11, 0x48, 0x03, 0x20, 0x05, 0x10, 0x09, 0x20, 0x01, 0x40, 0x01, 0x80, 0x01, 0x00
};
const unsigned char bm_boot [] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xfc, 0x38, 0x66, 0x67, 0x1c, 0x3f, 0xff, 0xff, 0xfc, 0x99, 0xe6, 0x66, 0x4c, 0xff, 0xff,
0xff, 0xfc, 0x98, 0x70, 0xe6, 0x7c, 0x3f, 0xff, 0xff, 0xfc, 0x99, 0xf0, 0xe6, 0x4c, 0xff, 0xff,
0xff, 0xfc, 0x38, 0x79, 0xe7, 0x1c, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x0c, 0x38, 0xe1, 0xc3, 0x33, 0x38, 0x7f, 0xfe, 0x7e, 0x72, 0x64, 0xe7, 0x31, 0x33, 0xff,
0xff, 0x1e, 0x70, 0x61, 0xe7, 0x30, 0x32, 0x7f, 0xff, 0xce, 0x72, 0x61, 0xe7, 0x32, 0x32, 0x7f,
0xfe, 0x1e, 0x72, 0x64, 0xe7, 0x33, 0x38, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
const unsigned char bm_version [] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,

View File

@ -52,8 +52,7 @@ char sbuf[128];
void setup() {
#if MCU_VARIANT == MCU_ESP32
// TODO: Reset?
// delay(500);
boot_seq();
EEPROM.begin(EEPROM_SIZE);
Serial.setRxBufferSize(CONFIG_UART_BUFFER_SIZE);
#endif
@ -90,16 +89,22 @@ void setup() {
// pins for the LoRa module
LoRa.setPins(pin_cs, pin_reset, pin_dio);
#if HAS_DISPLAY
disp_ready = display_init();
update_display();
#endif
#if MCU_VARIANT == MCU_ESP32
#if HAS_PMU == true
pmu_ready = init_pmu();
#endif
kiss_indicate_reset();
#if HAS_BLUETOOTH
bt_init();
bt_init_ran = true;
#endif
#if HAS_DISPLAY
disp_ready = display_init();
kiss_indicate_reset();
#endif
// Validate board health, EEPROM and config
@ -832,7 +837,10 @@ void validate_status() {
hw_ready = false;
Serial.write("Error, invalid hardware check state\r\n");
#if HAS_DISPLAY
if (disp_ready) update_display();
if (disp_ready) {
device_init_done = true;
update_display();
}
#endif
led_indicate_boot_error();
}
@ -846,7 +854,10 @@ void validate_status() {
} else {
Serial.write("Error, indeterminate boot vector\r\n");
#if HAS_DISPLAY
if (disp_ready) update_display();
if (disp_ready) {
device_init_done = true;
update_display();
}
#endif
led_indicate_boot_error();
}
@ -881,7 +892,10 @@ void validate_status() {
hw_ready = false;
Serial.write("Error, incorrect boot vector\r\n");
#if HAS_DISPLAY
if (disp_ready) update_display();
if (disp_ready) {
device_init_done = true;
update_display();
}
#endif
led_indicate_boot_error();
}
@ -947,11 +961,6 @@ void loop() {
#endif
#if HAS_BLUETOOTH
if (!bt_init_ran && millis() > 1000) {
bt_init();
bt_init_ran = true;
}
if (bt_ready) update_bt();
#endif
}

View File

@ -66,6 +66,20 @@ uint8_t boot_vector = 0x00;
pixels.show();
}
}
void boot_seq() {
uint8_t rs[] = { 0x00, 0x00, 0x00 };
uint8_t gs[] = { 0x10, 0x08, 0x00 };
uint8_t bs[] = { 0x00, 0x08, 0x10 };
for (int i = 0; i < 1*sizeof(rs); i++) {
npset(rs[i%sizeof(rs)], gs[i%sizeof(gs)], bs[i%sizeof(bs)]);
delay(33);
npset(0x00, 0x00, 0x00);
delay(66);
}
}
#else
void boot_seq() { }
#endif
#if MCU_VARIANT == MCU_1284P || MCU_VARIANT == MCU_2560