Author Topic: Programming QSPI-Flash on TE0726-03 from (Peta-)Linux  (Read 202 times)

Wolfgang Zehetmair

  • Active Member
  • *
  • Posts: 1
Programming QSPI-Flash on TE0726-03 from (Peta-)Linux
« on: January 20, 2021, 09:55:36 AM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1605
Re: Programming QSPI-Flash on TE0726-03 from (Peta-)Linux
« Reply #1 on: January 21, 2021, 07:08:27 AM »
Hi,
thanks for posting this patch.
br
John