uboot中对U盘文件进行读写

   最近有个项目,需要在uboot中读入U盘中的文件,并把相关数据写入到原来的U盘文件中,由于在uboot中,没有完整的文件系统API,因而在文件操作上,需要借助uboot中的原生命令来进行操作。
   常用的有关USB的uboot命令有(在uboot中敲入help usb):
usb reset - reset (rescan) USB controller
usb stop [f]  - stop USB [f]=force stop
usb tree  - show USB device tree
usb info [dev] - show available USB devices
usb storage  - show details of USB storage devices
usb dev [dev] - show or set current USB storage device
usb part [dev] - print partition table of one or all USB storage devices
usb 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      [bytes]
    - load binary file 'filename' from 'dev' on 'interface'
      to address 'addr' from dos filesystem
fatinfo  
    - print information about filesystem from 'dev' on 'interface'
    从U盘中读取文件到指定内存地址,比如我U盘上有一个名为mak.cfg的文件,读到0x30000000的地址处

执行:fatload usb 0 0x30000000 mak.cfg

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

你可能感兴趣的:(Uboot,uboot)