Drop newlib printf: log via BDK s_vprintf, add debug.ini log switch
log_write was the only vsnprintf user and pulled in newlib's printf, dtoa, malloc and soft-float code (~44 KB). The payload now fits the RCM limit again (146800 -> 102801 bytes); the build fails if it grows past it. debug.ini log=1 writes sd:/config/omninx/install.log.
This commit is contained in:
1 parent
555ff07ae4
commit
702cce7d3e
7 files changed
+205
-156
No files matched your search
+13
-7
@@ -9,14 +9,15 @@
|
||||
#include <string.h>
|
||||
#include <utils/sprintf.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define FS_BUFFER_SIZE 0x100000 // 1MB copy buffer
|
||||
#define LOG_BUFFER_SIZE 512
|
||||
#define LOG_BUFFER_SIZE 1024 // fits two 255-char paths plus text
|
||||
#define LOG_SYNC_EVERY 16
|
||||
|
||||
// Log file handle
|
||||
static FIL log_file;
|
||||
static bool log_enabled = false;
|
||||
static u32 log_lines;
|
||||
static char log_buf[LOG_BUFFER_SIZE];
|
||||
|
||||
// Initialize log file
|
||||
@@ -24,6 +25,7 @@ void log_init(const char *path) {
|
||||
int res = f_open(&log_file, path, FA_WRITE | FA_CREATE_ALWAYS);
|
||||
if (res == FR_OK) {
|
||||
log_enabled = true;
|
||||
log_lines = 0;
|
||||
log_write("=== OmniNX Installer Log ===\n\n");
|
||||
}
|
||||
}
|
||||
@@ -44,15 +46,19 @@ void log_write(const char *fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
// Format the message
|
||||
vsnprintf(log_buf, LOG_BUFFER_SIZE, fmt, args);
|
||||
// BDK formatter (no newlib printf). Callers keep paths <= 255 chars.
|
||||
u32 len = s_vprintf(log_buf, fmt, args);
|
||||
|
||||
va_end(args);
|
||||
|
||||
// Write to file
|
||||
UINT bw;
|
||||
f_write(&log_file, log_buf, strlen(log_buf), &bw);
|
||||
f_sync(&log_file); // Flush to ensure data is written
|
||||
f_write(&log_file, log_buf, len, &bw);
|
||||
if (++log_lines % LOG_SYNC_EVERY == 0)
|
||||
f_sync(&log_file);
|
||||
}
|
||||
|
||||
bool log_is_enabled(void) {
|
||||
return log_enabled;
|
||||
}
|
||||
|
||||
// Convert FatFS error code to string
|
||||
|
||||
Reference in new issue
Block a user