LINUX系统下UBOOT利用U盘升级程序

LINUX系统下UBOOT利用U盘升级程序

前言:
要实现标题中的功能需要uboot支持识别U盘和文件系统

1、uboot移植

uboot需要支持的功能
(1)使能USB OHCI:支持uboot识别U盘;
(2)MMC驱动移植:uboot能初始化U盘;
(3)FAT文件系统支持:uboot能挂载U盘,并以FAT32格式去读取U盘上的内容;
uboot移植的步骤
(1)uboot代码先使能USB OHCI、移植MMC驱动、支持FAT文件系统;
(2)在uboot的命令行,通过手动敲命令去测试U盘,先达到能正确识别并挂载U盘,能把U盘里的内容读取到内存或者烧写到flash中;
(3)将第二步的测试过程,封装成uboot下的一个命令,然后在bootcmd里添加这个命令,这样每次uboot启动都会去尝试U盘升级;

2、手动实现uboot下的U盘升级

(1)usb device:安装USB设备;
(2)usb start:初始化并检索USB存储设备;
(2)usb tree:例举当前识别到的USB设备;
(3)fatls usb 0:用FAT32格式去查看usb 0里的文件;
(4)fatload usb 0 0x43000000 u-boot.bin:将usb 0设备的u-boot.bin文件写到内存地址0x43000000处;

System startup

Uncompress Ok!

U-Boot 2020.01 (Nov 26 2022 - 10:18:53 +0800)

DRAM:  Relocation Offset is: 1771a000
Relocating to 5ff1a000, new gd at 5fe79df8, sp at 5fe79de0
SPI Nor:  Boot Media isn't SPI Nor
NAND:  fmc_ip_ver_check(34): Check Flash Memory Controller v100 ...fmc_ip_ver_check(40):  Found
SPI Nand ID Table Version 2.7
SPI Nand(cs 0) ID: 0xc2 0x90 Name:"MX35UF1G14AC"
Block:128KB Page:2KB OOB:64B ECC:4bit/512 
Chipsize:128 MiB
MMC:   Card did not respond to voltage select!
No EMMC device found !
bsp-sdhci: 0
Loading Environment from SPI Flash... Boot Media isn't SPI Nor
*** Warning - spi_flash_probe() failed, using default environment

Loading Environment from NAND... OK
In:    serial
Out:   serial
Err:   serial

Net:   gmac0, gmac1
Error: gmac1 address not set.

Hit any key to stop autoboot:  0 
# usb device
Install USB Device...
# usb start
starting USB...
USB0:   Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus 0 for devices... 1 USB Device(s) found
USB1:   Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus 1 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
# usb tree
USB device tree:
  1  Hub (5 Gb/s, 0mA)
     U-Boot XHCI Host Controller 
   
  2  Hub (5 Gb/s, 0mA)
  |  U-Boot XHCI Host Controller 
  |
  +-3  Mass Storage (480 Mb/s, 100mA)
       USB2.0 Flash Disk 2013110511330078
     
# fatls usb 0
            System Volume Information/
      402   config
      765   config_debug.txt
   327680   u-boot.bin

 30007296   vmcore

16 file(s), 1 dir(s)

# fatload usb 0 0x43000000 u-boot.bin
1071412 bytes read in 82 ms (12.5 MiB/s)

3、实现开机自动识别U盘并完成升级

(1)将uboot终端下手动升级的过程封装成一个命令,假设是usbupdate命令;
(2)在bootcmd中添加usbupdate命令,这样每次uboot在启动内核前都会去执行U盘自动升级的过程;

#原来的bootcmd
bootcmd=partload kernel;bootm 0x44000000

# 支持U盘自动升级的bootcmd
bootcmd=usbupdate;partload kernel;bootm 0x44000000

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值