[U-Boot] [PATCH 1/5] mtd: nand: add initialization flag

From: Hou Zhiqiang Zhiqiang.Hou@nxp.com
Add initialization flag to avoid initializing NAND Flash multiple times, otherwise it will calculate a wrong total size.
Signed-off-by: Hou Zhiqiang Zhiqiang.Hou@nxp.com --- drivers/mtd/nand/nand.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c index 0551241..3ea2dcf 100644 --- a/drivers/mtd/nand/nand.c +++ b/drivers/mtd/nand/nand.c @@ -133,6 +133,16 @@ static void create_mtd_concat(void)
void nand_init(void) { + static int initialized; + + /* + * Avoid initializing NAND Flash multiple times, + * otherwise it will calculate a wrong total size. + */ + if (initialized) + return; + initialized = 1; + #ifdef CONFIG_SYS_NAND_SELF_INIT board_nand_init(); #else

From: Hou Zhiqiang Zhiqiang.Hou@nxp.com
Add nand_size() function to move the nand size print into initr_nand(). Remove nand size print from nand_init() to allow other function to call nand_init() without printing nand size.
Signed-off-by: Hou Zhiqiang Zhiqiang.Hou@nxp.com --- common/board_r.c | 1 + drivers/mtd/nand/nand.c | 7 +++++-- include/nand.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/common/board_r.c b/common/board_r.c index 48fa4ee..c39afe8 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -426,6 +426,7 @@ static int initr_nand(void) { puts("NAND: "); nand_init(); + printf("%lu MiB\n", nand_size() / 1024); return 0; } #endif diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c index 3ea2dcf..168bac6 100644 --- a/drivers/mtd/nand/nand.c +++ b/drivers/mtd/nand/nand.c @@ -131,6 +131,11 @@ static void create_mtd_concat(void) } #endif
+unsigned long nand_size(void) +{ + return total_nand_size; +} + void nand_init(void) { static int initialized; @@ -152,8 +157,6 @@ void nand_init(void) nand_init_chip(i); #endif
- printf("%lu MiB\n", total_nand_size / 1024); - #ifdef CONFIG_SYS_NAND_SELECT_DEVICE /* * Select the chip in the board/cpu specific driver diff --git a/include/nand.h b/include/nand.h index b6eb223..a1f6632 100644 --- a/include/nand.h +++ b/include/nand.h @@ -28,6 +28,7 @@ #endif
extern void nand_init(void); +extern unsigned long nand_size(void);
#include <linux/compat.h> #include <linux/mtd/mtd.h>

-----Original Message----- From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Zhiqiang Hou Sent: Friday, March 03, 2017 7:01 PM To: u-boot@lists.denx.de; oss@buserror.net; york sun york.sun@nxp.com; Mingkai.hu@freescale.com; sjg@chromium.org; Xiaobo Xie xiaobo.xie@nxp.com Cc: Z.Q. Hou zhiqiang.hou@nxp.com Subject: [U-Boot] [PATCH 2/5] mtd: nand: remove nand size print from nand_init function
From: Hou Zhiqiang Zhiqiang.Hou@nxp.com
Add nand_size() function to move the nand size print into initr_nand(). Remove nand size print from nand_init() to allow other function to call nand_init() without printing nand size.
What problem is faced if nand_init() printing NAND size
--prabhakar

Hi Parbhakar,
Thanks a lot for your comments!
-----Original Message----- From: Prabhakar Kushwaha Sent: Tuesday, March 07, 2017 11:20 AM To: Z.Q. Hou zhiqiang.hou@nxp.com; u-boot@lists.denx.de; oss@buserror.net; york sun york.sun@nxp.com; Mingkai.hu@freescale.com; sjg@chromium.org; Xiaobo Xie xiaobo.xie@nxp.com Cc: Z.Q. Hou zhiqiang.hou@nxp.com Subject: RE: [U-Boot] [PATCH 2/5] mtd: nand: remove nand size print from nand_init function
-----Original Message----- From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Zhiqiang Hou Sent: Friday, March 03, 2017 7:01 PM To: u-boot@lists.denx.de; oss@buserror.net; york sun york.sun@nxp.com; Mingkai.hu@freescale.com; sjg@chromium.org;
Xiaobo
Xie xiaobo.xie@nxp.com Cc: Z.Q. Hou zhiqiang.hou@nxp.com Subject: [U-Boot] [PATCH 2/5] mtd: nand: remove nand size print from nand_init function
From: Hou Zhiqiang Zhiqiang.Hou@nxp.com
Add nand_size() function to move the nand size print into initr_nand(). Remove nand size print from nand_init() to allow other function to call nand_init() without printing nand size.
What problem is faced if nand_init() printing NAND size
When the nand_init() called by other function than initr_nand(), it will print an isolated size and don't know what's this size for.
Thanks, Zhiqiang

From: Hou Zhiqiang Zhiqiang.Hou@nxp.com
Signed-off-by: Hou Zhiqiang Zhiqiang.Hou@nxp.com --- arch/arm/cpu/armv8/fsl-layerscape/ppa.c | 118 +++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/ppa.c b/arch/arm/cpu/armv8/fsl-layerscape/ppa.c index b68e87d..322432b 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/ppa.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/ppa.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> +#include <malloc.h> #include <config.h> #include <errno.h> #include <asm/system.h> @@ -21,9 +22,17 @@ #include <fsl_validate.h> #endif
+#ifdef CONFIG_SYS_LS_PPA_FW_IN_NAND +#include <nand.h> +#elif defined(CONFIG_SYS_LS_PPA_FW_IN_MMC) +#include <mmc.h> +#endif + +DECLARE_GLOBAL_DATA_PTR; + int ppa_init(void) { - const void *ppa_fit_addr; + void *ppa_fit_addr; u32 *boot_loc_ptr_l, *boot_loc_ptr_h; int ret;
@@ -34,10 +43,112 @@ int ppa_init(void)
#ifdef CONFIG_SYS_LS_PPA_FW_IN_XIP ppa_fit_addr = (void *)CONFIG_SYS_LS_PPA_FW_ADDR; + debug("%s: PPA image load from XIP\n", __func__); +#else /* !CONFIG_SYS_LS_PPA_FW_IN_XIP */ + size_t fw_length, fdt_header_len = sizeof(struct fdt_header); + + /* Copy PPA image from MMC/SD/NAND to allocated memory */ +#ifdef CONFIG_SYS_LS_PPA_FW_IN_MMC + struct mmc *mmc; + int dev = CONFIG_SYS_MMC_ENV_DEV; + struct fdt_header *fitp; + u32 cnt; + u32 blk = CONFIG_SYS_LS_PPA_FW_ADDR / 512; + + debug("%s: PPA image load from eMMC/SD\n", __func__); + + mmc_initialize(gd->bd); + mmc = find_mmc_device(dev); + if (!mmc) { + printf("PPA: MMC cannot find device for PPA firmware\n"); + return -ENODEV; + } + + mmc_init(mmc); + + fitp = malloc(roundup(fdt_header_len, 512)); + if (!fitp) { + printf("PPA: malloc failed for FIT header(size 0x%zx)\n", + roundup(fdt_header_len, 512)); + return -ENOMEM; + } + + cnt = DIV_ROUND_UP(fdt_header_len, 512); + debug("%s: MMC read PPA FIT header: dev # %u, block # %u, count %u\n", + __func__, dev, blk, cnt); + ret = mmc->block_dev.block_read(&mmc->block_dev, blk, cnt, fitp); + if (ret != cnt) { + free(fitp); + printf("MMC/SD read of PPA FIT header at offset 0x%x failed\n", + CONFIG_SYS_LS_PPA_FW_ADDR); + return -EIO; + } + + /* flush cache after read */ + flush_cache((ulong)fitp, cnt * 512); + + fw_length = fdt_totalsize(fitp); + free(fitp); + + fw_length = roundup(fw_length, 512); + ppa_fit_addr = malloc(fw_length); + if (!ppa_fit_addr) { + printf("PPA: malloc failed for PPA image(size 0x%zx)\n", + fw_length); + return -ENOMEM; + } + + cnt = DIV_ROUND_UP(fw_length, 512); + debug("%s: MMC read PPA FIT image: dev # %u, block # %u, count %u\n", + __func__, dev, blk, cnt); + ret = mmc->block_dev.block_read(&mmc->block_dev, + blk, cnt, ppa_fit_addr); + if (ret != cnt) { + free(ppa_fit_addr); + printf("MMC/SD read of PPA FIT header at offset 0x%x failed\n", + CONFIG_SYS_LS_PPA_FW_ADDR); + return -EIO; + } + + flush_cache((ulong)ppa_fit_addr, cnt * 512); + +#elif CONFIG_SYS_LS_PPA_FW_IN_NAND + struct fdt_header fit; + + debug("%s: PPA image load from NAND\n", __func__); + + nand_init(); + ret = nand_read(nand_info[0], (loff_t)CONFIG_SYS_LS_PPA_FW_ADDR, + &fdt_header_len, (u_char *)&fit); + if (ret == -EUCLEAN) { + printf("NAND read of PPA FIT header at offset 0x%x failed\n", + CONFIG_SYS_LS_PPA_FW_ADDR); + return -EIO; + } + + fw_length = fdt_totalsize(&fit); + + ppa_fit_addr = malloc(fw_length); + if (!ppa_fit_addr) { + printf("PPA: malloc failed for PPA image(size 0x%zx)\n", + fw_length); + return -ENOMEM; + } + + ret = nand_read(nand_info[0], (loff_t)CONFIG_SYS_LS_PPA_FW_ADDR, + &fw_length, (u_char *)ppa_fit_addr); + if (ret == -EUCLEAN) { + free(ppa_fit_addr); + printf("NAND read of PPA firmware at offset 0x%x failed\n", + CONFIG_SYS_LS_PPA_FW_ADDR); + return -EIO; + } #else #error "No CONFIG_SYS_LS_PPA_FW_IN_xxx defined" #endif
+#endif + #ifdef CONFIG_CHAIN_OF_TRUST ppa_img_addr = (uintptr_t)ppa_fit_addr; if (fsl_check_boot_mode_secure() != 0) { @@ -65,5 +176,10 @@ int ppa_init(void) boot_loc_ptr_l, boot_loc_ptr_h); ret = sec_firmware_init(ppa_fit_addr, boot_loc_ptr_l, boot_loc_ptr_h);
+#if defined(CONFIG_SYS_LS_PPA_FW_IN_MMC) || \ + defined(CONFIG_SYS_LS_PPA_FW_IN_NAND) + free(ppa_fit_addr); +#endif + return ret; }

On 03/03/2017 05:45 AM, Zhiqiang Hou wrote:
From: Hou Zhiqiang Zhiqiang.Hou@nxp.com
Signed-off-by: Hou Zhiqiang Zhiqiang.Hou@nxp.com
arch/arm/cpu/armv8/fsl-layerscape/ppa.c | 118 +++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-)
<snip>
#ifdef CONFIG_SYS_LS_PPA_FW_IN_XIP ppa_fit_addr = (void *)CONFIG_SYS_LS_PPA_FW_ADDR;
- debug("%s: PPA image load from XIP\n", __func__);
+#else /* !CONFIG_SYS_LS_PPA_FW_IN_XIP */
- size_t fw_length, fdt_header_len = sizeof(struct fdt_header);
- /* Copy PPA image from MMC/SD/NAND to allocated memory */
+#ifdef CONFIG_SYS_LS_PPA_FW_IN_MMC
- struct mmc *mmc;
- int dev = CONFIG_SYS_MMC_ENV_DEV;
- struct fdt_header *fitp;
- u32 cnt;
- u32 blk = CONFIG_SYS_LS_PPA_FW_ADDR / 512;
- debug("%s: PPA image load from eMMC/SD\n", __func__);
- mmc_initialize(gd->bd);
- mmc = find_mmc_device(dev);
- if (!mmc) {
printf("PPA: MMC cannot find device for PPA firmware\n");
return -ENODEV;
- }
- mmc_init(mmc);
- fitp = malloc(roundup(fdt_header_len, 512));
- if (!fitp) {
printf("PPA: malloc failed for FIT header(size 0x%zx)\n",
roundup(fdt_header_len, 512));
return -ENOMEM;
- }
- cnt = DIV_ROUND_UP(fdt_header_len, 512);
- debug("%s: MMC read PPA FIT header: dev # %u, block # %u, count %u\n",
__func__, dev, blk, cnt);
- ret = mmc->block_dev.block_read(&mmc->block_dev, blk, cnt, fitp);
- if (ret != cnt) {
free(fitp);
printf("MMC/SD read of PPA FIT header at offset 0x%x failed\n",
CONFIG_SYS_LS_PPA_FW_ADDR);
return -EIO;
- }
- /* flush cache after read */
- flush_cache((ulong)fitp, cnt * 512);
- fw_length = fdt_totalsize(fitp);
- free(fitp);
- fw_length = roundup(fw_length, 512);
- ppa_fit_addr = malloc(fw_length);
- if (!ppa_fit_addr) {
printf("PPA: malloc failed for PPA image(size 0x%zx)\n",
fw_length);
return -ENOMEM;
- }
- cnt = DIV_ROUND_UP(fw_length, 512);
- debug("%s: MMC read PPA FIT image: dev # %u, block # %u, count %u\n",
__func__, dev, blk, cnt);
- ret = mmc->block_dev.block_read(&mmc->block_dev,
blk, cnt, ppa_fit_addr);
- if (ret != cnt) {
free(ppa_fit_addr);
printf("MMC/SD read of PPA FIT header at offset 0x%x failed\n",
CONFIG_SYS_LS_PPA_FW_ADDR);
return -EIO;
- }
- flush_cache((ulong)ppa_fit_addr, cnt * 512);
+#elif CONFIG_SYS_LS_PPA_FW_IN_NAND
- struct fdt_header fit;
- debug("%s: PPA image load from NAND\n", __func__);
- nand_init();
- ret = nand_read(nand_info[0], (loff_t)CONFIG_SYS_LS_PPA_FW_ADDR,
&fdt_header_len, (u_char *)&fit);
- if (ret == -EUCLEAN) {
printf("NAND read of PPA FIT header at offset 0x%x failed\n",
CONFIG_SYS_LS_PPA_FW_ADDR);
return -EIO;
- }
- fw_length = fdt_totalsize(&fit);
- ppa_fit_addr = malloc(fw_length);
- if (!ppa_fit_addr) {
printf("PPA: malloc failed for PPA image(size 0x%zx)\n",
fw_length);
return -ENOMEM;
- }
- ret = nand_read(nand_info[0], (loff_t)CONFIG_SYS_LS_PPA_FW_ADDR,
&fw_length, (u_char *)ppa_fit_addr);
- if (ret == -EUCLEAN) {
free(ppa_fit_addr);
printf("NAND read of PPA firmware at offset 0x%x failed\n",
CONFIG_SYS_LS_PPA_FW_ADDR);
return -EIO;
- }
#else #error "No CONFIG_SYS_LS_PPA_FW_IN_xxx defined" #endif
Why do you flush the cache after reading from SD but not from NAND?
York

Hi York,
Thanks a lot for your comments!
-----Original Message----- From: york sun Sent: Saturday, March 04, 2017 12:51 AM To: Z.Q. Hou zhiqiang.hou@nxp.com; u-boot@lists.denx.de; oss@buserror.net; Mingkai.hu@freescale.com; sjg@chromium.org; Xiaobo Xie xiaobo.xie@nxp.com Subject: Re: [PATCH 3/5] fsl PPA: add support PPA image loading from NAND and SD
On 03/03/2017 05:45 AM, Zhiqiang Hou wrote:
From: Hou Zhiqiang Zhiqiang.Hou@nxp.com
Signed-off-by: Hou Zhiqiang Zhiqiang.Hou@nxp.com
arch/arm/cpu/armv8/fsl-layerscape/ppa.c | 118 +++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-)
<snip>
#ifdef CONFIG_SYS_LS_PPA_FW_IN_XIP ppa_fit_addr = (void *)CONFIG_SYS_LS_PPA_FW_ADDR;
- debug("%s: PPA image load from XIP\n", __func__); #else /*
+!CONFIG_SYS_LS_PPA_FW_IN_XIP */
- size_t fw_length, fdt_header_len = sizeof(struct fdt_header);
- /* Copy PPA image from MMC/SD/NAND to allocated memory */
#ifdef
+CONFIG_SYS_LS_PPA_FW_IN_MMC
- struct mmc *mmc;
- int dev = CONFIG_SYS_MMC_ENV_DEV;
- struct fdt_header *fitp;
- u32 cnt;
- u32 blk = CONFIG_SYS_LS_PPA_FW_ADDR / 512;
- debug("%s: PPA image load from eMMC/SD\n", __func__);
- mmc_initialize(gd->bd);
- mmc = find_mmc_device(dev);
- if (!mmc) {
printf("PPA: MMC cannot find device for PPA firmware\n");
return -ENODEV;
- }
- mmc_init(mmc);
- fitp = malloc(roundup(fdt_header_len, 512));
- if (!fitp) {
printf("PPA: malloc failed for FIT header(size 0x%zx)\n",
roundup(fdt_header_len, 512));
return -ENOMEM;
- }
- cnt = DIV_ROUND_UP(fdt_header_len, 512);
- debug("%s: MMC read PPA FIT header: dev # %u, block # %u,
count %u\n",
__func__, dev, blk, cnt);
- ret = mmc->block_dev.block_read(&mmc->block_dev, blk, cnt, fitp);
- if (ret != cnt) {
free(fitp);
printf("MMC/SD read of PPA FIT header at offset 0x%x
failed\n",
CONFIG_SYS_LS_PPA_FW_ADDR);
return -EIO;
- }
- /* flush cache after read */
- flush_cache((ulong)fitp, cnt * 512);
- fw_length = fdt_totalsize(fitp);
- free(fitp);
- fw_length = roundup(fw_length, 512);
- ppa_fit_addr = malloc(fw_length);
- if (!ppa_fit_addr) {
printf("PPA: malloc failed for PPA image(size 0x%zx)\n",
fw_length);
return -ENOMEM;
- }
- cnt = DIV_ROUND_UP(fw_length, 512);
- debug("%s: MMC read PPA FIT image: dev # %u, block # %u,
count %u\n",
__func__, dev, blk, cnt);
- ret = mmc->block_dev.block_read(&mmc->block_dev,
blk, cnt, ppa_fit_addr);
- if (ret != cnt) {
free(ppa_fit_addr);
printf("MMC/SD read of PPA FIT header at offset 0x%x
failed\n",
CONFIG_SYS_LS_PPA_FW_ADDR);
return -EIO;
- }
- flush_cache((ulong)ppa_fit_addr, cnt * 512);
+#elif CONFIG_SYS_LS_PPA_FW_IN_NAND
- struct fdt_header fit;
- debug("%s: PPA image load from NAND\n", __func__);
- nand_init();
- ret = nand_read(nand_info[0],
(loff_t)CONFIG_SYS_LS_PPA_FW_ADDR,
&fdt_header_len, (u_char *)&fit);
- if (ret == -EUCLEAN) {
printf("NAND read of PPA FIT header at offset 0x%x failed\n",
CONFIG_SYS_LS_PPA_FW_ADDR);
return -EIO;
- }
- fw_length = fdt_totalsize(&fit);
- ppa_fit_addr = malloc(fw_length);
- if (!ppa_fit_addr) {
printf("PPA: malloc failed for PPA image(size 0x%zx)\n",
fw_length);
return -ENOMEM;
- }
- ret = nand_read(nand_info[0],
(loff_t)CONFIG_SYS_LS_PPA_FW_ADDR,
&fw_length, (u_char *)ppa_fit_addr);
- if (ret == -EUCLEAN) {
free(ppa_fit_addr);
printf("NAND read of PPA firmware at offset 0x%x failed\n",
CONFIG_SYS_LS_PPA_FW_ADDR);
return -EIO;
- }
#else #error "No CONFIG_SYS_LS_PPA_FW_IN_xxx defined" #endif
Why do you flush the cache after reading from SD but not from NAND?
Added the flush operation because I referred to the FMan ucode loading process. It works well when loading from SD without the flush cache action, will remove the flush action.
Thanks, Zhiqiang

