WIP: Booting and display working, Lora32 V3, debug and some
checks bypassed.
This commit is contained in:
parent
262518efef
commit
36ab438625
52
Boards.h
52
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
|
||||
|
|
46
Display.h
46
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) {
|
||||
|
|
10
Makefile
10
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
|
||||
|
|
|
@ -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) {
|
||||
|
|
14
Utilities.h
14
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); }
|
||||
|
|
Loading…
Reference in New Issue