From f8c7e2a36dcece484c1ff472ff4fa6561785523b Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Fri, 16 Jan 2026 12:08:11 +0100 Subject: [PATCH] move to espidf + arduino, this reduces flash size a shitload --- .gitignore | 2 ++ CMakeLists.txt | 3 +++ platformio.ini | 5 +++-- sdkconfig.defaults | 50 ++++++++++++++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 6 ++++++ src/main.cpp | 16 +++++++++++++-- 6 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 sdkconfig.defaults create mode 100644 src/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 89cc49c..c231dd7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ .vscode/c_cpp_properties.json .vscode/launch.json .vscode/ipch +sdkconfig** +!sdkconfig.defaults \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ed629c9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16.0) +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(TEF6686_ESP32) diff --git a/platformio.ini b/platformio.ini index 1499847..3db78a5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -6,7 +6,8 @@ platform = espressif32 upload_speed = 921600 monitor_speed = 115200 board = esp32dev -framework = arduino +framework = arduino, espidf +board_build.f_flash = 80000000L board_build.partitions = maxapp.csv build_flags = -Wall @@ -18,8 +19,8 @@ build_flags = -ffunction-sections -fdata-sections -Wl,--gc-sections - -DARDUINO_LOOP_STACK_SIZE=4096 -Werror + -Wno-error=missing-field-initializers monitor_filters = esp32_exception_decoder default diff --git a/sdkconfig.defaults b/sdkconfig.defaults new file mode 100644 index 0000000..8479f90 --- /dev/null +++ b/sdkconfig.defaults @@ -0,0 +1,50 @@ +CONFIG_APP_EXCLUDE_PROJECT_VER_VAR=y +CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR=y +CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y +CONFIG_ESPTOOLPY_FLASHFREQ_80M=y +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_BEFORE_NORESET=y +CONFIG_ESPTOOLPY_AFTER_NORESET=y +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="maxapp.csv" +CONFIG_ARDUINO_RUN_CORE0=y +CONFIG_ARDUINO_SELECTIVE_COMPILATION=y +# CONFIG_ARDUINO_SELECTIVE_AsyncUDP is not set +# CONFIG_ARDUINO_SELECTIVE_AzureIoT is not set +# CONFIG_ARDUINO_SELECTIVE_BLE is not set +# CONFIG_ARDUINO_SELECTIVE_BluetoothSerial is not set +# CONFIG_ARDUINO_SELECTIVE_EEPROM is not set +# CONFIG_ARDUINO_SELECTIVE_FFat is not set +# CONFIG_ARDUINO_SELECTIVE_HTTPClient is not set +# CONFIG_ARDUINO_SELECTIVE_LITTLEFS is not set +# CONFIG_ARDUINO_SELECTIVE_NetBIOS is not set +# CONFIG_ARDUINO_SELECTIVE_Preferences is not set +# CONFIG_ARDUINO_SELECTIVE_SD is not set +# CONFIG_ARDUINO_SELECTIVE_SD_MMC is not set +# CONFIG_ARDUINO_SELECTIVE_SimpleBLE is not set +# CONFIG_ARDUINO_SELECTIVE_Ticker is not set +# CONFIG_ARDUINO_SELECTIVE_Update is not set +# CONFIG_ARDUINO_SELECTIVE_WiFiClientSecure is not set +# CONFIG_ARDUINO_SELECTIVE_WiFiProv is not set +CONFIG_COMPILER_OPTIMIZATION_SIZE=y +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y +CONFIG_ESP32_REV_MIN_1=y +# CONFIG_ETH_USE_ESP32_EMAC is not set +# CONFIG_ETH_USE_SPI_ETHERNET is not set +# CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS is not set +# CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH is not set +CONFIG_FREERTOS_HZ=1000 +CONFIG_HAL_ASSERTION_DISABLE=y +CONFIG_LOG_DEFAULT_LEVEL_ERROR=y +# CONFIG_LOG_COLORS is not set +CONFIG_MBEDTLS_PSK_MODES=y +CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y +# CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK is not set +# CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK is not set +# CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_PSK is not set +# CONFIG_MQTT_PROTOCOL_311 is not set +# CONFIG_MQTT_TRANSPORT_SSL is not set +CONFIG_SPIFFS_MAX_PARTITIONS=1 +# CONFIG_SPIFFS_USE_MTIME is not set +# CONFIG_WS_TRANSPORT is not set +# CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER is not set diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..483bc0c --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,6 @@ +# This file was automatically generated for projects +# without default 'CMakeLists.txt' file. + +FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*) + +idf_component_register(SRCS ${app_sources}) diff --git a/src/main.cpp b/src/main.cpp index 44783d0..76f5aaf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,9 @@ using fs::FS; #include "nonvolatile.h" #include "utils.h" #include "system_console.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "esp_task_wdt.h" #pragma endregion Console console(&tft); @@ -846,7 +849,7 @@ int GetNum() { // According to the docs, register 0 contains pins IO0_x where x is equal to the bit from the right (x = 7, is MSB) int cnt = 0; - int16_t temp; + uint16_t temp; unsigned int num; if(Wire.available() == 2) { keypadtimer = millis(); @@ -3958,4 +3961,13 @@ uint8_t doAutoMemory(uint16_t startfreq, uint16_t stopfreq, uint8_t startmem, ui SQ = false; return error; -} \ No newline at end of file +} + +extern "C" void app_main() { + initArduino(); + setup(); + while(true) { + loop(); + esp_task_wdt_reset(); + } +}