通过u-boot把内核和文件系统烧录到Nand Flash

前提条件:
板子可以启动到u-boot环境;
内核文件、文件系统都准备好而且能正常运行;
tftp服务器打开;
测试环境:
AT91SAM9263-EK;
设置板子和tftp服务器的ip地址以及板子的mac地址;
U-Boot>setenv ipaddr 192.168.1.2
U-Boot>setenv serverip 192.168.1.100
U-Boot>setenv ethaddr 0:1:2:3:4:5
通过tftp下载内核文件vmlinux和文件系统ramdisk.gz,并将他们写入Nand Flash中;
先擦除flash
U-Boot>nand scrub 或者 nand erase
下载并写入flash
U-Boot>tftp 0x22000000 vmlinux
U-Boot>nand write 0x22000000 0x0 0x200000
U-Boot>tftp 0x22000000 ramdisk.gz
U-Boot>nand write 0x22000000 0x400000 0x300000
从Nand Flash读出内核和文件系统到SDRAM上,注意此处读出操作可以省,只要上一步的下载地址指定好既可;
U-Boot>nand read 0x22000000 0x0 0x16c58a (vmlinux大小)
U-Boot>nand read 0x20500000 0x400000 0x24bc12 (ramdisk.gz大小)
从SDRAM启动系统
U-Boot>go 0x22000000
如果能正确运行系统,烧录文件到Nand Flash成功。
自动启动(自动从Nand Flash拷贝文件到SDRAM里),设置U-boot的环境变量:
U-Boot>setenv bootcmd nand read 0x22000000 0x0 0x16c58a\;nand read 0x20500000 0x400000 0x24bc12\;go 0x22000000
U-Boot>saveenv
reset板子即可。
附上U-boot下Nand Flash的相关命令(u-boot-/common/cmd_nand.c — U_BOOT_CMD) :
    "nand - NAND sub-system\n",
"info - show available NAND devices\n"
"nand device [dev] - show or set current device\n"
"nand read[.jffs2] - addr off|partition size\n"
"nand write[.jffs2] - addr off|partiton size - read/write `size' bytes starting\n"
" at offset `off' to/from memory address `addr'\n"
"nand erase [clean] [off size] - erase `size' bytes from\n"
" offset `off' (entire device if not specified)\n"
"nand bad - show bad blocks\n"
"nand dump[.oob] off - dump page\n"
"nand scrub - really clean NAND erasing bad blocks (UNSAFE)\n"
"nand markbad off - mark bad block at offset (UNSAFE)\n"
"nand biterr off - make a bit error at offset (UNSAFE)\n"
"nand lock [tight] [status] - bring nand to lock state or display locked pages\n"
"nand unlock [offset] [size] - unlock section\n";
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享