News:

Attention: For security reasons,please choose a user name *different* from your login name.
Also make sure to choose a secure password and change it regularly.

Main Menu

Programming QSPI-Flash on TE0726-03 from (Peta-)Linux

Started by Wolfgang Zehetmair, January 20, 2021, 09:55:36 AM

Previous topic - Next topic

Wolfgang Zehetmair

For programming flashes within Linux, I have been using flashcp from package mtd-utils since long time. Doing this on the TE0726-03 however lead to verification errors, which irritated me as long-term user.
Further investigation revealed, that the populated QSPI device S25FL127S is designed to handle two alternative page sizes 256 or 512 bytes. The latter is device's default in terms of increased programming performance and thus announced within the BFPT, however Linux programming algorithm in drivers/mtd/spi-nor/spi-nor.c probably is not set up to deal correctly with page size 512 instead of 256.

This applies for petalinux kernels up to 2020.x (equivalent kernel version 5.4)

Patching spi-nor.c in a manner of (i.e pretending 256 bytes as pagesize)
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -2851,6 +2851,9 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
        params->page_size &= BFPT_DWORD11_PAGE_SIZE_MASK;
        params->page_size >>= BFPT_DWORD11_PAGE_SIZE_SHIFT;
        params->page_size = 1U << params->page_size;

+       params->page_size = 256;

        /* Quad Enable Requirements. */
        switch (bfpt.dwords[BFPT_DWORD(15)] & BFPT_DWORD15_QER_MASK) {

works around this problem.

JH