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: <num_of_log_modules>*4 bytes
- RAM: <num_of_log_modules>*8 bytes (if runtime filtering is enabled)

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2018-11-08 06:58:23 +01:00 committed by Anas Nashif
commit f75d11adb2

View file

@ -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.