1. 程式人生 > >u-boot中nand相關命令使用---- ubi, ubifsls, ubifsmount, ubifsumount

u-boot中nand相關命令使用---- ubi, ubifsls, ubifsmount, ubifsumount

轉載地址:https://blog.csdn.net/voice_shen/article/details/8425763

 [Version: 2013-01-rc2]

[Author: Bo Shen <[email protected]>]

1.  幫助資訊

1.1 ubi

-------------------------------------

U-Boot> ubi
ubi - ubi commands

Usage:
ubi part [part] [offset]
- Show or set current partition (with optional VID header offset)
ubi info [l[ayout]] - Display volume and ubi layout information
ubi create[vol] volume [size] [type] - create volume name with size
ubi write[vol] address volume size - Write volume from address with size
ubi read[vol] address volume [size] - Read volume to address with size
ubi remove[vol] volume - Remove volume
[Legends]
volume: character name
size: specified in bytes
type: s[tatic] or d[ynamic] (default=dynamic)

-------------------------------------

1.2 ubifsls

------------------------------------

U-Boot> ubifsls 
UBIFS not mounted, use ubifsmount to mount volume first!
ubifsls - list files in a directory

Usage:
ubifsls [directory]
- list files in a 'directory' (default '/')

------------------------------------

1.3 ubifsmout

------------------------------------

U-Boot> ubifsmount 
ubifsmount - mount UBIFS volume

Usage:
ubifsmount <volume-name>
- mount 'volume-name' volume

------------------------------------

1.4 ubifsumount

------------------------------------

U-Boot> ubifsumount 
No UBIFS volume mounted!
ubifsumount - unmount UBIFS volume

Usage:
ubifsumount - unmount current volume

------------------------------------

2. 具體使用方法

如果board配置檔案中有設定mtdids和mtdparts,則可以直接用mtdparts檢視,如果沒有,可以通過設定環境變數來使能。

U-Boot> setenv mtdids 'nand0=atmel_nand'

U-Boot> setenv mtdparts 'mtdparts=atmel_nand:8M(bootstrap)ro,-(rootfs)'

U-Boot> mtdparts

---------------------------------------------------------------

device nand0 <atmel_nand>, # parts = 2
#: name size offset mask_flags
0: bootstrap/uboot/kernel0x00800000 0x00000000 1
1: rootfs 0x0f800000 0x00800000 0

active partition: nand0,0 - (bootstrap/uboot/kernel) 0x00800000 @ 0x00000000

defaults:
mtdids : nand0=atmel_nand
mtdparts: mtdparts=atmel_nand:8M(bootstrap/uboot/kernel)ro,-(rootfs)

---------------------------------------------------------------

U-Boot> ubi part rootfs

---------------------------------------------------------------

U-Boot> ubi part rootfs
Creating 1 MTD partitions on "nand0":
0x000000800000-0x000010000000 : "mtd=1"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size: 131072 bytes (128 KiB)
UBI: logical eraseblock size: 126976 bytes
UBI: smallest flash I/O unit: 2048
UBI: VID header offset: 2048 (aligned 2048)
UBI: data offset: 4096
UBI: empty MTD device detected
UBI: create volume table (copy #1)
UBI: create volume table (copy #2)
UBI: attached mtd1 to ubi0
UBI: MTD device name: "mtd=1"
UBI: MTD device size: 248 MiB
UBI: number of good PEBs: 1984
UBI: number of bad PEBs: 0
UBI: max. allowed volumes: 128
UBI: wear-leveling threshold: 4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 0
UBI: available PEBs: 1961
UBI: total number of reserved PEBs: 23
UBI: number of PEBs reserved for bad PEB handling: 19
UBI: max/mean erase counter: 1/0

---------------------------------------------------------------

U-Boot> ubi create rootfs

---------------------------------------------------------------

U-Boot> ubi create rootfs
No size specified -> Using max size (248999936)
Creating dynamic volume rootfs of size 248999936

---------------------------------------------------------------

U-Boot> tftpboot 0x20000000 rootfs.ubi

U-Boot> ubi write 0x20000000 rootfs 0x1911000

---------------------------------------------------------------

U-Boot> ubi write 0x20000000 rootfs 0x1911000
26284032 bytes written to volume rootfs

---------------------------------------------------------------

U-Boot> ubifsmount rootfs

---------------------------------------------------------------

U-Boot> ubifsmount rootfs
UBIFS: mounted UBI device 0, volume 0, name "rootfs"
UBIFS: mounted read-only
UBIFS: file system size: 247603200 bytes (241800 KiB, 236 MiB, 1950 LEBs)
UBIFS: journal size: 9023488 bytes (8812 KiB, 8 MiB, 72 LEBs)
UBIFS: media format: w4/r0 (latest is w4/r0)
UBIFS: default compressor: LZO
UBIFS: reserved for root: 0 bytes (0 KiB)

---------------------------------------------------------------

U-Boot> ubifsls

---------------------------------------------------------------

U-Boot> ubifsls
<DIR> 5368 Mon Dec 24 08:18:48 2012 bin
<DIR> 288 Mon Oct 29 07:56:14 2012 dev
<DIR> 2128 Mon Dec 24 08:18:47 2012 etc
<DIR> 2408 Mon Dec 24 08:18:47 2012 lib
<DIR> 160 Tue Dec 18 03:07:01 2012 mnt
<DIR> 160 Tue Dec 18 03:07:01 2012 opt
<LNK> 3 Tue Nov 27 02:10:35 2012 run
<DIR> 304 Tue Dec 18 03:30:12 2012 tmp
<DIR> 160 Tue Dec 18 03:07:01 2012 sys
<DIR> 672 Mon Oct 29 07:56:14 2012 var
<DIR> 480 Wed Dec 19 01:41:33 2012 usr
<DIR> 288 Tue Dec 18 03:30:26 2012 home
<DIR> 160 Tue Dec 18 03:07:01 2012 proc
<DIR> 3720 Mon Dec 24 08:18:48 2012 sbin
<DIR> 376 Tue Dec 18 03:07:01 2012 root
<LNK> 11 Tue Dec 18 03:15:34 2012 linuxrc
<DIR> 160 Tue Dec 18 03:07:01 2012 media

---------------------------------------------------------------

U-Boot> ubifsumount

---------------------------------------------------------------

U-Boot> ubifsumount
Unmounting UBIFS volume rootfs!

3. FAQ

3.1 如何從ubifs image中讀取Linux kernel然後boot呢?

      --> ubi part rootfs; ubifsmount rootfs; ubifsload 0x20000000 boot/uImage; bootm 0x20000000;

      如何確保每一步都正常執行呢? (將;全部改為&&除最後一個)

      --> ubi part rootfs && ubifsmount rootfs && ubifsload 0x20000000 boot/uImage && bootm 0x20000000;


--------------------- 
作者:voice_shen 
來源:CSDN 
原文:https://blog.csdn.net/voice_shen/article/details/8425763 
版權宣告:本文為博主原創文章,轉載請附上博文連結!