[U-Boot-Users] u-boot and CONFIG_MTD_NAND_ECC_SMC patch
mark roths
mroths at gmail.com
Wed Jun 11 02:06:51 CEST 2008
Sorry if this has been covered already, the problem exists in all the u-boot
versions I have up to 1.2.0.
When linux has CONFIG_MTD_NAND_ECC_SMC configured, NAND flash sectors
written under linux appear to have ECC errors when read by u-boot.
The help for CONFIG_MTD_NAND_ECC_SMC:
Software ECC according to the Smart Media Specification.
The original Linux implementation had byte 0 and 1 swapped.
u-boot appears to conform to the 'original' linux implementation. The
following patch fixes this.
*** ../u-boot-1.1.5/drivers/nand/nand_ecc.c 2006-10-20
08:54:33.000000000 -0700
--- drivers/nand/nand_ecc.c 2008-06-10 12:59:21.000000000 -0700
***************
*** 118,123 ****
--- 118,124 ----
{
u_char idx, reg1, reg2, reg3;
int j;
+ u_char tmp0, tmp1;
/* Initialize variables */
reg1 = reg2 = reg3 = 0;
***************
*** 140,148 ****
--- 141,157 ----
/* Create non-inverted ECC code from line parity */
nand_trans_result(reg2, reg3, ecc_code);
+ #define CONFIG_MTD_NAND_ECC_SMC
/* Calculate final ECC code */
+ #ifdef CONFIG_MTD_NAND_ECC_SMC
+ tmp0 = ~ecc_code[0];
+ tmp1 = ~ecc_code[1];
+ ecc_code[0] = tmp1;
+ ecc_code[1] = tmp0;
+ #else
ecc_code[0] = ~ecc_code[0];
ecc_code[1] = ~ecc_code[1];
+ #endif
ecc_code[2] = ((~reg1) << 2) | 0x03;
return 0;
}
Mark Roths
Softair Microsystems
More information about the U-Boot
mailing list