From 36ab43862543ce564f799ba2de549972f90886be Mon Sep 17 00:00:00 2001 From: Kevin Brosius Date: Mon, 11 Mar 2024 03:59:42 -0400 Subject: [PATCH 1/6] WIP: Booting and display working, Lora32 V3, debug and some checks bypassed. --- Boards.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++ Display.h | 46 +++++++++++++++++++++++++++++++++++++++- Makefile | 10 +++++++++ RNode_Firmware.ino | 46 +++++++++++++++++++++++++++++++++++++++- Utilities.h | 14 ++++++++++--- 5 files changed, 163 insertions(+), 5 deletions(-) diff --git a/Boards.h b/Boards.h index 9bf8a69..14dbdec 100644 --- a/Boards.h +++ b/Boards.h @@ -36,12 +36,21 @@ #define BOARD_LORA32_V2_1 0x37 #define BOARD_LORA32_V1_0 0x39 #define BOARD_HELTEC32_V2 0x38 + #define BOARD_HELTEC_LORA32_V3 0x3a #define BOARD_RNODE_NG_20 0x40 #define BOARD_RNODE_NG_21 0x41 #define BOARD_RNODE_NG_22 0x42 #define BOARD_GENERIC_NRF52 0x50 #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__) #define PLATFORM PLATFORM_AVR #define MCU_VARIANT MCU_1284P @@ -71,6 +80,7 @@ #define HAS_DISPLAY false #define HAS_BLUETOOTH false + #define HAS_BLE false #define HAS_TCXO false #define HAS_PMU false #define HAS_NP false @@ -143,6 +153,7 @@ #define HAS_DISPLAY true #define HAS_PMU true #define HAS_BLUETOOTH true + #define HAS_BLE true #define HAS_CONSOLE true #define HAS_SD false #define HAS_EEPROM true @@ -178,6 +189,7 @@ #elif BOARD_MODEL == BOARD_LORA32_V1_0 #define HAS_DISPLAY true #define HAS_BLUETOOTH true + #define HAS_BLE true #define HAS_CONSOLE true #define HAS_EEPROM true const int pin_cs = 18; @@ -194,6 +206,7 @@ #elif BOARD_MODEL == BOARD_LORA32_V2_0 #define HAS_DISPLAY true #define HAS_BLUETOOTH true + #define HAS_BLE true #define HAS_CONSOLE true #define HAS_EEPROM true const int pin_cs = 18; @@ -210,6 +223,7 @@ #elif BOARD_MODEL == BOARD_LORA32_V2_1 #define HAS_DISPLAY true #define HAS_BLUETOOTH true + #define HAS_BLE true #define HAS_PMU true #define HAS_CONSOLE true #define HAS_EEPROM true @@ -243,6 +257,44 @@ const int pin_led_tx = 25; #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 #define HAS_DISPLAY true #define HAS_BLUETOOTH true diff --git a/Display.h b/Display.h index 5dd2a17..37c5d7f 100644 --- a/Display.h +++ b/Display.h @@ -32,6 +32,12 @@ #define DISP_ADDR 0x3C #define SCL_OLED 15 #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 #define DISP_RST -1 #define DISP_ADDR 0x3C @@ -108,6 +114,29 @@ bool display_init() { Wire.begin(SDA_OLED, SCL_OLED); #elif BOARD_MODEL == BOARD_HELTEC32_V2 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 int pin_display_en = 16; digitalWrite(pin_display_en, LOW); @@ -149,6 +178,10 @@ bool display_init() { #elif BOARD_MODEL == BOARD_HELTEC32_V2 disp_mode = DISP_MODE_PORTRAIT; display.setRotation(1); + #elif BOARD_MODEL == BOARD_HELTEC_LORA32_V3 + disp_mode = DISP_MODE_PORTRAIT; + display.setRotation(1); + //display.setRotation(3); #else disp_mode = DISP_MODE_PORTRAIT; display.setRotation(3); @@ -165,7 +198,14 @@ bool display_init() { disp_area.cp437(true); display.cp437(true); + Serial.print("(1)display int= "); + Serial.println(display_intensity); 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; } @@ -349,7 +389,9 @@ void draw_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(); if (disp_mode == DISP_MODE_PORTRAIT) { @@ -524,6 +566,8 @@ void draw_disp_area() { } void update_disp_area() { + // ble debug + Serial.println("...update 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); if (disp_mode == DISP_MODE_LANDSCAPE) { diff --git a/Makefile b/Makefile index 27068dc..88c7c74 100644 --- a/Makefile +++ b/Makefile @@ -93,6 +93,9 @@ firmware-heltec32_v2: 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\"" +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: 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 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: arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:ttgo-lora32 @sleep 1 diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index 54ddb12..925406f 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -143,6 +143,9 @@ void setup() { eeprom_update(eeprom_addr(ADDR_CONF_DINT), 0xFF); } disp_ready = display_init(); + // ble debug + Serial.print("disp ready = "); + Serial.println(disp_ready); update_display(); #endif @@ -380,6 +383,10 @@ void stopRadio() { } 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) { radio_locked = false; } else { @@ -605,6 +612,9 @@ void serialCallback(uint8_t sbyte) { lora_freq = freq; if (op_mode == MODE_HOST) setFrequency(); kiss_indicate_frequency(); + // ble debug + //Serial.print("freq "); + //Serial.println(lora_freq); } } } else if (command == CMD_BANDWIDTH) { @@ -690,6 +700,8 @@ void serialCallback(uint8_t sbyte) { } else if (sbyte == 0x01) { startRadio(); kiss_indicate_radiostate(); + // ble debug + //Serial.println("start radio"); } } else if (command == CMD_ST_ALOCK) { if (sbyte == FESC) { @@ -1063,6 +1075,11 @@ void validate_status() { uint8_t F_WDR = 0x01; #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) { hw_ready = false; 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 (eeprom_lock_set()) { + //if (eeprom_lock_set()) { + if (1) { if (eeprom_product_valid() && eeprom_model_valid() && eeprom_hwrev_valid()) { if (eeprom_checksum_valid()) { eeprom_ok = true; if (modem_installed) { #if PLATFORM == PLATFORM_ESP32 if (device_init()) { + // ble debug + Serial.println("hw ready 1"); hw_ready = true; } else { hw_ready = false; + // ble debug + Serial.println("hw ! ready 1"); } #else hw_ready = true; + // ble debug + Serial.println("hw ready 2"); #endif } else { hw_ready = false; + // ble debug + Serial.println("hw ! ready 3"); Serial.write("No valid radio module found\r\n"); #if HAS_DISPLAY if (disp_ready) { @@ -1122,9 +1148,14 @@ void validate_status() { eeprom_conf_load(); op_mode = MODE_TNC; startRadio(); + // ble debug + Serial.println("hw ready - start radio"); + } } else { hw_ready = false; + // ble debug + Serial.println("hw ! ready 4"); #if HAS_DISPLAY if (disp_ready) { device_init_done = true; @@ -1134,15 +1165,26 @@ void validate_status() { } } else { hw_ready = false; + // ble debug + Serial.println("hw ! ready 5 - override - TODO"); + + // override eeprom flags - ble debug + hw_ready = true; + // + #if HAS_DISPLAY if (disp_ready) { device_init_done = true; update_display(); + // ble debug + Serial.println("update display called"); } #endif } } else { hw_ready = false; + // ble debug + Serial.println("hw ! ready 6"); #if HAS_DISPLAY if (disp_ready) { device_init_done = true; @@ -1152,6 +1194,8 @@ void validate_status() { } } else { hw_ready = false; + // ble debug + Serial.println("hw ! ready 7 - bad boot vector"); Serial.write("Error, incorrect boot vector\r\n"); #if HAS_DISPLAY if (disp_ready) { diff --git a/Utilities.h b/Utilities.h index dcb085e..3b325c1 100644 --- a/Utilities.h +++ b/Utilities.h @@ -60,9 +60,12 @@ sx128x *LoRa = &sx128x_modem; #include "Device.h" #endif #if MCU_VARIANT == MCU_ESP32 - #if BOARD_MODEL != BOARD_RNODE_NG_22 - #include "soc/rtc_wdt.h" - #endif + //#if BOARD_MODEL != BOARD_RNODE_NG_22 && BOARD_MODEL != BOARD_HELTEC_LORA32_V3 + // #include "soc/rtc_wdt.h" + //#else + //https://github.com/espressif/esp-idf/issues/8855 + #include "hal/wdt_hal.h" + //#endif #define ISR_VECT IRAM_ATTR #else #define ISR_VECT @@ -192,6 +195,11 @@ uint8_t boot_vector = 0x00; void led_tx_on() { digitalWrite(pin_led_tx, HIGH); } void led_tx_off() { digitalWrite(pin_led_tx, LOW); } #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 void led_rx_on() { digitalWrite(pin_led_rx, HIGH); } void led_rx_off() { digitalWrite(pin_led_rx, LOW); } From 5c1e0f25ee7d1ea8c32f296b5c070c113525023c Mon Sep 17 00:00:00 2001 From: Kevin Brosius Date: Mon, 11 Mar 2024 12:35:29 -0400 Subject: [PATCH 2/6] Clean up debug prints for PR --- Boards.h | 6 +++--- Display.h | 27 ++++---------------------- Makefile | 2 +- RNode_Firmware.ino | 48 +--------------------------------------------- Utilities.h | 8 ++++---- 5 files changed, 13 insertions(+), 78 deletions(-) diff --git a/Boards.h b/Boards.h index 14dbdec..bdc557b 100644 --- a/Boards.h +++ b/Boards.h @@ -261,14 +261,13 @@ #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 + // Only one LED on pin 35 #if defined(EXTERNAL_LEDS) const int pin_led_rx = 35; const int pin_led_tx = 2; @@ -278,11 +277,12 @@ #endif #define MODEM SX1262 + // TODO TCXO? //#define HAS_TCXO true #define HAS_TCXO false + const int pin_tcxo_enable = -1; #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; diff --git a/Display.h b/Display.h index 37c5d7f..a880357 100644 --- a/Display.h +++ b/Display.h @@ -34,7 +34,6 @@ #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 @@ -115,28 +114,17 @@ bool display_init() { #elif BOARD_MODEL == BOARD_HELTEC32_V2 Wire.begin(SDA_OLED, SCL_OLED); #elif BOARD_MODEL == BOARD_HELTEC_LORA32_V3 - Serial.println("display - 1 "); - // vext + // enable vext / pin 36 pinMode(Vext, OUTPUT); - //digitalWrite(36, LOW); digitalWrite(Vext, LOW); - delay(500); - Serial.println("display - 2 "); - //Serial.print("vext "); - //Serial.println(Vext); + delay(50); 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 int pin_display_en = 16; digitalWrite(pin_display_en, LOW); @@ -180,7 +168,9 @@ bool display_init() { display.setRotation(1); #elif BOARD_MODEL == BOARD_HELTEC_LORA32_V3 disp_mode = DISP_MODE_PORTRAIT; + // Antenna conx up display.setRotation(1); + // USB-C up //display.setRotation(3); #else disp_mode = DISP_MODE_PORTRAIT; @@ -198,14 +188,7 @@ bool display_init() { disp_area.cp437(true); display.cp437(true); - Serial.print("(1)display int= "); - Serial.println(display_intensity); 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; } @@ -566,8 +549,6 @@ void draw_disp_area() { } void update_disp_area() { - // ble debug - Serial.println("...update 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); if (disp_mode == DISP_MODE_LANDSCAPE) { diff --git a/Makefile b/Makefile index 88c7c74..b0576c9 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,7 @@ 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\"" 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\"" + 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=0x3a\"" 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\"" diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index 925406f..9bb5def 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -143,9 +143,6 @@ void setup() { eeprom_update(eeprom_addr(ADDR_CONF_DINT), 0xFF); } disp_ready = display_init(); - // ble debug - Serial.print("disp ready = "); - Serial.println(disp_ready); update_display(); #endif @@ -383,10 +380,6 @@ void stopRadio() { } 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) { radio_locked = false; } else { @@ -612,9 +605,6 @@ void serialCallback(uint8_t sbyte) { lora_freq = freq; if (op_mode == MODE_HOST) setFrequency(); kiss_indicate_frequency(); - // ble debug - //Serial.print("freq "); - //Serial.println(lora_freq); } } } else if (command == CMD_BANDWIDTH) { @@ -700,8 +690,6 @@ void serialCallback(uint8_t sbyte) { } else if (sbyte == 0x01) { startRadio(); kiss_indicate_radiostate(); - // ble debug - //Serial.println("start radio"); } } else if (command == CMD_ST_ALOCK) { if (sbyte == FESC) { @@ -1075,11 +1063,6 @@ void validate_status() { uint8_t F_WDR = 0x01; #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) { hw_ready = false; Serial.write("Error, invalid hardware check state\r\n"); @@ -1110,32 +1093,22 @@ void validate_status() { } if (boot_vector == START_FROM_BOOTLOADER || boot_vector == START_FROM_POWERON) { - //if (eeprom_lock_set()) { - if (1) { + if (eeprom_lock_set()) { if (eeprom_product_valid() && eeprom_model_valid() && eeprom_hwrev_valid()) { if (eeprom_checksum_valid()) { eeprom_ok = true; if (modem_installed) { #if PLATFORM == PLATFORM_ESP32 if (device_init()) { - // ble debug - Serial.println("hw ready 1"); hw_ready = true; } else { hw_ready = false; - // ble debug - Serial.println("hw ! ready 1"); } #else hw_ready = true; - // ble debug - Serial.println("hw ready 2"); #endif } else { hw_ready = false; - // ble debug - Serial.println("hw ! ready 3"); - Serial.write("No valid radio module found\r\n"); #if HAS_DISPLAY if (disp_ready) { device_init_done = true; @@ -1148,14 +1121,9 @@ void validate_status() { eeprom_conf_load(); op_mode = MODE_TNC; startRadio(); - // ble debug - Serial.println("hw ready - start radio"); - } } else { hw_ready = false; - // ble debug - Serial.println("hw ! ready 4"); #if HAS_DISPLAY if (disp_ready) { device_init_done = true; @@ -1165,26 +1133,15 @@ void validate_status() { } } else { hw_ready = false; - // ble debug - Serial.println("hw ! ready 5 - override - TODO"); - - // override eeprom flags - ble debug - hw_ready = true; - // - #if HAS_DISPLAY if (disp_ready) { device_init_done = true; update_display(); - // ble debug - Serial.println("update display called"); } #endif } } else { hw_ready = false; - // ble debug - Serial.println("hw ! ready 6"); #if HAS_DISPLAY if (disp_ready) { device_init_done = true; @@ -1194,9 +1151,6 @@ void validate_status() { } } else { hw_ready = false; - // ble debug - Serial.println("hw ! ready 7 - bad boot vector"); - Serial.write("Error, incorrect boot vector\r\n"); #if HAS_DISPLAY if (disp_ready) { device_init_done = true; diff --git a/Utilities.h b/Utilities.h index 3b325c1..0bb84a7 100644 --- a/Utilities.h +++ b/Utilities.h @@ -60,12 +60,12 @@ sx128x *LoRa = &sx128x_modem; #include "Device.h" #endif #if MCU_VARIANT == MCU_ESP32 - //#if BOARD_MODEL != BOARD_RNODE_NG_22 && BOARD_MODEL != BOARD_HELTEC_LORA32_V3 - // #include "soc/rtc_wdt.h" - //#else + #if BOARD_MODEL == BOARD_HELTEC_LORA32_V3 //https://github.com/espressif/esp-idf/issues/8855 #include "hal/wdt_hal.h" - //#endif + #elif BOARD_MODEL != BOARD_RNODE_NG_22 + #include "soc/rtc_wdt.h" + #endif #define ISR_VECT IRAM_ATTR #else #define ISR_VECT From 0a08e7ffbf4b8f49410a541231fc1765487a0026 Mon Sep 17 00:00:00 2001 From: Kevin Brosius Date: Mon, 11 Mar 2024 16:55:01 -0400 Subject: [PATCH 3/6] Remove debug build settings from PR --- Boards.h | 8 -------- Display.h | 4 +--- RNode_Firmware.ino | 2 ++ 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/Boards.h b/Boards.h index bdc557b..a111fab 100644 --- a/Boards.h +++ b/Boards.h @@ -43,14 +43,6 @@ #define BOARD_GENERIC_NRF52 0x50 #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__) #define PLATFORM PLATFORM_AVR #define MCU_VARIANT MCU_1284P diff --git a/Display.h b/Display.h index a880357..e0b17c6 100644 --- a/Display.h +++ b/Display.h @@ -372,9 +372,7 @@ void draw_stat_area() { } void update_stat_area() { - // override eeprom check for BLE - //if (eeprom_ok && !firmware_update_mode && !console_active) { - if ( !firmware_update_mode && !console_active) { + if (eeprom_ok && !firmware_update_mode && !console_active) { draw_stat_area(); if (disp_mode == DISP_MODE_PORTRAIT) { diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index 9bb5def..54ddb12 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -1109,6 +1109,7 @@ void validate_status() { #endif } else { hw_ready = false; + Serial.write("No valid radio module found\r\n"); #if HAS_DISPLAY if (disp_ready) { device_init_done = true; @@ -1151,6 +1152,7 @@ void validate_status() { } } else { hw_ready = false; + Serial.write("Error, incorrect boot vector\r\n"); #if HAS_DISPLAY if (disp_ready) { device_init_done = true; From dc97de363b8ac08b3b87e58e5c55bdf0e3b33d72 Mon Sep 17 00:00:00 2001 From: Kevin Brosius Date: Wed, 13 Mar 2024 19:18:27 -0400 Subject: [PATCH 4/6] Need sx1262 SPI and tcxo setup for Lora32 V3 to work. --- sx126x.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sx126x.cpp b/sx126x.cpp index 5f6db55..fcf7371 100644 --- a/sx126x.cpp +++ b/sx126x.cpp @@ -127,7 +127,7 @@ bool sx126x::preInit() { pinMode(_ss, OUTPUT); digitalWrite(_ss, HIGH); - #if BOARD_MODEL == BOARD_RNODE_NG_22 + #if BOARD_MODEL == BOARD_RNODE_NG_22 || BOARD_MODEL == BOARD_HELTEC_LORA32_V3 SPI.begin(pin_sclk, pin_miso, pin_mosi, pin_cs); #else SPI.begin(); @@ -717,7 +717,7 @@ void sx126x::sleep() void sx126x::enableTCXO() { #if HAS_TCXO - #if BOARD_MODEL == BOARD_RAK4630 + #if BOARD_MODEL == BOARD_RAK4630 || BOARD_MODEL == BOARD_HELTEC_LORA32_V3 uint8_t buf[4] = {MODE_TCXO_3_3V_6X, 0x00, 0x00, 0xFF}; #elif BOARD_MODEL == BOARD_TBEAM uint8_t buf[4] = {MODE_TCXO_1_8V_6X, 0x00, 0x00, 0xFF}; From 7ed70727a3bba10cbf8318364084e1d9a00b606d Mon Sep 17 00:00:00 2001 From: Kevin Brosius Date: Wed, 13 Mar 2024 19:23:26 -0400 Subject: [PATCH 5/6] Lora32 V3 TCXO setting true --- Boards.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Boards.h b/Boards.h index a111fab..1f08807 100644 --- a/Boards.h +++ b/Boards.h @@ -269,9 +269,7 @@ #endif #define MODEM SX1262 - // TODO TCXO? - //#define HAS_TCXO true - #define HAS_TCXO false + #define HAS_TCXO true const int pin_tcxo_enable = -1; #define HAS_BUSY true #define DIO2_AS_RF_SWITCH true From 56a51fdafe2b86feb93c5ec2ccaf1837d5d4e8d8 Mon Sep 17 00:00:00 2001 From: Kevin Brosius Date: Thu, 11 Apr 2024 01:38:06 -0400 Subject: [PATCH 6/6] Update to add product and model codes for Heltec V3, swap to HELTEC32_V3 name for board ID. Bluetooth still disabled. --- Boards.h | 4 ++-- Display.h | 10 +++++----- Makefile | 2 +- RNode_Firmware.ino | 10 +++++++++- ROM.h | 3 +++ Utilities.h | 8 +++++--- sx126x.cpp | 4 ++-- 7 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Boards.h b/Boards.h index 1f08807..f5be0e9 100644 --- a/Boards.h +++ b/Boards.h @@ -36,7 +36,7 @@ #define BOARD_LORA32_V2_1 0x37 #define BOARD_LORA32_V1_0 0x39 #define BOARD_HELTEC32_V2 0x38 - #define BOARD_HELTEC_LORA32_V3 0x3a + #define BOARD_HELTEC32_V3 0x3A #define BOARD_RNODE_NG_20 0x40 #define BOARD_RNODE_NG_21 0x41 #define BOARD_RNODE_NG_22 0x42 @@ -249,7 +249,7 @@ const int pin_led_tx = 25; #endif - #elif BOARD_MODEL == BOARD_HELTEC_LORA32_V3 + #elif BOARD_MODEL == BOARD_HELTEC32_V3 #define IS_ESP32S3 true #define HAS_DISPLAY true //ESP32-S3 no bluetooth classic diff --git a/Display.h b/Display.h index e0b17c6..695fa90 100644 --- a/Display.h +++ b/Display.h @@ -32,7 +32,7 @@ #define DISP_ADDR 0x3C #define SCL_OLED 15 #define SDA_OLED 4 -#elif BOARD_MODEL == BOARD_HELTEC_LORA32_V3 +#elif BOARD_MODEL == BOARD_HELTEC32_V3 #define DISP_RST 21 #define DISP_ADDR 0x3C #define SCL_OLED 18 @@ -113,7 +113,7 @@ bool display_init() { Wire.begin(SDA_OLED, SCL_OLED); #elif BOARD_MODEL == BOARD_HELTEC32_V2 Wire.begin(SDA_OLED, SCL_OLED); - #elif BOARD_MODEL == BOARD_HELTEC_LORA32_V3 + #elif BOARD_MODEL == BOARD_HELTEC32_V3 // enable vext / pin 36 pinMode(Vext, OUTPUT); digitalWrite(Vext, LOW); @@ -166,12 +166,12 @@ bool display_init() { #elif BOARD_MODEL == BOARD_HELTEC32_V2 disp_mode = DISP_MODE_PORTRAIT; display.setRotation(1); - #elif BOARD_MODEL == BOARD_HELTEC_LORA32_V3 + #elif BOARD_MODEL == BOARD_HELTEC32_V3 disp_mode = DISP_MODE_PORTRAIT; // Antenna conx up - display.setRotation(1); + //display.setRotation(1); // USB-C up - //display.setRotation(3); + display.setRotation(3); #else disp_mode = DISP_MODE_PORTRAIT; display.setRotation(3); diff --git a/Makefile b/Makefile index b0576c9..6019a54 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,7 @@ 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\"" 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=0x3a\"" + 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=0x3A\"" 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\"" diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index 54ddb12..acbf3e0 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -1102,7 +1102,15 @@ void validate_status() { if (device_init()) { hw_ready = true; } else { - hw_ready = false; + #if !HAS_BLUETOOTH && !HAS_BLE + // Without bluetooth, bt_ready and device_init_done + // are not set + // and neither is hw_ready (see device_init()) + hw_ready = true; + device_init_done = true; + #else + hw_ready = false; + #endif } #else hw_ready = true; diff --git a/ROM.h b/ROM.h index b186318..a945d97 100644 --- a/ROM.h +++ b/ROM.h @@ -25,6 +25,7 @@ #define PRODUCT_T32_20 0xB0 #define PRODUCT_T32_21 0xB1 #define PRODUCT_H32_V2 0xC0 + #define PRODUCT_H32_V3 0xC1 #define MODEL_A1 0xA1 #define MODEL_A6 0xA6 #define MODEL_A4 0xA4 @@ -41,6 +42,8 @@ #define MODEL_BB 0xBB #define MODEL_C4 0xC4 #define MODEL_C9 0xC9 + #define MODEL_C5 0xC5 + #define MODEL_CA 0xCA #define MODEL_E4 0xE4 #define MODEL_E9 0xE9 #define MODEL_E3 0xE3 diff --git a/Utilities.h b/Utilities.h index 0bb84a7..db60800 100644 --- a/Utilities.h +++ b/Utilities.h @@ -60,7 +60,7 @@ sx128x *LoRa = &sx128x_modem; #include "Device.h" #endif #if MCU_VARIANT == MCU_ESP32 - #if BOARD_MODEL == BOARD_HELTEC_LORA32_V3 + #if BOARD_MODEL == BOARD_HELTEC32_V3 //https://github.com/espressif/esp-idf/issues/8855 #include "hal/wdt_hal.h" #elif BOARD_MODEL != BOARD_RNODE_NG_22 @@ -195,7 +195,7 @@ uint8_t boot_vector = 0x00; void led_tx_on() { digitalWrite(pin_led_tx, HIGH); } void led_tx_off() { digitalWrite(pin_led_tx, LOW); } #endif - #elif BOARD_MODEL == BOARD_HELTEC_LORA32_V3 + #elif BOARD_MODEL == BOARD_HELTEC32_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); } @@ -1281,7 +1281,7 @@ bool eeprom_product_valid() { #if PLATFORM == PLATFORM_AVR if (rval == PRODUCT_RNODE || rval == PRODUCT_HMBRW) { #elif PLATFORM == PLATFORM_ESP32 - if (rval == PRODUCT_RNODE || rval == BOARD_RNODE_NG_20 || rval == BOARD_RNODE_NG_21 || rval == PRODUCT_HMBRW || rval == PRODUCT_TBEAM || rval == PRODUCT_T32_10 || rval == PRODUCT_T32_20 || rval == PRODUCT_T32_21 || rval == PRODUCT_H32_V2) { + if (rval == PRODUCT_RNODE || rval == BOARD_RNODE_NG_20 || rval == BOARD_RNODE_NG_21 || rval == PRODUCT_HMBRW || rval == PRODUCT_TBEAM || rval == PRODUCT_T32_10 || rval == PRODUCT_T32_20 || rval == PRODUCT_T32_21 || rval == PRODUCT_H32_V2 || rval == PRODUCT_H32_V3) { #elif PLATFORM == PLATFORM_NRF52 if (rval == PRODUCT_HMBRW) { #else @@ -1319,6 +1319,8 @@ bool eeprom_model_valid() { if (model == MODEL_B4 || model == MODEL_B9) { #elif BOARD_MODEL == BOARD_HELTEC32_V2 if (model == MODEL_C4 || model == MODEL_C9) { + #elif BOARD_MODEL == BOARD_HELTEC32_V3 + if (model == MODEL_C5 || model == MODEL_CA) { #elif BOARD_MODEL == BOARD_RAK4630 if (model == MODEL_FF) { #elif BOARD_MODEL == BOARD_HUZZAH32 diff --git a/sx126x.cpp b/sx126x.cpp index fcf7371..a425e00 100644 --- a/sx126x.cpp +++ b/sx126x.cpp @@ -127,7 +127,7 @@ bool sx126x::preInit() { pinMode(_ss, OUTPUT); digitalWrite(_ss, HIGH); - #if BOARD_MODEL == BOARD_RNODE_NG_22 || BOARD_MODEL == BOARD_HELTEC_LORA32_V3 + #if BOARD_MODEL == BOARD_RNODE_NG_22 || BOARD_MODEL == BOARD_HELTEC32_V3 SPI.begin(pin_sclk, pin_miso, pin_mosi, pin_cs); #else SPI.begin(); @@ -717,7 +717,7 @@ void sx126x::sleep() void sx126x::enableTCXO() { #if HAS_TCXO - #if BOARD_MODEL == BOARD_RAK4630 || BOARD_MODEL == BOARD_HELTEC_LORA32_V3 + #if BOARD_MODEL == BOARD_RAK4630 || BOARD_MODEL == BOARD_HELTEC32_V3 uint8_t buf[4] = {MODE_TCXO_3_3V_6X, 0x00, 0x00, 0xFF}; #elif BOARD_MODEL == BOARD_TBEAM uint8_t buf[4] = {MODE_TCXO_1_8V_6X, 0x00, 0x00, 0xFF};