From 516f08cada39703fb4dc9a1ab318c40be920575a Mon Sep 17 00:00:00 2001 From: maidnl Date: Wed, 28 Aug 2024 17:08:33 +0200 Subject: [PATCH 1/3] renaming storage debug function to avoid clash with user code --- .../BlockDevices/CodeFlashBlockDevice.cpp | 3 +++ libraries/BlockDevices/MBRBlockDevice.cpp | 3 +++ .../BlockDevices/QSPIFlashBlockDevice.cpp | 3 +++ libraries/FATFilesystem/FATFileSystem.cpp | 2 ++ libraries/Storage/storage_common.cpp | 2 +- libraries/Storage/storage_common.h | 26 +++++++++---------- 6 files changed, 25 insertions(+), 14 deletions(-) diff --git a/libraries/BlockDevices/CodeFlashBlockDevice.cpp b/libraries/BlockDevices/CodeFlashBlockDevice.cpp index 695831db3..00d655099 100644 --- a/libraries/BlockDevices/CodeFlashBlockDevice.cpp +++ b/libraries/BlockDevices/CodeFlashBlockDevice.cpp @@ -19,6 +19,9 @@ #include "CodeFlashBlockDevice.h" +#define debug_if rns_storage_dbg_if +#define debug_mem rns_storage_dbg_mem + // To enable debug set CF_DBG to 1 and make sure STORAGE_DEBUG is defined // in Storage/storage_common.h #define CF_DBG 0 diff --git a/libraries/BlockDevices/MBRBlockDevice.cpp b/libraries/BlockDevices/MBRBlockDevice.cpp index 1abafaac7..3c6bcf1db 100644 --- a/libraries/BlockDevices/MBRBlockDevice.cpp +++ b/libraries/BlockDevices/MBRBlockDevice.cpp @@ -19,6 +19,9 @@ #include #include +#define debug_if rns_storage_dbg_if +#define debug_mem rns_storage_dbg_mem + // To enable debug set MBR_DBG to 1 and make sure STORAGE_DEBUG is defined // in Storage/storage_common.h #define MBR_DBG 0 diff --git a/libraries/BlockDevices/QSPIFlashBlockDevice.cpp b/libraries/BlockDevices/QSPIFlashBlockDevice.cpp index d2a2b01a2..85d6de958 100644 --- a/libraries/BlockDevices/QSPIFlashBlockDevice.cpp +++ b/libraries/BlockDevices/QSPIFlashBlockDevice.cpp @@ -19,6 +19,9 @@ /* ########################################################################## */ #include "QSPIFlashBlockDevice.h" +#define debug_if rns_storage_dbg_if +#define debug_mem rns_storage_dbg_mem + #ifdef HAS_QSPI // To enable debug set QSPIF_DBG to 1 and make sure STORAGE_DEBUG is defined diff --git a/libraries/FATFilesystem/FATFileSystem.cpp b/libraries/FATFilesystem/FATFileSystem.cpp index 8f632c3c6..a675f49b6 100644 --- a/libraries/FATFilesystem/FATFileSystem.cpp +++ b/libraries/FATFilesystem/FATFileSystem.cpp @@ -25,6 +25,8 @@ #include #include +#define debug_if rns_storage_dbg_if + //namespace mbed { //using namespace mbed; diff --git a/libraries/Storage/storage_common.cpp b/libraries/Storage/storage_common.cpp index 888ba3e8c..18b915c1d 100644 --- a/libraries/Storage/storage_common.cpp +++ b/libraries/Storage/storage_common.cpp @@ -3,7 +3,7 @@ #ifdef STORAGE_DEBUG -char debug_buffer[STORAGE_BUFF_DIM]; +char rns_storage_dbg_buf[STORAGE_BUFF_DIM]; #endif diff --git a/libraries/Storage/storage_common.h b/libraries/Storage/storage_common.h index 353d1fa44..2017a50bb 100644 --- a/libraries/Storage/storage_common.h +++ b/libraries/Storage/storage_common.h @@ -18,21 +18,21 @@ extern "C" { #define STORAGE_BUFF_DIM 512 #define PRINT_SIZE 32 -extern char debug_buffer[STORAGE_BUFF_DIM]; +extern char rns_storage_dbg_buf[STORAGE_BUFF_DIM]; /** Output a debug message * * @param format printf-style format string, followed by variables */ -static inline void debug(const char *fmt, ...) +static inline void rns_storage_dbg(const char *fmt, ...) { - memset(debug_buffer,0x00,256); + memset(rns_storage_dbg_buf,0x00,256); va_list va; va_start (va, fmt); - vsnprintf (debug_buffer,STORAGE_BUFF_DIM, fmt, va); + vsnprintf (rns_storage_dbg_buf,STORAGE_BUFF_DIM, fmt, va); va_end (va); if(Serial) - Serial.println(debug_buffer); + Serial.println(rns_storage_dbg_buf); } @@ -44,20 +44,20 @@ static inline void debug(const char *fmt, ...) * @param condition output only if condition is true (!= 0) * @param format printf-style format string, followed by variables */ -static inline void debug_if(int condition, const char *fmt, ...) +static inline void rns_storage_dbg_if(int condition, const char *fmt, ...) { if (condition) { - memset(debug_buffer,0x00,256); + memset(rns_storage_dbg_buf,0x00,256); va_list va; va_start (va, fmt); - vsnprintf (debug_buffer,STORAGE_BUFF_DIM, fmt, va); + vsnprintf (rns_storage_dbg_buf,STORAGE_BUFF_DIM, fmt, va); va_end (va); if(Serial) - Serial.println(debug_buffer); + Serial.println(rns_storage_dbg_buf); } } -static inline void debug_mem(uint8_t *b, uint32_t _size) +static inline void rns_storage_dbg_mem(uint8_t *b, uint32_t _size) { if (b != nullptr) { Serial.println(""); @@ -76,16 +76,16 @@ static inline void debug_mem(uint8_t *b, uint32_t _size) #else -static inline void debug_if(int condition, const char *format, ...) { +static inline void rns_storage_dbg_if(int condition, const char *format, ...) { (void)condition; (void)format; } -static inline void debug(const char *format, ...) { +static inline void rns_storage_dbg(const char *format, ...) { (void)format; } -static inline void debug_mem(uint8_t *b, uint32_t _size) { +static inline void _rns_storage_dbg_mem(uint8_t *b, uint32_t _size) { (void)b; (void)_size; } From 9753db186fb482ecb9cedd591a37d556d874eb18 Mon Sep 17 00:00:00 2001 From: maidnl Date: Thu, 29 Aug 2024 09:37:12 +0200 Subject: [PATCH 2/3] fixed typo (removed underscore character) --- libraries/Storage/storage_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Storage/storage_common.h b/libraries/Storage/storage_common.h index 2017a50bb..7ffb75166 100644 --- a/libraries/Storage/storage_common.h +++ b/libraries/Storage/storage_common.h @@ -85,7 +85,7 @@ static inline void rns_storage_dbg(const char *format, ...) { (void)format; } -static inline void _rns_storage_dbg_mem(uint8_t *b, uint32_t _size) { +static inline void rns_storage_dbg_mem(uint8_t *b, uint32_t _size) { (void)b; (void)_size; } From 8530a4aa9b0b3e5cf04e7ec828606ed40b803cd8 Mon Sep 17 00:00:00 2001 From: maidnl Date: Thu, 3 Oct 2024 09:20:43 +0200 Subject: [PATCH 3/3] renamed forgotten debug functions with new name used to avoid clash --- libraries/Storage/storage_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Storage/storage_common.h b/libraries/Storage/storage_common.h index 7ffb75166..ab5258116 100644 --- a/libraries/Storage/storage_common.h +++ b/libraries/Storage/storage_common.h @@ -98,7 +98,7 @@ static inline void rns_storage_dbg_mem(uint8_t *b, uint32_t _size) { #ifdef STORAGE_ASSERT #define MBED_ASSERT(expr) do { if (!(expr)) { \ - debug("ASSERT FAILED at line %d in file %s",__LINE__,__FILE__); }} while(0) + rns_storage_dbg("ASSERT FAILED at line %d in file %s",__LINE__,__FILE__); }} while(0) #else #define MBED_ASSERT(expr) #endif