一区二区三区三上|欧美在线视频五区|国产午夜无码在线观看视频|亚洲国产裸体网站|无码成年人影视|亚洲AV亚洲AV|成人开心激情五月|欧美性爱内射视频|超碰人人干人人上|一区二区无码三区亚洲人区久久精品

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

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

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

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

DS小龍哥-嵌入式技術(shù) ? 來(lái)源:DS小龍哥-嵌入式技術(shù) ? 作者:DS小龍哥-嵌入式技 ? 2022-08-14 08:55 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

1. 前言

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

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

image-20220124134555164

2. UBOOT命令

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

查看幫助:

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

參數(shù)說(shuō)明:

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

查看SD卡中的文件列表(查看之前SD需要有完好的分區(qū)才行,可以通過(guò)fdisk進(jìn)行分區(qū),從U-BOOT和內(nèi)核地址之后開(kā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)   共用兩個(gè)目錄,0個(gè)文件----進(jìn)過(guò)確認(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 從一個(gè)MMC文件系統(tǒng)(fat)中加載一個(gè)二進(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ù)說(shuō)明:

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

image-20220124134658482

先將SD卡從開(kāi)發(fā)板取出(開(kāi)發(fā)板不要斷電),通過(guò)讀卡器插入 PC,復(fù)制一些文件到卡里,然后再重新插入開(kāi)發(fā)板中 (SD卡拔出來(lái)時(shí)開(kāi)發(fā)板不要斷電,目的想測(cè)試一下 mmc rescan 命令作用)。SD卡拔掉之后,UBOOT一樣可以運(yùn)行,因?yàn)槌绦蛞呀?jīng)拷貝到DDR中運(yùn)行了,只要不斷電U-BOOT就可以正常運(yùn)行。

image-20220124134724136

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

TINY4412 # fatls mmc 0
 /* 打印錯(cuò)誤信息,因?yàn)殚_(kāi)發(fā)板沒(méi)有斷電,設(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

開(kāi)始測(cè)試 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個(gè)字節(jié)方式
cmp .w :以2 個(gè)字節(jié)方式
cmp .l :以4 個(gè)字節(jié)方式
?
格式:
Cmp.b 地址1 地址2 比較數(shù)據(jù)的數(shù)量
?
①比較DRR兩個(gè)地址數(shù)據(jù)是否相等
TINY4412 # cmp.b 48000000 49000000 10   比較兩個(gè)地址數(shù)據(jù)---數(shù)量是10個(gè)
byte at 0x48000000 (0x00) != byte at 0x49000000 (0xff)
Total of 0 bytes were the same  共有0字節(jié)是相同的
TINY4412 # 
?
?
②從MMC讀取1個(gè)扇區(qū)的數(shù)據(jù)到DDR的兩個(gè)地址
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
 
③再次比較兩個(gè)地址的數(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個(gè)字節(jié)都是一樣的。
復(fù)制代碼

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

查看幫助:
TINY4412 # ? mm
mm - memory modify (auto-incrementing address)  修改內(nèi)存(增加的地址)
?
Usage:
mm [.b, .w, .l] address  格式: address要修改的地址
?
①先將DDR某處數(shù)據(jù)打印出來(lái),方便修改完比較
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 ?    不想修改直接按下<回車(chē)鍵>跳過(guò)
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)修改成功!
其他類(lèi)似命令:
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兩個(gè)地址的數(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個(gè)字節(jié)拷貝到45000000地址處
TINY4412 # cp 49000000 45000000 10
?
③將兩處地址的數(shù)據(jù)再顯示出來(lái)
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ù)說(shuō)明:
[ off ]: DDR 內(nèi)存地址, 可選。
[ baud ]:使用多快的波特率下載, 可選,不填就表示默認(rèn)的115200波特率。
示例:
loady 0x40000000 115200
復(fù)制代碼

測(cè)試loady命令:

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

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

image-20220124135312187image-20220124135330283

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

image-20220124135349614

(3)執(zhí)行代碼

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

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

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

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

查看幫助:

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

測(cè)試go命令

將SD卡第一個(gè)扇區(qū)數(shù)據(jù)讀到DDR內(nèi)存中等待執(zhí)行。讀8個(gè)扇區(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 ...  開(kāi)始執(zhí)行地址處的代碼,因?yàn)樯葏^(qū)1開(kāi)始存放的是BL1代碼,重新執(zhí)行啟動(dòng)了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 打開(kāi)關(guān)閉emmc設(shè)備引導(dǎo)分區(qū)

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

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

該指令在產(chǎn)品發(fā)布時(shí)需要用到,用來(lái)固化內(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 寫(xiě)入數(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     寫(xiě)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)存,然后再寫(xiě)入 emmc 對(duì)應(yīng)位置

movi read fwbl1 0 40000000;    //從SD(設(shè)備編號(hào)為)拷貝bl1到DDR內(nèi)存地址
emmc open 1;          //打開(kāi)EMMC設(shè)備
movi write zero fwbl1 1 40000000;  //將DDR地址處數(shù)據(jù)寫(xiě)入到EMMC對(duì)應(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個(gè)扇區(qū)開(kāi)始讀,連續(xù)讀16個(gè)扇區(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個(gè)扇區(qū)寫(xiě),連續(xù)寫(xiě)16個(gè)扇區(qū)
completed
TINY4412 # emmc close 1; 
eMMC CLOSE Success.!!
?
因?yàn)镾D卡的特性,第0個(gè)扇區(qū)不能使用,數(shù)據(jù)只能從第1個(gè)扇區(qū)開(kāi)始存放。
EMMC可以直接從第0個(gè)扇區(qū)存放數(shù)據(jù)。
所以-----EMMC的第0個(gè)扇區(qū)相當(dāng)于SD卡的第1個(gè)扇區(qū)
復(fù)制代碼

image-20220124140004454

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

movi read bl2 0 40000000;   //從SD(設(shè)備編號(hào)為0)拷貝bl2到DDR內(nèi)存地址
emmc open 1;         //打開(kāi)EMMC設(shè)備
movi write zero bl2 1 40000000; //將DDR地址處數(shù)據(jù)寫(xiě)入到EMMC對(duì)應(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個(gè)扇區(qū)開(kāi)始讀,連續(xù)讀32個(gè)扇區(qū)。
                           //查看UBOOT燒寫(xiě)腳本可知,BL2是從SD卡第17扇區(qū)開(kāi)始燒寫(xiě)的
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個(gè)扇區(qū)開(kāi)始寫(xiě),連續(xù)寫(xiě)32個(gè)扇區(qū)。
completed
TINY4412 # emmc close 1
eMMC CLOSE Success.!!
復(fù)制代碼

image-20220124140109626

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

movi read u-boot 0 40000000;    將SD卡的U-BOOT.Bin讀到DDR內(nèi)存空間
emmc open 1;          打開(kāi)EMMC設(shè)備
movi write zero u-boot 1 40000000;  將DDR的數(shù)據(jù)寫(xiě)入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個(gè)扇區(qū)開(kāi)始,讀取656個(gè)扇區(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個(gè)扇區(qū),連續(xù)寫(xiě)入656個(gè)扇區(qū)到DDR內(nèi)存
completed
TINY4412 # emmc close 1
eMMC CLOSE Success.!!
復(fù)制代碼

image-20220124140204306

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

movi read tzsw 0 40000000;    將安全加密數(shù)據(jù)拷貝到DDR
emmc open 1;         打開(kāi)EMMC設(shè)備
movi write zero tzsw 1 40000000;  將DDR數(shù)據(jù)寫(xiě)入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個(gè)扇區(qū)開(kāi)始,連續(xù)讀取320個(gè)扇區(qū)到DDR
Completed                        安全加密數(shù)據(jù)是從SD的705個(gè)扇區(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  寫(xiě)入EMMC
completed
TINY4412 # emmc close 1
eMMC CLOSE Success.!!
復(fù)制代碼

image-20220124140305180image-20220124140317064

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

movi read kernel 0 40000000;   將SD卡的內(nèi)核數(shù)據(jù)讀到DDR內(nèi)存中
movi write kernel 1 40000000;   將DDR的數(shù)據(jù)寫(xiě)入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ū)開(kāi)始,連續(xù)讀12288個(gè)扇區(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ù)寫(xiě)入EMMC,從1057開(kāi)始寫(xiě),連續(xù)寫(xiě)12288個(gè)扇區(qū)
completed
復(fù)制代碼

image-20220124140413623

2.10 movi 精簡(jiǎn)命令-一鍵拷貝

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

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啟動(dòng)成功后執(zhí)行的命令代碼。

示例:

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

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

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

查看幫助:

TINY4412 # ? bootm
bootm - boot application image from memory  //bootm從內(nèi)存中啟動(dòng)應(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 啟動(dòng)操作系統(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ū)開(kāi)始存放的,連續(xù)占用了12288個(gè)扇區(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òng)成功自動(dòng)引導(dǎo)內(nèi)核

TINY4412 # setenv bootcmd 'mmc read 0 40007fc0 421 3000;bootm 40007fc0' U-BOOT啟動(dòng)成功之后自動(dòng)執(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. //硬盤(pán)分區(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ū)開(kāi)始地址     扇區(qū)數(shù)量(512字節(jié)一個(gè)扇區(qū))     分區(qū)ID名稱(chēng)
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ū)時(shí)--會(huì)自行在SD卡開(kāi)頭大約66M后的空間開(kāi)始分區(qū),因?yàn)殚_(kāi)頭部分需要用來(lái)存放內(nèi)核與U-BOOT)

TINY4412 # fdisk -c 0 320 2057 520   //給SD卡分區(qū), -c 表示分區(qū)
fdisk is completed   //提示分區(qū)完成
?
分區(qū)      大小     扇區(qū)開(kāi)始地址     扇區(qū)數(shù)量(512字節(jié)一個(gè)扇區(qū))     分區(qū)ID名稱(chēng)
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
       指定磁盤(pán)的格式位FAT32
?
Usage:
fatformat   用法格式
    - format by FAT32 on 'interface'   
?
其他兩個(gè)命令,用法一樣!
復(fù)制代碼(only>

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

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

image-20220124141306110

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

image-20220124141338477

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

image-20220124141411181image-20220124141436392

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

    關(guān)注

    87

    文章

    11509

    瀏覽量

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

    關(guān)注

    5

    文章

    737

    瀏覽量

    22876
  • Uboot
    +關(guān)注

    關(guān)注

    4

    文章

    129

    瀏覽量

    29089
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    Linux常用命令匯總

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

    Linux常用命令介紹

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

    Linux常用命令大全

    Linux常用命令是指在Linux操作系統(tǒng)中廣泛使用的命令工具,這些命令工具可以完成各種不同的任務(wù),如管理文件和目錄、操作進(jìn)程、網(wǎng)絡(luò)通信、軟
    的頭像 發(fā)表于 05-03 18:08 ?1117次閱讀

    請(qǐng)問(wèn)嵌入式Linux GCC常用命令有哪些?

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

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

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

    嵌入式Linux常用命令

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

    Linux終端常用命令大全

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

    vim常用命令

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

    Linux教程之Linux常用命令大全

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

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

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

    linux常用命令手冊(cè)

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

    linux常用命令大全

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

    Linux常用命令

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

    Linux常用命令手冊(cè)分享

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

    linux常用命令及用法

    Linux是一種開(kāi)源的操作系統(tǒng),它以穩(wěn)定、高效和安全的特點(diǎn)受到廣大用戶(hù)的喜愛(ài)。掌握Linux常用命令及其用法對(duì)于操作系統(tǒng)的管理和開(kāi)發(fā)都至關(guān)重要。本文將詳盡、詳實(shí)、細(xì)致地
    的頭像 發(fā)表于 11-17 09:47 ?971次閱讀