This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 5c433542c6246664a775e0cefd34afa9b6981154 Author: Marco Casaroli <[email protected]> AuthorDate: Wed Nov 11 12:23:26 2026 +0100 arch/arm/rp23xx: Keep the lock of the PSRAM heap in the SRAM. mm_initialize() puts struct mm_heap_s, and with it the lock of the heap, at the start of the region: for the separate PSRAM heap, in the PSRAM. An atomic operation there excludes only the local core (RP2350 datasheet, section 2.1.6), so with SMP the lock of the PSRAM heap did not exclude the other core, and two cores could change the heap at the same time. Allocate struct mm_heap_s from the kernel heap in the SRAM with mm_initialize_heap(), as rptun does for its shared memory heaps. The memory of the heap stays in the PSRAM. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- arch/arm/src/rp23xx/rp23xx_heaps.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/rp23xx/rp23xx_heaps.c b/arch/arm/src/rp23xx/rp23xx_heaps.c index 56422614f31..39e2bf61582 100644 --- a/arch/arm/src/rp23xx/rp23xx_heaps.c +++ b/arch/arm/src/rp23xx/rp23xx_heaps.c @@ -29,6 +29,8 @@ #include <nuttx/kmalloc.h> #include <nuttx/mm/mm.h> +#include <string.h> + #include "arm_internal.h" #include "rp23xx_psram.h" @@ -114,11 +116,21 @@ void up_allocate_heap(void **heap_start, size_t *heap_size) void up_extraheaps_init(void) { + struct mm_heap_config_s config; size_t psram_size = rp23xx_psram_size(); if (psram_size > 0) { - g_psramheap = mm_initialize("psram", PSRAM_START, psram_size); + /* Keep the heap and its lock in the SRAM: in the PSRAM an atomic + * operation does not exclude the other core. + */ + + memset(&config, 0, sizeof(config)); + config.heap = KRN_HEAP; + config.name = "psram"; + config.start = PSRAM_START; + config.size = psram_size; + g_psramheap = mm_initialize_heap(&config); } } #endif
