Replaced Logger usage with LOG_x (#548)
This commit is contained in:
committed by
GitHub
parent
ecad2248d9
commit
9d5993930d
@@ -5,14 +5,14 @@
|
||||
#include <Tactility/hal/usb/Usb.h>
|
||||
#include <Tactility/hal/usb/UsbTusb.h>
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/driver.h>
|
||||
#include <tactility/drivers/esp32_sdcard.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
namespace tt::hal::usb {
|
||||
|
||||
static const auto LOGGER = Logger("USB");
|
||||
constexpr auto* TAG = "USB";
|
||||
|
||||
constexpr auto BOOT_FLAG_SDMMC = 42; // Existing
|
||||
constexpr auto BOOT_FLAG_FLASH = 43; // For flash mode
|
||||
@@ -38,7 +38,7 @@ sdmmc_card_t* getCard() {
|
||||
});
|
||||
|
||||
if (card == nullptr) {
|
||||
LOGGER.warn("Couldn't find a mounted SD card");
|
||||
LOG_W(TAG, "Couldn't find a mounted SD card");
|
||||
}
|
||||
|
||||
return card;
|
||||
@@ -54,7 +54,7 @@ bool isSupported() {
|
||||
|
||||
bool startMassStorageWithSdmmc(bool fromBootMode) {
|
||||
if (!canStartNewMode()) {
|
||||
LOGGER.error("Can't start");
|
||||
LOG_E(TAG, "Can't start");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ bool startMassStorageWithSdmmc(bool fromBootMode) {
|
||||
currentMode = Mode::MassStorageSdmmc;
|
||||
return true;
|
||||
} else {
|
||||
LOGGER.error("Failed to init mass storage");
|
||||
LOG_E(TAG, "Failed to init mass storage");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ void rebootIntoMassStorageSdmmc() {
|
||||
// NEW: Flash mass storage functions
|
||||
bool startMassStorageWithFlash(bool fromBootMode) {
|
||||
if (!canStartNewMode()) {
|
||||
LOGGER.error("Can't start flash mass storage");
|
||||
LOG_E(TAG, "Can't start flash mass storage");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ bool startMassStorageWithFlash(bool fromBootMode) {
|
||||
currentMode = Mode::MassStorageFlash;
|
||||
return true;
|
||||
} else {
|
||||
LOGGER.error("Failed to init flash mass storage");
|
||||
LOG_E(TAG, "Failed to init flash mass storage");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#if CONFIG_TINYUSB_MSC_ENABLED == 1
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <esp_system.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
@@ -15,6 +14,8 @@
|
||||
#include <tusb_msc_storage.h>
|
||||
#include <wear_levelling.h>
|
||||
|
||||
#include <tactility/log.h>
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32P4
|
||||
#include "hal/usb_wrap_ll.h"
|
||||
#endif
|
||||
@@ -23,7 +24,7 @@
|
||||
#define TUSB_DESC_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_MSC_DESC_LEN)
|
||||
#define SECTOR_SIZE 512
|
||||
|
||||
static const auto LOGGER = tt::Logger("USB");
|
||||
constexpr auto* TAG = "USB";
|
||||
|
||||
namespace tt::hal::usb {
|
||||
extern sdmmc_card_t* getCard();
|
||||
@@ -105,18 +106,18 @@ 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) {
|
||||
LOGGER.info("MSC Mounted");
|
||||
LOG_I(TAG, "MSC Mounted");
|
||||
// Storage is only (re)mounted into our own filesystem after the host sends a SCSI
|
||||
// START STOP UNIT eject (see tud_msc_start_stop_cb() in tusb_msc_storage.c). Windows
|
||||
// is known not to send this reliably, so this is a best-effort path for hosts that do
|
||||
// (e.g. Linux/macOS) - the "Return to OS" button on the boot screen is the primary one.
|
||||
// If we got here while booted into MSC mode, it's safe to reboot back into normal OS now.
|
||||
if (startedFromBootMode) {
|
||||
LOGGER.info("MSC ejected by host, rebooting into normal OS");
|
||||
LOG_I(TAG, "MSC ejected by host, rebooting into normal OS");
|
||||
esp_restart();
|
||||
}
|
||||
} else {
|
||||
LOGGER.info("MSC Unmounted");
|
||||
LOG_I(TAG, "MSC Unmounted");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +150,7 @@ static bool ensureDriverInstalled() {
|
||||
};
|
||||
|
||||
if (tinyusb_driver_install(&tusb_cfg) != ESP_OK) {
|
||||
LOGGER.error("Failed to install TinyUSB driver");
|
||||
LOG_E(TAG, "Failed to install TinyUSB driver");
|
||||
#if CONFIG_IDF_TARGET_ESP32P4
|
||||
// Roll back routing when TinyUSB did not start.
|
||||
usb_wrap_ll_phy_select(&USB_WRAP, 1);
|
||||
@@ -171,7 +172,7 @@ bool tusbStartMassStorageWithSdmmc(bool fromBootMode) {
|
||||
|
||||
auto* card = tt::hal::usb::getCard();
|
||||
if (card == nullptr) {
|
||||
LOGGER.error("SD card not mounted");
|
||||
LOG_E(TAG, "SD card not mounted");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -190,16 +191,16 @@ bool tusbStartMassStorageWithSdmmc(bool fromBootMode) {
|
||||
|
||||
auto result = tinyusb_msc_storage_init_sdmmc(&config_sdmmc);
|
||||
if (result != ESP_OK) {
|
||||
LOGGER.error("TinyUSB SDMMC init failed: {}", esp_err_to_name(result));
|
||||
LOG_E(TAG, "TinyUSB SDMMC init failed: %s", esp_err_to_name(result));
|
||||
} else {
|
||||
LOGGER.info("TinyUSB SDMMC init success");
|
||||
LOG_I(TAG, "TinyUSB SDMMC init success");
|
||||
}
|
||||
|
||||
return result == ESP_OK;
|
||||
}
|
||||
|
||||
bool tusbStartMassStorageWithFlash(bool fromBootMode) {
|
||||
LOGGER.info("Starting flash MSC");
|
||||
LOG_I(TAG, "Starting flash MSC");
|
||||
if (!ensureDriverInstalled()) {
|
||||
return false;
|
||||
}
|
||||
@@ -207,7 +208,7 @@ bool tusbStartMassStorageWithFlash(bool fromBootMode) {
|
||||
|
||||
wl_handle_t handle = tt::getDataPartitionWlHandle();
|
||||
if (handle == WL_INVALID_HANDLE) {
|
||||
LOGGER.error("WL not mounted for /data");
|
||||
LOG_E(TAG, "WL not mounted for /data");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -226,9 +227,9 @@ bool tusbStartMassStorageWithFlash(bool fromBootMode) {
|
||||
|
||||
esp_err_t result = tinyusb_msc_storage_init_spiflash(&config_flash);
|
||||
if (result != ESP_OK) {
|
||||
LOGGER.error("TinyUSB flash init failed: {}", esp_err_to_name(result));
|
||||
LOG_E(TAG, "TinyUSB flash init failed: %s", esp_err_to_name(result));
|
||||
} else {
|
||||
LOGGER.info("TinyUSB flash init success");
|
||||
LOG_I(TAG, "TinyUSB flash init success");
|
||||
}
|
||||
return result == ESP_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user