Skip to content

Commit

Permalink
logging: Handle nios2 global pointer register issue
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nordic-krch authored and nashif committed Nov 10, 2018
1 parent 5e34681 commit f75d11a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/logging/log_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit f75d11a

Please sign in to comment.