Merge develop into main (#419)

- Apply IRAM optimization to all platforms instead of only ESP32
- Implement performance optimizations
- Created `tt::hal::uart::open(uart_port_t)`
This commit is contained in:
Ken Van Hoeylandt 2025-11-23 00:11:08 +01:00 committed by GitHub
parent eba1f8955a
commit 6ab6ae5686
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 62 additions and 38 deletions

View File

@ -31,10 +31,6 @@
- Support direct installation of an `.app` file with `tactility.py install helloworld.app <ip>`
- Support `tactility.py target <ip>` 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

View File

@ -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;

View File

@ -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;
};

View File

@ -119,6 +119,13 @@ public:
*/
std::unique_ptr<Uart> 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<Uart> open(uart_port_t port);
std::vector<std::string> getNames();
} // namespace tt::hal::uart

View File

@ -1,6 +1,7 @@
#include "Tactility/hal/Device.h"
#include <Tactility/Mutex.h>
#include <algorithm>
namespace tt::hal {

View File

@ -100,6 +100,34 @@ size_t Uart::readUntil(std::byte* buffer, size_t bufferSize, uint8_t untilByte,
}
}
static std::unique_ptr<Uart> 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<Uart> 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<Uart> open(std::string name) {
TT_LOG_I(TAG, "Open %s", name.c_str());
@ -112,17 +140,7 @@ std::unique_ptr<Uart> 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) {

View File

@ -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)