Optimizing Flash Storage Write Speed on nRF54L15 DK

Hello,

I am continuing to work on my project with the nRF54L15 DK and have run into another challenge. Currently, the issue is storing images (320 × 492 bytes) in an external flash memory (MX66L2G45GXRI00-T). The write process works but takes significantly longer than expected.

Do you have any suggestions on which parameters or approaches could be optimized here?

At the moment, I am using SPIM with jedec,spi-nor. From my online research, it seems that for higher write speeds, switching to QSPI with the Nordic driver (nordic,qspi-nor) is recommended. Is this correct? How could this be implemented? And is it even possible on the nRF54L15 DK?

Thank you in advance for your support!

Below is a snippet of my overlay file:

&spi21{
status = "okay";
cs-gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
pinctrl-0 = <&spi21_default>;
pinctrl-1 = <&spi21_sleep>;
pinctrl-names = "default", "sleep";

flash0: flash@0 {
compatible = "jedec,spi-nor";
reg = <0x00000000 0x10000000>; /* Offset = 0x0, Size = 256 MB */
spi-max-frequency = <8000000>;
jedec-id = [c2 20 1c];
size = <2147483648>;
enter-4byte-addr = <1>;
};

compatible = "nordic,nrf-spim";
};

In my main, I use the flash device as follows (also just a snippet):

#define FRAME_SIZE (320 * 492)
#define FLASH_START 0x00000
#define BLOCK_SIZE_UART 128
#define PAGE_SIZE 256

const struct device *flash_dev = DEVICE_DT_GET(DT_NODELABEL(flash0));

void write_frame(const struct device *flash_dev, const uint8_t *data, size_t len)
{
off_t write_addr = FLASH_START + flash_write_offset;

for (size_t offset = 0; offset < len; offset += PAGE_SIZE)
{
size_t chunk = MIN(PAGE_SIZE, len - offset);

int rc = flash_write(flash_dev,
write_addr + offset,
&data[offset],
chunk);
if (rc != 0)
{
LOG_ERR("Flash write failed at 0x%06lx: %d",
(unsigned long)(write_addr + offset), rc);
return;
}
}

LOG_INF("Frame written at offset 0x%06lx (%zu bytes)",
(unsigned long)flash_write_offset, len);

flash_write_offset =
((flash_write_offset + len + ERASE_BLOCK_SIZE - 1) /
ERASE_BLOCK_SIZE) * ERASE_BLOCK_SIZE;

last_block_end = flash_write_offset;
LOG_INF("Last block end set to 0x%06zx", last_block_end);
frames_written++;
}

  • Hi Lea,

    At the moment, I am using SPIM with jedec,spi-nor. From my online research, it seems that for higher write speeds, switching to QSPI with the Nordic driver (nordic,qspi-nor) is recommended. Is this correct? How could this be implemented? And is it even possible on the nRF54L15 DK?

    First of all, I see you've set spi-max-frequency = <8000000> there. It can go higher with a "high speed instance"

    Yes, it's true that QSPI can improve the speed. Though since you say that the speed you are currently getting is less than expected, what are you currently getting and what did you expect? If it is surprisingly slow it might be an idea to take a logic trace of the communication here to figure out if there is something strange going on.

    Using QSPI is an option. Though one thing about the nRF54L15 is that it does not have a dedicated QSPI peripheral, but what we call a softperipheral. For more, you can for instance see here. The sQSPI supports clock frequencies up to 64MHz.

    Regards,

    Elfving

Related