Merge develop into main (#304)

## New

- Read property files with `PropertiesFile`
- Support `boot.properties` so the user can specify the launcher app and an optional app to start after the launcher finishes. (see `BootProperties.cpp`)
- Create registry for CPU affinity and update code to make use of it
- `AppRegistration` and `ServiceRegistration` now also ensure that the `/data` directories always exist for all apps
- `Notes` is now the default app for opening text files. `TextViewer` is removed entirely. Created `tt::app::notes::start(path)` function.
- WiFi settings moved from NVS to properties file.
- Specify `*.ap.properties` file on the SD card for automatic WiFi settings import on start-up.
- Added `file::getLock(path)` and `file::withLock(path, function)` to do safe file operations on SD cards

## Improvements

- Update TinyUSB to `1.7.6~1`
- Improved `Boot.cpp` code. General code quality fixes and some restructuring to improve readability.
- `tt::string` functionality improvements
- Rename `AppRegistry` to `AppRegistration`
- Rename `ServiceRegistry` to `ServiceRegistration`
- Cleanup in `Notes.cpp`
- `FileTest.cpp` fix for PC
- Created `TestFile` helper class for tests, which automatically deletes files after the test.
- Renamed `Partitions.h` to `MountPoints.h`
- Created `std::string getMountPoints()` function for easy re-use
- Other code quality improvements
- `SdCardDevice`'s `getState()` and `isMounted()` now have a timeout argument

## Fixes

- ELF loading now has a lock so to avoid a bug when 2 ELF apps are loaded in parallel
This commit is contained in:
Ken Van Hoeylandt
2025-08-23 17:10:18 +02:00
committed by GitHub
parent fbaff8cbac
commit ee5a5a7181
109 changed files with 1396 additions and 744 deletions
@@ -0,0 +1,27 @@
#pragma once
#include "RtosCompat.h"
namespace tt {
typedef portBASE_TYPE CpuAffinity;
constexpr static CpuAffinity None = -1;
/**
* Determines the preferred affinity for certain (sub)systems.
*/
struct CpuAffinityConfiguration {
CpuAffinity system;
CpuAffinity graphics; // Display, LVGL
CpuAffinity wifi;
CpuAffinity mainDispatcher;
CpuAffinity apps;
CpuAffinity timer; // Tactility Timer (based on FreeRTOS)
};
void setCpuAffinityConfiguration(const CpuAffinityConfiguration& config);
const CpuAffinityConfiguration& getCpuAffinityConfiguration();
}
+1 -1
View File
@@ -66,7 +66,7 @@ public:
explicit ScopedLock(const Lock& lockable) : lockable(lockable) {}
~ScopedLock() final {
~ScopedLock() override {
lockable.unlock(); // We don't care whether it succeeded or not
}
+3 -3
View File
@@ -43,18 +43,18 @@ public:
using Lock::lock;
explicit Mutex(Type type = Type::Normal);
~Mutex() final = default;
~Mutex() override = default;
/** Attempt to lock the mutex. Blocks until timeout passes or lock is acquired.
* @param[in] timeout
* @return success result
*/
bool lock(TickType_t timeout) const final;
bool lock(TickType_t timeout) const override;
/** Attempt to unlock the mutex.
* @return success result
*/
bool unlock() const final;
bool unlock() const override;
/** @return the owner of the thread */
ThreadId getOwner() const;
@@ -4,6 +4,7 @@
#include <cstdio>
#include <string>
#include <vector>
#include <functional>
namespace tt::string {
@@ -30,6 +31,16 @@ std::string getLastPathSegment(const std::string& path);
*/
std::vector<std::string> split(const std::string& input, const std::string& delimiter);
/**
* Splits the provided input into separate pieces with delimiter as separator text.
* When the input string is empty, the output list will be empty too.
*
* @param input the input to split up
* @param delimiter a non-empty string to recognize as separator
* @param callback the callback function that receives the split parts
*/
void split(const std::string& input, const std::string& delimiter, std::function<void(const std::string&)> callback);
/**
* Join a set of tokens into a single string, given a delimiter (separator).
* If the input is an empty list, the result will be an empty string.
+1 -1
View File
@@ -18,7 +18,7 @@ public:
private:
struct TimerHandleDeleter {
void operator()(TimerHandle_t handleToDelete) {
void operator()(TimerHandle_t handleToDelete) const {
xTimerDelete(handleToDelete, portMAX_DELAY);
}
};
@@ -44,7 +44,7 @@ void getIv(const void* data, size_t dataLength, uint8_t iv[16]);
* @param[in] dataLength data length, a multiple of 16 (for both inData and outData)
* @return the result of esp_aes_crypt_cbc() (MBEDTLS_ERR_*)
*/
int encrypt(const uint8_t iv[16], uint8_t* inData, uint8_t* outData, size_t dataLength);
int encrypt(const uint8_t iv[16], const uint8_t* inData, uint8_t* outData, size_t dataLength);
/**
* @brief Decrypt data.
@@ -58,6 +58,7 @@ int encrypt(const uint8_t iv[16], uint8_t* inData, uint8_t* outData, size_t data
* @param[in] dataLength data length, a multiple of 16 (for both inData and outData)
* @return the result of esp_aes_crypt_cbc() (MBEDTLS_ERR_*)
*/
int decrypt(const uint8_t iv[16], uint8_t* inData, uint8_t* outData, size_t dataLength);
int decrypt(const uint8_t iv[16], const uint8_t* inData, uint8_t* outData, size_t dataLength);
} // namespace
+17 -18
View File
@@ -7,28 +7,23 @@
#include <sys/stat.h>
#include <vector>
/**
* @warning SD card access requires a locking mechanism:
* @warning When using this in the Tactility main project, use `file::getLock()` or `file::withLock()`
*/
namespace tt::file {
/** File types for `dirent`'s `d_type`. */
enum {
TT_DT_UNKNOWN = 0,
#define TT_DT_UNKNOWN TT_DT_UNKNOWN // Unknown type
TT_DT_FIFO = 1,
#define TT_DT_FIFO TT_DT_FIFO // Named pipe or FIFO
TT_DT_CHR = 2,
#define TT_DT_CHR TT_DT_CHR // Character device
TT_DT_DIR = 4,
#define TT_DT_DIR TT_DT_DIR // Directory
TT_DT_BLK = 6,
#define TT_DT_BLK TT_DT_BLK // Block device
TT_DT_REG = 8,
#define TT_DT_REG TT_DT_REG // Regular file
TT_DT_LNK = 10,
#define TT_DT_LNK TT_DT_LNK // Symbolic link
TT_DT_SOCK = 12,
#define TT_DT_SOCK TT_DT_SOCK // Local-domain socket
TT_DT_WHT = 14
#define TT_DT_WHT TT_DT_WHT // Whiteout inodes
TT_DT_UNKNOWN = 0, // Unknown type
TT_DT_FIFO = 1, // Named pipe or FIFO
TT_DT_CHR = 2, // Character device
TT_DT_DIR = 4, // Directory
TT_DT_BLK = 6, // Block device
TT_DT_REG = 8, // Regular file
TT_DT_LNK = 10, // Symbolic link
TT_DT_SOCK = 12, // Local-domain socket
TT_DT_WHT = 14 // Whiteout inodes
};
#ifdef _WIN32
@@ -92,6 +87,10 @@ bool direntSortAlphaAndType(const dirent& left, const dirent& right);
/** A filter for filtering out "." and ".." */
int direntFilterDotEntries(const dirent* entry);
bool isFile(const std::string& path);
bool isDirectory(const std::string& path);
/**
* A scandir()-like implementation that works on ESP32.
* It does not return "." and ".." items but otherwise functions the same.
@@ -1,76 +0,0 @@
#pragma once
#include "File.h"
#include <cstdint>
#include <functional>
#include <string>
#include <utility>
namespace tt::file {
class ObjectFileReader {
private:
const std::string filePath;
const uint32_t recordSize = 0;
std::unique_ptr<FILE, FileCloser> file;
uint32_t recordCount = 0;
uint32_t recordVersion = 0;
uint32_t recordsRead = 0;
public:
ObjectFileReader(std::string filePath, uint32_t recordSize) :
filePath(std::move(filePath)),
recordSize(recordSize)
{}
bool open();
void close();
bool hasNext() const { return recordsRead < recordCount; }
bool readNext(void* output);
uint32_t getRecordCount() const { return recordCount; }
uint32_t getRecordSize() const { return recordSize; }
uint32_t getRecordVersion() const { return recordVersion; }
};
class ObjectFileWriter {
private:
const std::string filePath;
const uint32_t recordSize;
const uint32_t recordVersion;
const bool append;
std::unique_ptr<FILE, FileCloser> file;
uint32_t recordsWritten = 0;
public:
ObjectFileWriter(std::string filePath, uint32_t recordSize, uint32_t recordVersion, bool append) :
filePath(std::move(filePath)),
recordSize(recordSize),
recordVersion(recordVersion),
append(append)
{}
~ObjectFileWriter() {
if (file != nullptr) {
close();
}
}
bool open();
void close();
bool write(void* data);
};
}