-
int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
-
{
-
if (strncmp(cmd, "read", 4) == 0 || strncmp(cmd, "write", 5) == 0) {
-
addr = (ulong)simple_strtoul(argv[2], NULL, 16);
-
read = strncmp(cmd, "read", 4) == 0; /* 1 = read, 0 = write */
-
-
if (arg_off_size(argc - 3, argv + 3, nand, &off, &size) != 0)
-
return 1;
-
-
s = strchr(cmd, '.');
-
if (!read && s != NULL && + (!strcmp(s, ".yaffs2") || !strcmp(s, ".yaffs1")))
-
{
-
nand_write_options_t opts;
-
memset(&opts, 0, sizeof(opts));
-
opts.buffer = (u_char*) addr; // addr=0x50008000内存
-
opts.length = size; // length是文件长度
-
opts.offset = off; // offset 是要写到nand flash的地址0x600000
-
opts.pad = 0;
-
opts.blockalign = 1;
-
opts.quiet = quiet;
-
opts.writeoob = 1;
-
opts.autoplace = 1;
-
ret = nand_write_opts(nand, &opts);
-
}
-
}
argv[0] argv[1] argv[2] argv[3] argv[4]
nand write.yaffs2 50008000 600000 $(filesize)
addr off size=0x420000