吴忠躺衫网络科技有限公司

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

嵌入式Linux開發(fā)-uboot常用命令介紹(下篇)

DS小龍哥-嵌入式技術(shù) ? 來源:DS小龍哥-嵌入式技術(shù) ? 作者:DS小龍哥-嵌入式技 ? 2022-08-14 08:55 ? 次閱讀

1. 前言

這篇文章是UBOOT命令介紹的下篇,接著上篇文章介紹剩下的幾個命令用法。

主要是涉及的命令是:磁盤分區(qū)、磁盤文件加載、內(nèi)核引導(dǎo)、二進(jìn)制文件加載、跳轉(zhuǎn)命令、磁盤文件系統(tǒng)格式等等。

image-20220124134555164

2. UBOOT命令

2.1 fatls –列出指定目錄下的文件

查看幫助:

TINY4412 # ? fatls
fatls - list files in a directory (default /)
     列出一個目錄文件
?
Usage:
fatls  [directory]
?
  - list files from 'dev' on 'interface' in a 'directory'
復(fù)制代碼[:part]>

參數(shù)說明:

: mmc 或 usb;
dev: 設(shè)備編號;
part: 設(shè)備分區(qū)號;
[directory]: 目錄, 是可選, 可以不寫,不寫默認(rèn) / 目錄
復(fù)制代碼

查看SD卡中的文件列表(查看之前SD需要有完好的分區(qū)才行,可以通過fdisk進(jìn)行分區(qū),從U-BOOT和內(nèi)核地址之后開始分區(qū),防止將U-BOOT和內(nèi)核清除)

TINY4412 # fatls mmc 0 /
Partition1: Start Address(0x71c53a), Size(0x2025c6)
       system volume information/
      12345/
?
0 file(s), 2 dir(s)   共用兩個目錄,0個文件----進(jìn)過確認(rèn)正確的
復(fù)制代碼

查看子目錄下的文件:

TINY4412 # fatls mmc 0 /12345 
Partition1: Start Address(0x71c53a), Size(0x2025c6)
       ./
       ../
      5567/
?
0 file(s), 3 dir(s)
復(fù)制代碼

image-20220124134543267

2.2 從一個MMC文件系統(tǒng)(fat)中加載一個二進(jìn)制文件到DDR

查看幫助:

TINY4412 # help fatload
fatload - fatload - load binary file from a dos filesystem
?
?
Usage:
fatload  [bytes]
  - load binary file 'filename' from 'dev' on 'interface'
    to address 'addr' from dos filesystem
復(fù)制代碼[:part]>

參數(shù)說明:

: mmc 或 usb;
dev:    設(shè)備編號(可以通過啟動時查看或者列出存儲器);
part:    設(shè)備分區(qū)號;
:   DDR 內(nèi)存地址
: 要加載二進(jìn)制文件( 包含完整路徑)
[bytes]:要加載數(shù)據(jù)大小,字節(jié)為單位。可選的,可以不寫, 不寫時候默認(rèn)等于文件大小。
加載文件需要SD或者EMMC有完好的文件系統(tǒng)。
復(fù)制代碼

image-20220124134658482

先將SD卡從開發(fā)板取出(開發(fā)板不要斷電),通過讀卡器插入 PC,復(fù)制一些文件到卡里,然后再重新插入開發(fā)板中 (SD卡拔出來時開發(fā)板不要斷電,目的想測試一下 mmc rescan 命令作用)。SD卡拔掉之后,UBOOT一樣可以運行,因為程序已經(jīng)拷貝到DDR中運行了,只要不斷電U-BOOT就可以正常運行。

image-20220124134724136

文件拷貝完將SD卡再放回開發(fā)板,先不要重新掃描 mmc 設(shè)備,直接輸入 fatls 就會出錯:

TINY4412 # fatls mmc 0
 /* 打印錯誤信息,因為開發(fā)板沒有斷電,設(shè)備0是SD卡*/
count: 1
# Tx: Inverter delay / Rx: Inverter delay
?
count: 2
## Tx: Basic delay / Rx: Inverter delay
?
count: 3
## Tx: Inverter delay / Rx: Basic delay
?
count: 4
### Tx: Basic delay / Rx: Basic delay
?
count: 5
# Tx: Disable / Rx: Basic delay
?
count: 6
## Tx: Disable / Rx: Inverter delay
?
count: 7
### Tx: Basic delay / Rx: Disable
?
count: 8
### Tx: Inverter delay / Rx: Disable
mmc read failed ERROR: -19
data.dest: 0xc3cfbbdc
data.blocks: 1
data.blocksize: 512
MMC_DATA_READ
** Can't read from device 0 **
?
** Unable to use mmc 0:1 for fatls **
TINY4412 # 
復(fù)制代碼

掃描設(shè)備0,再讀出信息:

TINY4412 # mmc rescan 0  掃描設(shè)備
TINY4412 # fatls mmc 0   列出設(shè)備的文件目錄
?
/* 成功列出了SD卡文件目錄信息*/
Partition1: Start Address(0xa203d2), Size(0x2037b2)
       system volume information/
 4783928  zimage 
  277108  u-boot.bin 
  127245  纇/u-boot.pdf 
   5268  2015-12-30txt 
  731729  shell,
          - a.pdf 
?
5 file(s), 1 dir(s)
復(fù)制代碼

image-20220124134820305

開始測試 fatload 命令:

TINY4412 #  fatload mmc 0 48000000 zimage    將 zimage文件加載到DDR的48000000地址處  
Partition1: Start Address(0xa203d2), Size(0x2037b2)
reading zimage
?
4783928 bytes read  成功加載文件的大小(字節(jié)單位)
TINY4412 # md.b 48000000    打印出DDR 48000000地址處的數(shù)據(jù)
48000000: 00 00 a0 e1 00 00 a0 e1 00 00 a0 e1 00 00 a0 e1   ................
48000010: 00 00 a0 e1 00 00 a0 e1 00 00 a0 e1 00 00 a0 e1   ................
48000020: 02 00 00 ea 18 28 6f 01 00 00 00 00 38 ff 48 00   .....(o.....8.H.
48000030: 01 70 a0 e1 02 80 a0 e1 00 20 0f e1 03 00 12 e3   .p....... ......
復(fù)制代碼

image-20220124134903661

2.3 cmp --比較內(nèi)存數(shù)據(jù)是否相同

查看幫助
TINY4412 # ? cmp           
cmp - memory compare  內(nèi)存比較
?
Usage:
cmp [.b, .w, .l] addr1 addr2 count  格式     注意:count 是用十六進(jìn)制表示
cmp .b :以1個字節(jié)方式
cmp .w :以2 個字節(jié)方式
cmp .l :以4 個字節(jié)方式
?
格式:
Cmp.b 地址1 地址2 比較數(shù)據(jù)的數(shù)量
?
①比較DRR兩個地址數(shù)據(jù)是否相等
TINY4412 # cmp.b 48000000 49000000 10   比較兩個地址數(shù)據(jù)---數(shù)量是10個
byte at 0x48000000 (0x00) != byte at 0x49000000 (0xff)
Total of 0 bytes were the same  共有0字節(jié)是相同的
TINY4412 # 
?
?
②從MMC讀取1個扇區(qū)的數(shù)據(jù)到DDR的兩個地址
TINY4412 #  mmc read 0 48000000 1 1
?
MMC read: dev # 0, block # 1, count 1 ... 1 blocks read: OK
TINY4412 #  mmc read 0 49000000 1 1
?
MMC read: dev # 0, block # 1, count 1 ... 1 blocks read: OK
 
③再次比較兩個地址的數(shù)據(jù)
TINY4412 # cmp.b 48000000 49000000 10  ( 注意:這里的10是十六進(jìn)制的10 ,轉(zhuǎn)成十進(jìn)制就是16)
Total of 16 bytes were the same  共有16個字節(jié)都是一樣的。
復(fù)制代碼

2.4 mm --地址以自動增加的方式修改內(nèi)存數(shù)據(jù)

查看幫助:
TINY4412 # ? mm
mm - memory modify (auto-incrementing address)  修改內(nèi)存(增加的地址)
?
Usage:
mm [.b, .w, .l] address  格式: address要修改的地址
?
①先將DDR某處數(shù)據(jù)打印出來,方便修改完比較
TINY4412 # md.b 48000000 10
48000000: a3 69 d3 18 e9 7d b9 66 d1 6b d5 6e d4 79 a6 79   .i...}.f.k.n.y.y
?
②修改數(shù)據(jù)
TINY4412 # mm.b 48000000       
48000000: a3 ? 5  //把a(bǔ)3 修改為5
48000001: 69 ? 6  //把69 修改為6
48000002: d3 ? 7
48000003: 18 ? 8
48000004: e9 ?    不想修改直接按下<回車鍵>跳過
48000005: 7d ? 9
48000006: b9 ? TINY4412 #   修改完直接按ctrl+c 結(jié)束
?
③再次查看數(shù)據(jù)
TINY4412 # md.b 48000000 10
48000000: 05 06 07 08 e9 09 b9 66 d1 6b d5 6e d4 79 a6 79   .......f.k.n.y.y  修改之后的數(shù)據(jù)
?
將修改之前的數(shù)據(jù)與修改之后的比較,發(fā)現(xiàn)已經(jīng)修改成功!
其他類似命令:
mm.w:一次修改 2 字節(jié)
mm.l:一次修改 4 字節(jié)
復(fù)制代碼

