What are the timeouts?
I don't know what OpenOCD calls a "sector" for this device. In the datasheet nomenclature there are not 128 sectors in the device, so I suppose it is some number of pages. What is the actual size being erased? Erasing the device by individual sectors may take up to 30 seconds, so increasing the timeouts would be the first thing to try.
Hello, thank you for replying. The timeouts usually last anywhere from 10-12 seconds. It is not a consistent or exact number of seconds by the looks of things.
As for the sectors, I did some digging and , as you know, according to the SAMV71Q21 datasheet "The memory is organized in sectors. Each sector has a size of 128 Kbytes.". This is followed by a diagram (attached) demonstrating the layout of the first sector and all subsequent sectors, of which there are 16 given the total flash size of 2048Kb. However, what OpenOCD appears to be referencing is the "lock regions". "A lock region is composed of several consecutive pages, and each lock region has its associated lock bit.". So it appears, given there are 128 lock bits for lock regions of size 16Kbytes each, OpenOCD is triggering the use of the Erase Pages Command (EPA) via the EEFC peripheral's EEFC Flash Command Register to delete 32 pages (512bytes each * 32 = 16Kbytes. 2048/16 = 128 "sectors") at a time, meaning 128 erases in total to erase the whole flash.
What's interesting is when I use the '-d3' debugging option on an OpenOCD process, I notice that upon attempting to erase all 128 "sectors" via the "flash erase_sector 0 0 127" command, it uses the EEFC peripheral's EA (Erase All) command instead (see"Flash Erase All Command Followed by Endless FRDY status bit checks.png"), and then it probes the FRDY status bit until the timeout is triggered. I'm not entirely sure what I can do with this information but it does hint at either a misuse of the EA EEFC command, or a regular timeout due to its likely longer runtime.
As for your recommendation of increasing the timeout, I have thus far been unable to do so for this particular command. I can only seem to increase the GDB remote timeout via the openocd launch commands, which is an entirely separate timeout mechanic from the EEFC commands that it is performing. Of course, that's just as far as I could find, if you know how to extend the timeout for the EA EEFC command, I would be extremely grateful to know how.
Also, the actual size being erased is the entirety of the flash (2048Kbytes) as this is a bootloader packaged with several copies of firmware and additional padding.
Thanks for your help thus far.