mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
rp23xx: Add an MTD driver over the unused QSPI flash.
The rp2350 executes in place from external QSPI flash, and a NuttX image normally leaves most of that flash unused. This exposes the unused region as an MTD device so it can carry a filesystem, mirroring what the rp2040 port already provides with rp2040_flash_mtd.c. The region is given by RP23XX_FLASH_MTD_OFFSET and RP23XX_FLASH_MTD_SIZE, both multiples of the 4096 byte erase sector. Initialization fails rather than corrupting the running image if the region would overlap the NuttX binary, checked against __flash_binary_end. Erase and program use the bootrom flash routines. Those stall instruction fetch from the same flash, so they run from SRAM with interrupts disabled and, on SMP builds, the other core parked; afterwards the QSPI interface is returned to execute-in-place mode. By default that restores the fast read mode the bootrom configured at boot; RP23XX_FLASH_MTD_SAFE_XIP instead always uses the bootrom flash_enter_cmd_xip routine, which is slower to execute from but depends only on the documented bootrom entry point. The driver answers BIOC_XIPBASE with the memory-mapped address of the region, so a filesystem supporting execute in place can hand out real flash pointers rather than copying into RAM. The common board bringup registers the device as /dev/rpflash. Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
This commit is contained in:
parent
6da4269c46
commit
8c94a72657
7 changed files with 946 additions and 0 deletions
|
|
@ -42,6 +42,7 @@ Flash ROM Boot Working Does not require boot2 from pico-sdk
|
|||
SRAM Boot Working Requires external SWD debugger
|
||||
PSRAM Working Three modes of heap allocation described below
|
||||
TRNG Working Hardware RNG at /dev/random and /dev/urandom
|
||||
Flash MTD Working Unused flash tail as an MTD device, answers BIOC_XIPBASE
|
||||
============== ============ =====
|
||||
|
||||
Installation
|
||||
|
|
@ -222,6 +223,39 @@ six 32-bit EHR words, and repeats until the request is satisfied. For example::
|
|||
|
||||
nsh> dd if=/dev/random of=/dev/console bs=16 count=1
|
||||
|
||||
Flash MTD
|
||||
=========
|
||||
|
||||
The rp2350 executes in place from its external QSPI flash, and a NuttX image
|
||||
normally leaves most of that flash unused. Enabling ``RP23XX_FLASH_MTD``
|
||||
exposes the unused region as an MTD device, registered by the common board
|
||||
bringup as ``/dev/rpflash``.
|
||||
|
||||
The region is described by ``RP23XX_FLASH_MTD_OFFSET`` (byte offset from
|
||||
``0x10000000``) and ``RP23XX_FLASH_MTD_SIZE``, both of which must be multiples
|
||||
of the 4096 byte erase sector. The driver refuses to initialize if the region
|
||||
would overlap the NuttX image (it checks ``__flash_binary_end``), so a bad
|
||||
offset fails at boot instead of corrupting the running firmware.
|
||||
|
||||
Erase and program go through the bootrom flash routines. Because those
|
||||
operations stall instruction fetch from the same flash, the driver runs them
|
||||
from SRAM with interrupts disabled and, on SMP builds, the other core parked;
|
||||
expect interrupt latency to suffer for the duration of a write. Afterwards the
|
||||
QSPI interface is put back into execute-in-place mode -- by default restoring
|
||||
the fast read mode the bootrom set up at boot, or, with
|
||||
``RP23XX_FLASH_MTD_SAFE_XIP``, always through the bootrom
|
||||
``flash_enter_cmd_xip`` routine, which is slower to execute from but depends
|
||||
only on the documented bootrom entry point.
|
||||
|
||||
The driver answers the ``BIOC_XIPBASE`` ioctl with the memory-mapped address of
|
||||
the region, so a filesystem that supports execute in place can hand out real
|
||||
flash pointers instead of copying into RAM.
|
||||
|
||||
Any MTD-based filesystem can be layered on the device, for example::
|
||||
|
||||
nsh> mksmartfs /dev/rpflash
|
||||
nsh> mount -t smartfs /dev/rpflash /mnt
|
||||
|
||||
Supported Boards
|
||||
================
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue