uboot中对U盘文件进行读写

来源:互联网 发布:ov7670摄像头数据手册 编辑:程序博客网 时间:2024/05/21 19:39
   最近有个项目,需要在uboot中读入U盘中的文件,并把相关数据写入到原来的U盘文件中,由于在uboot中,没有完整的文件系统API,因而在文件操作上,需要借助uboot中的原生命令来进行操作。   常用的有关USB的uboot命令有(在uboot中敲入help usb):
usb reset - reset (rescan) USB controllerusb stop [f]  - stop USB [f]=force stopusb tree  - show USB device treeusb info [dev] - show available USB devicesusb storage  - show details of USB storage devicesusb dev [dev] - show or set current USB storage deviceusb part [dev] - print partition table of one or all USB storage devicesusb read addr blk# cnt - read 'cnt' blocks starting at block 'blk#'to memory address 'addr'usb write addr blk# cnt - write 'cnt' blocks starting at block 'blk#'from memory address 'addr'
    另外,关于文件操作的有:
fatload <interface> <dev[:part]>  <addr> <filename> [bytes]    - load binary file 'filename' from 'dev' on 'interface'      to address 'addr' from dos filesystem
fatinfo <interface> <dev[:part]>    - print information about filesystem from 'dev' on 'interface'
    从U盘中读取文件到指定内存地址,比如我U盘上有一个名为mak.cfg的文件,读到0x30000000的地址处

执行:fatload usb 0 0x30000000 mak.cfg

    然后调用fatwrite命令将数据写入到文件中:
fatwrite <interface> <dev[:part]>  <addr> <filename> [bytes]    - load binary file 'filename' from 'dev' on 'interface'      to address 'addr' from dos filesystem
0 0