SWD programming NVMC maximum write size between wait for ready

Our application requires that we are able to program the nRF52832 device from our host microcontroller, in order to upgrade the nRF52832 firmware.

We are using an SPI peripheral on our host micro in order to communicate with the SWD peripheral on the nRF device. We have got to the point where we are able to write to the program memory via the NVMC, however we are stuck on something that is not mentioned explicitly in the documentation.

The NVMC seems to be locking up after some writes in between steps 3 and 4, writing and polling on the NVMC.READY register, where the NVMC stops reporting NVMC.READY == 1. The size we are writing at a time using auto-increment in the SWD for the write address is 1024 Bytes - we are now attempting 512 Bytes.

There are some mentions in other tickets for the NVMC indicating that you need to check NVMC.READY register in between each word.
https://devzone.nordicsemi.com/f/nordic-q-a/70012/how-to-write-the-data-in-nvmc-block-wise
https://devzone.nordicsemi.com/f/nordic-q-a/12428/regarding-flash-read-and-write

Question 1: What is the maximum size that can be written between NVMC.READY checks when using the SWD interface for writing to internal flash vis NVMC?

There are some articles that suggest that using auto-increment is possible, but what would be the point as you would need to write the NVMC.READY register to the TAR each time you need to poll the ready flag?

Question 2: Is there any other way to check the NVMC.READY register using SWD without writing to the TAR? This would enable the use of auto-increment in the SWD for the write address.

We are looking forward to your advice on this, thank you.

Parents
  • It is possible to skip reading the Ready register entirely. Just continuously write the data (make sure you write a new target base address when crossing 4096 byte boundary though if you use the auto-increment feature). What will happen if you write too fast (faster than the flash write speed) is that the device will return WAIT instead of OK for the swd ack. Just try again repeating the same write in that case until you get OK. If you tune the SWD speed you can find an optimal SWD Hz that will not result in any waits. We have flashed hundreds and thousands of nrf52811 devices this way without any issues. Not sure about nrf52832 though, but I would assume it works similarly.

Reply
  • It is possible to skip reading the Ready register entirely. Just continuously write the data (make sure you write a new target base address when crossing 4096 byte boundary though if you use the auto-increment feature). What will happen if you write too fast (faster than the flash write speed) is that the device will return WAIT instead of OK for the swd ack. Just try again repeating the same write in that case until you get OK. If you tune the SWD speed you can find an optimal SWD Hz that will not result in any waits. We have flashed hundreds and thousands of nrf52811 devices this way without any issues. Not sure about nrf52832 though, but I would assume it works similarly.

Children
No Data
Related