Description
PSRAM not accessible by the core after a flash_range_erase
or flash_range_program
.
Inspection of the QMI interface before and after a call to these SDK functions shows that the 2nd memory region control register (PSRAM, qmi_hw->m[1]
) have had their values modified, rendering the interface inoperative. If the original values are restored by the application manually, communication succeeds and PSRAM data is accessible.
In the instance of the PSRAM on the Pimoroni PGA2350, we see the following behavior:
Before flash write
qmi_hw->m[1].timing = 61a48102
qmi_hw->m[1].rfmt = 000612aa
qmi_hw->m[1].rcmd = 000000eb
qmi_hw->m[1].wfmt = 000012aa
qmi_hw->m[1].wcmd = 00000038
xip_ctrl_hw->ctrl = 00000883
After flash_range_erase / flash_range_program
qmi_hw->m[1].timing = 60007203
qmi_hw->m[1].rfmt = 000492a8
qmi_hw->m[1].rcmd = 000000eb
qmi_hw->m[1].wfmt = 000012aa
qmi_hw->m[1].wcmd = 00000038
xip_ctrl_hw->ctrl = 00000883
A more detailed description and test code (Arduino based, sorry, because PSRAM setup is not in the SDK yet) is being tracked in earlephilhower/arduino-pico#2537 .
As a workaround, by using GCC to wrap the flash functions and manually saving/restoring the registers, we're able to both access PSRAM and write to flash. I haven't gone through the RP2350 ROM code, but I would guess as part of the XIP restart after a flash command it is setting what it things are "safe" values to the QMI regions which is great for chip reset, but not so good for when things are already configured.