2.5 cp –內(nèi)存拷貝

查看幫助:
TINY4412 # ? cp
cp - memory copy  內(nèi)存復(fù)制
?
Usage:  用法格式
cp [.b, .w, .l] source target count  注意這里的數(shù)量是用16進(jìn)制表示的
格式:cp.b 源地址 目標(biāo)地址 數(shù)量
①讀出DDR兩個地址的數(shù)據(jù),方便后面比較
TINY4412 # md.b 45000000 10  顯示數(shù)據(jù)
45000000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff   ................
TINY4412 # md.b 49000000 10  顯示數(shù)據(jù)
49000000: a3 69 d3 18 e9 7d b9 66 d1 6b d5 6e d4 79 a6 79   .i...}.f.k.n.y.y
?
?
②將DDR的4900000地址前10個字節(jié)拷貝到45000000地址處
TINY4412 # cp 49000000 45000000 10
?
③將兩處地址的數(shù)據(jù)再顯示出來
TINY4412 # md.b 45000000 10     
45000000: a3 69 d3 18 e9 7d b9 66 d1 6b d5 6e d4 79 a6 79   .i...}.f.k.n.y.y
TINY4412 # md.b 49000000 10
49000000: a3 69 d3 18 e9 7d b9 66 d1 6b d5 6e d4 79 a6 79   .i...}.f.k.n.y.y
拷貝之后,將兩處地址數(shù)據(jù)再次比較,兩邊數(shù)據(jù)是一樣的。
復(fù)制代碼

2.6 loady - 使用串口下載二進(jìn)制數(shù)據(jù)到內(nèi)存中

U-BOOT支持的串口傳輸模式:

loadb  - load binary file over serial line (kermit mode)
loads  - load S-Record file over serial line
loady  - load binary file over serial line (ymodem mode)
復(fù)制代碼

串口下載文件到DDR,上面是U-BOOT支持串口的3種傳輸模式。

CRT串口終端支持的協(xié)議:

image-20220124135202201
查看幫助:
TINY4412 # ? loady
Unknown command '' - try 'help' without arguments for list of all known commands
?
loady - load binary file over serial line (ymodem mode)
用在串行線加載二進(jìn)制文件(ymodem模式)
?
Usage:
loady [ off ] [ baud ]
  - load binary file over serial line with offset 'off' and baudrate 'baud'
參數(shù)說明:
[ off ]: DDR 內(nèi)存地址, 可選。
[ baud ]:使用多快的波特率下載, 可選,不填就表示默認(rèn)的115200波特率。
示例:
loady 0x40000000 115200
復(fù)制代碼

測試loady命令:

(1)下載文件到內(nèi)存

TINY4412 # loady 40000000   下載文件到DDR 40000000地址
## Ready for binary (ymodem) download to 0x40000000 at 0 bps...
復(fù)制代碼

image-20220124135312187image-20220124135330283

(2)對比數(shù)據(jù)內(nèi)容

image-20220124135349614

(3)執(zhí)行代碼

上面下載的bin文件是一個按鍵的裸機(jī)程序,可以用go命令跳轉(zhuǎn)到指定地址去執(zhí)行下載的代碼。

TINY4412 # go 40000000
## Starting application at 0x40000000 ...
跳轉(zhuǎn)過去之后,按下按鍵測試! 測試結(jié)果正常,按鍵程序可以正常執(zhí)行。
復(fù)制代碼

2.7 go–CPU 跳轉(zhuǎn)到指定的地址執(zhí)行代碼

一旦 go 指令執(zhí)行后, CPU 就會去執(zhí)行指定地址處的代碼。

查看幫助:

TINY4412 # ? go
go - start application at address 'addr'
   在addr處啟動應(yīng)用程序
?
Usage:
go addr [arg ...]
  - start application at address 'addr'
    passing 'arg' as arguments 作為參數(shù)傳遞的參數(shù)
復(fù)制代碼

測試go命令

