env: Introduce support for SPI NAND flash
PATCH 1/1 env: Introduce support for SPI NAND flash
Introduce support for SPI NAND flash. Currently we only support SPI flash based on the lagacy sf cmd that assume SPI flash are always NOR. This is not the case as to SPI controller also NAND can be attached. Add support for it by adding an env driver that base entirely on the MTD api.
Introduce a new kconfig ENV_IS_IN_SPI_NAND_FLASH and CONFIG_SYS_SNAND_ENV_DEV to define the name of the SPI nand as exposed by mtd list.
--- env/Kconfig | 41 ++++- env/Makefile | 1 + env/env.c | 3 + env/snand.c | 338 +++++++++++++++++++++++++++++++++++++++++ include/env_internal.h | 1 + 5 files changed, 380 insertions(+), 4 deletions(-) create mode 100644 env/snand.c
env/Kconfig +37 -4
@@ -74,7 +74,7 @@ config ENV_IS_DEFAULT !ENV_IS_IN_MMC && !ENV_IS_IN_NAND && \ !ENV_IS_IN_NVRAM && !ENV_IS_IN_ONENAND && \ !ENV_IS_IN_REMOTE && !ENV_IS_IN_SPI_FLASH && \ - !ENV_IS_IN_UBI + !ENV_IS_IN_UBI && !ENV_IS_IN_SPI_NAND_FLASH select ENV_IS_NOWHERE config ENV_IS_NOWHERE
@@ -387,6 +387,33 @@ config ENV_IS_IN_SPI_FLASH during a "saveenv" operation. CONFIG_ENV_OFFSET_REDUND must be aligned to an erase sector boundary. +config ENV_IS_IN_SPI_NAND_FLASH + bool "Environment is in SPI NAND flash" + depends on !CHAIN_OF_TRUST && (SPI_FLASH || DM_SPI_FLASH) + default y if ARMADA_XP + default y if INTEL_BAYTRAIL + default y if INTEL_BRASWELL + default y if INTEL_BROADWELL + default y if NORTHBRIDGE_INTEL_IVYBRIDGE + default y if INTEL_QUARK + default y if INTEL_QUEENSBAY + default y if ARCH_SUNXI + default y if ARCH_AIROHA + help + Define this if you have a SPI NAND Flash memory device which you + want to use for the environment. + + - CONFIG_SYS_SNAND_ENV_DEV: + + Specifies which SPI NAND device the environment is stored in. + + - CONFIG_ENV_OFFSET: + - CONFIG_ENV_SIZE: + + These two #defines specify the offset and size of the + environment area within the SPI NAND Flash. + CONFIG_ENV_OFFSET must be aligned to an erase sector boundary. + config ENV_SECT_SIZE_AUTO bool "Use automatically detected sector size" depends on ENV_IS_IN_SPI_FLASH
@@ -562,8 +589,8 @@ config ENV_EXT4_FILE config ENV_ADDR hex "Environment address" depends on ENV_IS_IN_FLASH || ENV_IS_IN_NVRAM || ENV_IS_IN_ONENAND || \ - ENV_IS_IN_REMOTE || ENV_IS_IN_SPI_FLASH - default 0x0 if ENV_IS_IN_SPI_FLASH + ENV_IS_IN_REMOTE || ENV_IS_IN_SPI_FLASH || ENV_IS_IN_SPI_NAND_FLASH + default 0x0 if ENV_IS_IN_SPI_FLASH || ENV_IS_IN_SPI_NAND_FLASH help Offset from the start of the device (or partition)
@@ -577,7 +604,7 @@ config ENV_ADDR_REDUND config ENV_OFFSET hex "Environment offset" depends on ENV_IS_IN_EEPROM || ENV_IS_IN_MMC || ENV_IS_IN_NAND || \ - ENV_IS_IN_SPI_FLASH + ENV_IS_IN_SPI_FLASH || ENV_IS_IN_SPI_NAND_FLASH default 0x3f8000 if ARCH_ROCKCHIP && ENV_IS_IN_MMC default 0x140000 if ARCH_ROCKCHIP && ENV_IS_IN_SPI_FLASH default 0xF0000 if ARCH_SUNXI
@@ -666,6 +693,12 @@ config SYS_RELOC_GD_ENV_ADDR Relocate the early env_addr pointer so we know it is not inside the binary. Some systems need this and for the rest, it doesn't hurt. +config SYS_SNAND_ENV_DEV + string "spi nand device name" + depends on ENV_IS_IN_SPI_NAND_FLASH + help + SPI NAND device name on the platform where the environment is stored. + config SYS_MMC_ENV_DEV int "mmc device number" depends on ENV_IS_IN_MMC || ENV_IS_IN_FAT || ENV_IS_IN_EXT4 || \
env/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_$(PHASE_)ENV_IS_IN_FAT) += fat.o obj-$(CONFIG_$(PHASE_)ENV_IS_IN_EXT4) += ext4.o obj-$(CONFIG_$(PHASE_)ENV_IS_IN_NAND) += nand.o obj-$(CONFIG_$(PHASE_)ENV_IS_IN_SPI_FLASH) += sf.o +obj-$(CONFIG_$(PHASE_)ENV_IS_IN_SPI_NAND_FLASH) += snand.o obj-$(CONFIG_$(PHASE_)ENV_IS_IN_FLASH) += flash.o CFLAGS_embedded.o := -Wa,--no-warn -DENV_CRC=$(shell tools/envcrc 2>/dev/null)
env/env.c +3 -0
@@ -58,6 +58,9 @@ static enum env_location env_locations[] = {#ifdef CONFIG_ENV_IS_IN_SPI_FLASH ENVL_SPI_FLASH,#endif +#ifdef CONFIG_ENV_IS_IN_SPI_NAND_FLASH + ENVL_SPI_NAND_FLASH, +#endif #ifdef CONFIG_ENV_IS_IN_UBI ENVL_UBI,#endif
env/snand.c new file +338 -0
338 lines not on this page · raw message
include/env_internal.h +1 -0
@@ -113,6 +113,7 @@ enum env_location {ENVL_ONENAND ,ENVL_REMOTE ,ENVL_SPI_FLASH , +ENVL_SPI_NAND_FLASH ,ENVL_UBI , ENVL_NOWHERE,
Signature · 1 line
2.48.1
Quoted 11 lines · Christian Marangi
Introduce support for SPI NAND flash. Currently we only support SPI flash based on the lagacy sf cmd that assume SPI flash are always NOR. This is not the case as to SPI controller also NAND can be attached. Add support for it by adding an env driver that base entirely on the MTD api.
Introduce a new kconfig
ENV_IS_IN_SPI_NAND_FLASHandCONFIG_SYS_SNAND_ENV_DEVto define the name of the SPI nand as exposed by mtd list.Signed-off-by Christian Marangi <[email protected]>
Quoted 8 lines
--- env/Kconfig | 41 ++++- env/Makefile | 1 + env/env.c | 3 + env/snand.c | 338 +++++++++++++++++++++++++++++++++++++++++ include/env_internal.h | 1 + 5 files changed, 380 insertions(+), 4 deletions(-) create mode 100644 env/snand.c
Since this uses the generic mtd API, it can also support SPI NOR, and "regular" NAND too yes? If so, I'd like to see this named more generically (and my feedback about naming things from the UFS one applies here too), and then perhaps a follow-up converting some other platforms to use this? Thanks.
Signature · 1 line
Tom
Quoted 22 lines · Tom Rini
Quoted 11 lines · Christian Marangi
Introduce support for SPI NAND flash. Currently we only support SPI flash based on the lagacy sf cmd that assume SPI flash are always NOR. This is not the case as to SPI controller also NAND can be attached. Add support for it by adding an env driver that base entirely on the MTD api.
Introduce a new kconfig
ENV_IS_IN_SPI_NAND_FLASHandCONFIG_SYS_SNAND_ENV_DEVto define the name of the SPI nand as exposed by mtd list.Signed-off-by Christian Marangi <[email protected]>Quoted 8 lines
--- env/Kconfig | 41 ++++- env/Makefile | 1 + env/env.c | 3 + env/snand.c | 338 +++++++++++++++++++++++++++++++++++++++++ include/env_internal.h | 1 + 5 files changed, 380 insertions(+), 4 deletions(-) create mode 100644 env/snand.c
Quoted 6 lines
Since this uses the generic mtd API, it can also support SPI NOR, and "regular" NAND too yes? If so, I'd like to see this named more generically (and my feedback about naming things from the UFS one applies here too), and then perhaps a follow-up converting some other platforms to use this? Thanks.
I assume yes. So maybe we can change this to env/mtd.c? Any hint for a better name?
Can you link the feedback from UFS, I can't find it.
Signature · 1 line
Ansuel
Quoted 30 lines · Christian Marangi
Quoted 22 lines · Tom Rini
Quoted 11 lines · Christian Marangi
Introduce support for SPI NAND flash. Currently we only support SPI flash based on the lagacy sf cmd that assume SPI flash are always NOR. This is not the case as to SPI controller also NAND can be attached. Add support for it by adding an env driver that base entirely on the MTD api.
Introduce a new kconfig
ENV_IS_IN_SPI_NAND_FLASHandCONFIG_SYS_SNAND_ENV_DEVto define the name of the SPI nand as exposed by mtd list.Signed-off-by Christian Marangi <[email protected]>Quoted 8 lines
--- env/Kconfig | 41 ++++- env/Makefile | 1 + env/env.c | 3 + env/snand.c | 338 +++++++++++++++++++++++++++++++++++++++++ include/env_internal.h | 1 + 5 files changed, 380 insertions(+), 4 deletions(-) create mode 100644 env/snand.cQuoted 6 lines
Since this uses the generic mtd API, it can also support SPI NOR, and "regular" NAND too yes? If so, I'd like to see this named more generically (and my feedback about naming things from the UFS one applies here too), and then perhaps a follow-up converting some other platforms to use this? Thanks.
Quoted 2 lines
I assume yes. So maybe we can change this to
env/mtd.c? Any hint for a better name?
Sounds good to me.
Quoted 1 line
Can you link the feedback from UFS, I can't find it.
Here:
https://lore.kernel.org/u-boot/[email protected]/T/#m90111fe8a18efad7fc4f4e03745fe5e7b00db028
Signature · 1 line
Tom