From c61445a7874175da17fcc7ceccfcd5a8f67385b6 Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Tue, 3 Nov 2020 14:22:13 +0000 Subject: [PATCH] QSPIFBlockDevice: fix misconception in minimum program size Prior to this PR, the minimum program size (QSPI_MIN_PROG_SIZE) of QSPIFBlockDevice was 256 by default and 512 for some targets. Those values were in fact page sizes, not program sizes. Here's an explanation: * Most QSPI flashes can be programmed to a granularity of a single byte or a few bytes - no need to be a whole page. This should be the value of QSPI_MIN_PROG_SIZE. Applications need to align buffer sizes to this granularity when programming QSPI flashes. * Each sending of the underlying QSPI program signal requires destination bytes to be located within the same page. If a QSPIFBlockDevice::program() call crosses page boundaries, this function breaks down the operation into multiple chunks, so it's not a concern for the application. So this PR changes the default program size to 1 (byte), and for targets with a 4-byte (1-word) read size it overrides the program size. Note: No config is needed for the page size, as it comes from the SFDP table parsed during initialisation. --- storage/blockdevice/COMPONENT_QSPIF/mbed_lib.json | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/storage/blockdevice/COMPONENT_QSPIF/mbed_lib.json b/storage/blockdevice/COMPONENT_QSPIF/mbed_lib.json index ea6a2bf30a..ca461079e8 100644 --- a/storage/blockdevice/COMPONENT_QSPIF/mbed_lib.json +++ b/storage/blockdevice/COMPONENT_QSPIF/mbed_lib.json @@ -18,7 +18,7 @@ "QSPI_POLARITY_MODE": 0, "QSPI_FREQ": "40000000", "QSPI_MIN_READ_SIZE": "1", - "QSPI_MIN_PROG_SIZE": "256" + "QSPI_MIN_PROG_SIZE": "1" }, "target_overrides": { "MX25R6435F": { @@ -37,15 +37,18 @@ "MCU_NRF52840": { "QSPI_FREQ": "32000000", "QSPI_MIN_READ_SIZE": "4", - "QSPI_MIN_PROG_SIZE": "256" + "QSPI_MIN_PROG_SIZE": "4" }, "MCU_PSOC6": { - "QSPI_FREQ": "50000000", - "QSPI_MIN_PROG_SIZE": "512" + "QSPI_FREQ": "50000000" }, "EFM32GG11_STK3701": { "QSPI_MIN_READ_SIZE": "4", - "QSPI_MIN_PROG_SIZE": "256" + "QSPI_MIN_PROG_SIZE": "4" + }, + "MCU_LPC546XX": { + "QSPI_MIN_READ_SIZE": "4", + "QSPI_MIN_PROG_SIZE": "4" } } }