i.MX6: nand: extend nandbcb command for imx6UL(L)
Subsystems (3)
PATCH v2 1/2 i.MX6: nand: extend nandbcb command for imx6UL(L)
Firmware Configuration Block(FCB) for imx6ul(l) needs to be BCH encoded. This patch depends on [1].
[1]: https://patchwork.ozlabs.org/project/uboot/list/?series=113810
---
Notes:
Changes in v2:
- use kfree instead of free
arch/arm/mach-imx/Kconfig | 1 + arch/arm/mach-imx/cmd_nandbcb.c | 72 ++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 2 deletions(-)
arch/arm/mach-imx/Kconfig +1 -0
@@ -74,6 +74,7 @@ config CMD_HDMIDETECT config CMD_NANDBCB bool "i.MX6 NAND Boot Control Block(BCB) command" depends on NAND && CMD_MTDPARTS + select BCH if MX6UL || MX6ULL default y if ARCH_MX6 && NAND_MXS help Unlike normal 'nand write/erase' commands, this command update
arch/arm/mach-imx/cmd_nandbcb.c +70 -2
92 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v2 2/2 imx: pcl063: add nand boot support
Booting from NAND needs nandbcb and nand boot device selection
---
Notes:
Changes in v2:
- None
board/phytec/pcl063/spl.c | 3 +++ configs/phycore_pcl063_defconfig | 1 + 2 files changed, 4 insertions(+)
board/phytec/pcl063/spl.c +3 -0
@@ -197,6 +197,9 @@ void board_boot_order(u32 *spl_boot_list)case IMX6_BMODE_EMMC : boot_dev =BOOT_DEVICE_MMC2 ;break ; + case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX: + boot_dev =BOOT_DEVICE_NAND ; +break ;default :/* Default - BOOT_DEVICE_MMC1 */ printf ("Wrong board boot order\n" );
configs/phycore_pcl063_defconfig +1 -0
@@ -27,6 +27,7 @@ CONFIG_CMD_MTD=y CONFIG_CMD_USB=y CONFIG_CMD_USB_SDP=y CONFIG_CMD_CACHE=y +CONFIG_CMD_NANDBCB=y CONFIG_MTDIDS_DEFAULT="nand0=gpmi-nand" CONFIG_MTDPARTS_DEFAULT="gpmi-nand:4m(uboot),1m(env),-(root)" CONFIG_CMD_UBI=y
Signature · 1 line
2.21.0
PATCH v2 2/2 imx: pcl063: add nand boot support
Quoted 35 lines
Subject: [PATCH v2 2/2] imx: pcl063: add nand boot support
Booting from NAND needs nandbcb and nand boot device selection
Signed-off-by Parthiban Nallathambi <[email protected]>---
Notes:
Changes in v2:
- Noneboard/phytec/pcl063/spl.c | 3 +++ configs/phycore_pcl063_defconfig | 1 + 2 files changed, 4 insertions(+)board/phytec/pcl063/spl.c index renamed from board/phytec/pcl063/spl.c +0
-0
6d4c827918..358156bfbc100644board/phytec/pcl063/spl.c +3
-0@@ -197,6 +197,9 @@ void board_boot_order(u32 *spl_boot_list)case IMX6_BMODE_EMMC : boot_dev =BOOT_DEVICE_MMC2 ;break ; + case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX: + boot_dev =BOOT_DEVICE_NAND ; +break ;default :/* Default - BOOT_DEVICE_MMC1 */ printf ("Wrong board boot order\n" );configs/phycore_pcl063_defconfig +0
-0
configs/phycore_pcl063_defconfig CONFIG_CMD_MTD=y · line 33
Quoted 7 lines
configs/phycore_pcl063_defconfig +1
-0@@ -27,6 +27,7 @@ CONFIG_CMD_MTD=y CONFIG_CMD_USB=y CONFIG_CMD_USB_SDP=y CONFIG_CMD_CACHE=y +CONFIG_CMD_NANDBCB=y CONFIG_MTDIDS_DEFAULT="nand0=gpmi-nand" CONFIG_MTDPARTS_DEFAULT="gpmi-nand:4m(uboot),1m(env),-(root)" CONFIG_CMD_UBI=y
Quoted 2 lines
--
2.21.0
PATCH v2 1/2 i.MX6: nand: extend nandbcb command for imx6UL(L)
In reply to Parthiban NallathambiQuoted 14 lines
Subject: [PATCH v2 1/2] i.MX6: nand: extend nandbcb command for imx6UL(L)
Firmware Configuration Block(FCB) for imx6ul(l) needs to be BCH encoded. This patch depends on [1].
[1]:
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatch
work.ozlabs.org%2Fproject%2Fuboot%2Flist%2F%3Fseries%3D113810& data=02%7C01%7Cpeng.fan%40nxp.com%7Cd3b7409c0d254724d28508d727 e5c283%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637021740 084139651&sdata=SxaieXR9bG3ChctaPrpYBI6yqXOD6blKSu6tjP0qccE%3 D&reserved=0
Quoted 2 lines
Signed-off-by Parthiban Nallathambi <[email protected]>Acked-by Shyam Saini <[email protected]>
Quoted 128 lines
---
Notes:
Changes in v2:
- use kfree instead of freearch/arm/mach-imx/Kconfig | 1 + arch/arm/mach-imx/cmd_nandbcb.c | 72 ++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 2 deletions(-)arch/arm/mach-imx/Kconfig index renamed from arch/arm/mach-imx/Kconfig +0
-0
aeb5493488..175bed601e100644arch/arm/mach-imx/Kconfig +1
-0@@ -74,6 +74,7 @@ config CMD_HDMIDETECT config CMD_NANDBCB bool "i.MX6 NAND Boot Control Block(BCB) command" depends on NAND && CMD_MTDPARTS + select BCH if MX6UL || MX6ULL default y if ARCH_MX6 && NAND_MXS help Unlike normal 'nand write/erase' commands, this command update(quoted diff) +0
-0
b/arch/arm/mach-imx/cmd_nandbcb.cindex065b814b2e..e11df401e4100644arch/arm/mach-imx/cmd_nandbcb.c +70
-2@@ -14,8 +14,10 @@#include <asm/io.h> #include <jffs2/jffs2.h> +#include <linux/bch.h> #include <linux/mtd/mtd.h> +#include <asm/arch/sys_proto.h> #include <asm/mach-imx/imx-nandbcb.h> #include <asm/mach-imx/imximage.cfg> #include <mxs_nand.h> @@ -25,6 +27,66 @@#define BF_VAL (v, bf) (((v) & bf##_MASK) >> bf##_OFFSET)#define GETBIT (v, n) (((v) >> (n)) & 0x1) +static uint8_t reverse_bit (uint8_t b) +{ + b = (b &0xf0 ) >>4 | (b &0x0f ) <<4 ; + b = (b &0xcc ) >>2 | (b &0x33 ) <<2 ; + b = (b &0xaa ) >>1 | (b &0x55 ) <<1 ; + +return b; +} + +static void encode_bch_ecc (void *buf,struct fcb_block *fcb,int +eccbits) { +int i, j, m =13 ; +int blocksize =128 ; +int numblocks =8 ; +int ecc_buf_size = (m * eccbits +7 ) /8 ; +struct bch_control *bch =init_bch (m, eccbits,0 ); +u8 *ecc_buf =kzalloc (ecc_buf_size,GFP_KERNEL ); +u8 *tmp_buf =kzalloc (blocksize * numblocks,GFP_KERNEL ); +u8 *psrc, *pdst; + +/* +* The blocks here are bit aligned. If eccbits is a multiple of 8, +* we just can copy bytes. Otherwiese we must move the blocks to +* the next free bit position. +*/ +WARN_ON (eccbits %8 ); + +memcpy (tmp_buf, fcb,sizeof (*fcb)); + +for (i =0 ; i < numblocks; i++) { +memset (ecc_buf,0 , ecc_buf_size); + psrc = tmp_buf + i * blocksize; + pdst = buf + i * (blocksize + ecc_buf_size); + +/* copy data byte aligned to destination buf */ +memcpy (pdst, psrc, blocksize); + +/* +* imx-kobs use a modified encode_bch which reverse the +* bit order of the data before calculating bch. +* Do this in the buffer and use the bch lib here. +*/ +for (j =0 ; j < blocksize; j++) + psrc[j] =reverse_bit (psrc[j]); + +encode_bch (bch, psrc, blocksize, ecc_buf); + +/* reverse ecc bit */ +for (j =0 ; j < ecc_buf_size; j++) + ecc_buf[j] =reverse_bit (ecc_buf[j]); + +/* Here eccbuf is byte aligned and we can just copy it */ +memcpy (pdst + blocksize, ecc_buf, ecc_buf_size); + } + +kfree (ecc_buf); +kfree (tmp_buf); +free_bch (bch); +} +static u8 calculate_parity_13_8 (u8 d) {u8 p =0 ;@@ -231,8 +293,14 @@ static int nandbcb_update(struct mtd_info *mtd, loff_t off, size_t size, goto dbbt_data_page_err; } -memcpy (fcb_raw_page +12 , fcb,sizeof (struct fcb_block )); -encode_hamming_13_8 (fcb_raw_page +12 , fcb_raw_page +12 +512 , 512); +if (is_mx6ul () ||is_mx6ull ()) { +/* 40 bit BCH, for i.MX6UL(L) */ +encode_bch_ecc (fcb_raw_page +32 , fcb,40 ); + }else { +memcpy (fcb_raw_page +12 , fcb,sizeof (struct fcb_block )); +encode_hamming_13_8 (fcb_raw_page +12 , + fcb_raw_page +12 +512 ,512 ); + }/* arch/arm/mach-imx/cmd_nandbcb.c +0
-0* Set the first and second byte of OOB data to 0xFF, not 0x00. These * bytes are used as the Manufacturers Bad Block Marker (MBBM). Since
--
2.21.0
PATCH v2 1/2 i.MX6: nand: extend nandbcb command for imx6UL(L)
In reply to Parthiban NallathambiHi Parthiban,
Quoted 5 lines · Parthiban Nallathambi
Firmware Configuration Block(FCB) for imx6ul(l) needs to be BCH encoded. This patch depends on [1].
[1]: https://patchwork.ozlabs.org/project/uboot/list/?series=113810
Why does it depend on this if it is just defoconfig for a board ?
Quoted 17 lines
Signed-off-by Parthiban Nallathambi <[email protected]>Acked-by Shyam Saini <[email protected]>---
Notes:
Changes in v2:
- use kfree instead of freearch/arm/mach-imx/Kconfig | 1 + arch/arm/mach-imx/cmd_nandbcb.c | 72 ++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 2 deletions(-)arch/arm/mach-imx/Kconfig +0
-0
arch/arm/mach-imx/Kconfig config CMD_HDMIDETECT · line 77
Quoted 4 lines
arch/arm/mach-imx/Kconfig +1
-0@@ -74,6 +74,7 @@ config CMD_HDMIDETECT config CMD_NANDBCB bool "i.MX6 NAND Boot Control Block(BCB) command" depends on NAND && CMD_MTDPARTS + select BCH if MX6UL || MX6ULL
This eems to break all i.MX6 boards (not UL(L)) using NAND. In fact, I get these errors:
Building current source for 1 boards (1 thread, 8 jobs per thread)
arm: + pfla02+arch/arm/mach-imx/built-in.o: In function `encode_bch_ecc':+arch/arm/mach-imx/cmd_nandbcb.c:45: undefined reference to init_bch' +arch/arm/mach-imx/cmd_nandbcb.c:75: undefined reference to encode_bch' +arch/arm/mach-imx/cmd_nandbcb.c:87: undefined reference to `free_bch' +arm-poky-linux-gnueabi-ld.bfd: BFD (GNU Binutils) 2.28.0.20170307 assertion fail ../../bfd/elf32-arm.c:9512
+make[1]: *** [u-boot] Error 1
+make: *** [sub-make] Error 2
0 0 1 /1 pfla02
Can you check this please ? I temporary remove the patch from -next branch.
Best regards,
Stefano Babic
Quoted 103 lines
arch/arm/mach-imx/Kconfig +0
-0default y if ARCH_MX6 && NAND_MXS help Unlike normal 'nand write/erase' commands, this command updatearch/arm/mach-imx/cmd_nandbcb.c +70
-2@@ -14,8 +14,10 @@#include <asm/io.h> #include <jffs2/jffs2.h> +#include <linux/bch.h> #include <linux/mtd/mtd.h> +#include <asm/arch/sys_proto.h> #include <asm/mach-imx/imx-nandbcb.h> #include <asm/mach-imx/imximage.cfg> #include <mxs_nand.h> @@ -25,6 +27,66 @@#define BF_VAL (v, bf) (((v) & bf##_MASK) >> bf##_OFFSET)#define GETBIT (v, n) (((v) >> (n)) & 0x1) +static uint8_t reverse_bit (uint8_t b) +{ + b = (b &0xf0 ) >>4 | (b &0x0f ) <<4 ; + b = (b &0xcc ) >>2 | (b &0x33 ) <<2 ; + b = (b &0xaa ) >>1 | (b &0x55 ) <<1 ; + +return b; +} + +static void encode_bch_ecc (void *buf,struct fcb_block *fcb,int eccbits) +{ +int i, j, m =13 ; +int blocksize =128 ; +int numblocks =8 ; +int ecc_buf_size = (m * eccbits +7 ) /8 ; +struct bch_control *bch =init_bch (m, eccbits,0 ); +u8 *ecc_buf =kzalloc (ecc_buf_size,GFP_KERNEL ); +u8 *tmp_buf =kzalloc (blocksize * numblocks,GFP_KERNEL ); +u8 *psrc, *pdst; + +/* +* The blocks here are bit aligned. If eccbits is a multiple of 8, +* we just can copy bytes. Otherwiese we must move the blocks to +* the next free bit position. +*/ +WARN_ON (eccbits %8 ); + +memcpy (tmp_buf, fcb,sizeof (*fcb)); + +for (i =0 ; i < numblocks; i++) { +memset (ecc_buf,0 , ecc_buf_size); + psrc = tmp_buf + i * blocksize; + pdst = buf + i * (blocksize + ecc_buf_size); + +/* copy data byte aligned to destination buf */ +memcpy (pdst, psrc, blocksize); + +/* +* imx-kobs use a modified encode_bch which reverse the +* bit order of the data before calculating bch. +* Do this in the buffer and use the bch lib here. +*/ +for (j =0 ; j < blocksize; j++) + psrc[j] =reverse_bit (psrc[j]); + +encode_bch (bch, psrc, blocksize, ecc_buf); + +/* reverse ecc bit */ +for (j =0 ; j < ecc_buf_size; j++) + ecc_buf[j] =reverse_bit (ecc_buf[j]); + +/* Here eccbuf is byte aligned and we can just copy it */ +memcpy (pdst + blocksize, ecc_buf, ecc_buf_size); + } + +kfree (ecc_buf); +kfree (tmp_buf); +free_bch (bch); +} +static u8 calculate_parity_13_8 (u8 d) {u8 p =0 ;@@ -231,8 +293,14 @@ static int nandbcb_update(struct mtd_info *mtd, loff_t off, size_t size, goto dbbt_data_page_err; } -memcpy (fcb_raw_page +12 , fcb,sizeof (struct fcb_block )); -encode_hamming_13_8 (fcb_raw_page +12 , fcb_raw_page +12 +512 ,512 ); +if (is_mx6ul () ||is_mx6ull ()) { +/* 40 bit BCH, for i.MX6UL(L) */ +encode_bch_ecc (fcb_raw_page +32 , fcb,40 ); + }else { +memcpy (fcb_raw_page +12 , fcb,sizeof (struct fcb_block )); +encode_hamming_13_8 (fcb_raw_page +12 , + fcb_raw_page +12 +512 ,512 ); + }/* * Set the first and second byte of OOB data to 0xFF, not 0x00. These * bytes are used as the Manufacturers Bad Block Marker (MBBM). Since
Signature · 5 lines
===================================================================== 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: sbabic at denx.de =====================================================================
PATCH v2 1/2 i.MX6: nand: extend nandbcb command for imx6UL(L)
Hi Stefano,
Quoted 10 lines · Stefano Babic
Hi Parthiban,
Quoted 5 lines · Parthiban Nallathambi
Firmware Configuration Block(FCB) for imx6ul(l) needs to be BCH encoded. This patch depends on [1].
[1]: https://patchwork.ozlabs.org/project/uboot/list/?series=113810
Why does it depend on this if it is just defoconfig for a board ?
The patch series was nandbcb inclusion, but this is already merged in u-boot. patchwork query shows only the pending merger now.
As the nandbcb is already in mainline, this patch should apply fine.
Thanks,
Parthiban N
Quoted 148 lines
Quoted 18 lines
Signed-off-by Parthiban Nallathambi <[email protected]>Acked-by Shyam Saini <[email protected]>---
Notes:
Changes in v2:
- use kfree instead of freearch/arm/mach-imx/Kconfig | 1 + arch/arm/mach-imx/cmd_nandbcb.c | 72 ++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 2 deletions(-)arch/arm/mach-imx/Kconfig +0
-0arch/arm/mach-imx/Kconfig config CMD_HDMIDETECT · line 77
Quoted 4 lines
arch/arm/mach-imx/Kconfig +1
-0@@ -74,6 +74,7 @@ config CMD_HDMIDETECT config CMD_NANDBCB bool "i.MX6 NAND Boot Control Block(BCB) command" depends on NAND && CMD_MTDPARTS + select BCH if MX6UL || MX6ULLThis eems to break all i.MX6 boards (not UL(L)) using NAND. In fact, I get these errors:
Building current source for 1 boards (1 thread, 8 jobs per thread)
arm: + pfla02(quoted diff) +5
-0+arch/arm/mach-imx/built-in.o: In function `encode_bch_ecc': +arch/arm/mach-imx/cmd_nandbcb.c:45: undefined reference to `init_bch' +arch/arm/mach-imx/cmd_nandbcb.c:75: undefined reference to `encode_bch' +arch/arm/mach-imx/cmd_nandbcb.c:87: undefined reference to `free_bch' +arm-poky-linux-gnueabi-ld.bfd: BFD (GNU Binutils) 2.28.0.20170307assertion fail
../../bfd/elf32-arm.c:9512(quoted diff) +2
-0+make[1]: *** [u-boot] Error 1 +make: *** [sub-make] Error 2 0 0 1 /1 pfla02Can you check this please ? I temporary remove the patch from -next branch.
Best regards,
Stefano BabicQuoted 103 lines
arch/arm/mach-imx/Kconfig +0
-0default y if ARCH_MX6 && NAND_MXS help Unlike normal 'nand write/erase' commands, this command updatearch/arm/mach-imx/cmd_nandbcb.c +70
-2@@ -14,8 +14,10 @@#include <asm/io.h> #include <jffs2/jffs2.h> +#include <linux/bch.h> #include <linux/mtd/mtd.h> +#include <asm/arch/sys_proto.h> #include <asm/mach-imx/imx-nandbcb.h> #include <asm/mach-imx/imximage.cfg> #include <mxs_nand.h> @@ -25,6 +27,66 @@#define BF_VAL (v, bf) (((v) & bf##_MASK) >> bf##_OFFSET)#define GETBIT (v, n) (((v) >> (n)) & 0x1) +static uint8_t reverse_bit (uint8_t b) +{ + b = (b &0xf0 ) >>4 | (b &0x0f ) <<4 ; + b = (b &0xcc ) >>2 | (b &0x33 ) <<2 ; + b = (b &0xaa ) >>1 | (b &0x55 ) <<1 ; + +return b; +} + +static void encode_bch_ecc (void *buf,struct fcb_block *fcb,int eccbits) +{ +int i, j, m =13 ; +int blocksize =128 ; +int numblocks =8 ; +int ecc_buf_size = (m * eccbits +7 ) /8 ; +struct bch_control *bch =init_bch (m, eccbits,0 ); +u8 *ecc_buf =kzalloc (ecc_buf_size,GFP_KERNEL ); +u8 *tmp_buf =kzalloc (blocksize * numblocks,GFP_KERNEL ); +u8 *psrc, *pdst; + +/* +* The blocks here are bit aligned. If eccbits is a multiple of 8, +* we just can copy bytes. Otherwiese we must move the blocks to +* the next free bit position. +*/ +WARN_ON (eccbits %8 ); + +memcpy (tmp_buf, fcb,sizeof (*fcb)); + +for (i =0 ; i < numblocks; i++) { +memset (ecc_buf,0 , ecc_buf_size); + psrc = tmp_buf + i * blocksize; + pdst = buf + i * (blocksize + ecc_buf_size); + +/* copy data byte aligned to destination buf */ +memcpy (pdst, psrc, blocksize); + +/* +* imx-kobs use a modified encode_bch which reverse the +* bit order of the data before calculating bch. +* Do this in the buffer and use the bch lib here. +*/ +for (j =0 ; j < blocksize; j++) + psrc[j] =reverse_bit (psrc[j]); + +encode_bch (bch, psrc, blocksize, ecc_buf); + +/* reverse ecc bit */ +for (j =0 ; j < ecc_buf_size; j++) + ecc_buf[j] =reverse_bit (ecc_buf[j]); + +/* Here eccbuf is byte aligned and we can just copy it */ +memcpy (pdst + blocksize, ecc_buf, ecc_buf_size); + } + +kfree (ecc_buf); +kfree (tmp_buf); +free_bch (bch); +} +static u8 calculate_parity_13_8 (u8 d) {u8 p =0 ;@@ -231,8 +293,14 @@ static int nandbcb_update(struct mtd_info *mtd, loff_t off, size_t size, goto dbbt_data_page_err; } -memcpy (fcb_raw_page +12 , fcb,sizeof (struct fcb_block )); -encode_hamming_13_8 (fcb_raw_page +12 , fcb_raw_page +12 +512 ,512 ); +if (is_mx6ul () ||is_mx6ull ()) { +/* 40 bit BCH, for i.MX6UL(L) */ +encode_bch_ecc (fcb_raw_page +32 , fcb,40 ); + }else { +memcpy (fcb_raw_page +12 , fcb,sizeof (struct fcb_block )); +encode_hamming_13_8 (fcb_raw_page +12 , + fcb_raw_page +12 +512 ,512 ); + }/* * Set the first and second byte of OOB data to 0xFF, not 0x00. These * bytes are used as the Manufacturers Bad Block Marker (MBBM). Since
Signature · 6 lines
Thanks, Parthiban N DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-22 Fax: (+49)-8142-66989-80 Email: pn at denx.de
PATCH v2 1/2 i.MX6: nand: extend nandbcb command for imx6UL(L)
Quoted 12 lines · Parthiban Nallathambi
Hi Stefano,
Quoted 9 lines · Stefano Babic
Hi Parthiban,
Quoted 5 lines · Parthiban Nallathambi
Firmware Configuration Block(FCB) for imx6ul(l) needs to be BCH encoded. This patch depends on [1].
[1]: https://patchwork.ozlabs.org/project/uboot/list/?series=113810
Quoted 6 lines
Quoted 1 line
Why does it depend on this if it is just defoconfig for a board ?
The patch series was nandbcb inclusion, but this is already merged in u-boot. patchwork query shows only the pending merger now.
As the nandbcb is already in mainline, this patch should apply fine.
Please read the whole e-mail. Issue is not that patch cannot be applied, issue is that it breaks several boards. All i.MX6 boards with NAND - check again:
Quoted 11 lines
Review
Quoted 11 lines
Building current source for 1 boards (1 thread, 8 jobs per thread)
arm: + pfla02(quoted diff) +5
-0+arch/arm/mach-imx/built-in.o: In function `encode_bch_ecc': +arch/arm/mach-imx/cmd_nandbcb.c:45: undefined reference to `init_bch' +arch/arm/mach-imx/cmd_nandbcb.c:75: undefined reference to `encode_bch' +arch/arm/mach-imx/cmd_nandbcb.c:87: undefined reference to `free_bch' +arm-poky-linux-gnueabi-ld.bfd: BFD (GNU Binutils) 2.28.0.20170307assertion fail
../../bfd/elf32-arm.c:9512(quoted diff) +2
-0+make[1]: *** [u-boot] Error 1 +make: *** [sub-make] Error 2 0 0 1 /1 pfla02
The same happens to other boards, too.
Best regards,
Stefano Babic
Quoted 153 lines
Thanks,
Parthiban NQuoted 148 lines
Quoted 18 lines
Signed-off-by Parthiban Nallathambi <[email protected]>Acked-by Shyam Saini <[email protected]>---
Notes:
Changes in v2:
- use kfree instead of freearch/arm/mach-imx/Kconfig | 1 + arch/arm/mach-imx/cmd_nandbcb.c | 72 ++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 2 deletions(-)arch/arm/mach-imx/Kconfig +0
-0arch/arm/mach-imx/Kconfig config CMD_HDMIDETECT · line 77
Quoted 4 lines
arch/arm/mach-imx/Kconfig +1
-0@@ -74,6 +74,7 @@ config CMD_HDMIDETECT config CMD_NANDBCB bool "i.MX6 NAND Boot Control Block(BCB) command" depends on NAND && CMD_MTDPARTS + select BCH if MX6UL || MX6ULLThis eems to break all i.MX6 boards (not UL(L)) using NAND. In fact, I get these errors:
Building current source for 1 boards (1 thread, 8 jobs per thread)
arm: + pfla02(quoted diff) +5
-0+arch/arm/mach-imx/built-in.o: In function `encode_bch_ecc': +arch/arm/mach-imx/cmd_nandbcb.c:45: undefined reference to `init_bch' +arch/arm/mach-imx/cmd_nandbcb.c:75: undefined reference to `encode_bch' +arch/arm/mach-imx/cmd_nandbcb.c:87: undefined reference to `free_bch' +arm-poky-linux-gnueabi-ld.bfd: BFD (GNU Binutils) 2.28.0.20170307assertion fail
../../bfd/elf32-arm.c:9512(quoted diff) +2
-0+make[1]: *** [u-boot] Error 1 +make: *** [sub-make] Error 2 0 0 1 /1 pfla02Can you check this please ? I temporary remove the patch from -next branch.
Best regards,
Stefano BabicQuoted 103 lines
arch/arm/mach-imx/Kconfig +0
-0default y if ARCH_MX6 && NAND_MXS help Unlike normal 'nand write/erase' commands, this command updatearch/arm/mach-imx/cmd_nandbcb.c +70
-2@@ -14,8 +14,10 @@#include <asm/io.h> #include <jffs2/jffs2.h> +#include <linux/bch.h> #include <linux/mtd/mtd.h> +#include <asm/arch/sys_proto.h> #include <asm/mach-imx/imx-nandbcb.h> #include <asm/mach-imx/imximage.cfg> #include <mxs_nand.h> @@ -25,6 +27,66 @@#define BF_VAL (v, bf) (((v) & bf##_MASK) >> bf##_OFFSET)#define GETBIT (v, n) (((v) >> (n)) & 0x1) +static uint8_t reverse_bit (uint8_t b) +{ + b = (b &0xf0 ) >>4 | (b &0x0f ) <<4 ; + b = (b &0xcc ) >>2 | (b &0x33 ) <<2 ; + b = (b &0xaa ) >>1 | (b &0x55 ) <<1 ; + +return b; +} + +static void encode_bch_ecc (void *buf,struct fcb_block *fcb,int eccbits) +{ +int i, j, m =13 ; +int blocksize =128 ; +int numblocks =8 ; +int ecc_buf_size = (m * eccbits +7 ) /8 ; +struct bch_control *bch =init_bch (m, eccbits,0 ); +u8 *ecc_buf =kzalloc (ecc_buf_size,GFP_KERNEL ); +u8 *tmp_buf =kzalloc (blocksize * numblocks,GFP_KERNEL ); +u8 *psrc, *pdst; + +/* +* The blocks here are bit aligned. If eccbits is a multiple of 8, +* we just can copy bytes. Otherwiese we must move the blocks to +* the next free bit position. +*/ +WARN_ON (eccbits %8 ); + +memcpy (tmp_buf, fcb,sizeof (*fcb)); + +for (i =0 ; i < numblocks; i++) { +memset (ecc_buf,0 , ecc_buf_size); + psrc = tmp_buf + i * blocksize; + pdst = buf + i * (blocksize + ecc_buf_size); + +/* copy data byte aligned to destination buf */ +memcpy (pdst, psrc, blocksize); + +/* +* imx-kobs use a modified encode_bch which reverse the +* bit order of the data before calculating bch. +* Do this in the buffer and use the bch lib here. +*/ +for (j =0 ; j < blocksize; j++) + psrc[j] =reverse_bit (psrc[j]); + +encode_bch (bch, psrc, blocksize, ecc_buf); + +/* reverse ecc bit */ +for (j =0 ; j < ecc_buf_size; j++) + ecc_buf[j] =reverse_bit (ecc_buf[j]); + +/* Here eccbuf is byte aligned and we can just copy it */ +memcpy (pdst + blocksize, ecc_buf, ecc_buf_size); + } + +kfree (ecc_buf); +kfree (tmp_buf); +free_bch (bch); +} +static u8 calculate_parity_13_8 (u8 d) {u8 p =0 ;@@ -231,8 +293,14 @@ static int nandbcb_update(struct mtd_info *mtd, loff_t off, size_t size, goto dbbt_data_page_err; } -memcpy (fcb_raw_page +12 , fcb,sizeof (struct fcb_block )); -encode_hamming_13_8 (fcb_raw_page +12 , fcb_raw_page +12 +512 ,512 ); +if (is_mx6ul () ||is_mx6ull ()) { +/* 40 bit BCH, for i.MX6UL(L) */ +encode_bch_ecc (fcb_raw_page +32 , fcb,40 ); + }else { +memcpy (fcb_raw_page +12 , fcb,sizeof (struct fcb_block )); +encode_hamming_13_8 (fcb_raw_page +12 , + fcb_raw_page +12 +512 ,512 ); + }/* * Set the first and second byte of OOB data to 0xFF, not 0x00. These * bytes are used as the Manufacturers Bad Block Marker (MBBM). Since
Signature · 5 lines
===================================================================== 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: sbabic at denx.de =====================================================================
PATCH v2 1/2 i.MX6: nand: extend nandbcb command for imx6UL(L)
Hello Stefano,
Quoted 24 lines · Stefano Babic
Quoted 12 lines · Parthiban Nallathambi
Hi Stefano,
Quoted 9 lines · Stefano Babic
Hi Parthiban,
Quoted 5 lines · Parthiban Nallathambi
Firmware Configuration Block(FCB) for imx6ul(l) needs to be BCH encoded. This patch depends on [1].
[1]: https://patchwork.ozlabs.org/project/uboot/list/?series=113810
Quoted 6 lines
Quoted 1 line
Why does it depend on this if it is just defoconfig for a board ?
The patch series was nandbcb inclusion, but this is already merged in u-boot. patchwork query shows only the pending merger now.
As the nandbcb is already in mainline, this patch should apply fine.
Please read the whole e-mail. Issue is not that patch cannot be applied, issue is that it breaks several boards. All i.MX6 boards with NAND - check again:
Quoted 13 lines
Quoted 11 lines
Review
Quoted 11 lines
Building current source for 1 boards (1 thread, 8 jobs per thread)
arm: + pfla02(quoted diff) +5
-0+arch/arm/mach-imx/built-in.o: In function `encode_bch_ecc': +arch/arm/mach-imx/cmd_nandbcb.c:45: undefined reference to `init_bch' +arch/arm/mach-imx/cmd_nandbcb.c:75: undefined reference to `encode_bch' +arch/arm/mach-imx/cmd_nandbcb.c:87: undefined reference to `free_bch' +arm-poky-linux-gnueabi-ld.bfd: BFD (GNU Binutils) 2.28.0.20170307assertion fail
../../bfd/elf32-arm.c:9512(quoted diff) +2
-0+make[1]: *** [u-boot] Error 1 +make: *** [sub-make] Error 2 0 0 1 /1 pfla02The same happens to other boards, too.
I missed this. Will send v3 with conditionally including BCH in source as well.
Thanks,
Parthiban N
Quoted 159 lines
Best regards,
Stefano BabicQuoted 153 lines
Thanks,
Parthiban NQuoted 148 lines
Quoted 18 lines
Signed-off-by Parthiban Nallathambi <[email protected]>Acked-by Shyam Saini <[email protected]>---
Notes:
Changes in v2:
- use kfree instead of freearch/arm/mach-imx/Kconfig | 1 + arch/arm/mach-imx/cmd_nandbcb.c | 72 ++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 2 deletions(-)arch/arm/mach-imx/Kconfig +0
-0arch/arm/mach-imx/Kconfig config CMD_HDMIDETECT · line 77
Quoted 4 lines
arch/arm/mach-imx/Kconfig +1
-0@@ -74,6 +74,7 @@ config CMD_HDMIDETECT config CMD_NANDBCB bool "i.MX6 NAND Boot Control Block(BCB) command" depends on NAND && CMD_MTDPARTS + select BCH if MX6UL || MX6ULLThis eems to break all i.MX6 boards (not UL(L)) using NAND. In fact, I get these errors:
Building current source for 1 boards (1 thread, 8 jobs per thread)
arm: + pfla02(quoted diff) +5
-0+arch/arm/mach-imx/built-in.o: In function `encode_bch_ecc': +arch/arm/mach-imx/cmd_nandbcb.c:45: undefined reference to `init_bch' +arch/arm/mach-imx/cmd_nandbcb.c:75: undefined reference to `encode_bch' +arch/arm/mach-imx/cmd_nandbcb.c:87: undefined reference to `free_bch' +arm-poky-linux-gnueabi-ld.bfd: BFD (GNU Binutils) 2.28.0.20170307assertion fail
../../bfd/elf32-arm.c:9512(quoted diff) +2
-0+make[1]: *** [u-boot] Error 1 +make: *** [sub-make] Error 2 0 0 1 /1 pfla02Can you check this please ? I temporary remove the patch from -next branch.
Best regards,
Stefano BabicQuoted 103 lines
arch/arm/mach-imx/Kconfig +0
-0default y if ARCH_MX6 && NAND_MXS help Unlike normal 'nand write/erase' commands, this command updatearch/arm/mach-imx/cmd_nandbcb.c +70
-2@@ -14,8 +14,10 @@#include <asm/io.h> #include <jffs2/jffs2.h> +#include <linux/bch.h> #include <linux/mtd/mtd.h> +#include <asm/arch/sys_proto.h> #include <asm/mach-imx/imx-nandbcb.h> #include <asm/mach-imx/imximage.cfg> #include <mxs_nand.h> @@ -25,6 +27,66 @@#define BF_VAL (v, bf) (((v) & bf##_MASK) >> bf##_OFFSET)#define GETBIT (v, n) (((v) >> (n)) & 0x1) +static uint8_t reverse_bit (uint8_t b) +{ + b = (b &0xf0 ) >>4 | (b &0x0f ) <<4 ; + b = (b &0xcc ) >>2 | (b &0x33 ) <<2 ; + b = (b &0xaa ) >>1 | (b &0x55 ) <<1 ; + +return b; +} + +static void encode_bch_ecc (void *buf,struct fcb_block *fcb,int eccbits) +{ +int i, j, m =13 ; +int blocksize =128 ; +int numblocks =8 ; +int ecc_buf_size = (m * eccbits +7 ) /8 ; +struct bch_control *bch =init_bch (m, eccbits,0 ); +u8 *ecc_buf =kzalloc (ecc_buf_size,GFP_KERNEL ); +u8 *tmp_buf =kzalloc (blocksize * numblocks,GFP_KERNEL ); +u8 *psrc, *pdst; + +/* +* The blocks here are bit aligned. If eccbits is a multiple of 8, +* we just can copy bytes. Otherwiese we must move the blocks to +* the next free bit position. +*/ +WARN_ON (eccbits %8 ); + +memcpy (tmp_buf, fcb,sizeof (*fcb)); + +for (i =0 ; i < numblocks; i++) { +memset (ecc_buf,0 , ecc_buf_size); + psrc = tmp_buf + i * blocksize; + pdst = buf + i * (blocksize + ecc_buf_size); + +/* copy data byte aligned to destination buf */ +memcpy (pdst, psrc, blocksize); + +/* +* imx-kobs use a modified encode_bch which reverse the +* bit order of the data before calculating bch. +* Do this in the buffer and use the bch lib here. +*/ +for (j =0 ; j < blocksize; j++) + psrc[j] =reverse_bit (psrc[j]); + +encode_bch (bch, psrc, blocksize, ecc_buf); + +/* reverse ecc bit */ +for (j =0 ; j < ecc_buf_size; j++) + ecc_buf[j] =reverse_bit (ecc_buf[j]); + +/* Here eccbuf is byte aligned and we can just copy it */ +memcpy (pdst + blocksize, ecc_buf, ecc_buf_size); + } + +kfree (ecc_buf); +kfree (tmp_buf); +free_bch (bch); +} +static u8 calculate_parity_13_8 (u8 d) {u8 p =0 ;@@ -231,8 +293,14 @@ static int nandbcb_update(struct mtd_info *mtd, loff_t off, size_t size, goto dbbt_data_page_err; } -memcpy (fcb_raw_page +12 , fcb,sizeof (struct fcb_block )); -encode_hamming_13_8 (fcb_raw_page +12 , fcb_raw_page +12 +512 ,512 ); +if (is_mx6ul () ||is_mx6ull ()) { +/* 40 bit BCH, for i.MX6UL(L) */ +encode_bch_ecc (fcb_raw_page +32 , fcb,40 ); + }else { +memcpy (fcb_raw_page +12 , fcb,sizeof (struct fcb_block )); +encode_hamming_13_8 (fcb_raw_page +12 , + fcb_raw_page +12 +512 ,512 ); + }/* * Set the first and second byte of OOB data to 0xFF, not 0x00. These * bytes are used as the Manufacturers Bad Block Marker (MBBM). Since
Signature · 6 lines
Thanks, Parthiban N DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-22 Fax: (+49)-8142-66989-80 Email: pn at denx.de
PATCH v2 1/2 i.MX6: nand: extend nandbcb command for imx6UL(L)
Quoted 43 lines · Parthiban Nallathambi
Hello Stefano,
Quoted 25 lines · Stefano Babic
Quoted 12 lines · Parthiban Nallathambi
Hi Stefano,
Quoted 9 lines · Stefano Babic
Hi Parthiban,
Quoted 5 lines · Parthiban Nallathambi
Firmware Configuration Block(FCB) for imx6ul(l) needs to be BCH encoded. This patch depends on [1].
[1]: https://patchwork.ozlabs.org/project/uboot/list/?series=113810
Quoted 7 lines
Quoted 1 line
Why does it depend on this if it is just defoconfig for a board ?
The patch series was nandbcb inclusion, but this is already merged in u-boot.
patchwork query shows only the pending merger now.As the nandbcb is already in mainline, this patch should apply fine.
Please read the whole e-mail. Issue is not that patch cannot be applied, issue is that it breaks several boards. All i.MX6 boards with NAND - check again:
Quoted 14 lines
Quoted 4 lines
Quoted 4 lines
Building current source for 1 boards (1 thread, 8 jobs per thread) arm: + pfla02
(quoted diff) +2
-0+arch/arm/mach-imx/built-in.o: In function `encode_bch_ecc': +arch/arm/mach-imx/cmd_nandbcb.c:45: undefined reference to `init_bch'Quoted 8 lines
Quoted 8 lines
+arch/arm/mach-imx/cmd_nandbcb.c:75: undefined reference to `encode_bch'(quoted diff) +2
-0+arch/arm/mach-imx/cmd_nandbcb.c:87: undefined reference to `free_bch' +arm-poky-linux-gnueabi-ld.bfd: BFD (GNU Binutils) 2.28.0.20170307assertion fail
../../bfd/elf32-arm.c:9512(quoted diff) +2
-0+make[1]: *** [u-boot] Error 1 +make: *** [sub-make] Error 20 0 1 /1 pfla02
The same happens to other boards, too.
Quoted 3 lines
I missed this. Will send v3 with conditionally including BCH in source as well.
ok, thanks !
Stefano
Quoted 169 lines
Thanks,
Parthiban NQuoted 165 lines
Best regards,
Stefano BabicQuoted 159 lines
Thanks,
Parthiban NQuoted 154 lines
Quoted 19 lines
Signed-off-by Parthiban Nallathambi <[email protected]>Acked-by Shyam Saini <[email protected]>---
Notes:
Changes in v2:
- use kfree instead of freearch/arm/mach-imx/Kconfig | 1 +
arch/arm/mach-imx/cmd_nandbcb.c| 72
++++++++++++++++++++++++++++++++-2 files changed, 71 insertions(+), 2 deletions(-)arch/arm/mach-imx/Kconfig +0
-0@@ -74,6 +74,7 @@ config CMD_HDMIDETECTQuoted 4 lines
config
CMD_NANDBCB
bool "i.MX6 NAND Boot Control Block(BCB) command" depends on NAND &&CMD_MTDPARTS
+ select BCH if MX6UL || MX6ULLThis eems to break all i.MX6 boards (not UL(L)) using NAND. In fact, I get these errors:
Building current source for 1 boards (1 thread, 8 jobs per thread) arm: + pfla02
(quoted diff) +3
-0+arch/arm/mach-imx/built-in.o: In function `encode_bch_ecc': +arch/arm/mach-imx/cmd_nandbcb.c:45: undefined reference to `init_bch' +arch/arm/mach-imx/cmd_nandbcb.c:75: undefined reference to`encode_bch'
(quoted diff) +2
-0+arch/arm/mach-imx/cmd_nandbcb.c:87: undefined reference to `free_bch' +arm-poky-linux-gnueabi-ld.bfd: BFD (GNU Binutils) 2.28.0.20170307assertion fail
../../bfd/elf32-arm.c:9512(quoted diff) +2
-0+make[1]: *** [u-boot] Error 1 +make: *** [sub-make] Error 20 0 1 /1 pfla02
Can you check this please ? I temporary remove the patch from -next branch.
Best regards,
Stefano BabicQuoted 106 lines
default y if
ARCH_MX6&&NAND_MXS
help
Unlike normal 'nand write/erase' commands, this command updatearch/arm/mach-imx/cmd_nandbcb.c +1
-0@@ -14,8 +14,10 @@ #include <asm/io.h> #include <jffs2/jffs2.h> +#include <linux/bch.h> #include <linux/mtd/mtd.h>+#include <
asm/arch/sys_proto.h>
#include <asm/mach-imx/imx-nandbcb.h>
#include <asm/mach-imx/imximage.cfg>
#include <mxs_nand.h>arch/arm/mach-imx/cmd_nandbcb.c +59
-0@@ -25,6 +27,66 @@ #define BF_VAL(v, bf) (((v) & bf##_MASK) >> bf##_OFFSET) #define GETBIT(v, n) (((v) >> (n)) & 0x1) +static uint8_t reverse_bit(uint8_t b) +{ + b = (b & 0xf0) >> 4 | (b & 0x0f) << 4; + b = (b & 0xcc) >> 2 | (b & 0x33) << 2; + b = (b & 0xaa) >> 1 | (b & 0x55) << 1; + + return b; +} + +static void encode_bch_ecc (void *buf,struct fcb_block *fcb,int eccbits) +{ + int i, j, m = 13; + int blocksize = 128; + int numblocks = 8; + int ecc_buf_size = (m * eccbits + 7) / 8; + struct bch_control *bch = init_bch(m, eccbits, 0); + u8 *ecc_buf = kzalloc(ecc_buf_size, GFP_KERNEL); + u8 *tmp_buf = kzalloc(blocksize * numblocks, GFP_KERNEL); + u8 *psrc, *pdst; + + /* + * The blocks here are bit aligned. If eccbits is a multiple of 8, + * we just can copy bytes. Otherwiese we must move the blocks to + * the next free bit position. + */ + WARN_ON(eccbits % 8); + + memcpy(tmp_buf, fcb, sizeof(*fcb)); + + for (i = 0; i < numblocks; i++) { + memset(ecc_buf, 0, ecc_buf_size); + psrc = tmp_buf + i * blocksize; + pdst = buf + i * (blocksize + ecc_buf_size); + + /* copy data byte aligned to destination buf */ + memcpy(pdst, psrc, blocksize); + + /* + * imx-kobs use a modified encode_bch which reverse the + * bit order of the data before calculating bch. + * Do this in the buffer and use the bch lib here. + */ + for (j = 0; j < blocksize; j++) + psrc[j] = reverse_bit(psrc[j]); + + encode_bch(bch, psrc, blocksize, ecc_buf); + + /* reverse ecc bit */ + for (j = 0; j < ecc_buf_size; j++) + ecc_buf[j] = reverse_bit(ecc_buf[j]); + + /* Here eccbuf is byte aligned and we can just copy it */ + memcpy(pdst + blocksize, ecc_buf, ecc_buf_size); + } + + kfree(ecc_buf); + kfree(tmp_buf); + free_bch(bch); +} + static u8 calculate_parity_13_8(u8 d){
u8 p = 0;arch/arm/mach-imx/cmd_nandbcb.c +8
-1@@ -231,8 +293,14 @@ static int nandbcb_update(struct mtd_info *mtd, loff_t off, size_t size, goto dbbt_data_page_err; } - memcpy(fcb_raw_page + 12, fcb, sizeof(struct fcb_block)); - encode_hamming_13_8(fcb_raw_page + 12, fcb_raw_page + 12 + 512, 512); + if (is_mx6ul() || is_mx6ull()) { + /* 40 bit BCH, for i.MX6UL(L) */ + encode_bch_ecc(fcb_raw_page + 32, fcb, 40); + } else { + memcpy(fcb_raw_page + 12, fcb, sizeof(struct fcb_block)); + encode_hamming_13_8(fcb_raw_page + 12, + fcb_raw_page + 12 + 512, 512); + } /** Set the first and second byte of OOB data to
0xFF, not0x00. These
* bytes are used as the Manufacturers Bad Block Marker (MBBM). Since
Signature · 5 lines
===================================================================== 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: sbabic at denx.de =====================================================================