將SD卡第一個扇區(qū)數(shù)據(jù)讀到DDR內(nèi)存中等待執(zhí)行。讀8個扇區(qū)
TINY4412 # mmc read 0 45000000 1 8  
?
MMC read: dev # 0, block # 1, count 8 ... 8 blocks read: OK
?
跳轉(zhuǎn)到45000000地址去執(zhí)行程序
TINY4412 # go 45000000 
## Starting application at 0x45000000 ...  開始執(zhí)行地址處的代碼,因為扇區(qū)1開始存放的是BL1代碼,重新執(zhí)行啟動了UBOOT
OK
?
U-Boot 2010.12 (Jan 01 2016 - 02:37:55) for TINY4412
?
CPU:   S5PC220 [Samsung SOC on SMP Platform Base on ARM CortexA9]
     APLL = 1400MHz, MPLL = 800MHz
?
Board:  TINY4412
DRAM:  1023 MiB
...........................................................................................................
復(fù)制代碼

image-20220124135654581

2.8 打開關(guān)閉emmc設(shè)備引導(dǎo)分區(qū)

查看幫助:
TINY4412 # ? emmc
emmc - Open/Close eMMC boot Partition  打開/關(guān)閉emmc引導(dǎo)分區(qū)
?
Usage:
emmc open  
emmc close  
?
對設(shè)備讀寫操作,需要先打開,讀寫完畢,再關(guān)閉。
示例: 
emmc close 1   打開設(shè)備1
emmc open 1   關(guān)閉設(shè)備1
?
emmc close 0   打開設(shè)備0
emmc open 0   關(guān)閉設(shè)備0
復(fù)制代碼

2.9 movi 子系統(tǒng)----從MMC向DDR讀寫數(shù)據(jù)

該指令在產(chǎn)品發(fā)布時需要用到,用來固化內(nèi)核和UBOOT。

查看幫助:

TINY4412 # ? movi
movi - movi   - sd/mmc r/w sub system for SMDK board
?
Usage:
movi init - Initialize moviNAND and show card info
movi read zero {fwbl1 | u-boot} {device_number} {addr} - Read data from sd/mmc  讀取數(shù)據(jù)從sd / mmc
movi write zero {fwbl1 | u-boot} {device_number} {addr} - Read data from sd/mmc  讀取數(shù)據(jù)從sd / mmc
movi read {u-boot | kernel} {device_number} {addr} - Read data from sd/mmc    讀取數(shù)據(jù)從sd / mmc
movi write {fwbl1 | u-boot | kernel} {device_number} {addr} - Write data to sd/mmc 寫入數(shù)據(jù)到sd / mmc
movi read rootfs {device_number} {addr} [bytes(hex)] - Read rootfs data from sd/mmc by size    從sd/mmc讀取rootfs數(shù)據(jù)大小
movi write rootfs {device_number} {addr} [bytes(hex)] - Write rootfs data to sd/mmc by size     寫rootfs sd/mmc的數(shù)據(jù)大小
movi read {sector#} {device_number} {bytes(hex)} {addr} - instead of this, you can use "mmc read"
movi write {sector#} {device_number} {bytes(hex)} {addr} - instead of this, you can use "mmc write"
復(fù)制代碼

(1)把 sd 卡中 u-boot 的第一階段的 bl1 數(shù)據(jù)復(fù)制到內(nèi)存,然后再寫入 emmc 對應(yīng)位置

movi read fwbl1 0 40000000;    //從SD(設(shè)備編號為)拷貝bl1到DDR內(nèi)存地址
emmc open 1;          //打開EMMC設(shè)備
movi write zero fwbl1 1 40000000;  //將DDR地址處數(shù)據(jù)寫入到EMMC對應(yīng)位置
emmc close 1;           //關(guān)閉EMMC設(shè)備
復(fù)制代碼

用法示例:

TINY4412 # movi read fwbl1 0 40000000;
reading FWBL1 ..device 0 Start 1, Count 16 
MMC read: dev # 0, block # 1, count 16 ... 16 blocks read: OK  從SD卡第1個扇區(qū)開始讀,連續(xù)讀16個扇區(qū)
completed
TINY4412 # emmc open 1;
eMMC OPEN Success.!!
             !!!Notice!!!
!You must close eMMC boot Partition after all image writing!
!eMMC boot partition has continuity at image writing time.!
!So, Do not close boot partition, Before, all images is written.!
TINY4412 # movi write zero fwbl1 1 40000000; 
writing FWBL1 ..device 1 Start 0, Count 16 
MMC write: dev # 1, block # 0, count 16 ... 16 blocks written: OK 從EMMC第0個扇區(qū)寫,連續(xù)寫16個扇區(qū)
completed
TINY4412 # emmc close 1; 
eMMC CLOSE Success.!!
?
因為SD卡的特性,第0個扇區(qū)不能使用,數(shù)據(jù)只能從第1個扇區(qū)開始存放。
EMMC可以直接從第0個扇區(qū)存放數(shù)據(jù)。
所以-----EMMC的第0個扇區(qū)相當(dāng)于SD卡的第1個扇區(qū)
復(fù)制代碼

image-20220124140004454

(2)把sd卡中u-boot的BL2 數(shù)據(jù)復(fù)制到內(nèi)存,然后再寫入 emmc 對應(yīng)位置

movi read bl2 0 40000000;   //從SD(設(shè)備編號為0)拷貝bl2到DDR內(nèi)存地址
emmc open 1;         //打開EMMC設(shè)備
movi write zero bl2 1 40000000; //將DDR地址處數(shù)據(jù)寫入到EMMC對應(yīng)位置
emmc close 1;         //關(guān)閉EMMC設(shè)備
復(fù)制代碼

示例:

TINY4412 # movi read bl2 0 40000000
reading BL2 ..device 0 Start 17, Count 32 
MMC read: dev # 0, block # 17, count 32 ... 32 blocks read: OK  //從SD卡的第17個扇區(qū)開始讀,連續(xù)讀32個扇區(qū)。
                           //查看UBOOT燒寫腳本可知,BL2是從SD卡第17扇區(qū)開始燒寫的
completed
TINY4412 # emmc open 1     
eMMC OPEN Success.!!
             !!!Notice!!!
!You must close eMMC boot Partition after all image writing!
!eMMC boot partition has continuity at image writing time.!
!So, Do not close boot partition, Before, all images is written.!
TINY4412 # movi write zero bl2 1 40000000  
writing BL2 ..device 1 Start 16, Count 32 
MMC write: dev # 1, block # 16, count 32 ... 32 blocks written: OK  //向EMMC的第17個扇區(qū)開始寫,連續(xù)寫32個扇區(qū)。
completed
TINY4412 # emmc close 1
eMMC CLOSE Success.!!
復(fù)制代碼

image-20220124140109626

(3)把 sd 卡中 u-boot 復(fù)制到內(nèi)存,然后再寫入 emmc 對應(yīng)位置

movi read u-boot 0 40000000;    將SD卡的U-BOOT.Bin讀到DDR內(nèi)存空間
emmc open 1;          打開EMMC設(shè)備
movi write zero u-boot 1 40000000;  將DDR的數(shù)據(jù)寫入EMMC設(shè)備
emmc close 1;           關(guān)閉EMMC
復(fù)制代碼

示例:

TINY4412 # movi read u-boot 0 40000000
reading bootloader..device 0 Start 49, Count 656 
MMC read: dev # 0, block # 49, count 656 ... 656 blocks read: OK  從SD卡第49個扇區(qū)開始,讀取656個扇區(qū)到DDR內(nèi)存
completed
TINY4412 # emmc open 1
eMMC OPEN Success.!!
             !!!Notice!!!
!You must close eMMC boot Partition after all image writing!
!eMMC boot partition has continuity at image writing time.!
!So, Do not close boot partition, Before, all images is written.!
TINY4412 # movi write zero u-boot 1 40000000
writing bootloader..device 1 Start 48, Count 656    
MMC write: dev # 1, block # 48, count 656 ... 656 blocks written: OK 向EMMC的第49個扇區(qū),連續(xù)寫入656個扇區(qū)到DDR內(nèi)存
completed
TINY4412 # emmc close 1
eMMC CLOSE Success.!!
復(fù)制代碼

image-20220124140204306

(4)把 sd 卡中 u-boot 安全加密數(shù)據(jù)復(fù)制到內(nèi)存,然后再寫入 emmc 對應(yīng)位置

movi read tzsw 0 40000000;    將安全加密數(shù)據(jù)拷貝到DDR
emmc open 1;         打開EMMC設(shè)備
movi write zero tzsw 1 40000000;  將DDR數(shù)據(jù)寫入EMMC
emmc close 1;          關(guān)閉EMMC設(shè)備
復(fù)制代碼

示例:

TINY4412 # movi read tzsw 0 40000000
reading 0 TrustZone S/W.. Start 705, Count 320 
MMC read: dev # 0, block # 705, count 320 ... 320 blocks read: OK  從SD卡的第705個扇區(qū)開始,連續(xù)讀取320個扇區(qū)到DDR
Completed                        安全加密數(shù)據(jù)是從SD的705個扇區(qū)存放的
TINY4412 # emmc open  1
eMMC OPEN Success.!!
             !!!Notice!!!
!You must close eMMC boot Partition after all image writing!
!eMMC boot partition has continuity at image writing time.!
!So, Do not close boot partition, Before, all images is written.!
TINY4412 # movi write zero tzsw 1 40000000;
writing 1 TrustZone S/W.. Start 704, Count 320 
MMC write: dev # 1, block # 704, count 320 ... 320 blocks written: OK  寫入EMMC
completed
TINY4412 # emmc close 1
eMMC CLOSE Success.!!
復(fù)制代碼

image-20220124140305180image-20220124140317064

(5)把 sd 卡中內(nèi)核數(shù)據(jù)復(fù)制到內(nèi)存,然后再寫入 emmc 對應(yīng)位置

movi read kernel 0 40000000;   將SD卡的內(nèi)核數(shù)據(jù)讀到DDR內(nèi)存中
movi write kernel 1 40000000;   將DDR的數(shù)據(jù)寫入EMMC中
復(fù)制代碼

示例:

TINY4412 # movi read kernel 0 40000000
reading kernel..device 0 Start 1057, Count 12288 
MMC read: dev # 0, block # 1057, count 12288 ... 12288 blocks read: OK  從SD卡1057扇區(qū)開始,連續(xù)讀12288個扇區(qū)到DDR
completed
TINY4412 # movi write kernel 1 40000000
writing kernel..device 1 Start 1057, Count 12288 
MMC write: dev # 1, block # 1057, count 12288 ... 12288 blocks written: OK將DDR的數(shù)據(jù)寫入EMMC,從1057開始寫,連續(xù)寫12288個扇區(qū)
completed
復(fù)制代碼

image-20220124140413623

2.10 movi 精簡命令-一鍵拷貝

將UBOOT和內(nèi)核數(shù)據(jù)固化到EMMC精簡命令:

movi r f 0 40008000;emmc open 1;movi w z f 1 40008000;emmc close 1;
movi r b 0 40008000;emmc open 1;movi w z b 1 40008000;emmc close 1;
movi r u 0 40008000;emmc open 1;movi w z u 1 40008000;emmc close 1;
movi r t 0 40008000;emmc open 1;movi w z t 1 40008000;emmc close 1;
movi r k 0 40008000;movi w k 1 40008000;
復(fù)制代碼

2.11 bootcmd命令的使用

bootcmd命令是設(shè)置U-BOOT啟動成功后執(zhí)行的命令代碼。

示例:

set bootcmd 'mmc read 0 40000000 421 1;md.b 40000000'
?
格式:setenv  ‘ 需要執(zhí)行的命令’
    Save  //保存設(shè)置
復(fù)制代碼

2.12 執(zhí)行二進(jìn)制文件-->bootm命令

bootm命令是用來引導(dǎo)經(jīng)過U-Boot的工具mkimage打包后的kernel image的。

查看幫助:

TINY4412 # ? bootm
bootm - boot application image from memory  //bootm從內(nèi)存中啟動應(yīng)用程序
?
Usage:
bootm [addr [arg ...]]
  - boot application image stored in memory
     passing arguments 'arg ...'; when booting a Linux kernel,
    'arg' can be the address of an initrd image
//傳遞參數(shù)的參數(shù)…”;當(dāng)引導(dǎo)Linux內(nèi)核,“參數(shù)”可以是映像文件的地址
?
Sub-commands to do part of the bootm sequence.  The sub-commands must be
issued in the order below (it's ok to not issue all sub-commands):
    start [addr [arg ...]]
     loados - load OS image  加載操作系統(tǒng)映像
     cmdline - OS specific command line processing/setup 操作系統(tǒng)特定的命令行處理/設(shè)置
     bdt   - OS specific bd_t processing 操作系統(tǒng)特定bd_t處理
     prep  - OS specific prep before relocation or go 
     go   - start OS 啟動操作系統(tǒng)
復(fù)制代碼

示例:

(1)直接引導(dǎo)內(nèi)核

TINY4412 # mmc read 0 40007fc0 421 3000 
將SD卡內(nèi)核讀到DDR內(nèi)存空間----內(nèi)核映像是從SD卡1057扇區(qū)開始存放的,連續(xù)占用了12288個扇區(qū) 
(注意: 421是0x421 3000是0x3000)
MMC read: dev # 0, block # 1057, count 12288 ... 12288 blocks read: OK
?
TINY4412 # bootm 40007fc0  執(zhí)行DDR--40007fc0地址處的二進(jìn)制文件
Boot with zImage
?
Starting kernel ...
?
Uncompressing Linux... done, booting the kernel.  
復(fù)制代碼

image-20220124140814996

(2)設(shè)置UBOOT啟動成功自動引導(dǎo)內(nèi)核

TINY4412 # setenv bootcmd 'mmc read 0 40007fc0 421 3000;bootm 40007fc0' U-BOOT啟動成功之后自動執(zhí)行
TINY4412 # save 保存設(shè)置
或者使用bootcmd=movi read kernel 0 40008000;movi read rootfs 0 41000000 100000;bootm 40008000 41000000
復(fù)制代碼

image-20220124140849754

2.13 分區(qū)命令-fdisk

查看幫助:

TINY4412 # ? fdisk
fdisk - fdisk for sd/mmc. //硬盤分區(qū)工具
Usage:
fdisk -p   - print partition information   //打印分區(qū)信息
fdisk -c  []
    - create partition  //創(chuàng)建分區(qū)(分區(qū)單位是M)
復(fù)制代碼

(1)查看分區(qū)信息示例

TINY4412 # fdisk -p 0  //查看SD卡分區(qū)信息
?
分區(qū)      大小     扇區(qū)開始地址     扇區(qū)數(shù)量(512字節(jié)一個扇區(qū))     分區(qū)ID名稱
partion #   size(MB)     block start #       block count             partition_Id 
  1     1028     7456058       2106822              0x06 
  4       0     28049408        441                0x00 
復(fù)制代碼

image-20220124141021889

(2)給SD卡分區(qū)示例

(分區(qū)時--會自行在SD卡開頭大約66M后的空間開始分區(qū),因為開頭部分需要用來存放內(nèi)核與U-BOOT)

TINY4412 # fdisk -c 0 320 2057 520   //給SD卡分區(qū), -c 表示分區(qū)
fdisk is completed   //提示分區(qū)完成
?
分區(qū)      大小     扇區(qū)開始地址     扇區(qū)數(shù)量(512字節(jié)一個扇區(qū))     分區(qū)ID名稱
partion #   size(MB)   block start #        block count           partition_Id 
  1     4416     6090216       9045762             0x0C 
  2      320      134343       656788             0x83 
  3     2062      791131       4224341             0x83 
  4      524     5015472       1074744             0x83 
復(fù)制代碼

image-20220124141108289

2.14 指定EMMC的分區(qū)文件系統(tǒng)格式

U-BOOT支持格式化的文件系統(tǒng)格式:

fatformat- fatformat - disk format by FAT32
ext3format- ext3format - disk format by ext3
ext2format- ext2format - disk format by ext2
復(fù)制代碼

查看 fatformat命令使用幫助:

TINY4412 # ? fatformat
fatformat - fatformat - disk format by FAT32
       指定磁盤的格式位FAT32
?
Usage:
fatformat   用法格式
    - format by FAT32 on 'interface'   
?
其他兩個命令,用法一樣!
復(fù)制代碼(only>

(1)指定分區(qū)命令-用法示例

fatformat  mmc 0:1     //表示將第0個盤的第一個分區(qū)初始化為 fat
ext3format mmc 0:2     //表示將第0個盤的第二個分區(qū)初始化為 ext3
ext2format mmc 0:3    //表示將第0個盤的第三個分區(qū)初始化為  ext2
ext3format mmc 0:4     //表示將第0個盤的第四個分區(qū)初始化為  ext3

image-20220124141306110

(2)SD卡分區(qū)文件系統(tǒng)格式化完畢,將SD卡插入電腦,查看SD卡的分區(qū)信息

image-20220124141338477

(3)將SD卡掛載進(jìn)虛擬機(jī),查看設(shè)備節(jié)點。

image-20220124141411181image-20220124141436392

審核編輯:湯梓紅
聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • Linux
    +關(guān)注

    關(guān)注

    87

    文章

    11345

    瀏覽量

    210403
  • 命令
    +關(guān)注

    關(guān)注

    5

    文章

    696

    瀏覽量

    22112
  • Uboot
    +關(guān)注

    關(guān)注

    4

    文章

    125

    瀏覽量

    28350
收藏 人收藏

    評論

    相關(guān)推薦

    Linux常用命令匯總

    本篇文章一個介紹了約40個Linux常用命令,這些命令也正是Linux入門的精髓之處,所以,對于這些命令
    發(fā)表于 10-25 15:08 ?705次閱讀
    <b class='flag-5'>Linux</b><b class='flag-5'>常用命令</b>匯總

    Linux常用命令介紹

    大家好,我是嵌入式老林,從事嵌入式軟件開發(fā)多年,今天分享的內(nèi)容是Linux基礎(chǔ)知識,最常用命令
    發(fā)表于 07-14 15:58 ?407次閱讀
    <b class='flag-5'>Linux</b><b class='flag-5'>常用命令</b><b class='flag-5'>介紹</b>

    請問嵌入式Linux GCC常用命令有哪些?

    嵌入式Linux GCC常用命令有哪些?
    發(fā)表于 04-19 09:39

    了解嵌入式系統(tǒng)的應(yīng)用以及Linux系統(tǒng)的結(jié)構(gòu)和常用命令

    #嵌入式系統(tǒng)開發(fā)概述及Linux基礎(chǔ)本人進(jìn)度計劃及任務(wù):了解嵌入式系統(tǒng)的應(yīng)用以及Linux系統(tǒng)的結(jié)構(gòu)和
    發(fā)表于 12-22 08:24

    嵌入式Linux常用命令

    嵌入式Linux常用命令,比較基礎(chǔ),非常實用,適合新手學(xué)習(xí)。
    發(fā)表于 11-24 15:22 ?3次下載

    Linux終端常用命令大全

    Linux終端常用命令大全,通俗易懂,容易上手。包含所有命令,方便查找各個指令功能。
    發(fā)表于 04-28 16:30 ?15次下載

    vim常用命令

    vim常用命令
    發(fā)表于 01-08 15:59 ?3次下載

    Linux教程之Linux常用命令大全

    Linux教程之Linux常用命令大全
    的頭像 發(fā)表于 03-30 10:34 ?5735次閱讀

    周立功嵌入式Linux開發(fā)教程上冊PDF電子書免費下載

    本篇主要講述進(jìn)行嵌入式Linux 開發(fā)所必備的基礎(chǔ)知識, 以實用和夠用為標(biāo)準(zhǔn)進(jìn)行介紹,與嵌入式Linux
    發(fā)表于 11-13 17:28 ?129次下載
    周立功<b class='flag-5'>嵌入式</b><b class='flag-5'>Linux</b><b class='flag-5'>開發(fā)</b>教程上冊PDF電子書免費下載

    linux常用命令手冊

    linux常用命令手冊免費下載。
    發(fā)表于 06-01 14:59 ?68次下載

    linux常用命令大全

    linux常用命令大全,一些常用命令都可以找到
    發(fā)表于 03-03 09:20 ?0次下載

    嵌入式Linux開發(fā)-編寫自定義uboot命令

    U-Boot的命令為用戶提供了交互功能,并且已經(jīng)實現(xiàn)了幾十個常用命令,前面兩篇文章介紹uboot自帶的
    的頭像 發(fā)表于 08-14 08:56 ?1271次閱讀

    Linux常用命令

    Linux常用命令
    的頭像 發(fā)表于 01-12 11:19 ?1197次閱讀

    Linux常用命令手冊分享

    linux常用命令合集
    發(fā)表于 04-26 11:46 ?1次下載

    linux常用命令及用法

    Linux是一種開源的操作系統(tǒng),它以穩(wěn)定、高效和安全的特點受到廣大用戶的喜愛。掌握Linux常用命令及其用法對于操作系統(tǒng)的管理和開發(fā)都至關(guān)重要。本文將詳盡、詳實、細(xì)致地
    的頭像 發(fā)表于 11-17 09:47 ?722次閱讀
    百家乐官网出老千视频| 破解百家乐官网真人游戏| 尊龙国际| 百家乐园试玩| 百家乐客户端软件| 至尊百家乐官网于波| 百家乐官网游戏下裁| 昌邑市| bet365忠实奖金| 太阳百家乐开户| 易胜博百家乐娱乐城| 网上百家乐赌钱| 百家乐官网海滨网现场| 百家乐官网出千原理| 博狗足球开户| 大发888娱乐城加速器| 百家乐稳赢战术技巧| 线上百家乐开户| 百家乐是赌博吗| 有钱人百家乐官网的玩法技巧和规则 | 百家乐视频金币| 大世界百家乐官网娱乐| ez百家乐官网技巧| 赌百家乐官网的体会| 娱乐城棋牌| 大发888娱乐场下载 游戏平台| 百家乐平注资讯| 大都会百家乐的玩法技巧和规则| 希尔顿百家乐试玩| 云鼎百家乐官网的玩法技巧和规则 | 婺源县| 武宣县| 岳池县| 博罗县| 南召县| 鱼台县| 土默特右旗| 杭州市| 通许县| 芦溪县| 真人百家乐官网打法|