Sorry for top posting (using my phone). I think we should flush the cache by range. If you are relying on PPA flushing the cache for you (it is the case now), it's better to put a comment there.
York
-------- Original Message -------- From: "Z.Q. Hou" zhiqiang.hou@nxp.com Sent: Sunday, March 5, 2017 07:07 PM To: york sun york.sun@nxp.com,u-boot@lists.denx.de,oss@buserror.net,Mingkai.hu@freescale.com,sjg@chromium.org,Xiaobo Xie xiaobo.xie@nxp.com Subject: RE: [PATCH 3/5] fsl PPA: add support PPA image loading from NAND and SD
Hi York,
Thanks a lot for your comments!
-----Original Message----- From: york sun Sent: Saturday, March 04, 2017 12:51 AM To: Z.Q. Hou zhiqiang.hou@nxp.com; u-boot@lists.denx.de; oss@buserror.net; Mingkai.hu@freescale.com; sjg@chromium.org; Xiaobo Xie xiaobo.xie@nxp.com Subject: Re: [PATCH 3/5] fsl PPA: add support PPA image loading from NAND and SD
On 03/03/2017 05:45 AM, Zhiqiang Hou wrote:
From: Hou Zhiqiang Zhiqiang.Hou@nxp.com
Signed-off-by: Hou Zhiqiang Zhiqiang.Hou@nxp.com
arch/arm/cpu/armv8/fsl-layerscape/ppa.c | 118 +++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-)
<snip>
#ifdef CONFIG_SYS_LS_PPA_FW_IN_XIP ppa_fit_addr = (void *)CONFIG_SYS_LS_PPA_FW_ADDR;
- debug("%s: PPA image load from XIP\n", __func__); #else /*
+!CONFIG_SYS_LS_PPA_FW_IN_XIP */
- size_t fw_length, fdt_header_len = sizeof(struct fdt_header);
- /* Copy PPA image from MMC/SD/NAND to allocated memory */
#ifdef
+CONFIG_SYS_LS_PPA_FW_IN_MMC
- struct mmc *mmc;
- int dev = CONFIG_SYS_MMC_ENV_DEV;
- struct fdt_header *fitp;
- u32 cnt;
- u32 blk = CONFIG_SYS_LS_PPA_FW_ADDR / 512;
- debug("%s: PPA image load from eMMC/SD\n", __func__);
- mmc_initialize(gd->bd);
- mmc = find_mmc_device(dev);
- if (!mmc) {
- printf("PPA: MMC cannot find device for PPA firmware\n");
- return -ENODEV;
- }
- mmc_init(mmc);
- fitp = malloc(roundup(fdt_header_len, 512));
- if (!fitp) {
- printf("PPA: malloc failed for FIT header(size 0x%zx)\n",
roundup(fdt_header_len, 512));
- return -ENOMEM;
- }
- cnt = DIV_ROUND_UP(fdt_header_len, 512);
- debug("%s: MMC read PPA FIT header: dev # %u, block # %u,
count %u\n",
__func__, dev, blk, cnt);
- ret = mmc->block_dev.block_read(&mmc->block_dev, blk, cnt, fitp);
- if (ret != cnt) {
- free(fitp);
- printf("MMC/SD read of PPA FIT header at offset 0x%x
failed\n",
CONFIG_SYS_LS_PPA_FW_ADDR);
- return -EIO;
- }
- /* flush cache after read */
- flush_cache((ulong)fitp, cnt * 512);
- fw_length = fdt_totalsize(fitp);
- free(fitp);
- fw_length = roundup(fw_length, 512);
- ppa_fit_addr = malloc(fw_length);
- if (!ppa_fit_addr) {
- printf("PPA: malloc failed for PPA image(size 0x%zx)\n",
fw_length);
- return -ENOMEM;
- }
- cnt = DIV_ROUND_UP(fw_length, 512);
- debug("%s: MMC read PPA FIT image: dev # %u, block # %u,
count %u\n",
__func__, dev, blk, cnt);
- ret = mmc->block_dev.block_read(&mmc->block_dev,
- blk, cnt, ppa_fit_addr);
- if (ret != cnt) {
- free(ppa_fit_addr);
- printf("MMC/SD read of PPA FIT header at offset 0x%x
failed\n",
CONFIG_SYS_LS_PPA_FW_ADDR);
- return -EIO;
- }
- flush_cache((ulong)ppa_fit_addr, cnt * 512);
+#elif CONFIG_SYS_LS_PPA_FW_IN_NAND
- struct fdt_header fit;
- debug("%s: PPA image load from NAND\n", __func__);
- nand_init();
- ret = nand_read(nand_info[0],
(loff_t)CONFIG_SYS_LS_PPA_FW_ADDR,
&fdt_header_len, (u_char *)&fit);
- if (ret == -EUCLEAN) {
- printf("NAND read of PPA FIT header at offset 0x%x failed\n",
CONFIG_SYS_LS_PPA_FW_ADDR);
- return -EIO;
- }
- fw_length = fdt_totalsize(&fit);
- ppa_fit_addr = malloc(fw_length);
- if (!ppa_fit_addr) {
- printf("PPA: malloc failed for PPA image(size 0x%zx)\n",
fw_length);
- return -ENOMEM;
- }
- ret = nand_read(nand_info[0],
(loff_t)CONFIG_SYS_LS_PPA_FW_ADDR,
&fw_length, (u_char *)ppa_fit_addr);
- if (ret == -EUCLEAN) {
- free(ppa_fit_addr);
- printf("NAND read of PPA firmware at offset 0x%x failed\n",
CONFIG_SYS_LS_PPA_FW_ADDR);
- return -EIO;
- }
#else #error "No CONFIG_SYS_LS_PPA_FW_IN_xxx defined" #endif
Why do you flush the cache after reading from SD but not from NAND?
Added the flush operation because I referred to the FMan ucode loading process. It works well when loading from SD without the flush cache action, will remove the flush action.
Thanks, Zhiqiang

