Most SPI flash do support various "sector" sizes, 4kB is sometimes called 
subsector. OpenOCD uses for bigger flash always the largest available size: 
Erasing a substancial part by subsector erase is usually *much* slower than by 
the larger sectors.  E.g. for MT25QL512ABB: subsector 4kByte typ. 50ms, 64kByte 
typ. 150ms, so roughly factor 5. If you can't live with the larger sector size, 
these alternatives came to my mind:
1) *Add* corresponding subsector size/erase command to spi.c for *all* devices 
where applicable and a a suitable subsector erase command to the various flash 
drivers. Note that the "auto erase" option would still use the "old" erase 
command if you don't add a suitable strategy there.
2)* Change* all sector erase commands and sector sizes in spi.c to the 
appropriate subsector variants. But be prepared for some polite complaints that 
programming time increased by a factor of four ...
3) Add a special command to send arbitrary command bytes to the flash, see e.g. 
"stmqspi cmd" in the stmqspi flash driver or a command to override the flash 
parameters in spi.c like "stmqspi set" ibid. That might be useful for other 
purposes as well.


---

**[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 05:57 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