ricardgb opened a new pull request, #19255:
URL: https://github.com/apache/nuttx/pull/19255

   > ⚠️ **Disclosure:** developed with **Claude Code** (an AI coding agent) and 
validated on real Pico 2 W hardware. Please review accordingly.
   
   ## Summary
   
   Adds an on-chip flash **LittleFS** for the RP2350 (rp23xx). A new MTD driver 
(`rp23xx_flash_mtd.c`) is created over the region of the QSPI flash that lies 
beyond the NuttX image, and the common board bringup mounts a LittleFS on it 
for persistent local storage. It uses the RP2350 bootrom flash programming 
functions.
   
   Design notes:
   - The erase/program routine (`do_flash_op`) runs from RAM (`.ram_code`) with 
interrupts disabled and XIP exited during the operation; the QMI window‑1 (CS1) 
registers that `flash_exit_xip()` disturbs on the RP2350 are saved/restored. 
Erase is chunked **one 4 KiB block per critical section** to bound the 
interrupts‑off window.
   - Reads go through the **cached XIP window** (`0x10000000`) — the same alias 
the CPU executes from; freshness after a program/erase is guaranteed because 
`do_flash_op()` calls the bootrom `flash_flush_cache()`.
   - Off by default (`CONFIG_RP23XX_FLASH_FILE_SYSTEM`). Region offset/size and 
mount point are Kconfig‑configurable.
   - A blank/corrupt optional filesystem is **non‑fatal**: it is logged and 
bringup continues (previously a failed mount could abort the rest of bringup). 
Format once from NSH: `mount -t littlefs -o autoformat /dev/rpflash /data`.
   
   ## Impact
   
   - New: `arch/arm/src/rp23xx/rp23xx_flash_mtd.{c,h}`.
   - Wiring: arch `Make.defs`/`CMakeLists.txt` (compiled only under 
`CONFIG_RP23XX_FLASH_FILE_SYSTEM`), arch `Kconfig` (new options), common 
bringup (mount block, guarded). No behaviour change when the option is off (the 
default).
   
   ## Testing
   
   - **Build:** `raspberrypi-pico-2:nsh` + `CONFIG_RP23XX_FLASH_FILE_SYSTEM=y` 
— the driver and bringup compile cleanly; `nxstyle` clean on all changed files.
   - **Hardware (Raspberry Pi Pico 2 W):** formatted the FS, wrote/read files, 
confirmed **persistence across a power-cycle** (auto-mount of the formatted 
FS), and copied a code image onto the LittleFS and **loaded + executed it from 
flash**:
     ```console
     nsh> mount -t littlefs -o autoformat /dev/rpflash /data
     nsh> echo hello-littlefs > /data/test.txt
     nsh> cat /data/test.txt
     hello-littlefs
     ```
     After a reboot, `/data` auto-mounts and the contents persist.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to