extmod/modopenamp: Rework trace buffer setup procedure.

This commit reworks the setup procedure for the OpenAMP trace buffer,
used by the libmetal framework to provide cross-core logging data if
needed.

Before these changes, the buffer was provided by MicroPython, as a fixed
size 128 bytes chunk that was accidentally put into the .rodata section,
making it not usable for its intended purpose.

Now, a buffer placed in .bss with a default size of 128 bytes is
provided by MicroPython unless chosen otherwise.  A user-chosen buffer
pointer can be provided to MicroPython using the
MICROPY_PY_OPENAMP_TRACE_BUF preprocessor definition.  If what
MicroPython provides by default is fine, the buffer size can be
overridden with a new value for the MICROPY_PY_OPENAMP_TRACE_BUF_LEN
preprocessor definition instead.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
Alessandro Gatti
2025-11-30 11:05:57 +01:00
committed by Damien George
parent 11861e96a9
commit d468ccce62
2 changed files with 11 additions and 4 deletions

View File

@@ -80,11 +80,12 @@
#define VRING_BUFF_ADDR (METAL_SHM_ADDR + 0x2000)
#define VRING_BUFF_SIZE (METAL_SHM_SIZE - 0x2000)
#if MICROPY_PY_OPENAMP_HOST
static const char openamp_trace_buf[128];
#if MICROPY_PY_OPENAMP_HOST && MICROPY_PY_OPENAMP_TRACE_BUF_ENABLE
#ifndef MICROPY_PY_OPENAMP_TRACE_BUF
static char openamp_trace_buf[MICROPY_PY_OPENAMP_TRACE_BUF_LEN];
#define MICROPY_PY_OPENAMP_TRACE_BUF ((uint32_t)openamp_trace_buf)
#define MICROPY_PY_OPENAMP_TRACE_BUF_LEN sizeof(MICROPY_PY_OPENAMP_TRACE_BUF)
#endif // MICROPY_PY_OPENAMP_HOST
#endif // MICROPY_PY_OPENAMP_TRACE_BUF
#endif // MICROPY_PY_OPENAMP_HOST && MICROPY_PY_OPENAMP_TRACE_BUF_ENABLE
#endif // MICROPY_PY_OPENAMP_RSC_TABLE_ENABLE