ECC strength for device tree with imx6 processor

Torrelli, Maxime Maxime.Torrelli at conduent.com
Tue Sep 14 10:15:57 CEST 2021


Hello dear U-Boot members,

We recently tried to add support for a nand Flash (Micron MT29F4G08ABAEAWP among others) from U-Boot 2020.04 on an iMX6DL processor.
We try to configure the ECC strength to 16 bits through the DTSI but when the U-Boot is started, the command mtd list returns that the ECC strength is 8 bits.

An extract of our defconfig :
CONFIG_NAND_MXS=y
CONFIG_CMD_NAND=y
CONFIG_NAND_MXS_DT=y
CONFIG_MTD_RAW_NAND=y
CONFIG_DM_MTD=y

Content of our configs/*.h file :
#define CONFIG_SYS_NAND_ONFI_DETECTION

Content of our *.dtsi file :
&gpmi {
pinctrl-names = "default";
pinctrl-0 = <&configure_nandflash_pins>;
status = "okay";
nand-ecc-strength=<16>;
nand-ecc-step-size=<512>;
nand-on-flash-bbt;
};

I dug into the source code of the drivers and found out the function nand_dt_init (nand_base.c) reads the nand-ecc-strength property form the dtsi and puts its value into chip->ecc.strength.
Whereas, when the function mxs_nand_set_geometry (mxs_nand.c) calls mxs_nand_calc_ecc_layout_by_info, instead of using chip->ecc.strength as a parameter of mxs_nand_calc_ecc_layout_by_info, it uses chip->ecc_strength_ds.
The ecc_strength_ds value is set to 8 bits by nand_flash_detect_onfi (nand_base.c) which reads the ONFI data of our Nand.

I have tried to remove the define CONFIG_SYS_NAND_ONFI_DETECTION, but doing so the driver uses Legacy BCH Geometry and set the ECC strength to 8 bits.

I managed to get the driver to work by changing the following line from the function mxs_nand_set_geometry (mxs_nand.c) :
return mxs_nand_calc_ecc_layout_by_info(geo, mtd, chip->ecc_strength_ds, chip->ecc_step_ds);
changed to
return mxs_nand_calc_ecc_layout_by_info(geo, mtd, chip->ecc.strength, chip->ecc_step_ds);

Even though this quick fix solves our issue, I have no clue if it works with all the different configurations supported by the U-Boot.

If you have any suggestion to solve this issue, please let me know.
And if you have any question, I will do my utmost to answer.


Salutations/Greetings,

Maxime Torrelli
Embbeded Software Engineer
Conduent Business Solutions France

[cid:image001.png at 01D7A951.8A9B5600]
1 rue Claude Chappe
07500 Guilherand-Granges

T +334 75 81 56 81
maxime.torrelli at conduent.com<mailto:maxime.torrelli at conduent.com>

Through our dedicated associates, we deliver mission-critical services and solutions on behalf of businesses and governments - creating exceptional outcomes for our clients and the millions of people who count on them. Learn more at www.conduent.com<https://www.conduent.com/>.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 3329 bytes
Desc: image001.png
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210914/ff8c6add/attachment.png>


More information about the U-Boot mailing list