WIP: Booting and display working, Lora32 V3, debug and some

checks bypassed.
This commit is contained in:
Kevin Brosius 2024-03-11 03:59:42 -04:00
parent 262518efef
commit 36ab438625
5 changed files with 163 additions and 5 deletions

View File

@ -36,12 +36,21 @@
#define BOARD_LORA32_V2_1 0x37 #define BOARD_LORA32_V2_1 0x37
#define BOARD_LORA32_V1_0 0x39 #define BOARD_LORA32_V1_0 0x39
#define BOARD_HELTEC32_V2 0x38 #define BOARD_HELTEC32_V2 0x38
#define BOARD_HELTEC_LORA32_V3 0x3a
#define BOARD_RNODE_NG_20 0x40 #define BOARD_RNODE_NG_20 0x40
#define BOARD_RNODE_NG_21 0x41 #define BOARD_RNODE_NG_21 0x41
#define BOARD_RNODE_NG_22 0x42 #define BOARD_RNODE_NG_22 0x42
#define BOARD_GENERIC_NRF52 0x50 #define BOARD_GENERIC_NRF52 0x50
#define BOARD_RAK4630 0x51 #define BOARD_RAK4630 0x51
// -----------------------------------
// override for local compile
//#define BOARD_MODEL BOARD_LORA32_V1_0
#define BOARD_MODEL BOARD_HELTEC_LORA32_V3
// -----------------------------------
#if defined(__AVR_ATmega1284P__) #if defined(__AVR_ATmega1284P__)
#define PLATFORM PLATFORM_AVR #define PLATFORM PLATFORM_AVR
#define MCU_VARIANT MCU_1284P #define MCU_VARIANT MCU_1284P
@ -71,6 +80,7 @@
#define HAS_DISPLAY false #define HAS_DISPLAY false
#define HAS_BLUETOOTH false #define HAS_BLUETOOTH false
#define HAS_BLE false
#define HAS_TCXO false #define HAS_TCXO false
#define HAS_PMU false #define HAS_PMU false
#define HAS_NP false #define HAS_NP false
@ -143,6 +153,7 @@
#define HAS_DISPLAY true #define HAS_DISPLAY true
#define HAS_PMU true #define HAS_PMU true
#define HAS_BLUETOOTH true #define HAS_BLUETOOTH true
#define HAS_BLE true
#define HAS_CONSOLE true #define HAS_CONSOLE true
#define HAS_SD false #define HAS_SD false
#define HAS_EEPROM true #define HAS_EEPROM true
@ -178,6 +189,7 @@
#elif BOARD_MODEL == BOARD_LORA32_V1_0 #elif BOARD_MODEL == BOARD_LORA32_V1_0
#define HAS_DISPLAY true #define HAS_DISPLAY true
#define HAS_BLUETOOTH true #define HAS_BLUETOOTH true
#define HAS_BLE true
#define HAS_CONSOLE true #define HAS_CONSOLE true
#define HAS_EEPROM true #define HAS_EEPROM true
const int pin_cs = 18; const int pin_cs = 18;
@ -194,6 +206,7 @@
#elif BOARD_MODEL == BOARD_LORA32_V2_0 #elif BOARD_MODEL == BOARD_LORA32_V2_0
#define HAS_DISPLAY true #define HAS_DISPLAY true
#define HAS_BLUETOOTH true #define HAS_BLUETOOTH true
#define HAS_BLE true
#define HAS_CONSOLE true #define HAS_CONSOLE true
#define HAS_EEPROM true #define HAS_EEPROM true
const int pin_cs = 18; const int pin_cs = 18;
@ -210,6 +223,7 @@
#elif BOARD_MODEL == BOARD_LORA32_V2_1 #elif BOARD_MODEL == BOARD_LORA32_V2_1
#define HAS_DISPLAY true #define HAS_DISPLAY true
#define HAS_BLUETOOTH true #define HAS_BLUETOOTH true
#define HAS_BLE true
#define HAS_PMU true #define HAS_PMU true
#define HAS_CONSOLE true #define HAS_CONSOLE true
#define HAS_EEPROM true #define HAS_EEPROM true
@ -243,6 +257,44 @@
const int pin_led_tx = 25; const int pin_led_tx = 25;
#endif #endif
#elif BOARD_MODEL == BOARD_HELTEC_LORA32_V3
#define IS_ESP32S3 true
#define HAS_DISPLAY true
//ESP32-S3 no bluetooth classic
//#define HAS_BLUETOOTH true
#define HAS_BLUETOOTH false
//#define HAS_BLE true
// TODO BLE
#define HAS_BLE false
// Cannot run wifi and BLE at same time?
#define HAS_CONSOLE false
#define HAS_EEPROM true
#if defined(EXTERNAL_LEDS)
const int pin_led_rx = 35;
const int pin_led_tx = 2;
#else
const int pin_led_rx = 2;
const int pin_led_tx = 2;
#endif
#define MODEM SX1262
//#define HAS_TCXO true
#define HAS_TCXO false
#define HAS_BUSY true
#define DIO2_AS_RF_SWITCH true
const int pin_tcxo_enable = -1;
// following pins are for the sx1262
const int pin_cs = 8;
const int pin_busy = 13;
const int pin_dio = 14;
const int pin_reset = 12;
const int pin_mosi = 10;
const int pin_miso = 11;
const int pin_sclk = 9;
#elif BOARD_MODEL == BOARD_RNODE_NG_20 #elif BOARD_MODEL == BOARD_RNODE_NG_20
#define HAS_DISPLAY true #define HAS_DISPLAY true
#define HAS_BLUETOOTH true #define HAS_BLUETOOTH true

