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

2,901次阅读
没有评论
前提条件:
板子可以启动到 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";
正文完
 0
评论(没有评论)
验证码