From f75d11adb29adcea41b696d1591a6719bb74dc23 Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Thu, 8 Nov 2018 06:58:23 +0100 Subject: [PATCH] logging: Handle nios2 global pointer register issue Nios2 is trying to use global pointer register to access variables smaller than 8 bytes. GPR range is limited to 64 bytes and apparently does not handle well variables placed in custom sections. Current workaround is to increase logger structures (const and dynamic) size (+8 bytes for dynamic, +4 bytes for constant). Then GPR is not used and application can be linked. The downside is increase of memory usage: - ROM: *4 bytes - RAM: *8 bytes (if runtime filtering is enabled) Signed-off-by: Krzysztof Chruscinski --- include/logging/log_instance.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/logging/log_instance.h b/include/logging/log_instance.h index fe64c0708b1..c513b9d40d5 100644 --- a/include/logging/log_instance.h +++ b/include/logging/log_instance.h @@ -16,11 +16,25 @@ extern "C" { struct log_source_const_data { const char *name; u8_t level; +#ifdef CONFIG_NIOS2 + /* Workaround alert! Dummy data to ensure that structure is >8 bytes. + * Nios2 uses global pointer register for structures <=8 bytes and + * apparently does not handle well variables placed in custom sections. + */ + u32_t dummy; +#endif }; /** @brief Dynamic data associated with the source of log messages. */ struct log_source_dynamic_data { u32_t filters; +#ifdef CONFIG_NIOS2 + /* Workaround alert! Dummy data to ensure that structure is >8 bytes. + * Nios2 uses global pointer register for structures <=8 bytes and + * apparently does not handle well variables placed in custom sections. + */ + u32_t dummy[2]; +#endif }; /** @brief Creates name of variable and section for constant log data.