Hi York,
Thanks so much for your suggestion! Will add a comment there.
Thanks, Zhiqiang
From: york sun Sent: Monday, March 06, 2017 12:36 PM To: Z.Q. Hou zhiqiang.hou@nxp.com; u-boot@lists.denx.de; oss@buserror.net; Mingkai.hu@freescale.com; sjg@chromium.org; Xiaobo Xie xiaobo.xie@nxp.com Subject: RE: [PATCH 3/5] fsl PPA: add support PPA image loading from NAND and SD
Sorry for top posting (using my phone). I think we should flush the cache by range. If you are relying on PPA flushing the cache for you (it is the case now), it's better to put a comment there.
York
-------- Original Message -------- From: "Z.Q. Hou" <zhiqiang.hou@nxp.commailto:zhiqiang.hou@nxp.com> Sent: Sunday, March 5, 2017 07:07 PM To: york sun <york.sun@nxp.commailto:york.sun@nxp.com>,u-boot@lists.denx.de,oss@buserror.net,Mingkai.hu@freescale.com,sjg@chromium.org,Xiaobo Xie <xiaobo.xie@nxp.commailto:xiaobo.xie@nxp.com> Subject: RE: [PATCH 3/5] fsl PPA: add support PPA image loading from NAND and SD
Hi York,
Thanks a lot for your comments!
-----Original Message----- From: york sun Sent: Saturday, March 04, 2017 12:51 AM To: Z.Q. Hou <zhiqiang.hou@nxp.commailto:zhiqiang.hou@nxp.com>; u-boot@lists.denx.demailto:u-boot@lists.denx.de; oss@buserror.netmailto:oss@buserror.net; Mingkai.hu@freescale.commailto:Mingkai.hu@freescale.com; sjg@chromium.orgmailto:sjg@chromium.org; Xiaobo Xie <xiaobo.xie@nxp.commailto:xiaobo.xie@nxp.com> Subject: Re: [PATCH 3/5] fsl PPA: add support PPA image loading from NAND and SD
On 03/03/2017 05:45 AM, Zhiqiang Hou wrote:
From: Hou Zhiqiang <Zhiqiang.Hou@nxp.commailto:Zhiqiang.Hou@nxp.com>
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.commailto:Zhiqiang.Hou@nxp.com>
arch/arm/cpu/armv8/fsl-layerscape/ppa.c | 118 +++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-)
<snip>
#ifdef CONFIG_SYS_LS_PPA_FW_IN_XIP ppa_fit_addr = (void *)CONFIG_SYS_LS_PPA_FW_ADDR;
- debug("%s: PPA image load from XIP\n", __func__); #else /*
+!CONFIG_SYS_LS_PPA_FW_IN_XIP */
- size_t fw_length, fdt_header_len = sizeof(struct fdt_header);
- /* Copy PPA image from MMC/SD/NAND to allocated memory */
#ifdef
+CONFIG_SYS_LS_PPA_FW_IN_MMC
- struct mmc *mmc;
- int dev = CONFIG_SYS_MMC_ENV_DEV;
- struct fdt_header *fitp;
- u32 cnt;
- u32 blk = CONFIG_SYS_LS_PPA_FW_ADDR / 512;
- debug("%s: PPA image load from eMMC/SD\n", __func__);
- mmc_initialize(gd->bd);
- mmc = find_mmc_device(dev);
- if (!mmc) {
- printf("PPA: MMC cannot find device for PPA firmware\n");
- return -ENODEV;
- }
- mmc_init(mmc);
- fitp = malloc(roundup(fdt_header_len, 512));
- if (!fitp) {
- printf("PPA: malloc failed for FIT header(size 0x%zx)\n",
roundup(fdt_header_len, 512));
- return -ENOMEM;
- }
- cnt = DIV_ROUND_UP(fdt_header_len, 512);
- debug("%s: MMC read PPA FIT header: dev # %u, block # %u,
count %u\n",
__func__, dev, blk, cnt);
- ret = mmc->block_dev.block_read(&mmc->block_dev, blk, cnt, fitp);
- if (ret != cnt) {
- free(fitp);
- printf("MMC/SD read of PPA FIT header at offset 0x%x
failed\n",
CONFIG_SYS_LS_PPA_FW_ADDR);
- return -EIO;
- }
- /* flush cache after read */
- flush_cache((ulong)fitp, cnt * 512);
- fw_length = fdt_totalsize(fitp);
- free(fitp);
- fw_length = roundup(fw_length, 512);
- ppa_fit_addr = malloc(fw_length);
- if (!ppa_fit_addr) {
- printf("PPA: malloc failed for PPA image(size 0x%zx)\n",
fw_length);
- return -ENOMEM;
- }
- cnt = DIV_ROUND_UP(fw_length, 512);
- debug("%s: MMC read PPA FIT image: dev # %u, block # %u,
count %u\n",
__func__, dev, blk, cnt);
- ret = mmc->block_dev.block_read(&mmc->block_dev,
- blk, cnt, ppa_fit_addr);
- if (ret != cnt) {
- free(ppa_fit_addr);
- printf("MMC/SD read of PPA FIT header at offset 0x%x
failed\n",
CONFIG_SYS_LS_PPA_FW_ADDR);
- return -EIO;
- }
- flush_cache((ulong)ppa_fit_addr, cnt * 512);
+#elif CONFIG_SYS_LS_PPA_FW_IN_NAND
- struct fdt_header fit;
- debug("%s: PPA image load from NAND\n", __func__);
- nand_init();
- ret = nand_read(nand_info[0],
(loff_t)CONFIG_SYS_LS_PPA_FW_ADDR,
&fdt_header_len, (u_char *)&fit);
- if (ret == -EUCLEAN) {
- printf("NAND read of PPA FIT header at offset 0x%x failed\n",
CONFIG_SYS_LS_PPA_FW_ADDR);
- return -EIO;
- }
- fw_length = fdt_totalsize(&fit);
- ppa_fit_addr = malloc(fw_length);
- if (!ppa_fit_addr) {
- printf("PPA: malloc failed for PPA image(size 0x%zx)\n",
fw_length);
- return -ENOMEM;
- }
- ret = nand_read(nand_info[0],
(loff_t)CONFIG_SYS_LS_PPA_FW_ADDR,
&fw_length, (u_char *)ppa_fit_addr);
- if (ret == -EUCLEAN) {
- free(ppa_fit_addr);
- printf("NAND read of PPA firmware at offset 0x%x failed\n",
CONFIG_SYS_LS_PPA_FW_ADDR);
- return -EIO;
- }
#else #error "No CONFIG_SYS_LS_PPA_FW_IN_xxx defined" #endif
Why do you flush the cache after reading from SD but not from NAND?
Added the flush operation because I referred to the FMan ucode loading process. It works well when loading from SD without the flush cache action, will remove the flush action.
Thanks, Zhiqiang

