Xilinx Zynq pl353-nand使用

作者

QQ群:852283276
微信:arm80x86
微信公众号:青儿创客基地
B站:主页 https://space.bilibili.com/208826118

参考

U-Boot NAND Driver
NAND
Zynq Pl353 SMC and NAND drivers
ZYNQ 从NAND flash启动应用笔记
NAND flash sub-pages

FPGA

vivado下设置nand参数,
265

u-boot

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*/

u-boot下通过nand命令操作nand,

zynq-uboot> nand
nand - NAND sub-system

Usage:
nand info - show available NAND devices
nand device [dev] - show or set current device
nand read - addr off|partition size
nand write - addr off|partition size
    read/write 'size' bytes starting at offset 'off'
    to/from memory address 'addr', skipping bad blocks.
nand read.raw - addr off|partition [count]
nand write.raw - addr off|partition [count]
    Use read.raw/write.raw to avoid ECC and access the flash as-is.
nand erase[.spread] [clean] off size - erase 'size' bytes from offset 'off'
    With '.spread', erase enough for given file size, otherwise,
    'size' includes skipped bad blocks.
nand erase.part [clean] partition - erase entire mtd partition'
nand erase.chip [clean] - erase entire chip'
nand bad - show bad blocks
nand dump[.oob] off - dump page
nand scrub [-y] off size | scrub.part partition | scrub.chip
    really clean NAND erasing bad blocks (UNSAFE)
nand markbad off [...] - mark bad block(s) at offset (UNSAFE)
nand biterr off - make a bit error at offset (UNSAFE)
nand lock [tight] [status]
    bring nand to lock state or display locked pages
nand unlock[.allexcept] [offset] [size] - unlock section
zynq-uboot> nand info

Device 0: nand0, sector size 128 KiB
  Page size      2048 b
  OOB size         64 b
  Erase size   131072 b

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 id0xf1,这是Winbond的,然后通过ONFI来获取nand的基本信息,和u-boot下比对是对的。
272

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

Device Manufacturer是一个用空格补齐的字符串,所有nand参数都按照onfi标准,可读取,
273

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"
  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值