UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer derekparks
Observer
1,291 Views
Registered: ‎09-14-2017

u-boot & Linux nand drivers

Im having trouble writing an image from Linux into Nand flash and having u-boot boot that image from nand.  Basically the two drivers are not in sync.  In a more simple case, i write a 2K random file from uboot in nand, boot into Linux, read same 2K file from Linux, and see bit differences.

 

Zynq SoC 7100

Flash is Spansion Nand S34ML02G1

U-boot driver: Zynq_nand.c

Static memory controler: pl353

Linux drivers: pl353 for both nand and memory control

Petalinux 2017.3

0 Kudos
6 Replies
Observer derekparks
Observer
1,255 Views
Registered: ‎09-14-2017

Re: u-boot & Linux nand drivers

The nand timings we configure in the Linux devicetree for the SMC chip are:

arm,nand-cycle-t0 = <0x4>;

arm,nand-cycle-t1 = <0x4>;

arm,nand-cycle-t2 = <0x1>;

arm,nand-cycle-t3 = <0x2>;

arm,nand-cycle-t4 = <0x2>;

arm,nand-cycle-t5 = <0x2>;

arm,nand-cycle-t6 = <0x4>;

 

The FSBL sets them the same (using the included one from Petalinux):

EMIT_WRITE(0XE000E014, 0x00449144U)

 

I must then assume U-boot is using whatever the FSBL configures.

 

0 Kudos
Observer derekparks
Observer
1,251 Views
Registered: ‎09-14-2017

Re: u-boot & Linux nand drivers

I am noticing that u-boot and Linux drivers behave differently on the oob section.  U-boot seems to be doing it correctly as far as the number of bytes it uses for ECC...12 bytes in position 52-63 of the oob section. But Linux only uses 3bytes in position 52-54.

 

 

If i write a random binary file in u-boot, boot into Linux, and dump the contents, there are some bits that flip, but here is the OOB section from the first block:

OOB Data: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
OOB Data: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
OOB Data: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
OOB Data: ff ff ff ff d4 4a ad 3a aa a3 d2 d3 c2 1b bd d1

 

If i then erase flash, write the same random binary file from Linux, no bitflips occur and here is the OOB section from the first block:

OOB Data: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
OOB Data: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
OOB Data: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
OOB Data: ff ff ff ff c5 af 03 ff ff ff ff ff ff ff ff ff 

 

 This is strange and am using it as really strong lead.

0 Kudos
Xilinx Employee
Xilinx Employee
1,223 Views
Registered: ‎10-11-2011

Re: u-boot & Linux nand drivers

The ECC data in the OOB depends on the page size:

u32 NandOob16[] = {13, 14, 15}; /**< Ecc position for 16 bytes spare area */

u32 NandOob32[] = {26, 27, 28, 29, 30, 31};    /**< Ecc position for 32 bytes spare area */

u32 NandOob64[] = {52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63};    /**< Ecc position for 64 bytes spare area */

 

It does look like u-boot is doing the right thing.

Can I see your full device tree node for the NAND, please?

Please, give me few days to investigate this.

0 Kudos
Observer derekparks
Observer
1,189 Views
Registered: ‎09-14-2017

Re: u-boot & Linux nand drivers

Attached is workaround patch as i was not able to dig deep enough for root cause.  The patch allows me to write to flash correctly, but reads are still not work correctly.  I verified that i can write a new Linux image to a mtd partition and boot cleanly, but if were to read from that partition to a file, the checksum doesn't match the original.  Additionally from Linux, I can perform nanddump without ecc using the -n flag and the checksum match.  Leaning towards something in pl35x_nand_correct_data as there are only a few bits that differ per page.  

 

One final issue is with mounting jffs2 to a mtd partition.  We are using initramfs, but need persistent storage for configuration files.  A 10MB partition is carved out in the nand and when i perform a jffs2 mount (with flash_erase) i get too many badblocks and jffs2 declines to mount a filesystem.

0 Kudos
Observer derekparks
Observer
1,188 Views
Registered: ‎09-14-2017

Re: u-boot & Linux nand drivers

memory-controller@e000e000 {
#address-cells = <0x1>;
#size-cells = <0x1>;
status = "okay";
clock-names = "memclk", "aclk";
clocks = <0x1 0xb 0x1 0x2c>;
compatible = "arm,pl353-smc-r2p1";
interrupt-parent = <0x4>;
interrupts = <0x0 0x12 0x4>;
ranges;
reg = <0xe000e000 0x1000>;

flash@e1000000 {
status = "okay";
compatible = "arm,pl353-nand-r2p1";
reg = <0xe1000000 0x1000000>;
#address-cells = <0x1>;
#size-cells = <0x1>;
arm,nand-cycle-t0 = <0x4>;
arm,nand-cycle-t1 = <0x4>;
arm,nand-cycle-t2 = <0x1>;
arm,nand-cycle-t3 = <0x2>;
arm,nand-cycle-t4 = <0x2>;
arm,nand-cycle-t5 = <0x2>;
arm,nand-cycle-t6 = <0x4>;

partition@0x00000000 {
label = "boot.bin";
reg = <0x0 0x4000000>;
};

partition@0x04000000 {
label = "ubootenv";
reg = <0x4000000 0x20000>;
};

partition@0x04020000 {
label = "kernel";
reg = <0x4020000 0x6400000>;
};

partition@0x0a420000 {
label = "configfiles";
reg = <0xa420000 0xa00000>;
};
};
0 Kudos
Xilinx Employee
Xilinx Employee
1,125 Views
Registered: ‎10-11-2011

Re: u-boot & Linux nand drivers

Coming soon on the web an AR with a patch for this issue.

71078 - 2017.x Zynq-7000 - Embedded Linux: ubi ECC error on S34ML02G1

0 Kudos