From: Hou Zhiqiang Zhiqiang.Hou@nxp.com
Signed-off-by: Hou Zhiqiang Zhiqiang.Hou@nxp.com --- arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig index adccdf1..6d2dd15 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig +++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig @@ -122,6 +122,8 @@ config FSL_LS_PPA choice prompt "FSL Layerscape PPA firmware loading-media select" depends on FSL_LS_PPA + default SYS_LS_PPA_FW_IN_MMC if SD_BOOT + default SYS_LS_PPA_FW_IN_NAND if NAND_BOOT default SYS_LS_PPA_FW_IN_XIP
config SYS_LS_PPA_FW_IN_XIP @@ -130,12 +132,24 @@ config SYS_LS_PPA_FW_IN_XIP Say Y here if the PPA firmware locate at XIP flash, such as NOR or QSPI flash.
+config SYS_LS_PPA_FW_IN_MMC + bool "eMMC or SD Card" + help + Say Y here if the PPA firmware locate at eMMC/SD card. + +config SYS_LS_PPA_FW_IN_NAND + bool "NAND" + help + Say Y here if the PPA firmware locate at NAND flash. + endchoice
config SYS_LS_PPA_FW_ADDR hex "Address of PPA firmware loading from" depends on FSL_LS_PPA default 0x40500000 if SYS_LS_PPA_FW_IN_XIP && QSPI_BOOT + default 0x500000 if SYS_LS_PPA_FW_IN_MMC + default 0x500000 if SYS_LS_PPA_FW_IN_NAND default 0x60500000 if SYS_LS_PPA_FW_IN_XIP help If the PPA firmware locate at XIP flash, such as NOR or

