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

   ## Summary
   
   I compared rp23xx_flash_mtd.c with the hardware_flash library of the Pico 
SDK 2.3.1 and with the RP2350 datasheet. This PR fixes what I found, one commit 
per item.
   
       Save and restore the QSPI state. The bootrom flash functions reset the 
QMI window 1 (PSRAM) registers and the QSPI pads, and flash_flush_cache() 
discards dirty XIP cache lines. So after the first erase or program, PSRAM read 
garbage, and PSRAM writes still in the cache were lost. Now the driver cleans 
the cache first (through the alias that avoids erratum RP2350-E11), and saves 
and restores the pads and the M1 registers, as the SDK does. This removes 
rp23xx_psram_restore(), the earlier fix that nothing called.
       Restore XIP with the bootrom XIP setup function. The driver called 
flash_select_xip_read_mode() and tested its return value, but that ROM function 
returns void, so the test read a random r0. Now the driver copies the XIP setup 
function that the bootrom leaves in boot RAM to SRAM, and calls it, as the 
datasheet (5.2.7, 5.4.8.10) and the SDK do. It restores the read mode and clock 
divisor found at boot.
       Erase and program in small steps. Interrupts were off for a whole 
request, which can be seconds. Now they are off for one 64K block erase or one 
256 byte page program. On SMP the driver no longer sends the pause call to its 
own CPU, and the isolation data is static.
       Keep the operation off PSRAM and flash. During the operation an access 
to flash or PSRAM is a bus fault. The driver now copies a source page that is 
in flash or PSRAM to SRAM, and switches to a 1 KiB SRAM stack if the caller's 
stack is in PSRAM (the normal case with RP23XX_PSRAM_HEAP_USER).
       Check the region against the flash size. An address past the end of the 
flash wraps around to the NuttX image. The driver now reads the JEDEC ID at 
initialization and refuses a region that does not fit.
   
   The busy waits in this area are not an erratum workaround. They are the QMI 
direct-mode protocol (datasheet 12.14.5). The PSRAM side is in 
https://github.com/apache/nuttx/pull/20478. The two PRs are independent and 
merge in either order without conflict.
   
   ## Impact
   
   RELEASE
   
   ## Testing
   
   CI


-- 
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