Re: [U-Boot] [PATCH 2/2] i.MX6: nand: add nandbcb command for imx
On 10/06/19 21:18, Shyam Saini wrote: Thanks for this work - this is still missing in current U-Boot. I will merge this for the upcoming release - letting this in, we could win some more testers helping to adjust if there are some issues. >>> >>> Thanks. Looks like it is FINALLY making it into the main tree... >> >> >> Never say never...and it is not yet in. > > Oops > >> Patch breaks several boards due to the moving of mxs-nand.h. In fact, >> drivers/mtd/nand/raw/mxs_nand_dt.c expects to find the file in the same >> directory. > > Sorry, I should have asked this earlier. > The current patch uses some mtd nand driver api to access bch_geometry > elements. I was not sure whether to use driver/ includes files in > arch/ directorty so, I > moved it from divers/ to arch/ directory. > > Would be totally fine if I resend a patch which includes mxs-nand.h > from drivers/ > in arch/ code ? > Yes, it is fine. > Please let me know if you have any other suggestion. > > Thanks a lot, > Shyam > -- = DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] i.MX6: nand: add nandbcb command for imx
On Mon, 10 Jun 2019, Stefano Babic wrote: On 10/06/19 19:35, Sergey Kubushyn wrote: On Mon, 10 Jun 2019, Stefano Babic wrote: Hi Jagan, Shyam, [dd] Thanks for this work - this is still missing in current U-Boot. I will merge this for the upcoming release - letting this in, we could win some more testers helping to adjust if there are some issues. Thanks. Looks like it is FINALLY making it into the main tree... Never say never...and it is not yet in. :) Patch breaks several boards due to the moving of mxs-nand.h. In fact, drivers/mtd/nand/raw/mxs_nand_dt.c expects to find the file in the same directory. Could someone of you fix this and repost, please ? Eh, let Shyam do this -- I'm out of programming realm now, back to Electrical Engineering which is my primary trade... Might get back from time to time as I'm still in charge of lowest level firmware at my new job but that is not my primary role anymore... --- ** * KSI@homeKOI8 Net < > The impossible we do immediately. * * Las Vegas NV, USA < > Miracles require 24-hour notice. * ** ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] i.MX6: nand: add nandbcb command for imx
> >> Thanks for this work - this is still missing in current U-Boot. I will > >> merge this for the upcoming release - letting this in, we could win some > >> more testers helping to adjust if there are some issues. > > > > Thanks. Looks like it is FINALLY making it into the main tree... > > > Never say never...and it is not yet in. Oops > Patch breaks several boards due to the moving of mxs-nand.h. In fact, > drivers/mtd/nand/raw/mxs_nand_dt.c expects to find the file in the same > directory. Sorry, I should have asked this earlier. The current patch uses some mtd nand driver api to access bch_geometry elements. I was not sure whether to use driver/ includes files in arch/ directorty so, I moved it from divers/ to arch/ directory. Would be totally fine if I resend a patch which includes mxs-nand.h from drivers/ in arch/ code ? Please let me know if you have any other suggestion. Thanks a lot, Shyam ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] i.MX6: nand: add nandbcb command for imx
On 10/06/19 19:35, Sergey Kubushyn wrote: > On Mon, 10 Jun 2019, Stefano Babic wrote: > >> Hi Jagan, Shyam, > > [dd] > >> Thanks for this work - this is still missing in current U-Boot. I will >> merge this for the upcoming release - letting this in, we could win some >> more testers helping to adjust if there are some issues. > > Thanks. Looks like it is FINALLY making it into the main tree... Never say never...and it is not yet in. Patch breaks several boards due to the moving of mxs-nand.h. In fact, drivers/mtd/nand/raw/mxs_nand_dt.c expects to find the file in the same directory. Could someone of you fix this and repost, please ? Best regards, Stefano -- = DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] i.MX6: nand: add nandbcb command for imx
On Mon, 10 Jun 2019, Stefano Babic wrote: Hi Jagan, Shyam, [dd] Thanks for this work - this is still missing in current U-Boot. I will merge this for the upcoming release - letting this in, we could win some more testers helping to adjust if there are some issues. Thanks. Looks like it is FINALLY making it into the main tree... --- ** * KSI@homeKOI8 Net < > The impossible we do immediately. * * Las Vegas NV, USA < > Miracles require 24-hour notice. * ** ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] i.MX6: nand: add nandbcb command for imx
Hi Jagan, Shyam, On 06/06/19 10:59, Shyam Saini wrote: > Writing/updating boot image in nand device is not > straight forward in i.MX6 platform and it requires > boot control block(BCB) to be configured. > > It becomes difficult to use uboot 'nand' command to > write BCB since it requires platform specific attributes > need to be taken care of. > > It is even difficult to use existing msx-nand.c driver by > incorporating BCB attributes like mxs_dma_desc does > because it requires change in mtd and nand command. > > So, cmd_nandbcb implemented in arch/arm/mach-imx > > BCB contains two data structures, Firmware Configuration Block(FCB) > and Discovered Bad Block Table(DBBT). FCB has nand timings, > DBBT search area, page address of firmware. > > On summary, nandbcb update will > - erase the entire partition > - create BCB by creating 2 FCB/DBBT block followed by > 1 FW block based on partition size and erasesize. > - fill FCB/DBBT structures > - write FW/SPL on FW1 > - write FCB/DBBT in first 2 blocks > > for nand boot, up on reset bootrom look for FCB structure in > first block's if FCB found the nand timings are loaded for > further reads. once FCB read done, DTTB will load and finally > firmware will be loaded which is boot image. > > Refer section "NAND Boot" from doc/imx/common/imx6.txt for more usage > information. Thanks for this work - this is still missing in current U-Boot. I will merge this for the upcoming release - letting this in, we could win some more testers helping to adjust if there are some issues. Thanks again, Stefano > > Signed-off-by: Jagan Teki > Signed-off-by: Sergey Kubushyn > Signed-off-by: Shyam Saini > --- > Changes for v4: > - Remove obselete apis and use bch_geometry structure for calculating > ecc level, bad block start bit and bad block byte > - Write firmware only once > - Shorten variable names > - Update commit message > - Update docs as per current patch > - Fix checkpatch warnings > Changes for v3: > - Fixed multi-line comments > - Better error handling for failed allocations > Changes for v2: > - Fixed commit message notes > - Updated proper commit message > - Update doc/README.imx6 with NAND boot details > - Fixed long length variable names. > - Fixed Gigantic variable name. > - NULL checks for kzalloc > - Move Kconfig option in separate patch > - Fixed checkpatch warninigs > --- > arch/arm/include/asm/mach-imx/imx-nandbcb.h| 111 +++ > .../arm/include/asm/mach-imx/mxs-nand.h| 0 > arch/arm/mach-imx/Makefile | 1 + > arch/arm/mach-imx/cmd_nandbcb.c| 369 > + > doc/imx/common/imx6.txt| 75 + > drivers/mtd/nand/raw/mxs_nand.c| 2 +- > drivers/mtd/nand/raw/mxs_nand_spl.c| 3 +- > 7 files changed, 559 insertions(+), 2 deletions(-) > create mode 100644 arch/arm/include/asm/mach-imx/imx-nandbcb.h > rename drivers/mtd/nand/raw/mxs_nand.h => > arch/arm/include/asm/mach-imx/mxs-nand.h (100%) > create mode 100644 arch/arm/mach-imx/cmd_nandbcb.c > > diff --git a/arch/arm/include/asm/mach-imx/imx-nandbcb.h > b/arch/arm/include/asm/mach-imx/imx-nandbcb.h > new file mode 100644 > index 00..033659a038 > --- /dev/null > +++ b/arch/arm/include/asm/mach-imx/imx-nandbcb.h > @@ -0,0 +1,111 @@ > +/* > + * Copyright (C) 2017 Jagan Teki > + * > + * SPDX-License-Identifier: GPL-2.0+ > + */ > + > +#ifndef _IMX_NAND_BCB_H_ > +#define _IMX_NAND_BCB_H_ > + > +#define FCB_FINGERPRINT 0x20424346 /* 'FCB' */ > +#define FCB_VERSION_10x0100 > + > +#define DBBT_FINGERPRINT20x54424244 /* 'DBBT' */ > +#define DBBT_VERSION_1 0x0100 > + > +struct dbbt_block { > + u32 checksum; /* reserved on i.MX6 */ > + u32 fingerprint; > + u32 version; > + u32 numberbb; /* reserved on i.MX6 */ > + u32 dbbtpages; > +}; > + > +struct fcb_block { > + u32 checksum; /* First fingerprint in first byte */ > + u32 fingerprint;/* 2nd fingerprint at byte 4 */ > + u32 version;/* 3rd fingerprint at byte 8 */ > + u8 datasetup; > + u8 datahold; > + u8 addr_setup; > + u8 dsample_time; > + > + /* These are for application use only and not for ROM. */ > + u8 nandtiming; > + u8 rea; > + u8 rloh; > + u8 rhoh; > + u32 pagesize; /* 2048 for 2K pages, 4096 for 4K pages */ > + u32 oob_pagesize; /* 2112 for 2K pages, 4314 for 4K pages */ > + u32 sectors;/* Number of 2K sections per block */ > + u32 nr_nand;/* Total Number of NANDs - not used by ROM */ > + u32 nr_die; /* Number of separate chips in this NAND */ > + u32 celltype; /* MLC or SLC */ > + u32 ecc_type; /* Type of ECC, can be one of BCH-0-20 */ > + u32 ecc_nr; /* Number of bytes for Block0 - BCH */ > + > +
[U-Boot] [PATCH 2/2] i.MX6: nand: add nandbcb command for imx
Writing/updating boot image in nand device is not straight forward in i.MX6 platform and it requires boot control block(BCB) to be configured. It becomes difficult to use uboot 'nand' command to write BCB since it requires platform specific attributes need to be taken care of. It is even difficult to use existing msx-nand.c driver by incorporating BCB attributes like mxs_dma_desc does because it requires change in mtd and nand command. So, cmd_nandbcb implemented in arch/arm/mach-imx BCB contains two data structures, Firmware Configuration Block(FCB) and Discovered Bad Block Table(DBBT). FCB has nand timings, DBBT search area, page address of firmware. On summary, nandbcb update will - erase the entire partition - create BCB by creating 2 FCB/DBBT block followed by 1 FW block based on partition size and erasesize. - fill FCB/DBBT structures - write FW/SPL on FW1 - write FCB/DBBT in first 2 blocks for nand boot, up on reset bootrom look for FCB structure in first block's if FCB found the nand timings are loaded for further reads. once FCB read done, DTTB will load and finally firmware will be loaded which is boot image. Refer section "NAND Boot" from doc/imx/common/imx6.txt for more usage information. Signed-off-by: Jagan Teki Signed-off-by: Sergey Kubushyn Signed-off-by: Shyam Saini --- Changes for v4: - Remove obselete apis and use bch_geometry structure for calculating ecc level, bad block start bit and bad block byte - Write firmware only once - Shorten variable names - Update commit message - Update docs as per current patch - Fix checkpatch warnings Changes for v3: - Fixed multi-line comments - Better error handling for failed allocations Changes for v2: - Fixed commit message notes - Updated proper commit message - Update doc/README.imx6 with NAND boot details - Fixed long length variable names. - Fixed Gigantic variable name. - NULL checks for kzalloc - Move Kconfig option in separate patch - Fixed checkpatch warninigs --- arch/arm/include/asm/mach-imx/imx-nandbcb.h| 111 +++ .../arm/include/asm/mach-imx/mxs-nand.h| 0 arch/arm/mach-imx/Makefile | 1 + arch/arm/mach-imx/cmd_nandbcb.c| 369 + doc/imx/common/imx6.txt| 75 + drivers/mtd/nand/raw/mxs_nand.c| 2 +- drivers/mtd/nand/raw/mxs_nand_spl.c| 3 +- 7 files changed, 559 insertions(+), 2 deletions(-) create mode 100644 arch/arm/include/asm/mach-imx/imx-nandbcb.h rename drivers/mtd/nand/raw/mxs_nand.h => arch/arm/include/asm/mach-imx/mxs-nand.h (100%) create mode 100644 arch/arm/mach-imx/cmd_nandbcb.c diff --git a/arch/arm/include/asm/mach-imx/imx-nandbcb.h b/arch/arm/include/asm/mach-imx/imx-nandbcb.h new file mode 100644 index 00..033659a038 --- /dev/null +++ b/arch/arm/include/asm/mach-imx/imx-nandbcb.h @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2017 Jagan Teki + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifndef _IMX_NAND_BCB_H_ +#define _IMX_NAND_BCB_H_ + +#define FCB_FINGERPRINT0x20424346 /* 'FCB' */ +#define FCB_VERSION_1 0x0100 + +#define DBBT_FINGERPRINT2 0x54424244 /* 'DBBT' */ +#define DBBT_VERSION_1 0x0100 + +struct dbbt_block { + u32 checksum; /* reserved on i.MX6 */ + u32 fingerprint; + u32 version; + u32 numberbb; /* reserved on i.MX6 */ + u32 dbbtpages; +}; + +struct fcb_block { + u32 checksum; /* First fingerprint in first byte */ + u32 fingerprint;/* 2nd fingerprint at byte 4 */ + u32 version;/* 3rd fingerprint at byte 8 */ + u8 datasetup; + u8 datahold; + u8 addr_setup; + u8 dsample_time; + + /* These are for application use only and not for ROM. */ + u8 nandtiming; + u8 rea; + u8 rloh; + u8 rhoh; + u32 pagesize; /* 2048 for 2K pages, 4096 for 4K pages */ + u32 oob_pagesize; /* 2112 for 2K pages, 4314 for 4K pages */ + u32 sectors;/* Number of 2K sections per block */ + u32 nr_nand;/* Total Number of NANDs - not used by ROM */ + u32 nr_die; /* Number of separate chips in this NAND */ + u32 celltype; /* MLC or SLC */ + u32 ecc_type; /* Type of ECC, can be one of BCH-0-20 */ + u32 ecc_nr; /* Number of bytes for Block0 - BCH */ + + /* Block size in bytes for all blocks other than Block0 - BCH */ + u32 ecc_size; + u32 ecc_level; /* Ecc level for Block 0 - BCH */ + u32 meta_size; /* Metadata size - BCH */ + /* Number of blocks per page for ROM use - BCH */ + u32 nr_blocks; + u32 ecc_type_sdk; /* Type of ECC, can be one of BCH-0-20 */ + u32 ecc_nr_sdk; /* Number of bytes for Block0 - BCH */ + /* Block size in bytes for all blocks other