Skip to contentSkip to conversation

at91: Fix NAND PMECC on various SoCs/boards

PATCH New Tudor Ambarus 2 participants 6 messages Jan 8, 2021 – Jan 25, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover at91: Fix NAND PMECC on various SoCs/boards

Fix the Galois Field Table offsets for sama5d3 and sam9x60 SoCs. PMECC could not correct errors.

Fix the involuntarily disablement of NAND PMECC on some boards, and fix some wrong definitions for CONFIG_PMECC_CAP.

Tested on sam9x60ek and sama5d3_xplained. I/we "injected" bit flips into u-boot NAND memory area, and then read back. PMECC could not correct the errors. With these everything is fine.

Kai Stuhlemmer (ebee Engineering) (1):
sam9x60.h: Fix Galois Field Table offsets

Tudor Ambarus (3):
configs: at91: Fix the involuntarily disablement of NAND PMECC
configs: at91: Fix wrong definitions for CONFIG_PMECC_CAP
sama5d3: Fix Galois Field Table offsets

 arch/arm/mach-at91/include/mach/sam9x60.h   | 4 ++--
 arch/arm/mach-at91/include/mach/sama5d3.h   | 4 ++--
 configs/at91sam9n12ek_mmc_defconfig         | 1 +
 configs/at91sam9n12ek_spiflash_defconfig    | 1 +
 configs/at91sam9x5ek_mmc_defconfig          | 1 +
 configs/at91sam9x5ek_spiflash_defconfig     | 1 +
 configs/sama5d36ek_cmp_mmc_defconfig        | 2 ++
 configs/sama5d36ek_cmp_nandflash_defconfig  | 1 +
 configs/sama5d36ek_cmp_spiflash_defconfig   | 2 ++
 configs/sama5d3_xplained_mmc_defconfig      | 2 ++
 configs/sama5d3xek_mmc_defconfig            | 2 ++
 configs/sama5d3xek_spiflash_defconfig       | 2 ++
 configs/sama5d4_xplained_spiflash_defconfig | 2 ++
 configs/sama5d4ek_mmc_defconfig             | 2 ++
 configs/sama5d4ek_spiflash_defconfig        | 2 ++
 15 files changed, 25 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/4 configs: at91: Fix the involuntarily disablement of NAND PMECC

SPL_GENERATE_ATMEL_PMECC_HEADER selects:
ATMEL_NAND_HWECC [=y] && ATMEL_NAND_HW_PMECC [=y].

With the removal of SPL_GENERATE_ATMEL_PMECC_HEADER, ATMEL_NAND_HW_PMECC and ATMEL_NAND_HWECC were no longer selected. Also, when the SPL_GENERATE_ATMEL_PMECC_HEADER was removed, the configs were not updated using savedefconfig, thus the 'commit d168bcb6fe39 ("configs: Resync with savedefconfig")' further removes the CONFIG_PMECC_CAP value.

Update defconfigs and add CONFIG_ATMEL_NAND_HW_PMECC, which selects ATMEL_NAND_HWECC, in order to restore NAND PMECC support. Restore CONFIG_PMECC_CAP value.

Fixes 57f76c2a47 ("configs: at91: remove SPL_GENERATE_ATMEL_PMECC_HEADER from non-nand configs")
---
 configs/at91sam9n12ek_mmc_defconfig         | 1 +
 configs/at91sam9n12ek_spiflash_defconfig    | 1 +
 configs/at91sam9x5ek_mmc_defconfig          | 1 +
 configs/at91sam9x5ek_spiflash_defconfig     | 1 +
 configs/sama5d36ek_cmp_mmc_defconfig        | 1 +
 configs/sama5d36ek_cmp_spiflash_defconfig   | 1 +
 configs/sama5d3_xplained_mmc_defconfig      | 1 +
 configs/sama5d3xek_mmc_defconfig            | 2 ++
 configs/sama5d3xek_spiflash_defconfig       | 2 ++
 configs/sama5d4_xplained_spiflash_defconfig | 2 ++
 configs/sama5d4ek_mmc_defconfig             | 1 +
 configs/sama5d4ek_spiflash_defconfig        | 2 ++
 12 files changed, 16 insertions(+)
configs/at91sam9n12ek_mmc_defconfig +1 -0
index fa802c3625..0ddf8fcb56 100644
@@ -43,6 +43,7 @@ CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
+CONFIG_ATMEL_NAND_HW_PMECC=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=30000000
 CONFIG_SPI_FLASH_ATMEL=y
configs/at91sam9n12ek_spiflash_defconfig +1 -0
index 997594720b..4af64d8ac2 100644
@@ -45,6 +45,7 @@ CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
+CONFIG_ATMEL_NAND_HW_PMECC=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=30000000
 CONFIG_SPI_FLASH_ATMEL=y
configs/at91sam9x5ek_mmc_defconfig +1 -0
index 7f8fa22dc2..92b653f7d7 100644
@@ -46,6 +46,7 @@ CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
+CONFIG_ATMEL_NAND_HW_PMECC=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=30000000
 CONFIG_SPI_FLASH_ATMEL=y
configs/at91sam9x5ek_spiflash_defconfig +1 -0
index 8575a33943..ca3ae1fb62 100644
@@ -48,6 +48,7 @@ CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
+CONFIG_ATMEL_NAND_HW_PMECC=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=30000000
 CONFIG_SPI_FLASH_ATMEL=y
configs/sama5d36ek_cmp_mmc_defconfig +1 -0
index 846f96b595..177b020469 100644
@@ -47,6 +47,7 @@ CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
+CONFIG_ATMEL_NAND_HW_PMECC=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=30000000
 CONFIG_SPI_FLASH_ATMEL=y
configs/sama5d36ek_cmp_spiflash_defconfig +1 -0
index 6a63a74162..fe1600b798 100644
@@ -49,6 +49,7 @@ CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
+CONFIG_ATMEL_NAND_HW_PMECC=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=30000000
 CONFIG_SPI_FLASH_ATMEL=y
configs/sama5d3_xplained_mmc_defconfig +1 -0
index ec117ee693..dd36d809d0 100644
@@ -66,6 +66,7 @@ CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
+CONFIG_ATMEL_NAND_HW_PMECC=y
 CONFIG_DM_ETH=y
 CONFIG_MACB=y
 CONFIG_PINCTRL=y
configs/sama5d3xek_mmc_defconfig +2 -0
index 50f97e68e1..dcbffff413 100644
@@ -71,6 +71,8 @@ CONFIG_SYS_FLASH_CFI=y
 CONFIG_MTD_RAW_NAND=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
+CONFIG_ATMEL_NAND_HW_PMECC=y
+CONFIG_PMECC_CAP=4
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=30000000
 CONFIG_SPI_FLASH_ATMEL=y
configs/sama5d3xek_spiflash_defconfig +2 -0
index b8c4d3263f..7dd8f1bfe7 100644
@@ -72,6 +72,8 @@ CONFIG_SYS_FLASH_CFI=y
 CONFIG_MTD_RAW_NAND=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
+CONFIG_ATMEL_NAND_HW_PMECC=y
+CONFIG_PMECC_CAP=4
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=30000000
 CONFIG_SPI_FLASH_ATMEL=y
configs/sama5d4_xplained_spiflash_defconfig +2 -0
index de5f92de6f..db15514999 100644
@@ -68,6 +68,8 @@ CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
+CONFIG_ATMEL_NAND_HW_PMECC=y
+CONFIG_PMECC_CAP=8
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=30000000
 CONFIG_SPI_FLASH_ATMEL=y
configs/sama5d4ek_mmc_defconfig +1 -0
index 25d875ec2e..9aa37e5bae 100644
@@ -62,6 +62,7 @@ CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
+CONFIG_ATMEL_NAND_HW_PMECC=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=30000000
 CONFIG_SPI_FLASH_ATMEL=y