From: Hou Zhiqiang Zhiqiang.Hou@nxp.com
Signed-off-by: Hou Zhiqiang Zhiqiang.Hou@nxp.com --- configs/ls1043ardb_nand_defconfig | 1 + configs/ls1043ardb_sdcard_defconfig | 1 + configs/ls1046ardb_emmc_defconfig | 1 + configs/ls1046ardb_sdcard_defconfig | 1 + 4 files changed, 4 insertions(+)
diff --git a/configs/ls1043ardb_nand_defconfig b/configs/ls1043ardb_nand_defconfig index b4aaaa1..1dfbb34 100644 --- a/configs/ls1043ardb_nand_defconfig +++ b/configs/ls1043ardb_nand_defconfig @@ -11,6 +11,7 @@ CONFIG_SPL_WATCHDOG_SUPPORT=y CONFIG_DEFAULT_DEVICE_TREE="fsl-ls1043a-rdb" CONFIG_FIT=y CONFIG_FIT_VERBOSE=y +CONFIG_FSL_LS_PPA=y CONFIG_OF_BOARD_SETUP=y CONFIG_SYS_EXTRA_OPTIONS="RAMBOOT_PBL,SPL_FSL_PBL,NAND_BOOT" CONFIG_NAND_BOOT=y diff --git a/configs/ls1043ardb_sdcard_defconfig b/configs/ls1043ardb_sdcard_defconfig index 5587860..ee83530 100644 --- a/configs/ls1043ardb_sdcard_defconfig +++ b/configs/ls1043ardb_sdcard_defconfig @@ -11,6 +11,7 @@ CONFIG_SPL_WATCHDOG_SUPPORT=y CONFIG_DEFAULT_DEVICE_TREE="fsl-ls1043a-rdb" CONFIG_FIT=y CONFIG_FIT_VERBOSE=y +CONFIG_FSL_LS_PPA=y CONFIG_OF_BOARD_SETUP=y CONFIG_SYS_EXTRA_OPTIONS="RAMBOOT_PBL,SPL_FSL_PBL,SD_BOOT" CONFIG_SD_BOOT=y diff --git a/configs/ls1046ardb_emmc_defconfig b/configs/ls1046ardb_emmc_defconfig index 7b50fc7..1fead97 100644 --- a/configs/ls1046ardb_emmc_defconfig +++ b/configs/ls1046ardb_emmc_defconfig @@ -3,6 +3,7 @@ CONFIG_TARGET_LS1046ARDB=y CONFIG_DEFAULT_DEVICE_TREE="fsl-ls1046a-rdb" CONFIG_FIT=y CONFIG_FIT_VERBOSE=y +CONFIG_FSL_LS_PPA=y CONFIG_OF_BOARD_SETUP=y CONFIG_SYS_EXTRA_OPTIONS="RAMBOOT_PBL,SPL_FSL_PBL,EMMC_BOOT" CONFIG_SD_BOOT=y diff --git a/configs/ls1046ardb_sdcard_defconfig b/configs/ls1046ardb_sdcard_defconfig index 9e6d23b..d0d2860 100644 --- a/configs/ls1046ardb_sdcard_defconfig +++ b/configs/ls1046ardb_sdcard_defconfig @@ -3,6 +3,7 @@ CONFIG_TARGET_LS1046ARDB=y CONFIG_DEFAULT_DEVICE_TREE="fsl-ls1046a-rdb" CONFIG_FIT=y CONFIG_FIT_VERBOSE=y +CONFIG_FSL_LS_PPA=y CONFIG_OF_BOARD_SETUP=y CONFIG_SYS_EXTRA_OPTIONS="RAMBOOT_PBL,SPL_FSL_PBL" CONFIG_SD_BOOT=y

