diff --git a/Documentation/ideas.md b/Documentation/ideas.md index f70e25e0..76b8286a 100644 --- a/Documentation/ideas.md +++ b/Documentation/ideas.md @@ -31,10 +31,6 @@ - Support direct installation of an `.app` file with `tactility.py install helloworld.app ` - Support `tactility.py target ` to remember the device IP address. - minitar/untarFile(): "entry->metadata.path" can escape its confined path (e.g. "../something") -- Consider these defaults when PSRAM is present: - CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y - CONFIG_SPIRAM_RODATA=y - CONFIG_SPIRAM_XIP_FROM_PSRAM=y ## Medium Priority diff --git a/Tactility/Include/Tactility/app/AppManifest.h b/Tactility/Include/Tactility/app/AppManifest.h index 1c4e611a..0b363b7f 100644 --- a/Tactility/Include/Tactility/app/AppManifest.h +++ b/Tactility/Include/Tactility/app/AppManifest.h @@ -82,7 +82,7 @@ struct AppManifest { std::string appVersionName = {}; /** The technical version (must be incremented with new releases of the app */ - uint64_t appVersionCode = {}; + uint64_t appVersionCode = 0; /** App category helps with listing apps in Launcher, app list or settings apps. */ Category appCategory = Category::User; @@ -91,7 +91,7 @@ struct AppManifest { Location appLocation = Location::internal(); /** Controls various settings */ - uint32_t appFlags = Flags::None; + uint16_t appFlags = Flags::None; /** Create the instance of the app */ CreateApp createApp = nullptr; diff --git a/Tactility/Include/Tactility/hal/uart/Configuration.h b/Tactility/Include/Tactility/hal/uart/Configuration.h index 72d0942a..733afb10 100644 --- a/Tactility/Include/Tactility/hal/uart/Configuration.h +++ b/Tactility/Include/Tactility/hal/uart/Configuration.h @@ -1,5 +1,7 @@ #pragma once +#include "UartCompat.h" + namespace tt::hal::uart { #ifdef ESP_PLATFORM @@ -7,7 +9,7 @@ namespace tt::hal::uart { struct Configuration { /** The unique name for this UART */ std::string name; - /** The port idenitifier (e.g. UART_NUM_0) */ + /** The port identifier (e.g. UART_NUM_0) */ uart_port_t port; /** Receive GPIO pin */ gpio_num_t rxPin; @@ -25,12 +27,13 @@ struct Configuration { uart_config_t config; }; - #else struct Configuration { /** The unique name for this UART */ std::string name; + /** The port identifier (e.g. UART_NUM_0) */ + uart_port_t port; /** Initial baud rate in bits per second */ uint32_t baudRate; }; diff --git a/Tactility/Include/Tactility/hal/uart/Uart.h b/Tactility/Include/Tactility/hal/uart/Uart.h index da5f3003..6ea54e7b 100644 --- a/Tactility/Include/Tactility/hal/uart/Uart.h +++ b/Tactility/Include/Tactility/hal/uart/Uart.h @@ -119,6 +119,13 @@ public: */ std::unique_ptr open(std::string name); +/** + * Opens a UART. + * @param[in] port the UART port as specified in the board configuration. + * @return the UART when it was successfully opened, or nullptr when it is in use. + */ +std::unique_ptr open(uart_port_t port); + std::vector getNames(); } // namespace tt::hal::uart diff --git a/Tactility/Source/hal/Device.cpp b/Tactility/Source/hal/Device.cpp index 2b18203d..75890b43 100644 --- a/Tactility/Source/hal/Device.cpp +++ b/Tactility/Source/hal/Device.cpp @@ -1,6 +1,7 @@ #include "Tactility/hal/Device.h" #include +#include namespace tt::hal { diff --git a/Tactility/Source/hal/uart/Uart.cpp b/Tactility/Source/hal/uart/Uart.cpp index 4bac75f6..c647b8f1 100644 --- a/Tactility/Source/hal/uart/Uart.cpp +++ b/Tactility/Source/hal/uart/Uart.cpp @@ -100,6 +100,34 @@ size_t Uart::readUntil(std::byte* buffer, size_t bufferSize, uint8_t untilByte, } } +static std::unique_ptr open(UartEntry& entry) { + if (entry.usageId != uartIdNotInUse) { + TT_LOG_E(TAG, "UART in use: %s", entry.configuration.name.c_str()); + return nullptr; + } + + auto uart = create(entry.configuration); + assert(uart != nullptr); + entry.usageId = uart->getId(); + TT_LOG_I(TAG, "Opened %lu", entry.usageId); + return uart; +} + +std::unique_ptr open(uart_port_t port) { + TT_LOG_I(TAG, "Open %d", port); + + auto result = std::views::filter(uartEntries, [port](auto& entry) { + return entry.configuration.port == port; + }); + + if (result.empty()) { + TT_LOG_E(TAG, "UART not found: %d", port); + return nullptr; + } + + return open(*result.begin()); +} + std::unique_ptr open(std::string name) { TT_LOG_I(TAG, "Open %s", name.c_str()); @@ -112,17 +140,7 @@ std::unique_ptr open(std::string name) { return nullptr; } - auto& entry = *result.begin(); - if (entry.usageId != uartIdNotInUse) { - TT_LOG_E(TAG, "UART in use: %s", name.c_str()); - return nullptr; - } - - auto uart = create(entry.configuration); - assert(uart != nullptr); - entry.usageId = uart->getId(); - TT_LOG_I(TAG, "Opened %lu", entry.usageId); - return uart; + return open(*result.begin()); } void close(uint32_t uartId) { diff --git a/device.py b/device.py index 1ef893b4..e30fa276 100644 --- a/device.py +++ b/device.py @@ -148,16 +148,26 @@ def write_spiram_variables(output_file, device_properties: ConfigParser): # Speed output_file.write(f"CONFIG_SPIRAM_SPEED_{speed}=y\n") output_file.write(f"CONFIG_SPIRAM_SPEED={speed}\n") - # IRAM memory optimization + # Reduce IRAM usage output_file.write("CONFIG_SPIRAM_USE_MALLOC=y\n") output_file.write("CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y\n") - # Boot speed optimization - output_file.write("CONFIG_SPIRAM_MEMTEST=n\n") + # Performance improvements + if idf_target == "esp32s3": + output_file.write("CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y\n") + output_file.write("CONFIG_SPIRAM_RODATA=y\n") + output_file.write("CONFIG_SPIRAM_XIP_FROM_PSRAM=y\n") -def write_rgb_display_glitch_fix(output_file, device_properties: ConfigParser): - enabled = get_boolean_property_or_false(device_properties, "hardware", "fixRgbDisplayGlitch") - if enabled: - output_file.write("# Fixes glitches in the display driver when rendering new screens/apps\n") +def write_performance_improvements(output_file, device_properties: ConfigParser): + idf_target = get_property_or_exit(device_properties, "hardware", "target") + output_file.write("# Free up IRAM\n") + output_file.write("CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y\n") + output_file.write("CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y\n") + output_file.write("CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH=y\n") + output_file.write("CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y\n") + output_file.write("# Boot speed optimization\n") + output_file.write("CONFIG_SPIRAM_MEMTEST=n\n") + if idf_target == "esp32s3": + output_file.write("# Performance improvement: Fixes glitches in the RGB display driver when rendering new screens/apps\n") output_file.write("CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y\n") def write_lvgl_variables(output_file, device_properties: ConfigParser): @@ -179,16 +189,6 @@ def write_lvgl_variables(output_file, device_properties: ConfigParser): else: exit_with_error(f"Unknown theme: {theme}") -def write_iram_fix(output_file, device_properties: ConfigParser): - idf_target = get_property_or_exit(device_properties, "hardware", "target") - if idf_target == "ESP32": - # TODO: Try on ESP32S3 - output_file.write("# Free up IRAM on ESP32\n") - output_file.write("CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y\n") - output_file.write("CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y\n") - output_file.write("CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH=y\n") - output_file.write("CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y\n") - def write_usb_variables(output_file, device_properties: ConfigParser): has_tiny_usb = get_boolean_property_or_false(device_properties, "hardware", "tinyUsb") if has_tiny_usb: @@ -212,9 +212,8 @@ def write_properties(output_file, device_properties: ConfigParser, device_id: st write_flash_variables(output_file, device_properties) write_partition_table(output_file, device_properties, is_dev) write_spiram_variables(output_file, device_properties) - write_rgb_display_glitch_fix(output_file, device_properties) write_lvgl_variables(output_file, device_properties) - write_iram_fix(output_file, device_properties) + write_performance_improvements(output_file, device_properties) write_usb_variables(output_file, device_properties) write_custom_sdkconfig(output_file, device_properties)