configs/sama5d4ek_spiflash_defconfig +2 -0
index cb8ed99cdd..7ef589697c 100644
@@ -65,6 +65,8 @@ CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
+CONFIG_ATMEL_NAND_HW_PMECC=y
+CONFIG_PMECC_CAP=8
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=30000000
 CONFIG_SPI_FLASH_ATMEL=y
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/4 configs: at91: Fix wrong definitions for CONFIG_PMECC_CAP

In reply to Tudor Ambarus

When CONFIG_ATMEL_NAND_HW_PMECC is set, CONFIG_PMECC_CAP defaults to the value of 2. At the conversion to Kconfig for the PMECC config values, some boards/defconfigs were wrongly configured. Update CONFIG_PMECC_CAP to the PMECC_CAP value before the conversion.

Fixes 49ad40298c ("ARM: at91: Convert SPL_GENERATE_ATMEL_PMECC_HEADER to Kconfig")
---
 configs/sama5d36ek_cmp_mmc_defconfig       | 1 +
 configs/sama5d36ek_cmp_nandflash_defconfig | 1 +
 configs/sama5d36ek_cmp_spiflash_defconfig  | 1 +
 configs/sama5d3_xplained_mmc_defconfig     | 1 +
 configs/sama5d4ek_mmc_defconfig            | 1 +
 5 files changed, 5 insertions(+)
configs/sama5d36ek_cmp_mmc_defconfig +1 -0
index 177b020469..32580ce8f0 100644
@@ -48,6 +48,7 @@ CONFIG_MTD_RAW_NAND=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
 CONFIG_ATMEL_NAND_HW_PMECC=y
+CONFIG_PMECC_CAP=4
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=30000000
 CONFIG_SPI_FLASH_ATMEL=y
configs/sama5d36ek_cmp_nandflash_defconfig +1 -0
index d38a0bea6d..478720f72f 100644
@@ -47,6 +47,7 @@ CONFIG_GENERIC_ATMEL_MCI=y
 CONFIG_MTD=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
+CONFIG_PMECC_CAP=4
 CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=30000000
configs/sama5d36ek_cmp_spiflash_defconfig +1 -0
index fe1600b798..10227fe3bb 100644
@@ -50,6 +50,7 @@ CONFIG_MTD_RAW_NAND=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
 CONFIG_ATMEL_NAND_HW_PMECC=y
+CONFIG_PMECC_CAP=4
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=30000000
 CONFIG_SPI_FLASH_ATMEL=y
configs/sama5d3_xplained_mmc_defconfig +1 -0
index dd36d809d0..d713af77b1 100644
@@ -67,6 +67,7 @@ CONFIG_MTD_RAW_NAND=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
 CONFIG_ATMEL_NAND_HW_PMECC=y
+CONFIG_PMECC_CAP=4
 CONFIG_DM_ETH=y
 CONFIG_MACB=y
 CONFIG_PINCTRL=y
configs/sama5d4ek_mmc_defconfig +1 -0
index 9aa37e5bae..c1ee3793c6 100644
@@ -63,6 +63,7 @@ CONFIG_MTD_RAW_NAND=y
 # CONFIG_SYS_NAND_USE_FLASH_BBT is not set
 CONFIG_NAND_ATMEL=y
 CONFIG_ATMEL_NAND_HW_PMECC=y
+CONFIG_PMECC_CAP=8
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=30000000
 CONFIG_SPI_FLASH_ATMEL=y
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/4 sama5d3: Fix Galois Field Table offsets

In reply to Tudor Ambarus

Offsets are described in the datasheet at section:
"11.4.4.2 NAND Flash Boot: PMECC Error Detection and Correction".

For testing I "injected" bit flips into u-boot NAND memory area, and then read back. PMECC could not correct the errors. With the offsets updated everything is fine.

Fixes 3225f34e5c ("ARM: atmel: add sama5d3xek support")
---
 arch/arm/mach-at91/include/mach/sama5d3.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-at91/include/mach/sama5d3.h +2 -2
