Various improvements (#461)
* **New Features** * Time and delay utilities added (ticks, ms, µs); SD card now uses an expansion-header CS pin; HTTP downloads warn when run on the GUI task and yield to avoid blocking. * **Bug Fixes / Reliability** * Many hard-crash paths converted to guarded checks to reduce abrupt termination and improve stability. * **Tests** * Unit tests added to validate time and delay accuracy. * **Chores** * License header and build/macro updates.
This commit is contained in:
committed by
GitHub
parent
619b5aa53b
commit
e6abd496f9
@@ -0,0 +1,39 @@
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/FreeRTOS/task.h>
|
||||
|
||||
static const auto* TAG = LOG_TAG("Kernel");
|
||||
|
||||
static void log_memory_info() {
|
||||
#ifdef ESP_PLATFORM
|
||||
LOG_E(TAG, "Default memory caps:");
|
||||
LOG_E(TAG, " Total: %" PRIu64, static_cast<uint64_t>(heap_caps_get_total_size(MALLOC_CAP_DEFAULT)));
|
||||
LOG_E(TAG, " Free: %" PRIu64, static_cast<uint64_t>(heap_caps_get_free_size(MALLOC_CAP_DEFAULT)));
|
||||
LOG_E(TAG, " Min free: %" PRIu64, static_cast<uint64_t>(heap_caps_get_minimum_free_size(MALLOC_CAP_DEFAULT)));
|
||||
LOG_E(TAG, "Internal memory caps:");
|
||||
LOG_E(TAG, " Total: %" PRIu64, static_cast<uint64_t>(heap_caps_get_total_size(MALLOC_CAP_INTERNAL)));
|
||||
LOG_E(TAG, " Free: %" PRIu64, static_cast<uint64_t>(heap_caps_get_free_size(MALLOC_CAP_INTERNAL)));
|
||||
LOG_E(TAG, " Min free: %" PRIu64, static_cast<uint64_t>(heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL)));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void log_task_info() {
|
||||
const char* name = pcTaskGetName(nullptr);
|
||||
const char* safe_name = name ? name : "main";
|
||||
LOG_E(TAG, "Task: %s", safe_name);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
__attribute__((noreturn)) void __crash(void) {
|
||||
log_task_info();
|
||||
log_memory_info();
|
||||
// TODO: Add breakpoint when debugger is attached.
|
||||
#ifdef ESP_PLATFORM
|
||||
esp_system_abort("System halted. Connect debugger for more info.");
|
||||
#else
|
||||
while (true) { /* Indefinite lock-up */ }
|
||||
#endif
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -70,7 +70,6 @@ static error_t driver_remove(Driver* driver) {
|
||||
|
||||
ledger.lock();
|
||||
const auto iterator = std::ranges::find(ledger.drivers, driver);
|
||||
// check that there actually is a 3 in our vector
|
||||
if (iterator == ledger.drivers.end()) {
|
||||
ledger.unlock();
|
||||
return ERROR_NOT_FOUND;
|
||||
@@ -184,7 +183,7 @@ error_t driver_unbind(Driver* driver, Device* device) {
|
||||
driver_internal_data(driver)->use_count--;
|
||||
driver_unlock(driver);
|
||||
|
||||
LOG_I(TAG, "unbound %s to %s", driver->name, device->name);
|
||||
LOG_I(TAG, "unbound %s from %s", driver->name, device->name);
|
||||
|
||||
return ERROR_NONE;
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
void log_generic(const char* tag, const char* format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
@@ -16,4 +18,6 @@ void log_generic(const char* tag, const char* format, ...) {
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -48,7 +48,7 @@ error_t event_group_wait(
|
||||
uint32_t* outFlags,
|
||||
TickType_t timeout
|
||||
) {
|
||||
if (xPortInIsrContext()) {
|
||||
if (xPortInIsrContext() == pdTRUE) {
|
||||
return ERROR_ISR_STATUS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user