1. 程式人生 > >[uEnv.txt]在uEnv.txt檔案中使用if語句實現Image/dtb檔案切換

[uEnv.txt]在uEnv.txt檔案中使用if語句實現Image/dtb檔案切換

  • 指定image/dtb檔案
  • bootdir=
    bootfile=zImage
    fdtfile=embest-SBCC_PH8800_WLQ.dtb
    loadaddr=0x82000000
    fdtaddr=0x88000000
    
    finduuid=part uuid mmc ${mmcdev}:2 uuid
    loadfdt=fatload mmc ${mmcdev}:1 ${fdtaddr} ${fdtfile}
    loaduimage=fatload mmc ${mmcdev}:1 ${loadaddr} ${bootfile}
    
    uenvcmd=mdio write 7 0 0x800; mmc rescan; run loaduimage; run loadfdt; run fdtboot
    fdtboot=run mmc_args; bootz ${loadaddr} - ${fdtaddr}
    mmc_args=run finduuid; setenv bootargs console=ttyS0,115200n8 loglevel=0 systemd.log_target=null systemd.journald.forward_to_console=0 ${optargs} root=PARTUUID=${uuid} rw rootfstype=${mmcrootfstype}
  • 支援切換image/dtb檔案
  • bootdir=
    bootfile=zImage
    fdtfile=embest-SBCC_PH8800_WLQ.dtb
    loadaddr=0x82000000
    fdtaddr=0x88000000
    
    finduuid=part uuid mmc ${mmcdev}:2 uuid
    
    recoveryflag=false
    
    uenvcmd=if test ${recoveryflag} = "true"; then setenv bootfile zImage_bak; setenv fdtfile embest-SBCC_PH8800_WLQ_bak.dtb; echo bootfile=${bootfile} fdtfile=${fdtfile}; fi; setenv loadfdt fatload mmc ${mmcdev}:1 ${fdtaddr} ${fdtfile}; setenv loaduimage fatload mmc ${mmcdev}:1 ${loadaddr} ${bootfile}; mdio write 7 0 0x800; mmc rescan; run loaduimage; run loadfdt; run fdtboot
    
    fdtboot=run mmc_args; bootz ${loadaddr} - ${fdtaddr}
    mmc_args=run finduuid; setenv bootargs console=ttyS0,115200n8 loglevel=0 systemd.log_target=null systemd.journald.forward_to_console=0 ${optargs} root=PARTUUID=${uuid} rw rootfstype=${mmcrootfstype} 
    
  •  軟體更新
  • mount -o remount,rw /boot/firmware
    
    韌體更新成功:(注意-i和語句中的三個斜槓)
    sed -i 's/recoveryflag=true/recoveryflag=false/' /boot/firmware/uEnv.txt
    
    韌體更新失敗:
    sed -i 's/recoveryflag=false/recoveryflag=true/' /boot/firmware/uEnv.txt
    sync
    
    mount -o remount,ro /boot/firmware