參考
U-Boot NAND Driver
NAND
Zynq Pl353 SMC and NAND drivers
ZYNQ 從NAND flash啓動應用筆記
NAND flash sub-pages
FPGA
vivado下設置nand參數,
u-boot
#define CONFIG_NAND
#define CONFIG_NAND_ZYNQ
u-boot下mtd配置說明,
/*
* Three environment variables are used by the parsing routines:
*
* 'partition' - keeps current partition identifier
*
* partition := <part-id>
* <part-id> := <dev-id>,part_num
*
*
* 'mtdids' - linux kernel mtd device id <-> u-boot device id mapping
*
* mtdids=<idmap>[,<idmap>,...]
*
* <idmap> := <dev-id>=<mtd-id>
* <dev-id> := 'nand'|'nor'|'onenand'<dev-num>
* <dev-num> := mtd device number, 0...
* <mtd-id> := unique device tag used by linux kernel to find mtd device (mtd->name)
*
*
* 'mtdparts' - partition list
*
* mtdparts=mtdparts=<mtd-def>[;<mtd-def>...]
*
* <mtd-def> := <mtd-id>:<part-def>[,<part-def>...]
* <mtd-id> := unique device tag used by linux kernel to find mtd device (mtd->name)
* <part-def> := <size>[@<offset>][<name>][<ro-flag>]
* <size> := standard linux memsize OR '-' to denote all remaining space
* <offset> := partition start offset within the device
* <name> := '(' NAME ')'
* <ro-flag> := when set to 'ro' makes partition read-only (not used, passed to kernel)
*
* Notes:
* - each <mtd-id> used in mtdparts must albo exist in 'mtddis' mapping
* - if the above variables are not set defaults for a given target are used
*
* Examples:
*
* 1 NOR Flash, with 1 single writable partition:
* mtdids=nor0=edb7312-nor
* mtdparts=mtdparts=edb7312-nor:-
*
* 1 NOR Flash with 2 partitions, 1 NAND with one
* mtdids=nor0=edb7312-nor,nand0=edb7312-nand
* mtdparts=mtdparts=edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home)
*
*/
對於zynq,
#define MTDIDS_DEFAULT "nand0=pl353-nand"
#define MTDPARTS_DEFAULT "mtdparts=pl353-nand:128k(rcw),219008k(rootfs),32m(rd),128k(dtb)," \
"9088k(kernel),128k(fman),128k(bootenv),768k(boot)"/*modify by zhuce*/
linux
pl353-nand的驅動不支持slc nand的sub pages特性,開啓配置,
CONFIG_PL35X_SMC = y
CONFIG_MTD_NAND = y
CONFIG_MTD_NAND_PL35X = y
對應的驅動文件,
drivers\memory\pl353-smc.c
drivers\mtd\nand\pl353_nand.c
內核啓動報錯,
nand: device found, Manufacturer ID: 0xef, Chip ID: 0xf1
nand: Unknown W29N01HV
nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
mmc0: Problem switching card into high-speed mode!
mmc0: new SDHC card at address 0001
mmcblk0: mmc0:0001 SD 14.5 GiB
mmcblk0: p1
pl353_nand_cmd_function timed out
pl353_nand_cmd_function timed out
pl353_nand_cmd_function timed out
pl353_nand_cmd_function timed out
Bad block table not found for chip 0
pl353_nand_cmd_function timed out
pl353_nand_cmd_function timed out
pl353_nand_cmd_function timed out
pl353_nand_cmd_function timed out
Bad block table not found for chip 0
Scanning device for bad blocks
pl353_nand_cmd_function timed out
pl353_nand_cmd_function timed out
pl353_nand_cmd_function timed out
但是在u-boot下可以訪問,內核下不支持Winbond的nand,報nand: Unknown W29N01HV
,不包含這個廠商,但是檢測ondie_ecc_state
的的device id
有0xf1
,這是Winbond的,然後通過ONFI來獲取nand的基本信息,和u-boot下比對是對的。
ondie_ecc_state 0
ONFI version: 10
mtd name: pl353-nand
mtd writesize: 2048
mtd erasesize: 131072
mtd oobsize: 64
mtd chipsize: 134217728
mtd bits_per_cell: 1
mtd busw: 0 # x8
mtd ecc_bits: 1
mtd ecc_strength_ds: 1
mtd ecc_step_ds: 512
nand: device found, Manufacturer ID: 0xef, Chip ID: 0xf1
nand: Winbond W29N01HV
nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
Bad block table found at page 65472, version 0x01
Bad block table found at page 65408, version 0x01
nand_read_bbt: bad block at 0x000007f60000
nand_read_bbt: bad block at 0x000007f80000
nand_read_bbt: bad block at 0x000007fa0000
nand_read_bbt: bad block at 0x000007fc0000
6 ofpart partitions found on MTD device pl353-nand
Creating 6 MTD partitions on "pl353-nand":
0x000000000000-0x0000000c0000 : "boot"
0x0000000c0000-0x0000000e0000 : "bootenv"
0x0000000e0000-0x000000100000 : "bootenvredund"
0x000000100000-0x000001000000 : "pl"
0x000001000000-0x000001500000 : "kernel"
0x000001500000-0x000008000000 : "rootfs"