New logging and more (#446)

- `TT_LOG_*` macros are replaced by `Logger` via `#include<Tactility/Logger.h>`
- Changed default timezone to Europe/Amsterdam
- Fix for logic bug in unPhone hardware
- Fix for init/deinit in DRV2605 driver
- Other fixes
- Removed optimization that broke unPhone (disabled the moving of heap-related functions to flash)
This commit is contained in:
Ken Van Hoeylandt
2026-01-06 22:35:39 +01:00
committed by GitHub
parent 719f7bcece
commit f620255c41
188 changed files with 1973 additions and 1755 deletions
+9 -8
View File
@@ -4,11 +4,12 @@
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/hal/usb/UsbTusb.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
namespace tt::hal::usb {
constexpr auto* TAG = "usb";
static const auto LOGGER = Logger("USB");
constexpr auto BOOT_FLAG_SDMMC = 42; // Existing
constexpr auto BOOT_FLAG_FLASH = 43; // For flash mode
@@ -32,13 +33,13 @@ sdmmc_card_t* _Nullable getCard() {
}
if (usable_sdcard == nullptr) {
TT_LOG_W(TAG, "Couldn't find a mounted SpiSdCard");
LOGGER.warn("Couldn't find a mounted SpiSdCard");
return nullptr;
}
auto* sdmmc_card = usable_sdcard->getCard();
if (sdmmc_card == nullptr) {
TT_LOG_W(TAG, "SD card has no card object available");
LOGGER.warn("SD card has no card object available");
return nullptr;
}
@@ -55,7 +56,7 @@ bool isSupported() {
bool startMassStorageWithSdmmc() {
if (!canStartNewMode()) {
TT_LOG_E(TAG, "Can't start");
LOGGER.error("Can't start");
return false;
}
@@ -63,7 +64,7 @@ bool startMassStorageWithSdmmc() {
currentMode = Mode::MassStorageSdmmc;
return true;
} else {
TT_LOG_E(TAG, "Failed to init mass storage");
LOGGER.error("Failed to init mass storage");
return false;
}
}
@@ -96,7 +97,7 @@ void rebootIntoMassStorageSdmmc() {
// NEW: Flash mass storage functions
bool startMassStorageWithFlash() {
if (!canStartNewMode()) {
TT_LOG_E(TAG, "Can't start flash mass storage");
LOGGER.error("Can't start flash mass storage");
return false;
}
@@ -104,7 +105,7 @@ bool startMassStorageWithFlash() {
currentMode = Mode::MassStorageFlash;
return true;
} else {
TT_LOG_E(TAG, "Failed to init flash mass storage");
LOGGER.error("Failed to init flash mass storage");
return false;
}
}
-2
View File
@@ -2,8 +2,6 @@
#include "Tactility/hal/usb/Usb.h"
#define TAG "usb"
namespace tt::hal::usb {
bool startMassStorageWithSdmmc() { return false; }
+13 -12
View File
@@ -7,16 +7,17 @@
#if CONFIG_TINYUSB_MSC_ENABLED == 1
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <tinyusb.h>
#include <tusb_msc_storage.h>
#include <wear_levelling.h>
#define TAG "usb"
#define EPNUM_MSC 1
#define TUSB_DESC_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_MSC_DESC_LEN)
#define SECTOR_SIZE 512
static const auto LOGGER = tt::Logger("USB");
namespace tt::hal::usb {
extern sdmmc_card_t* _Nullable getCard();
}
@@ -93,9 +94,9 @@ static uint8_t const msc_hs_configuration_desc[] = {
static void storage_mount_changed_cb(tinyusb_msc_event_t* event) {
if (event->mount_changed_data.is_mounted) {
TT_LOG_I(TAG, "MSC Mounted");
LOGGER.info("MSC Mounted");
} else {
TT_LOG_I(TAG, "MSC Unmounted");
LOGGER.info("MSC Unmounted");
}
}
@@ -121,7 +122,7 @@ static bool ensureDriverInstalled() {
};
if (tinyusb_driver_install(&tusb_cfg) != ESP_OK) {
TT_LOG_E(TAG, "Failed to install TinyUSB driver");
LOGGER.error("Failed to install TinyUSB driver");
return false;
}
@@ -136,7 +137,7 @@ bool tusbStartMassStorageWithSdmmc() {
auto* card = tt::hal::usb::getCard();
if (card == nullptr) {
TT_LOG_E(TAG, "SD card not mounted");
LOGGER.error("SD card not mounted");
return false;
}
@@ -155,21 +156,21 @@ bool tusbStartMassStorageWithSdmmc() {
auto result = tinyusb_msc_storage_init_sdmmc(&config_sdmmc);
if (result != ESP_OK) {
TT_LOG_E(TAG, "TinyUSB SDMMC init failed: %s", esp_err_to_name(result));
LOGGER.error("TinyUSB SDMMC init failed: {}", esp_err_to_name(result));
} else {
TT_LOG_I(TAG, "TinyUSB SDMMC init success");
LOGGER.info("TinyUSB SDMMC init success");
}
return result == ESP_OK;
}
bool tusbStartMassStorageWithFlash() {
TT_LOG_I(TAG, "Starting flash MSC");
LOGGER.info("Starting flash MSC");
ensureDriverInstalled();
wl_handle_t handle = tt::getDataPartitionWlHandle();
if (handle == WL_INVALID_HANDLE) {
TT_LOG_E(TAG, "WL not mounted for /data");
LOGGER.error("WL not mounted for /data");
return false;
}
@@ -188,9 +189,9 @@ bool tusbStartMassStorageWithFlash() {
esp_err_t result = tinyusb_msc_storage_init_spiflash(&config_flash);
if (result != ESP_OK) {
TT_LOG_E(TAG, "TinyUSB flash init failed: %s", esp_err_to_name(result));
LOGGER.error("TinyUSB flash init failed: {}", esp_err_to_name(result));
} else {
TT_LOG_I(TAG, "TinyUSB flash init success");
LOGGER.info("TinyUSB flash init success");
}
return result == ESP_OK;
}