U-Boot NAND Driver

This page gives an overview of Zynq nand driver. NAND driver provides basic functions that are required for accessing the nand flash memory including the support for hw ecc and bad block management.

Table of Contents

U-Boot Configuration

For Zynq UltraScale+

CONFIG_SYS_MAX_NAND_DEVICE=y
CONFIG_SYS_NAND_ONFI_DETECTION=y
CONFIG_CMD_NAND_LOCK_UNLOCK=y
CONFIG_CMD_NAND=y
CONFIG_SYS_NAND_SELF_INIT=y
CONFIG_NAND=y
CONFIG_NAND_ARASAN=y
 

For Zynq-7000

CONFIG_NAND=y
CONFIG_NAND_ZYNQ=y
CONFIG_CMD_NAND_LOCK_UNLOCK=y
CONFIG_SYS_MAX_NAND_DEVICE=y
CONFIG_SYS_NAND_ONFI_DETECTION=y
CONFIG_SYS_NAND_SELF_INIT=y

Device Tree

For Zynq UltraScale+

&nand0 {
       status = "okay";
       pinctrl-names = "default";
       pinctrl-0 = <&pinctrl_nand0_default>;
       arasan,has-mdma;
 
       nand@0 {
               reg = <0x0>;
               #address-cells = <0x2>;
               #size-cells = <0x1>;
 
               partition@0 {   /* for testing purpose */
                       label = "nand-fsbl-uboot";
                       reg = <0x0 0x0 0x400000>;
               };
               partition@1 {   /* for testing purpose */
                       label = "nand-linux";
                       reg = <0x0 0x400000 0x1400000>;
               };
               partition@2 {   /* for testing purpose */
                       label = "nand-device-tree";
                       reg = <0x0 0x1800000 0x400000>;
               };
               partition@3 {   /* for testing purpose */
                       label = "nand-rootfs";
                       reg = <0x0 0x1c00000 0x1400000>;
               };
               partition@4 {   /* for testing purpose */
                       label = "nand-bitstream";
                       reg = <0x0 0x3000000 0x400000>;
               };
               partition@5 {   /* for testing purpose */
                       label = "nand-misc";
                       reg = <0x0 0x3400000 0xfcc00000>;
              };
       };
       nand@1 {
               reg = <0x1>;
               #address-cells = <0x2>;
               #size-cells = <0x1>;
 
               partition@0 {   /* for testing purpose */
                       label = "nand1-fsbl-uboot";
                       reg = <0x0 0x0 0x400000>;
               };
               partition@1 {   /* for testing purpose */
                       label = "nand1-linux";
                       reg = <0x0 0x400000 0x1400000>;
               };
                partition@2 {   /* for testing purpose */
                       label = "nand1-device-tree";
                       reg = <0x0 0x1800000 0x400000>;
               };
               partition@3 {   /* for testing purpose */
                        label = "nand1-rootfs";
                       reg = <0x0 0x1c00000 0x1400000>;
               };
               partition@4 {   /* for testing purpose */
                       label = "nand1-bitstream";
                       reg = <0x0 0x3000000 0x400000>;
               };
               partition@5 {   /* for testing purpose */
                       label = "nand1-misc";
                       reg = <0x0 0x3400000 0xfcc00000>;
               };
       };
};
 

For Zynq-7000

&nand0 {
       status = "okay";
       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@nand-fsbl-uboot {
               label = "nand-fsbl-uboot";
               reg = <0x0 0x100000>;
       };
       partition@nand-linux {
               label = "nand-linux";
               reg = <0x100000 0x500000>;
       };
       partition@nand-device-tree {
               label = "nand-device-tree";
               reg = <0x600000 0x20000>;
       };
       partition@nand-rootfs {
               label = "nand-rootfs";
               reg = <0x620000 0x5E0000>;
       };
       partition@nand-bitstream {
               label = "nand-bitstream";
               reg = <0xC00000 0x400000>;
       };

Test Procedure

Zynq> nand info
nand info
Device 0: nand0, sector size 128 KiB
Page size       2048 b
OOB size         64 b
Erase size   131072 b
subpagesize     512 b
options     0x00000000
bbt options 0x00028000
Zynq> nand erase 0 0x20000
 
NAND erase: device 0 offset 0x0, size 0x20000
Erasing at 0x0 -- 100% complete.
OK
Zynq> nand write 100000 0 0x20000
 
NAND write: device 0 offset 0x0, size 0x20000
131072 bytes written: OK
Zynq> nand read 200000 0 0x20000
 
NAND read: device 0 offset 0x0, size 0x20000
131072 bytes read: OK
Zynq> cmp.b 100000 200000 0x20000
Total of 131072 byte(s) were the same
Zynq>

Features

  • 8/16-bit I/O width with one chip select signal
  • ONFI specification 1.0
  • 16-word read and 16-word write data FIFOs
  • 8-word command FIFO
  • Programmable I/O cycle timing
  • ECC assist

© Copyright 2019 - 2022 Xilinx Inc. Privacy Policy