嵌入式系統 - uboot 相關



help 命令


IPQ6018# help
? - alias for 'help'
aq_load_fw- LOAD aq-fw-binary
aq_phy_restart- Restart Aquantia phy
base - print or set address offset
bdinfo - print Board Info structure
bootelf - Boot from an ELF image in memory
bootipq - bootipq from flash device
bootm - boot application image from memory
bootp - boot image via network using BOOTP/TFTP protocol
bootvx - Boot vxWorks from an ELF image
bootz - boot Linux zImage image from memory
canary - test stack canary
chpart - change active partition
cmp - memory compare
coninfo - print console devices and information
cp - memory copy
crc32 - checksum calculation
dhcp - boot image via network using DHCP/TFTP protocol
dm - Driver model low level access
echo - echo args to console
editenv - edit environment variable
env - environment handling commands
erase - erase FLASH memory
exectzt - execute TZT

exit - exit script
false - do nothing, unsuccessfully
fdt - flattened device tree utility commands
flash - flash part_name
flash part_name load_addr file_size

flasherase- flerase part_name

flinfo - print FLASH memory information
fuseipq - fuse QFPROM registers from memory

go - start application at address 'addr'
help - print command description/usage
i2c - I2C sub-system
imxtract- extract a part of a multi-image
ipq_mdio- IPQ mdio utility commands
is_sec_boot_enabled- check secure boot fuse is enabled or not

itest - return true/false on integer compare
loop - infinite loop on address range
md - memory display
mii - MII utility commands
mm - memory modify (auto-incrementing address)
mmc - MMC sub system
mmcinfo - display MMC info
mtdparts- define flash/nand partitions
mtest - simple RAM read/write test
mw - memory write (fill)
nand - NAND sub-system
nboot - boot from NAND device
nm - memory modify (constant address)
part - disk partition related commands
pci - list and access PCI Configuration Space
ping - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
protect - enable or disable FLASH write protection
reset - Perform RESET of the CPU
run - run commands in an environment variable
runmulticore- Enable and schedule secondary cores
saveenv - save environment variables to persistent storage
secure_authenticate- authenticate the signed image

setenv - set environment variables
setexpr - set environment variable as the result of eval expression
sf - SPI flash sub-system
showvar - print local hushshell variables
sleep - delay execution for some time
smeminfo- print SMEM FLASH information
source - run script from memory
test - minimal test like /bin/sh
tftpboot- boot image via network using TFTP protocol
tftpput - TFTP put command, for uploading files to a server
tftpsrv - act as a TFTP server and boot the first received file
true - do nothing, successfully
tzt - load and run tzt

uart - UART sub-system
ubi - ubi commands
usb - USB sub-system
usbboot - boot from USB device
version - print monitor, compiler and linker version



常用指令


printenv // 列印環境變數
setenv ipaddr X.X.X.X // 設定環境變數 - 自己的 ip
serenv serverip X.X.X.X // 設定環變數 - tftp server ip
saveenv // 儲存環境變數

tftpboot file.img // 從指定的 tftp server 下載 file.img
flasherase rootfs // 清空 mtd 分區名稱為 rootfs 的分區
flash rootfs // file.img 寫入 mtd 分區名稱為 rootfs 的分區 (此命令已包含清空)

nand erase [0x4000000 目的位址] [0x4000000 長度] // 清空位址內容
nand write [0x44000000 來源位址] [0x4000000 目的位址] [0x3f00000 長度] // 寫入位址內容

nand read [目的位址] [來源位址] [長度] // 讀取位址內容
tftpput [來源位址] [長度] [tftpServer的檔名] // 上傳位址內容 (需在server端先建立好檔名,並給寫入權限)

bootm 0x44000000 // 直接跳到 0x44000000 的位址進行開機
bootm // 從預設位址開機 (通常是 0x44000000)
reset // 重開機

mw [位址] [] [長度] // 設定記憶體中的值
md [位址] [長度] // 讀取記憶體中的值