index 83f18a8148..f4f05676f7 100644
@@ -190,8 +190,8 @@
 /*
  * PMECC table in ROM
  */
-#define ATMEL_PMECC_INDEX_OFFSET_512	0x10000
-#define ATMEL_PMECC_INDEX_OFFSET_1024	0x18000
+#define ATMEL_PMECC_INDEX_OFFSET_512	0x8000
+#define ATMEL_PMECC_INDEX_OFFSET_1024	0x10000
 
 /*
  * SAMA5D3 specific prototypes
Signature · 1 line
2.25.1
#4 lore raw

PATCH 4/4 sam9x60.h: Fix Galois Field Table offsets

In reply to Tudor Ambarus

From: "Kai Stuhlemmer (ebee Engineering)" <[email protected]>

Because ATMEL_BASE_ROM is defined to 0x100000, it already points to the begin of the index table for 512 byte sectors correction. Thus its offset must be zero and the index of the table for 1024 byte sectors must start at offset 0x8000.

---
 arch/arm/mach-at91/include/mach/sam9x60.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-at91/include/mach/sam9x60.h +2 -2
index b7f43226b7..c08d19c691 100644
@@ -154,8 +154,8 @@
 /*
  * PMECC table in ROM
  */
-#define ATMEL_PMECC_INDEX_OFFSET_512	0x8000
-#define ATMEL_PMECC_INDEX_OFFSET_1024	0x10000
+#define ATMEL_PMECC_INDEX_OFFSET_512	0x0000
+#define ATMEL_PMECC_INDEX_OFFSET_1024	0x8000
 
 /*
  * SAM9X60 specific prototypes
Signature · 1 line
2.25.1
#5 lore raw

cover at91: Fix NAND PMECC on various SoCs/boards

In reply to Tudor Ambarus
Quoted 18 lines · Tudor Ambarus

Fix the Galois Field Table offsets for sama5d3 and sam9x60 SoCs. PMECC could not correct errors.

Fix the involuntarily disablement of NAND PMECC on some boards, and fix some wrong definitions for CONFIG_PMECC_CAP.

Tested on sam9x60ek and sama5d3_xplained. I/we "injected" bit flips into u-boot NAND memory area, and then read back. PMECC could not correct the errors. With these everything is fine.

Kai Stuhlemmer (ebee Engineering) (1):
sam9x60.h: Fix Galois Field Table offsets

Tudor Ambarus (3):
configs: at91: Fix the involuntarily disablement of NAND PMECC
configs: at91: Fix wrong definitions for CONFIG_PMECC_CAP
sama5d3: Fix Galois Field Table offsets

Quoted 17 lines
  arch/arm/mach-at91/include/mach/sam9x60.h   | 4 ++--
  arch/arm/mach-at91/include/mach/sama5d3.h   | 4 ++--
  configs/at91sam9n12ek_mmc_defconfig         | 1 +
  configs/at91sam9n12ek_spiflash_defconfig    | 1 +
  configs/at91sam9x5ek_mmc_defconfig          | 1 +
  configs/at91sam9x5ek_spiflash_defconfig     | 1 +
  configs/sama5d36ek_cmp_mmc_defconfig        | 2 ++
  configs/sama5d36ek_cmp_nandflash_defconfig  | 1 +
  configs/sama5d36ek_cmp_spiflash_defconfig   | 2 ++
  configs/sama5d3_xplained_mmc_defconfig      | 2 ++
  configs/sama5d3xek_mmc_defconfig            | 2 ++
  configs/sama5d3xek_spiflash_defconfig       | 2 ++
  configs/sama5d4_xplained_spiflash_defconfig | 2 ++
  configs/sama5d4ek_mmc_defconfig             | 2 ++
  configs/sama5d4ek_spiflash_defconfig        | 2 ++
  15 files changed, 25 insertions(+), 4 deletions(-)

Applied to u-boot-atmel/master and pushed out, thanks !