-----Original Message----- From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Zhiqiang Hou Sent: Friday, March 03, 2017 7:01 PM To: u-boot@lists.denx.de; oss@buserror.net; york sun york.sun@nxp.com; Mingkai.hu@freescale.com; sjg@chromium.org; Xiaobo Xie xiaobo.xie@nxp.com Cc: Z.Q. Hou zhiqiang.hou@nxp.com Subject: [U-Boot] [PATCH 1/5] mtd: nand: add initialization flag
From: Hou Zhiqiang Zhiqiang.Hou@nxp.com
Add initialization flag to avoid initializing NAND Flash multiple times, otherwise it will calculate a wrong total size.
Signed-off-by: Hou Zhiqiang Zhiqiang.Hou@nxp.com
drivers/mtd/nand/nand.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c index 0551241..3ea2dcf 100644 --- a/drivers/mtd/nand/nand.c +++ b/drivers/mtd/nand/nand.c @@ -133,6 +133,16 @@ static void create_mtd_concat(void)
void nand_init(void) {
- static int initialized;
- /*
* Avoid initializing NAND Flash multiple times,
* otherwise it will calculate a wrong total size.
*/
- if (initialized)
return;
- initialized = 1;
#ifdef CONFIG_SYS_NAND_SELF_INIT board_nand_init(); #else
If I am correct, above has done to avoid nand_init() if already done from SPL boot. I will suggest to use compile time option to skip nand_init from board_r.c instead of global variable
--prabhakar

Hi Prabhakar,
Thanks for your comments!
-----Original Message----- From: Prabhakar Kushwaha Sent: Tuesday, March 07, 2017 11:17 AM To: Z.Q. Hou zhiqiang.hou@nxp.com; u-boot@lists.denx.de; oss@buserror.net; york sun york.sun@nxp.com; Mingkai.hu@freescale.com; sjg@chromium.org; Xiaobo Xie xiaobo.xie@nxp.com Cc: Z.Q. Hou zhiqiang.hou@nxp.com Subject: RE: [U-Boot] [PATCH 1/5] mtd: nand: add initialization flag
-----Original Message----- From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Zhiqiang Hou Sent: Friday, March 03, 2017 7:01 PM To: u-boot@lists.denx.de; oss@buserror.net; york sun york.sun@nxp.com; Mingkai.hu@freescale.com; sjg@chromium.org;
Xiaobo
Xie xiaobo.xie@nxp.com Cc: Z.Q. Hou zhiqiang.hou@nxp.com Subject: [U-Boot] [PATCH 1/5] mtd: nand: add initialization flag
From: Hou Zhiqiang Zhiqiang.Hou@nxp.com
Add initialization flag to avoid initializing NAND Flash multiple times, otherwise it will calculate a wrong total size.
Signed-off-by: Hou Zhiqiang Zhiqiang.Hou@nxp.com
drivers/mtd/nand/nand.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c index 0551241..3ea2dcf 100644 --- a/drivers/mtd/nand/nand.c +++ b/drivers/mtd/nand/nand.c @@ -133,6 +133,16 @@ static void create_mtd_concat(void)
void nand_init(void) {
- static int initialized;
- /*
* Avoid initializing NAND Flash multiple times,
* otherwise it will calculate a wrong total size.
*/
- if (initialized)
return;
- initialized = 1;
#ifdef CONFIG_SYS_NAND_SELF_INIT board_nand_init(); #else
If I am correct, above has done to avoid nand_init() if already done from SPL boot. I will suggest to use compile time option to skip nand_init from board_r.c instead of global variable
It is not the SPL's matter. When PPA is loaded from NAND flash, the nand_init() will be called by ppa_init(), which is called earlier than the initr_nand(), so it will calculate a wrong total size without this flag.
Could you please help to detail how to use compile time option to skip nand_init from board_r.c?
Thanks, Zhiqiang

-----Original Message----- From: Z.Q. Hou Sent: Tuesday, March 07, 2017 12:27 PM To: Prabhakar Kushwaha prabhakar.kushwaha@nxp.com; u- boot@lists.denx.de; oss@buserror.net; york sun york.sun@nxp.com; Mingkai.hu@freescale.com; sjg@chromium.org; Xiaobo Xie xiaobo.xie@nxp.com Subject: RE: [U-Boot] [PATCH 1/5] mtd: nand: add initialization flag
Hi Prabhakar,
Thanks for your comments!
-----Original Message----- From: Prabhakar Kushwaha Sent: Tuesday, March 07, 2017 11:17 AM To: Z.Q. Hou zhiqiang.hou@nxp.com; u-boot@lists.denx.de; oss@buserror.net; york sun york.sun@nxp.com; Mingkai.hu@freescale.com; sjg@chromium.org; Xiaobo Xie xiaobo.xie@nxp.com Cc: Z.Q. Hou zhiqiang.hou@nxp.com Subject: RE: [U-Boot] [PATCH 1/5] mtd: nand: add initialization flag
-----Original Message----- From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Zhiqiang Hou Sent: Friday, March 03, 2017 7:01 PM To: u-boot@lists.denx.de; oss@buserror.net; york sun york.sun@nxp.com; Mingkai.hu@freescale.com; sjg@chromium.org;
Xiaobo
Xie xiaobo.xie@nxp.com Cc: Z.Q. Hou zhiqiang.hou@nxp.com Subject: [U-Boot] [PATCH 1/5] mtd: nand: add initialization flag
From: Hou Zhiqiang Zhiqiang.Hou@nxp.com
Add initialization flag to avoid initializing NAND Flash multiple times, otherwise it will calculate a wrong total size.
Signed-off-by: Hou Zhiqiang Zhiqiang.Hou@nxp.com
drivers/mtd/nand/nand.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c index 0551241..3ea2dcf 100644 --- a/drivers/mtd/nand/nand.c +++ b/drivers/mtd/nand/nand.c @@ -133,6 +133,16 @@ static void create_mtd_concat(void)
void nand_init(void) {
- static int initialized;
- /*
* Avoid initializing NAND Flash multiple times,
* otherwise it will calculate a wrong total size.
*/
- if (initialized)
return;
- initialized = 1;
#ifdef CONFIG_SYS_NAND_SELF_INIT board_nand_init(); #else
If I am correct, above has done to avoid nand_init() if already done from SPL boot. I will suggest to use compile time option to skip nand_init from board_r.c instead of global variable
It is not the SPL's matter. When PPA is loaded from NAND flash, the nand_init() will be called by ppa_init(), which is called earlier than the initr_nand(), so it will calculate a wrong total size without this flag.
This means you have to use CONFIG_LS_PPA to avoid initr_nand() calling if nand_init() has been used earlier.
--prabhakar

Hi Prabhakar,
Thanks for your comments!
-----Original Message----- From: Prabhakar Kushwaha Sent: Tuesday, March 07, 2017 6:05 PM To: Z.Q. Hou zhiqiang.hou@nxp.com; u-boot@lists.denx.de; oss@buserror.net; york sun york.sun@nxp.com; Mingkai.hu@freescale.com; sjg@chromium.org; Xiaobo Xie xiaobo.xie@nxp.com Subject: RE: [U-Boot] [PATCH 1/5] mtd: nand: add initialization flag
-----Original Message----- From: Z.Q. Hou Sent: Tuesday, March 07, 2017 12:27 PM To: Prabhakar Kushwaha prabhakar.kushwaha@nxp.com; u- boot@lists.denx.de; oss@buserror.net; york sun york.sun@nxp.com; Mingkai.hu@freescale.com; sjg@chromium.org; Xiaobo Xie xiaobo.xie@nxp.com Subject: RE: [U-Boot] [PATCH 1/5] mtd: nand: add initialization flag
Hi Prabhakar,
Thanks for your comments!
-----Original Message----- From: Prabhakar Kushwaha Sent: Tuesday, March 07, 2017 11:17 AM To: Z.Q. Hou zhiqiang.hou@nxp.com; u-boot@lists.denx.de; oss@buserror.net; york sun york.sun@nxp.com; Mingkai.hu@freescale.com; sjg@chromium.org; Xiaobo Xie xiaobo.xie@nxp.com Cc: Z.Q. Hou zhiqiang.hou@nxp.com Subject: RE: [U-Boot] [PATCH 1/5] mtd: nand: add initialization flag
-----Original Message----- From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Zhiqiang Hou Sent: Friday, March 03, 2017 7:01 PM To: u-boot@lists.denx.de; oss@buserror.net; york sun york.sun@nxp.com; Mingkai.hu@freescale.com; sjg@chromium.org;
Xiaobo
Xie xiaobo.xie@nxp.com Cc: Z.Q. Hou zhiqiang.hou@nxp.com Subject: [U-Boot] [PATCH 1/5] mtd: nand: add initialization flag
From: Hou Zhiqiang Zhiqiang.Hou@nxp.com
Add initialization flag to avoid initializing NAND Flash multiple times, otherwise it will calculate a wrong total size.
Signed-off-by: Hou Zhiqiang Zhiqiang.Hou@nxp.com
drivers/mtd/nand/nand.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c index 0551241..3ea2dcf 100644 --- a/drivers/mtd/nand/nand.c +++ b/drivers/mtd/nand/nand.c @@ -133,6 +133,16 @@ static void create_mtd_concat(void)
void nand_init(void) {
- static int initialized;
- /*
* Avoid initializing NAND Flash multiple times,
* otherwise it will calculate a wrong total size.
*/
- if (initialized)
return;
- initialized = 1;
#ifdef CONFIG_SYS_NAND_SELF_INIT board_nand_init(); #else
If I am correct, above has done to avoid nand_init() if already done from SPL boot. I will suggest to use compile time option to skip nand_init from board_r.c instead of global variable
It is not the SPL's matter. When PPA is loaded from NAND flash, the nand_init() will be called by ppa_init(), which is called earlier than the initr_nand(), so it will calculate a wrong total size without this flag.
This means you have to use CONFIG_LS_PPA to avoid initr_nand() calling if nand_init() has been used earlier.
I think the run time determination is more reasonable, because if another function will call nand_init(), it doesn't need to add any other macro.
Thanks, Zhiqiang
participants (4)
-
Prabhakar Kushwaha
-
york sun
-
Z.Q. Hou
-
Zhiqiang Hou