View File

@ -32,6 +32,12 @@
#define DISP_ADDR 0x3C #define DISP_ADDR 0x3C
#define SCL_OLED 15 #define SCL_OLED 15
#define SDA_OLED 4 #define SDA_OLED 4
#elif BOARD_MODEL == BOARD_HELTEC_LORA32_V3
#define DISP_RST 21
//#define DISP_RST -1
#define DISP_ADDR 0x3C
#define SCL_OLED 18
#define SDA_OLED 17
#elif BOARD_MODEL == BOARD_RNODE_NG_21 #elif BOARD_MODEL == BOARD_RNODE_NG_21
#define DISP_RST -1 #define DISP_RST -1
#define DISP_ADDR 0x3C #define DISP_ADDR 0x3C
@ -108,6 +114,29 @@ bool display_init() {
Wire.begin(SDA_OLED, SCL_OLED); Wire.begin(SDA_OLED, SCL_OLED);
#elif BOARD_MODEL == BOARD_HELTEC32_V2 #elif BOARD_MODEL == BOARD_HELTEC32_V2
Wire.begin(SDA_OLED, SCL_OLED); Wire.begin(SDA_OLED, SCL_OLED);
#elif BOARD_MODEL == BOARD_HELTEC_LORA32_V3
Serial.println("display - 1 ");
// vext
pinMode(Vext, OUTPUT);
//digitalWrite(36, LOW);
digitalWrite(Vext, LOW);
delay(500);
Serial.println("display - 2 ");
//Serial.print("vext ");
//Serial.println(Vext);
int pin_display_en = 21;
//digitalWrite(pin_display_en, HIGH);
//delay(50);
pinMode(pin_display_en, OUTPUT);
digitalWrite(pin_display_en, LOW);
delay(50);
digitalWrite(pin_display_en, HIGH);
delay(50);
Wire.begin(SDA_OLED, SCL_OLED);
// ble debug
//Serial.println("Setup display pins LORA32 V3");
Serial.println("vext ");
Serial.println(Vext);
#elif BOARD_MODEL == BOARD_LORA32_V1_0 #elif BOARD_MODEL == BOARD_LORA32_V1_0
int pin_display_en = 16; int pin_display_en = 16;
digitalWrite(pin_display_en, LOW); digitalWrite(pin_display_en, LOW);
@ -149,6 +178,10 @@ bool display_init() {
#elif BOARD_MODEL == BOARD_HELTEC32_V2 #elif BOARD_MODEL == BOARD_HELTEC32_V2
disp_mode = DISP_MODE_PORTRAIT; disp_mode = DISP_MODE_PORTRAIT;
display.setRotation(1); display.setRotation(1);
#elif BOARD_MODEL == BOARD_HELTEC_LORA32_V3
disp_mode = DISP_MODE_PORTRAIT;
display.setRotation(1);
//display.setRotation(3);
#else #else
disp_mode = DISP_MODE_PORTRAIT; disp_mode = DISP_MODE_PORTRAIT;
display.setRotation(3); display.setRotation(3);
@ -165,7 +198,14 @@ bool display_init() {
disp_area.cp437(true); disp_area.cp437(true);
display.cp437(true); display.cp437(true);
Serial.print("(1)display int= ");
Serial.println(display_intensity);
display_intensity = EEPROM.read(eeprom_addr(ADDR_CONF_DINT)); display_intensity = EEPROM.read(eeprom_addr(ADDR_CONF_DINT));
Serial.print("(2)display int= ");
Serial.println(display_intensity);
display_intensity = 100;
Serial.print("(2)display int= ");
Serial.println(display_intensity);
return true; return true;
} }
@ -349,7 +389,9 @@ void draw_stat_area() {
} }
void update_stat_area() { void update_stat_area() {
if (eeprom_ok && !firmware_update_mode && !console_active) { // override eeprom check for BLE
//if (eeprom_ok && !firmware_update_mode && !console_active) {
if ( !firmware_update_mode && !console_active) {
draw_stat_area(); draw_stat_area();
if (disp_mode == DISP_MODE_PORTRAIT) { if (disp_mode == DISP_MODE_PORTRAIT) {
@ -524,6 +566,8 @@ void draw_disp_area() {
} }
void update_disp_area() { void update_disp_area() {
// ble debug
Serial.println("...update disp area...");
draw_disp_area(); draw_disp_area();
display.drawBitmap(p_ad_x, p_ad_y, disp_area.getBuffer(), disp_area.width(), disp_area.height(), SSD1306_WHITE, SSD1306_BLACK); display.drawBitmap(p_ad_x, p_ad_y, disp_area.getBuffer(), disp_area.width(), disp_area.height(), SSD1306_WHITE, SSD1306_BLACK);
if (disp_mode == DISP_MODE_LANDSCAPE) { if (disp_mode == DISP_MODE_LANDSCAPE) {

View File

@ -93,6 +93,9 @@ firmware-heltec32_v2:
firmware-heltec32_v2_extled: firmware-heltec32_v2_extled:
arduino-cli compile --fqbn esp32:esp32:heltec_wifi_lora_32_V2 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x38\" \"-DEXTERNAL_LEDS=true\"" arduino-cli compile --fqbn esp32:esp32:heltec_wifi_lora_32_V2 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x38\" \"-DEXTERNAL_LEDS=true\""
firmware-heltec32_v3:
arduino-cli compile --fqbn esp32:esp32:heltec_wifi_lora_32_V3 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x39\""
firmware-rnode_ng_20: firmware-rnode_ng_20:
arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x40\"" arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x40\""
@ -149,6 +152,13 @@ upload-heltec32_v2:
@sleep 3 @sleep 3
python ./Release/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin python ./Release/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin
upload-heltec32_v3:
arduino-cli upload -p COM3 --fqbn esp32:esp32:heltec_wifi_lora_32_V3
@sleep 1
rnodeconf COM3 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.heltec_wifi_lora_32_V3/RNode_Firmware.ino.bin)
@sleep 3
python ./Release/esptool/esptool.py --chip esp32-s3 --port COM3 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin
upload-rnode_ng_20: upload-rnode_ng_20:
arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:ttgo-lora32 arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:ttgo-lora32
@sleep 1 @sleep 1

View File

@ -143,6 +143,9 @@ void setup() {
eeprom_update(eeprom_addr(ADDR_CONF_DINT), 0xFF); eeprom_update(eeprom_addr(ADDR_CONF_DINT), 0xFF);
} }
disp_ready = display_init(); disp_ready = display_init();
// ble debug
Serial.print("disp ready = ");
Serial.println(disp_ready);
update_display(); update_display();
#endif #endif
@ -380,6 +383,10 @@ void stopRadio() {
} }
void update_radio_lock() { void update_radio_lock() {
// ble debug
//static char lock[40];
//sprintf(lock, "lock chk %d %d %x %d", lora_freq, lora_bw, lora_txp, lora_sf);
//Serial.println(lock);
if (lora_freq != 0 && lora_bw != 0 && lora_txp != 0xFF && lora_sf != 0) { if (lora_freq != 0 && lora_bw != 0 && lora_txp != 0xFF && lora_sf != 0) {
radio_locked = false; radio_locked = false;
} else { } else {
@ -605,6 +612,9 @@ void serialCallback(uint8_t sbyte) {
lora_freq = freq; lora_freq = freq;
if (op_mode == MODE_HOST) setFrequency(); if (op_mode == MODE_HOST) setFrequency();
kiss_indicate_frequency(); kiss_indicate_frequency();
// ble debug
//Serial.print("freq ");
//Serial.println(lora_freq);
} }
} }
} else if (command == CMD_BANDWIDTH) { } else if (command == CMD_BANDWIDTH) {
@ -690,6 +700,8 @@ void serialCallback(uint8_t sbyte) {
} else if (sbyte == 0x01) { } else if (sbyte == 0x01) {
startRadio(); startRadio();
kiss_indicate_radiostate(); kiss_indicate_radiostate();
// ble debug
//Serial.println("start radio");
} }
} else if (command == CMD_ST_ALOCK) { } else if (command == CMD_ST_ALOCK) {
if (sbyte == FESC) { if (sbyte == FESC) {
@ -1063,6 +1075,11 @@ void validate_status() {
uint8_t F_WDR = 0x01; uint8_t F_WDR = 0x01;
#endif #endif
// ble debug
Serial.print("hw_ready ");
Serial.print(hw_ready);
Serial.print(" device init done ");
Serial.println(device_init_done);
if (hw_ready || device_init_done) { if (hw_ready || device_init_done) {
hw_ready = false; hw_ready = false;
Serial.write("Error, invalid hardware check state\r\n"); Serial.write("Error, invalid hardware check state\r\n");
@ -1093,22 +1110,31 @@ void validate_status() {
} }
if (boot_vector == START_FROM_BOOTLOADER || boot_vector == START_FROM_POWERON) { if (boot_vector == START_FROM_BOOTLOADER || boot_vector == START_FROM_POWERON) {
if (eeprom_lock_set()) { //if (eeprom_lock_set()) {
if (1) {
if (eeprom_product_valid() && eeprom_model_valid() && eeprom_hwrev_valid()) { if (eeprom_product_valid() && eeprom_model_valid() && eeprom_hwrev_valid()) {
if (eeprom_checksum_valid()) { if (eeprom_checksum_valid()) {
eeprom_ok = true; eeprom_ok = true;
if (modem_installed) { if (modem_installed) {
#if PLATFORM == PLATFORM_ESP32 #if PLATFORM == PLATFORM_ESP32
if (device_init()) { if (device_init()) {
// ble debug
Serial.println("hw ready 1");
hw_ready = true; hw_ready = true;
} else { } else {
hw_ready = false; hw_ready = false;
// ble debug
Serial.println("hw ! ready 1");
} }
#else #else
hw_ready = true; hw_ready = true;
// ble debug
Serial.println("hw ready 2");
#endif #endif
} else { } else {
hw_ready = false; hw_ready = false;
// ble debug
Serial.println("hw ! ready 3");
Serial.write("No valid radio module found\r\n"); Serial.write("No valid radio module found\r\n");
#if HAS_DISPLAY #if HAS_DISPLAY
if (disp_ready) { if (disp_ready) {
@ -1122,9 +1148,14 @@ void validate_status() {
eeprom_conf_load(); eeprom_conf_load();
op_mode = MODE_TNC; op_mode = MODE_TNC;
startRadio(); startRadio();
// ble debug
Serial.println("hw ready - start radio");
} }
} else { } else {
hw_ready = false; hw_ready = false;
// ble debug
Serial.println("hw ! ready 4");
#if HAS_DISPLAY #if HAS_DISPLAY
if (disp_ready) { if (disp_ready) {
device_init_done = true; device_init_done = true;
@ -1134,15 +1165,26 @@ void validate_status() {
} }
} else { } else {
hw_ready = false; hw_ready = false;
// ble debug
Serial.println("hw ! ready 5 - override - TODO");
// override eeprom flags - ble debug
hw_ready = true;
//
#if HAS_DISPLAY #if HAS_DISPLAY
if (disp_ready) { if (disp_ready) {
device_init_done = true; device_init_done = true;
update_display(); update_display();
// ble debug
Serial.println("update display called");
} }
#endif #endif
} }
} else { } else {
hw_ready = false; hw_ready = false;
// ble debug
Serial.println("hw ! ready 6");
#if HAS_DISPLAY #if HAS_DISPLAY
if (disp_ready) { if (disp_ready) {
device_init_done = true; device_init_done = true;
@ -1152,6 +1194,8 @@ void validate_status() {
} }
} else { } else {
hw_ready = false; hw_ready = false;
// ble debug
Serial.println("hw ! ready 7 - bad boot vector");
Serial.write("Error, incorrect boot vector\r\n"); Serial.write("Error, incorrect boot vector\r\n");
#if HAS_DISPLAY #if HAS_DISPLAY
if (disp_ready) { if (disp_ready) {

View File

@ -60,9 +60,12 @@ sx128x *LoRa = &sx128x_modem;
#include "Device.h" #include "Device.h"
#endif #endif
#if MCU_VARIANT == MCU_ESP32 #if MCU_VARIANT == MCU_ESP32
#if BOARD_MODEL != BOARD_RNODE_NG_22 //#if BOARD_MODEL != BOARD_RNODE_NG_22 && BOARD_MODEL != BOARD_HELTEC_LORA32_V3
#include "soc/rtc_wdt.h" // #include "soc/rtc_wdt.h"
#endif //#else
//https://github.com/espressif/esp-idf/issues/8855
#include "hal/wdt_hal.h"
//#endif
#define ISR_VECT IRAM_ATTR #define ISR_VECT IRAM_ATTR
#else #else
#define ISR_VECT #define ISR_VECT
@ -192,6 +195,11 @@ uint8_t boot_vector = 0x00;
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); } void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); } void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
#endif #endif
#elif BOARD_MODEL == BOARD_HELTEC_LORA32_V3
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
#elif BOARD_MODEL == BOARD_LORA32_V2_1 #elif BOARD_MODEL == BOARD_LORA32_V2_1
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); }