基本過程為:uboot 啟動後,通過指令将U盤的的檔案讀取到記憶體中,再通過uboot 的flash 寫入指令将讀取到記憶體中的更新檔案寫入到flash的固定位置。
(一)usb常用指令
uboot一般支援對usb的操作指令有:start,reset,stop,tree,info,storage,dev,part,read,write等。
Usage:
usb start - start (scan) USB controller
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'
1.usb start
Wisdom # usb start
(Re)start USB...
USB: scanning bus for devices...
2 USB Device(s) found
scanning bus for storage devices... iVendor 0 iProduct 0
iVendor 5E3 iProduct 727
ss->subclass : 0x6
usb_stor_get_info->1496,blksz:512
1 Storage Device(s) found
Wisdom #
2.usb tree
Wisdom # usb tree
Device Tree:
1 Hub (12 Mb/s, 0mA)
| OHCI Root Hub
|
+-2 Mass Storage (12 Mb/s, 500mA)
Generic USB Storage 000000000250
3.usb infor
Wisdom #
Wisdom # usb info
1: Hub, USB Revision 1.10
- OHCI Root Hub
- Class: Hub
- PacketSize: 8 Configurations: 1
- Vendor: 0x0000 Product 0x0000 Version 0.0
Configuration: 1
- Interfaces: 1 Self Powered 0mA
Interface: 0
- Alternate Setting 0, Endpoints: 1
- Class Hub
- Endpoint 1 In Interrupt MaxPacket 2 Interval 255ms
2: Mass Storage, USB Revision 2.0
- Generic USB Storage 000000000250
- Class: (from Interface) Mass Storage
- PacketSize: 64 Configurations: 1
- Vendor: 0x05e3 Product 0x0727 Version 2.80
Configuration: 1
- Interfaces: 1 Bus Powered 500mA
Interface: 0
- Alternate Setting 0, Endpoints: 2
- Class Mass Storage, Transp. SCSI, Bulk only
- Endpoint 1 In Bulk MaxPacket 64
- Endpoint 2 Out Bulk MaxPacket 64
4.usb part
Wisdom # usb part
index: 0
Partition Map for USB device 0 -- Partition Type: DOS
Partition Start Sector Num Sectors Type
1 8192 7618560 b
index: 1
Wisdom #
5.usb storage
Wisdom # usb storage
Device 0: Vendor: Generic Rev: 0250 Prod: STORAGE DEVICE
Type: Removable Hard Disk
Capacity: 3724.0 MB = 3.6 GB (7626752 x 512)
Wisdom #
(二)U盤更新操作
(1)usb start 開始usb 操作
Wisdom # usb start
(Re)start USB...
USB: scanning bus for devices...
2 USB Device(s) found
scanning bus for storage devices... iVendor 0 iProduct 0
iVendor 5E3 iProduct 727
ss->subclass : 0x6
usb_stor_get_info->1496,blksz:512
1 Storage Device(s) found
(2)fatls usb 0 檢視usb 中的檔案
Wisdom # fatls usb 0
index: 0
.trash-1000/
4.8.7/
5.9.0/
20190323/
dejavu/
fb/
install/
mouse/
qt_4.8_install/
rules.d/
935839 gui_test
727 profile
3671576 uidemo18
3190568 uimage
4 file(s), 10 dir(s)
Wisdom #
(3)擦除記憶體中的一塊空間用來放置更新檔案:
将0x82000000開始的 4M空間填上0xFF
mw.b 82000000 ff 400000
(4)加載usb的更新檔案到記憶體
fatload usb 0 0x82000000 uimage
(5)擦除flash中原來的資料
nand erase 100000 400000
(6)将記憶體中的更新檔案寫入到flash中去
nand write 82000000 100000 400000
(3)~(6)操作過程
Wisdom # mw.b 82000000 ff 400000
Wisdom # fatload usb 0 0x82000000 uimage
index: 0
##########################################################################################################################################################################################
3190568 bytes read
Wisdom # nand erase 100000 400000
NAND erase: device 0 offset 0x100000, size 0x400000
Erasing at 0x4e0000 -- 100% complete.
OK
Wisdom # nand write 82000000 100000 400000
NAND write: device 0 offset 0x100000, size 0x400000
4194304 bytes written: OK
Wisdom #
全部更新操作指令:
usb start
fatls usb 0
mw.b 82000000 ff 400000
fatload usb 0 0x82000000 uimage
nand erase 100000 400000
nand write 82000000 100000 400000
以上,僅供參考。