讀取"裝備樹" & 顯示文字 (轉成 dts 格式)

tftpboot ipq6018-cp01-c3.dtb
fdt addr 0x44000000
fdt header
fdt printer


從 u-boot 備份 mtd 分區

kernel 的 mtd 分區訊息

[ 1.533431] 0x000000000000-0x000000180000 : "0:SBL1"
[ 1.540837] 0x000000180000-0x000000280000 : "0:MIBIB"
...
[ 1.601482] 0x000000d00000-0x000007700000 : "rootfs"


命令
setenv ipaddr X.X.X.X // 設定自己的 ip
serenv serverip X.X.X.X // 設定 tftp server 的 ip

nand read 0x44000000 0 0x180000
tftpput 0x44000000 0x180000 mtd.p1

nand read 0x44000000 0x180000 0x100000
tftpput 0x44000000 0x100000 mtd.p2

// rttofs 太大了,要分兩次
nand read 0x44000000 0xd00000 0x3000000
tftpput 0x44000000 0x3000000 mtd.p14-1
nand read 0x44000000 0x3d00000 0x3A00000
tftpput 0x44000000 0x3A00000 mtd.p14-2



在 u-boot 指定 mtd 分區範例


setenv bootargs ubi.mtd=rootfs root=mtd:ubi_rootfs rootfstype=squashfs rootwait mtdparts="spi32766.0:640k(0:SBL1)ro,64k(0:MIBIB)ro,128k(0:BOOTCONFIG)ro,128k(0:BOOTCONFIG1)ro,1472k(0:QSEE)ro,64k(0:DEVCFG)ro,128k(0:RPM)ro,64k(0:CDT)ro,64k(0:APPSBLENV),640k(0:APPSBL)ro,256k(0:ART)ro,448k(flash)ro;qcom_nand.0:64M(rootfs_1),64M(rootfs)"
saveenv


在 kernel 指定 mtd 分區範例


在 kernel/drivers/of/fdt.c Func:early_init_dt_scan_chosen 裡的 bootargs-append & strlcat 之後,加入以下代碼:

if(!strstr((char *)data, "mtdparts")) {
    //char *my_bootargs = "ubi.mtd=rootfs root=mtd:ubi_rootfs rootfstype=squashfs rootwait mtdparts=\"spi32766.0:640k(0:SBL1)ro,64k(0:MIBIB)ro,128k(0:BOOTCONFIG),128k(0:BOOTCONFIG1),1472k(0:QSEE)ro,64k(0:DEVCFG)ro,128k(0:RPM)ro,64k(0:CDT)ro,64k(0:APPSBLENV),640k(0:APPSBL)ro,256k(0:ART)ro,448k(flash)ro;qcom_nand.0:64M(rootfs_1),64M(rootfs)\" swiotlb=1 coherent_pool=2M ";
    char *my_bootargs = "console=ttyMSM0,115200n8 cnss2.bdf_pci0=0xa0 ubi.mtd=rootfs root=mtd:ubi_rootfs rootfstype=squashfs rootwait mtdparts=\"qcom_nand.0:1536k(0:SBL1)ro,1024k(0:MIBIB)ro,512k(0:BOOTCONFIG)ro,512k(0:BOOTCONFIG1)ro,3584k(0:QSEE)ro,512k(0:DEVCFG)ro,512k(0:RPM)ro,512k(0:CDT)ro,512k(0:APPSBLENV)ro,1536k(0:APPSBL)ro,512k(0:ART)ro,1024k(hwconfig)ro,1024k(swconfig)ro,106M(rootfs),512k(0:ETHPHYFW)ro,64M(image)\" swiotlb=1 coherent_pool=2M ";
    strlcpy(data, my_bootargs, min((int)strlen(my_bootargs), COMMAND_LINE_SIZE));
}

分區大小內容要自行修改
(或者修改 kernel 的 .config 參數,也可達到效果。
在 [Boot options -> Default kernel command string] (CONFIG_CMDLINE))



沒有留言:

張貼留言