海思Hi35xx 通过uboot 读取U盘文件进行固件升级

前言

基本过程为: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 


---------------------------End---------------------------

长按识别二维码
关注 liwen01 公众号
posted @ 2023-04-20 19:32  liwen01  阅读(445)  评论(0编辑  收藏  举报