diff --git a/src/modules/ExternalNotificationModule.h b/src/modules/ExternalNotificationModule.h index 03eac036bb6..694413853a6 100644 --- a/src/modules/ExternalNotificationModule.h +++ b/src/modules/ExternalNotificationModule.h @@ -23,7 +23,8 @@ extern AmbientLightingThread *ambientLightingThread; #endif #endif -#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(CONFIG_IDF_TARGET_ESP32C6) +#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(CONFIG_IDF_TARGET_ESP32C6) && \ + !defined(CONFIG_IDF_TARGET_ESP32H2) #include #else // Noop class for portduino. diff --git a/src/modules/SerialModule.cpp b/src/modules/SerialModule.cpp index 23e8e9790a6..5a5fb6eae01 100644 --- a/src/modules/SerialModule.cpp +++ b/src/modules/SerialModule.cpp @@ -175,7 +175,7 @@ int32_t SerialModule::runOnce() // Give it a chance to flush out 💩 delay(10); } -#if defined(CONFIG_IDF_TARGET_ESP32C6) +#if defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32H2) if (moduleConfig.serial.rxd && moduleConfig.serial.txd) { Serial1.setRxBufferSize(RX_BUFFER); Serial1.begin(baud, SERIAL_8N1, moduleConfig.serial.rxd, moduleConfig.serial.txd); @@ -279,7 +279,7 @@ int32_t SerialModule::runOnce() } #endif else { -#if defined(CONFIG_IDF_TARGET_ESP32C6) +#if defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32H2) while (Serial1.available()) { serialPayloadSize = Serial1.readBytes(serialBytes, meshtastic_Constants_DATA_PAYLOAD_LEN); #else @@ -542,8 +542,7 @@ ParsedLine parseLine(const char *line) */ void SerialModule::processWXSerial() { -#if SERIAL_PRINT_PORT != 0 && !defined(ARCH_STM32WL) && !defined(CONFIG_IDF_TARGET_ESP32C6) - +#if SERIAL_PRINT_PORT != 0 && !defined(ARCH_STM32WL) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2) static unsigned int lastAveraged = 0; static unsigned int averageIntervalMillis = 300000; // 5 minutes hard coded. static double dir_sum_sin = 0; diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index afbf4482d1f..e75581a6a10 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -277,6 +277,8 @@ void esp32Setup() // #define APP_WATCHDOG_SECS 45 #define APP_WATCHDOG_SECS 90 +// esp_task_wdt_init returns an unknown error, so skip it on ESP32H2 +#ifndef CONFIG_IDF_TARGET_ESP32H2 #if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0) const esp_task_wdt_config_t wdt_config = { .timeout_ms = APP_WATCHDOG_SECS * 1000, @@ -302,7 +304,7 @@ void esp32Setup() res = esp_task_wdt_add(NULL); } assert(res == ESP_OK); - +#endif #if HAS_32768HZ enableSlowCLK(); #endif @@ -311,7 +313,9 @@ void esp32Setup() /// loop code specific to ESP32 targets void esp32Loop() { +#ifndef CONFIG_IDF_TARGET_ESP32H2 esp_task_wdt_reset(); // service our app level watchdog +#endif // for debug printing // radio.radioIf.canSleep(); @@ -344,9 +348,10 @@ void cpuDeepSleep(uint32_t msecToWake) 13, #endif 34, 35, 37}; - +#ifndef CONFIG_IDF_TARGET_ESP32H2 for (int i = 0; i < sizeof(rtcGpios); i++) rtc_gpio_isolate((gpio_num_t)rtcGpios[i]); +#endif #endif // FIXME, disable internal rtc pullups/pulldowns on the non isolated pins. for inputs that we aren't using diff --git a/src/sleep.cpp b/src/sleep.cpp index 370c3338a15..6d451971958 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -564,6 +564,8 @@ void enableModemSleep() esp32_config.max_freq_mhz = CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ; #elif CONFIG_IDF_TARGET_ESP32C6 esp32_config.max_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ; +#elif CONFIG_IDF_TARGET_ESP32H2 + esp32_config.max_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ; #elif CONFIG_IDF_TARGET_ESP32C3 esp32_config.max_freq_mhz = CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ; #elif CONFIG_IDF_TARGET_ESP32P4 diff --git a/variants/esp32h2/esp32h2.ini b/variants/esp32h2/esp32h2.ini new file mode 100644 index 00000000000..045790600e1 --- /dev/null +++ b/variants/esp32h2/esp32h2.ini @@ -0,0 +1,26 @@ +[esp32h2_base] +extends = esp32_common +custom_esp32_kind = esp32h2 + +build_flags = + ${esp32_common.build_flags} + -DHAS_WIFI=0 + -DMESHTASTIC_EXCLUDE_WIFI=1 ; TODO + -DMESHTASTIC_EXCLUDE_MQTT=1 + -DMESHTASTIC_EXCLUDE_PAXCOUNTER=1 + -DMESHTASTIC_EXCLUDE_WEBSERVER=1 + +build_unflags= + -DHAS_UDP_MULTICAST=1 + +build_src_filter = + ${esp32_common.build_src_filter} - + +monitor_speed = 460800 +monitor_filters = esp32_h2_exception_decoder + +lib_ignore = + ${esp32_common.lib_ignore} + libpax + esp32_idf5_https_server + esp_http_server diff --git a/variants/esp32h2/waveshare-esp32-h2/platformio.ini b/variants/esp32h2/waveshare-esp32-h2/platformio.ini new file mode 100644 index 00000000000..413bfd72db6 --- /dev/null +++ b/variants/esp32h2/waveshare-esp32-h2/platformio.ini @@ -0,0 +1,12 @@ +[env:waveshare-esp32h2] +extends = esp32h2_base +board = esp32-h2-devkitm-1 +board_build.f_flash = 16000000L +; Set this back to 'pr' once the CI plumbing is in place. +; board_level = pr +board_level = extra +build_flags = + ${esp32h2_base.build_flags} + -I variants/esp32h2/waveshare-esp32-h2 + -DARDUINO_USB_CDC_ON_BOOT=1 + -DARDUINO_USB_MODE=1 diff --git a/variants/esp32h2/waveshare-esp32-h2/variant.h b/variants/esp32h2/waveshare-esp32-h2/variant.h new file mode 100644 index 00000000000..34110c4e0af --- /dev/null +++ b/variants/esp32h2/waveshare-esp32-h2/variant.h @@ -0,0 +1,9 @@ + +#define HAS_SCREEN 0 + +#define SERIAL_PRINT_PORT 1 + +#define LORA_SCK 4 +#define LORA_MISO 3 +#define LORA_MOSI 2 +#define LORA_CS 1