There are provisions (e.g. in SFDP data) for up to 4 differerent (erase) sector 
sizes. And most (all?) higher capacity devices have differerent sector sizes to 
choose from.  There are even devices where the large erase sector size can be 
switched by some non-volatile register. Infineon came up with such a "fancy" 
device ...
So, somewhat chaotic, I'd say.

Of course, it's possible to add an additional erase block size for only one 
device. But this is rather non-systematic and additionally it doesn't solve the 
problem: How would you select one of these sizes? Automatically, or by a 
different high level command? Depending on the usage model, one or the other 
choice (or even a combination, as you suggested) would fit better, so an 
automatic approach seems to be difficult. 

That's why I'd suggest the third alternative. You could more or less 
copy-and-paste the relevant code and docs from e.g. stmqspi driver. 

And the last point: "... we could then add ...". Who is "we"?


---

**[tickets:#437] Wrong sector size for w25q16jv / RP2040 pico**

**Status:** new
**Milestone:** 0.11.0
**Created:** Sun Sep 29, 2024 05:57 AM UTC by JustAnother1
**Last Updated:** Sun Sep 29, 2024 11:20 AM UTC
**Owner:** nobody


in line 305 of src/flash/nor/rp2040.c (current git) there is this comment:
~~~
        /*
        The RP2040 Boot ROM provides a _flash_range_erase() API call documented 
in Section 2.8.3.1.3:
        https://datasheets.raspberrypi.org/rp2040/rp2040-datasheet.pdf
        and the particular source code for said Boot ROM function can be found 
here:
        
https://github.com/raspberrypi/pico-bootrom/blob/master/bootrom/program_flash_generic.c

        In theory, the function algorithm provides for erasing both a smaller 
"sector" (4096 bytes) and
        an optional larger "block" (size and command provided in args).
        */
~~~

I have verified the erase function from the boot rom of the RP2040. That is the 
same function openocd uses here. And I found that it is able to erase a 4096 
byte sector. So the comment is right.
 I wrote something before and after and in a sector and then called 
_flash_range_erase() from the boot-rom to erase the one 4096 bytes sized sector 
and only the bytes in the sector have been erased. The data before and after 
were still there. So erasing 4096 bytes is not theory anymore.

I therefore think that line 55 in  src/flash/nor/rp2040.c and line 123 (129?) 
in src/flash/nor/spi.c should be changed. They specify the sector size to 
0x10000 (64k) and should be 1000(4k)

What else can I do to get this change merged, or is there a reason not to do 
this?



---

Sent from sourceforge.net because openocd-devel@lists.sourceforge.net is 
subscribed to https://sourceforge.net/p/openocd/tickets/

To unsubscribe from further messages, a project admin can change settings at 
https://sourceforge.net/p/openocd/admin/tickets/options.  Or, if this is a 
mailing list, you can unsubscribe from the mailing list.


Reply via email to