Skip to content

arch/arm/rp23xx: add text heap (up_textheap_memalign) support#19256

Open
ricardgb wants to merge 1 commit into
apache:masterfrom
ricardgb:rp23xx-textheap
Open

arch/arm/rp23xx: add text heap (up_textheap_memalign) support#19256
ricardgb wants to merge 1 commit into
apache:masterfrom
ricardgb:rp23xx-textheap

Conversation

@ricardgb

@ricardgb ricardgb commented Jul 1, 2026

Copy link
Copy Markdown

⚠️ Disclosure: developed with Claude Code (an AI coding agent) and validated on real Pico 2 W hardware.

Summary

Adds the text-heap allocator for the RP2350 (rp23xx), enabling relocatable/loadable code to be placed in executable RAM (up_textheap_memalign / up_textheap_free / up_textheap_heapmember). The RP2350 Cortex-M33 executes from SRAM and NuttX runs it with the MPU disabled, so the text heap is backed directly by the kernel heap (kmm_*); no separate executable region or up_textheap_data_address() alias is required.

Selected via ARCH_HAVE_TEXT_HEAP on ARCH_CHIP_RP23XX; compiled when CONFIG_ARCH_USE_TEXT_HEAP is set (off by default).

Impact

  • New: arch/arm/src/rp23xx/rp23xx_textheap.c.
  • arch/arm/Kconfig: RP23XX selects ARCH_HAVE_TEXT_HEAP.
  • Make.defs/CMakeLists.txt: compile the file under CONFIG_ARCH_USE_TEXT_HEAP. No change when the option is off.

Testing

  • Build: raspberrypi-pico-2:nsh + CONFIG_ARCH_USE_TEXT_HEAP=y compiles cleanly; nxstyle clean.
  • Hardware (Pico 2 W): loaded a Thumb code image into the text heap and executed it successfully.

🤖 Generated with Claude Code

Implement the text-heap allocator for the RP2350 so that relocatable code
(loadable modules, code buffers) can be placed in executable RAM.  The
RP2350 Cortex-M33 executes from SRAM and NuttX runs it with the MPU
disabled, so the text heap is backed directly by the kernel heap
(kmm_memalign / kmm_free / kmm_heapmember); no separate executable region
or up_textheap_data_address() alias is required.

Selected via ARCH_HAVE_TEXT_HEAP on ARCH_CHIP_RP23XX and compiled when
CONFIG_ARCH_USE_TEXT_HEAP is set (off by default).

Developed with Claude Code (Anthropic's agentic coding tool) and exercised
on a Raspberry Pi Pico 2 W by loading and running a Thumb code image from
the text heap.

Signed-off-by: Ricard Rosson <ricard@groundbits.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ricardgb ricardgb requested a review from jerpelea as a code owner July 1, 2026 17:32
@github-actions github-actions Bot added Arch: arm Issues related to ARM (32-bit) architecture Size: M The size of the change in this PR is medium labels Jul 2, 2026

void *up_textheap_memalign(size_t align, size_t size)
{
return kmm_memalign(align, size);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if text heap is same as kernel heap, why need select ARCH_HAVE_TEXT_HEAP?

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@linguini1 linguini1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting for consensus about fully generated PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants