顯示具有 uboot 標籤的文章。 顯示所有文章
顯示具有 uboot 標籤的文章。 顯示所有文章

2020年5月28日 星期四

SD Card 整合

SD Card 整合 #1
2020/05/29



整合至 sdcard.img #1

截至目前為止,我們已經完成了底下事項:
1. rootfs -> OK
2. linux kernel -> OK
3. boot loader (u-boot) -> OK
4. SD card image -> OK

現在要開始進行整合的步驟:
1+2+3 -> SD card -> qemu


1. 複製 Linux 核心至 /mnt/sdcard1

~eecs/virtualarm/kernel/linux-3.16.81/arch/arm/boot# cp uImage /mnt/sdcard1

2. 複製 u-boot 檔案至 /mnt/sdcard1

u-boot
u-boot.bin

~eecs/virtualarm/bootloader/u-boot-2016.09# cp u-boot /mnt/sdcard1
~eecs/virtualarm/bootloader/u-boot-2016.09# cp u-boot.bin /mnt/sdcard1

3. 複製 rootfs 目錄至 /mnt/sdcard2

~eecs/virtualarm# rsync -av rootfs/ /mnt/sdcard2

作完之後,我們先解除掛載,然後用 qemu 來開機。


4. 測試開機

~/virtualarm$ ~/virtualarm$ qemu-system-arm -machine vexpress-a9 -m 256 -nographic -kernel u-boot -drive file=../../sd_test.img,if=sd,format=raw,index=0


U-Boot 2016.09 (May 22 2020 - 09:58:23 +0800)

DRAM:  256 MiB
WARNING: Caches not enabled
Flash: 128 MiB
MMC:   MMC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   smc911x-0
Hit any key to stop autoboot:  0
=> fatload mmc 0:1 0x60000000 uimage

=> setenv bootargs console=ttyAMA0,38400n8 root=/dev/mmcblk0p2

=> bootm 0x60000000

此時即可開機,並以 root 或是 leenix 帳號登錄。

5. 與 br10 連接在一起

請將底下內容另存為  runsd.sh,再來執行即可。

MACHINE=vexpress-a9
#SD_IMAGE=sdcard.img
SD_IMAGE=sd_test.img
#SD_IMAGE=sd_512M.img

#FLASH_IMG=flash.img

KERNEL_VERSION=3.16.81
UBOOT_VERSION=2016.09

MAC="52:54:12:34:00:A0"
BRIDGE=br10


MEMORY=256
#MEMORY=1024

qemu-system-arm -machine $MACHINE -m $MEMORY \
  -serial stdio \
  -drive file=./$SD_IMAGE,if=sd,format=raw,index=0 \
  -kernel ./bootloader/u-boot-$UBOOT_VERSION/u-boot \
  -net nic,macaddr=$MAC -net bridge,br=$BRIDGE




2016年11月15日 星期二

u-boot 說明與安裝 (2020 改)

2021/05/7 改版

U-boot 是嵌入式開發板上的泛用型開機程式,也就是所謂的 bootloader,其支援相當多的嵌入式開發板。我們的系統要先載入 u-boot 後才能載入核心,然後完成開機流程。

U-boot 的官方網址是 http://www.denx.de,上面有提供最新版本的 U-boot 原始碼下載,目前最新的版本是 2020.04,但是本課程只要使用 2016.09,請至 ftp 下載,下載完會出現 u-boot-2016.09.tar.bz2 這個檔案。

首先請建立 bootloader 目錄以便存放待會解壓縮的檔案,如果裡面的舊的資料也請先刪除目錄:

rm -rf bootloader
mkdir bootloader

接下來請執行底下指令解開此檔:

tar xfva u-boot-2021.04.tar.bz2 -C bootloader

解開完畢後,會出現一個 u-boot-2021.04 的目錄。請切換至此目錄,然後執行:

makerpi vexpress_ca9x4_defconfig

這個指令會將 vexpress-a9 板子的設定導入,vexpress_ca9x4_defconfig 在 u-boot 目錄下的 configs 目錄,在此目錄我們可以看到其它 u-boot 已支援之板子設定,未來大家設定別的嵌入式開發板時可以使用。舉例來說,假設我們要使用 Raspberry Pi 板的話,此目錄下有底下設定檔可使用:
rpi_defconfig
rpi_2_defconfig
rpi_3_32b_defconfig
rpi_3_defconfig

如果還要再作一些修改,請再執行:

makerpi menuconfig

此時會進入類似 kernel 設定選單的畫面,如果有特殊要求請在此畫面修改,沒有的話可以離開準備編譯。編譯指令是:

makerpi -j 8

編完之後會出現

u-boot
u-boot.bin

兩個檔案,待會我們要來測試 u-boot 開機。請執行:

qemu-system-arm -machine vexpress-a9 -m 256 -nographic -kernel u-boot

之後會出現底下畫面,請在倒數記時的時候按 Enter 以中斷倒數計時。

U-Boot 2021.04 (May 07 2021 - 09:58:18 +0800)

DRAM:  256 MiB
WARNING: Caches not enabled
Flash: 128 MiB
MMC:   MMC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   smc911x-0
Hit any key to stop autoboot:  0 

=>

現在停留在 u-boot 的提示符號,我們可以開始作操作。

=========================================================
U-boot 的指令

首先請執行 help 指令,其輸出如底下所示:

=> help
?       - alias for 'help'
base    - print or set address offset
bdinfo  - print Board Info structure
bootefi - Boots an EFI payload from memory
bootelf - Boot from an ELF image in memory
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
cmp     - memory compare
cp      - memory copy
crc32   - checksum calculation
dhcp    - boot image via network using DHCP/TFTP protocol
echo    - echo args to console
env     - environment handling commands
erase   - erase FLASH memory
exit    - exit script
ext2load- load binary file from a Ext2 filesystem
ext2ls  - list files in a directory (default /)
ext4load- load binary file from a Ext4 filesystem
ext4ls  - list files in a directory (default /)
ext4size- determine a file's size
false   - do nothing, unsuccessfully
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls   - list files in a directory (default /)
fatsize - determine a file's size
fdt     - flattened device tree utility commands
flinfo  - print FLASH memory information
fstype  - Look up a filesystem type
go      - start application at address 'addr'
help    - print command description/usage
iminfo  - print header information for application image
load    - load binary file from a filesystem
loop    - infinite loop on address range
ls      - list files in a directory (default /)
md      - memory display
mii     - MII utility commands
mm      - memory modify (auto-incrementing address)
mmc     - MMC sub system
mmcinfo - display MMC info
mw      - memory write (fill)
nm      - memory modify (constant address)
part    - disk partition related commands
ping    - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
protect - enable or disable FLASH write protection
pxe     - commands to get and boot from pxe files
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
save    - save file to a filesystem
saveenv - save environment variables to persistent storage
setenv  - set environment variables
showvar - print local hushshell variables
size    - determine a file's size
source  - run script from memory
sysboot - command to get and boot from syslinux files
test    - minimal test like /bin/sh
tftpboot- boot image via network using TFTP protocol
true    - do nothing, successfully
version - print monitor, compiler and linker version

====
bdinfo -> 檢視嵌入式開發板資訊

=> bdinfo
arch_number = 0x000008E0
boot_params = 0x60002000
DRAM bank   = 0x00000000                -> 記憶體 bank0
-> start    = 0x60000000                -> 起始位址 0x60000000
-> size     = 0x10000000                -> 容量     0x10000000 = 256 M
DRAM bank   = 0x00000001                -> 記憶體 bank1
-> start    = 0x80000000                -> 起始位址 0x80000000
-> size     = 0x00000004                -> 容量     0x00000004 = 4 byte
eth0name    = smc911x-0
ethaddr     = 52:54:00:12:34:56
current eth = smc911x-0
ip_addr     = <NULL>
baudrate    = 38400 bps
TLB addr    = 0x6FFF0000
relocaddr   = 0x6FF7D000
reloc off   = 0x0F77D000
irq_sp      = 0x6FEDCEF0
sp start    = 0x6FEDCEE0

=====
mmcinfo -> 檢視記憶卡資訊

=> mmcinfo
Card did not respond to voltage select!

上述訊息是指目前沒有記憶卡插入,所以無法開機。我們使用底下指令來加入記憶下:

qemu-system-arm -machine vexpress-a9 -m 256 -nographic -kernel u-boot -drive file=../../sdcard.img,if=sd,format=raw,index=0


其中 -drive 參數是告訴 qemu 如何加上記憶卡,file=../../sdcard.img 是告訴 qemu sdcard.img 的位置,因為這個檔案的位是 ~/virtualarm,所以我們使用 ../../ 這個相對路徑的表示式。如果有接上記憶卡的話,其訊息如下:

=> mmcinfo
Device: MMC
Manufacturer ID: aa
OEM: 5859
Name: QEMU!
Tran Speed: 25000000
Rd Block Len: 512
SD version 1.0
High Capacity: No
Capacity: 400 MiB
Bus Width: 1-bit
Erase Group Size: 512 Bytes

這個訊息告訴我們記憶卡的大小為 400 MiB (Mega),接下來可以觀看其內容。

=====
fatls -> 檢視 fat 分割區之內容,由於第 1 個分割區是以 fat 來作格式化,所以要使用此指令來觀看。

=> fatls mmc 0:1
  2438600   uimage
  2438536   zimage
  1670756   u-boot
   269344   u-boot.bin

4 file(s), 0 dir(s)

=====
ext4ls -> 檢視 ext4 分割區之內容,因為我們使用 ext4 來格式化第 2 個分割區。

=> ext4ls mmc 0:2
<DIR>       1024 .
<DIR>       1024 ..
<DIR>      12288 lost+found
<DIR>       1024 var
<DIR>       1024 usr
<DIR>       5120 bin
<DIR>       1024 lib
<DIR>       5120 etc
<DIR>       1024 tmp
<DIR>       1024 sys
<DIR>       5120 sbin
<DIR>       1024 run
<DIR>       1024 root
<DIR>       1024 proc
<DIR>       1024 home
<DIR>       1024 dev
<DIR>       1024 boot
<DIR>       1024 mnt
<DIR>       1024 srv
<DIR>       1024 opt
<DIR>       1024 media



=====
ls -> 檢視分割區之內容,例如:

=> ls mmc 0:1 -> 看第 0 張記憶卡的第 1 個分割區。
=> ls mmc 0:2 -> 看第 0 張記憶卡的第 2 個分割區


如果 ext4 無法支援的話,要重新格式化 ext4 檔案系統,指令如下:

mkfs.ext4 -O ^metadata_csum,^64bit /dev/loop2 (linux 分割區)

詳細說明可以參考底下網頁:

https://archlinuxarm.org/forum/viewtopic.php?f=53&t=12572

=====
version -> 檢視 u-boot 版本

由於我們啟動 qemu 有載入 -nographic 參數,因此請執行 Ctrl-a + x 來退出 u-boot。
=> version

U-Boot 2016.09 (Nov 14 2016 - 10:39:46 +0800)
arm-linux-gnueabihf-gcc ( 4.9.2-10) 4.9.2
GNU ld (GNU Binutils for Debian) 2.25

2014年12月15日 星期一

uboot 常用指令介紹

U-Boot 是嵌入式系統上最常見的 Boot Loader,底下說明其常用指令:

U-Boot# help -> 列出可使用指令

U-Boot# version -> 觀看目前所使用 U-Boot 版本

U-Boot 2014.07 (Oct 14 2014 - 11:45:06)
arm-linux-gnueabi-gcc (Debian 4.4.5-8) 4.4.5
GNU ld (GNU Binutils for Debian) 2.20.1.20100303


U-Boot# bdinfo  -> 觀看嵌入式電路板資訊
arch_number = 0x0000060A
boot_params = 0x80000100
DRAM bank   = 0x00000000
-> start    = 0x80000000
-> size     = 0x08000000
DRAM bank   = 0x00000001
-> start    = 0x88000000
-> size     = 0x08000000
eth0name    = usb_ether
ethaddr     = (not set)
current eth = usb_ether
ip_addr     = <NULL>
baudrate    = 115200 bps
TLB addr    = 0x8FFF0000
relocaddr   = 0x8FF4C000
reloc off   = 0x0FE4C000
irq_sp      = 0x8EF2BEE0
sp start    = 0x8EF2BED0

U-Boot# mmc list        -> 列出目前板子上面的 sdcard
OMAP SD/MMC: 0

U-Boot# mmcinfo         -> 顯示(SD)記憶卡資訊,亦可以打成 mmc info
Device: OMAP SD/MMC
Manufacturer ID: aa
OEM: 5859
Name: QEMU!
Tran Speed: 25000000
Rd Block Len: 512
SD version 1.0
High Capacity: No
Capacity: 1 GiB
Bus Width: 4-bit

U-Boot# mmc part        -> 觀看 MMC 上的分割區

Partition Map for MMC device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     2048            163840          8a5a18c6-01     0b Boot
  2     165888          1931264         8a5a18c6-02     83

 U-Boot# ls              -> 可觀看目錄裡的檔案,底下介紹用法
ls - list files in a directory (default /)

Usage:
ls <interface> [<dev[:part]> [directory]]
    - List files in directory 'directory' of partition 'part' on
      device type 'interface' instance 'dev'.

U-Boot# ls mmc 0:1      -> 觀看第 0 個 MMC,第 1 個分割區之內容
  2404728   uimage
    51100   mlo
  1853076   u-boot
   392152   u-boot.bin
   392216   u-boot.img

5 file(s), 0 dir(s)

U-Boot# ls mmc 0:2      -> 觀看第 0 個 MMC,第 2 個分割區 (rootfs) 之內容


U-Boot# fatinfo         -> 觀看 FAT 檔案系統資訊
usage: fatinfo <interface> [<dev[:part]>]

U-Boot# fatinfo mmc 0:1 -> 觀看第 0 個 MMC,第 1 個分割區之資訊
Interface:  MMC
  Device 0: Vendor: Man 0000aa Snr adbeef00 Rev: 13.14 Prod: QEMU!
            Type: Removable Hard Disk
            Capacity: 1024.0 MB = 1.0 GB (2097152 x 512)
Filesystem: FAT16 "           "

U-Boot# fatinfo mmc 0:2 -> 觀看第 0 個 MMC,第 2 個分割區,因此分割區為 ext3,故
無資料顯示。

** Unable to use mmc 0:2 for fatinfo **

U-Boot# fatls mmc 0:1   -> 觀看第 0 個 MMC,第 1 個分割區之內容
  2404728   uimage
    51100   mlo
  1853076   u-boot
   392152   u-boot.bin
   392216   u-boot.img

5 file(s), 0 dir(s)
 U-Boot# ext2ls mmc 0:2  -> 觀看第 0 個 MMC,第 2 個分割區(ext3)之內容


** 所有 ls 指令如 fatls、ext2ls .. 等均可以直接用 ls 指令來代替,語法一樣 **

U-Boot# reset
resetting ...

U-Boot# usb             -> USB 操作相關指令
usb - USB sub-system

Usage:
usb start - start (scan) USB controller
usb reset - reset (rescan) USB controller
usb stop [f] - stop USB [f]=force stop
usb tree - show USB device tree
usb info [dev] - show available USB devices
usb test [dev] [port] [mode] - set USB 2.0 test mode
    (specify port 0 to indicate the device's upstream port)
    Available modes: J, K, S[E0_NAK], P[acket], F[orce_Enable]
usb storage - show details of USB storage devices
usb dev [dev] - show or set current USB storage device
usb part [dev] - print partition table of one or all USB storage    devices
usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'
    to memory address `addr'
usb write addr blk# cnt - write `cnt' blocks starting at block `blk#'
    from memory address `addr'

U-Boot# usb info        -> 觀看 USB 資訊,不過因為還沒啟動,所以沒資訊
USB is stopped. Please issue 'usb start' first.

U-Boot# usb start       -> 啟動 USB 裝置
(Re)start USB...
USB0:   USB EHCI 0.00
scanning bus 0 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
       scanning usb for ethernet devices... 0 Ethernet Device(s) found

此時再執行 usb info 可以看到 USB 裝置
U-Boot# usb info
1: Hub,  USB Revision 2.0
 - u-boot EHCI Host Controller
 - Class: Hub
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x0000  Product 0x0000 Version 1.0
   Configuration: 1
   - Interfaces: 1 Self Powered 0mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 1
     - Class Hub
     - Endpoint 1 In Interrupt MaxPacket 8 Interval 255ms

U-Boot# printenv        -> 列出開機環境設定,請全部複製下來修改
arch=arm
baudrate=115200
beaglerev=C4
board=beagle
board_name=beagle
bootargs=console=ttyO2,115200n8 mpurate=auto buddy=none camera=none vram=12M omapfb.mode=dvi:640x480MR-16@60 omapdss.def_disp=dvi root=ubi0:rootfs ubi.mtd=4 rootfstype=ubifs
bootcmd=run findfdt; mmc dev ${mmcdev}; if mmc rescan; then if run userbutton; then setenv bootenv uEnv.txt;else setenv bootenv user.txt;fi;echo SD/MMC found on device ${mmcdev};if run loadbootenv; then echo Loaded environment from ${bootenv};run importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run uenvcmd;fi;if run loadimage; then run mmcboot;fi;fi;run nandboot;setenv bootfile zImage;if run loadimage; then run loadfdt;run mmcbootz; fi;
bootdelay=1
bootdir=/boot
bootenv=uEnv.txt
bootfile=zImage
bootpart=0:2
buddy=none
camera=none
console=ttyO2,115200n8
cpu=armv7
defaultdisplay=dvi
dieid#=51454d5551454d555400000051454d55
dvimode=640x480MR-16@60
ethact=usb_ether
fdt_high=0xffffffff
fdtaddr=0x80f80000
fdtfile=omap3-beagle.dtb
findfdt=if test $beaglerev = AxBx; then setenv fdtfile omap3-beagle.dtb; fi; if test $beaglerev = Cx; then setenv fdtfile omap3-beagle.dtb; fi; if test $beaglerev = C4; then setenv fdtfile omap3-beagle.dtb; fi; if test $beaglerev = xMAB; then setenv fdtfile omap3-beagle-xm-ab.dtb; fi; if test $beaglerev = xMC; then setenv fdtfile omap3-beagle-xm.dtb; fi; if test $fdtfile = undefined; then echo WARNING: Could not determine device tree to use; fi;
importbootenv=echo Importing environment from mmc ...; env import -t $loadaddr $filesize
loadaddr=0x80200000
loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenv}
loadfdt=run validatefdt; load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}
loadimage=load mmc ${bootpart} ${loadaddr} ${bootdir}/${bootfile}
loadramdisk=load mmc ${bootpart} ${rdaddr} ${bootdir}/${ramdisk}
mmcargs=setenv bootargs console=${console} ${optargs} mpurate=${mpurate} buddy=${buddy} camera=${camera} vram=${vram} omapfb.mode=dvi:${dvimode} omapdss.def_disp=${defaultdisplay} root=${mmcroot} rootfstype=${mmcrootfstype}
mmcboot=echo Booting from mmc ...; run mmcargs; bootm ${loadaddr}
mmcbootz=echo Booting with DT from mmc${mmcdev} ...; run mmcargs; bootz ${loadaddr} - ${fdtaddr}
mmcdev=0
mmcroot=/dev/mmcblk0p2 rw
mmcrootfstype=ext3 rootwait
mpurate=auto
nandargs=setenv bootargs console=${console} ${optargs} mpurate=${mpurate} buddy=${buddy} camera=${camera} vram=${vram} omapfb.mode=dvi:${dvimode} omapdss.def_disp=${defaultdisplay} root=${nandroot} rootfstype=${nandrootfstype}
nandboot=echo Booting from nand ...; run nandargs; nand read ${loadaddr} 280000 400000; bootm ${loadaddr}
nandroot=ubi0:rootfs ubi.mtd=4
nandrootfstype=ubifs
ramargs=setenv bootargs console=${console} ${optargs} mpurate=${mpurate} buddy=${buddy} vram=${vram} omapfb.mode=dvi:${dvimode} omapdss.def_disp=${defaultdisplay} root=${ramroot} rootfstype=${ramrootfstype}
ramboot=echo Booting from ramdisk ...; run ramargs; bootm ${loadaddr}
ramdisk=ramdisk.gz
ramroot=/dev/ram0 rw ramdisk_size=65536 initrd=0x81000000,64M
ramrootfstype=ext2
rdaddr=0x81000000
soc=omap3
stderr=serial
stdin=serial
stdout=serial
usbtty=cdc_acm
userbutton=if gpio input 173; then run userbutton_xm; else run userbutton_nonxm; fi;
userbutton_nonxm=gpio input 7;
userbutton_xm=gpio input 4;
validatefdt=if test $beaglerev = xMAB; then if test ! -e mmc ${bootpart} ${bootdir}/${fdtfile}; then setenv fdtfile omap3-beagle-xm.dtb; fi; fi;
vendor=ti
ver=U-Boot 2014.07 (Oct 14 2014 - 11:45:06)
vram=12M

Environment size: 3604/131068 bytes

2013年12月9日 星期一

uboot 命令列操作簡介

%http://blog.csdn.net/ghostyu/article/details/6968681
%http://www.denx.de/wiki/view/DULG/Manual

目的:了解 uboot 的命令列操作方式

uboot 是一套廣泛使用在嵌入式系統上之 bootloader,要順利的使用 uboot,必須對其命令列操作方式有所了解,如此一來當 uboot 在開機時發生錯誤的話,才能夠自己一一針對故障進行排除。底下我們將針對 uboot 的指令作概略的說明:

help -> 呼叫可使用之指令,如底下所示:

?       - alias for 'help'
askenv  - get environment variables from stdin
base    - print or set address offset
bdinfo  - print Board Info structure
boot    - boot default, i.e., run 'bootcmd'
bootd   - boot default, i.e., run 'bootcmd'
bootm   - boot application image from memory
bootp   - boot image via network using BOOTP/TFTP protocol
bootz   - boot Linux zImage image from memory
chpart  - change active partition
cmp     - memory compare
coninfo - print console devices and information
cp      - memory copy
crc32   - checksum calculation
dcache  - enable or disable data cache
dhcp    - boot image via network using DHCP/TFTP protocol
echo    - echo args to console
editenv - edit environment variable
env     - environment handling commands
exit    - exit script
ext2load- load binary file from a Ext2 filesystem
ext2ls  - list files in a directory (default /)
false   - do nothing, unsuccessfully
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls   - list files in a directory (default /)
fdt     - flattened device tree utility commands
go      - start application at address 'addr'
gpio    - input/set/clear/toggle gpio pins
help    - print command description/usage
i2c     - I2C sub-system
icache  - enable or disable instruction cache
imxtract- extract a part of a multi-image
itest   - return true/false on integer compare
led     - [0|1|green|all] [on|off|toggle]
load    - load binary file from a filesystem
loadb   - load binary file over serial line (kermit mode)
loads   - load S-Record file over serial line
loadx   - load binary file over serial line (xmodem mode)
loady   - load binary file over serial line (ymodem mode)
loop    - infinite loop on address range
ls      - list files in a directory (default /)
md      - memory display
mm      - memory modify (auto-incrementing address)
mmc     - MMC sub system
mmcinfo - display MMC info
mtdparts- define flash/nand partitions
mw      - memory write (fill)
nand    - NAND sub-system
nandecc - switch OMAP3 NAND ECC calculation algorithm
nboot   - boot from NAND device
nfs     - boot image via network using NFS protocol
nm      - memory modify (constant address)
ping    - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
saveenv - save environment variables to persistent storage
setenv  - set environment variables
setexpr - set environment variable as the result of eval expression
showvar - print local hushshell variables
sleep   - delay execution for some time
source  - run script from memory
test    - minimal test like /bin/sh
tftpboot- boot image via network using TFTP protocol
true    - do nothing, successfully
usb     - USB sub-system
usbboot - boot from USB device
version - print monitor, compiler and linker version

version(v) -> 顯示目前 u-boot 版本,如底下所示:

U-Boot 2013.10 (Nov 15 2013 - 09:58:56)
arm-linux-gnueabi-gcc (Debian 4.4.6-14) 4.4.6
GNU ld (GNU Binutils for Debian) 2.22

usb start -> 啟動 usb 功能,其畫面如下所示:

(Re)start USB...
USB0:   ULPI: ulpi_reset: failed writing reset bit
ULPI: ulpi_reset: failed writing reset bit
USB EHCI 0.00
scanning bus 0 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
       scanning usb for ethernet devices... 0 Ethernet Device(s) found

usb info -> 觀看 usb 資訊,如底下所示:

1: Hub,  USB Revision 2.0
 - u-boot EHCI Host Controller
 - Class: Hub
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x0000  Product 0x0000 Version 1.0
   Configuration: 1
   - Interfaces: 1 Self Powered 0mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 1
     - Class Hub
     - Endpoint 1 In Interrupt MaxPacket 8 Interval 255ms


bdinfo -> 顯示目前板子資訊,如底下所示:

arch_number = 0x0000060A
boot_params = 0x80000100
DRAM bank   = 0x00000000
-> start    = 0x80000000
-> size     = 0x08000000
DRAM bank   = 0x00000001
-> start    = 0x88000000
-> size     = 0x08000000
eth0name    = usb_ether
ethaddr     = (not set)
current eth = usb_ether
ip_addr     = <NULL>
baudrate    = 115200 bps
TLB addr    = 0x8FFF0000
relocaddr   = 0x8FF59000
reloc off   = 0x0FE59000
irq_sp      = 0x8FEF8F30
sp start    = 0x8FEF8F20


mmcinfo -> 顯示目前記憶卡資訊,如底下所示:

Device: OMAP SD/MMC
Manufacturer ID: aa
OEM: 5859
Name: QEMU!
Tran Speed: 25000000
Rd Block Len: 512
SD version 1.0
High Capacity: No
Capacity: 1 GiB
Bus Width: 4-bit

mmc -> 顯示記憶卡之相關操作指令,如下所示:

Usage:
mmc read addr blk# cnt
mmc write addr blk# cnt
mmc erase blk# cnt
mmc rescan
mmc part - lists available partition on current mmc device
mmc dev [dev] [part] - show or set current mmc device [partition]
mmc list - lists available devices


mmclist -> 顯示目前的記憶卡,如底下所示:

OMAP SD/MMC: 0

mmc rescan -> 重新掃瞄目前板子上有幾張記憶卡

mmc part -> 顯示目前記憶卡上之分割區,如底下所示:

Partition Map for MMC device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     2048            163840          bafb41f7-01     0b Boot
  2     165888          1931264         bafb41f7-02     83


此資訊可搭配之前分割之 sdcard.img 來比較,如下所示:

      Device Boot      Start         End      Blocks   Id  System
/dev/loop0p1   *        2048      165887       81920    b  W95 FAT32
/dev/loop0p2          165888     2097151      965632   83  Linux



fatinfo -> 觀看 FAT filesystem 資訊,其語法如下:

fatinfo <interface> [<dev[:part]>]

其中的 interface 是指儲存介面,而 dev:part 則是指其裝置及分割區編號


我們可以執行底下指令來觀看 sdcard.img 的 #1 分割區:

fatinfo mmc 0:1

其輸出如下:

Interface:  MMC
  Device 0: Vendor: Man 0000aa Snr adbeef00 Rev: 13.14 Prod: QEMU!
            Type: Removable Hard Disk
            Capacity: 1024.0 MB = 1.0 GB (2097152 x 512)
Filesystem: FAT16 "           "

fatls -> 列出 FAT 分割區之內容,其語法如下:

fatls <interface> [<dev[:part]>] [directory]

因此我們可以執行底下指令來觀看 FAT 檔案系統中之檔案:

fatls mmc 0:1

其輸出如下所示:

  2539176   uimage
    47164   mlo
  1622640   u-boot
   346280   u-boot.img
   346216   u-boot.bin
  2539112   zimage

6 file(s), 0 dir(s)

fatloat -> 載入 FAT 檔案系統中之檔案,其語法如下:

fatload <interface> [<dev[:part]>]  <addr> <filename> [bytes [pos]]

現在,我們要將編好的 Linux 核心載入至 ARM 的初始記憶體位置,也就是

0x80000000,我們應該要下底下指令:

fatload mmc 0:1 0x80000000 uImage

其輸出如下所示:

reading uImage
2539176 bytes read in 325 ms (7.5 MiB/s)

這個訊息告訴我們,uboot 已載入 Linux 核心,其檔名為 uImage,根據我們所下的
指令,這個核心被載入至 0x80000000 的位置。

bootm -> 從某個記憶體位置開機,以我們的例子來說,其開機位置為 0x80000000。

因此我們可以下底下指令來開機:

bootm 0x80000000