daniel-p-carvalho opened a new pull request, #20788: URL: https://github.com/apache/nuttx/pull/20788
## Summary The PIC32MZ-W1 (WFI32E01) has no other non-volatile memory than its 1 MB program flash on some boards, and no driver to write it. Add `PIC32MZ_PROGMEM`, which exposes the last `PIC32MZ_PROGMEM_NPAGES` pages (4 KB each, default 2) of the program flash through the progmem interface (`up_progmem_*`), so that the generic `MTD_PROGMEM` makes an MTD device of them. It is the place to keep data that must survive a reset, such as a configuration. - `pic32mz_progmem.c` runs the operations of the flash controller (NVM): page erase and row program (1 KB). The word program is not used because it does not write the ECC. The source of a row is a physical RAM address read by the NVM itself, so the driver copies each row to an aligned buffer and flushes it from the cache. The data is read through the uncached window and the data cache lines of the cached window are invalidated after each operation, for the users of `BIOC_XIPBASE`. - The program image must not reach the pages. The build defines `PIC32MZ_PROGMEM_START` (where the pages begin) for the linker script of the board to check, and the EV49N51A script gets an `ASSERT` for it. When the option is off the symbol is the end of the flash, so nothing changes. - The EV49N51A registers the pages as `/dev/mtdblock1` when `MTD_PROGMEM` is enabled. The register facts come from the data sheet (DS70005425) and the PIC32MZ-W DFP, and the unlock sequence of `NVMKEY` from Microchip's Harmony NVM library; the code is written from scratch and tags them in the header comment. ## Impact New, optional (`PIC32MZ_PROGMEM`, default `n`), only for the PIC32MZ-W1. No change for the existing configurations: the EV49N51A linker script only gains an `ASSERT` that holds for the whole flash when the option is off. `MTD_PROGMEM` itself is not changed. ## Testing Host: Ubuntu Linux, XC32 v6.00 and the Pinguino compiler of the CI (ld 2.24). Target: EV49N51A, `wifibridge`-like test configuration with `PIC32MZ_PROGMEM`, `MTD_PROGMEM` and `BCH` (to open `/dev/mtdblock1` from `dd`, not part of the PR). - The image ends at 0x9009ab1c and the pages start at 0x900fe000 (`PIC32MZ_PROGMEM_START`). - `dd` and `hexdump` on `/dev/mtdblock1`: writing zeros at an offset of 1 KB and a text at 4 KB returns exactly that data, the rest of the erase block stays 0xff, and the cached (`xd`) and uncached reads agree after the write. - 16 rewrites of the whole 8 KB (erase of both pages, 8 rows each time) while the board answered a ping flood, with the data right at the end. - The data survives a reset. - `ev49n51a:nsh` builds with and without `PIC32MZ_PROGMEM`, with the XC32 and with the Pinguino toolchain. `checkpatch` passes. -- 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]
