让uboot 支持 ubi

 

转载地址:http://blog.chinaunix.net/uid-15706699-id-2670964.html

uboot已经支持ubi,只要在.h文件中打开宏定义就可以了,修改如下:

 

//新增加对ubifs的支持

#define CONFIG_MTD_DEVICE          1

#define CONFIG_MTD_PARTITIONS        1

#define CONFIG_CMD_MTDPARTS         

#define CONFIG_CMD_UBIFS           

#define CONFIG_CMD_UBI         

#define CONFIG_LZO                    1

#define CONFIG_RBTREE                    1

 

#define MTDIDS_DEFAULT                  "nand0=nandflash0"

 

#define MTDPARTS_DEFAULT            "mtdparts=nandflash0:512k@0(xload)," \

  "1920k(uboot)," \

                                   "128k(params)," \

                                   "5m(kernel)," \

                                   "-(root)"

 

 

需要注意的是增加UBI的支持之后uboot会增大100多KB,在NAND中启动,有可能需要修改

//copy U-Boot to RAM

ldr r0, =TEXT_BASE  //传递给C代码的第一个参数:u-boot在RAM中的起始地址

mov r1, #0x0         //传递给C代码的第二个参数:Nand Flash的起始地址

mov r2, #0x50000    //传递给C代码的第三个参数:u-boot的长度大小(320KB)

bl nand_read_ll    //此处调用C代码中读Nand的函数,现在还没有要自己编写实现

 

如果uboot传给nand_read_ll 的uboot的参数小于uboot的长度的话,uboot跑不起来,移植的时候被这个问题搞得很郁闷。

另外还有一个地方就是编译的时要求CONFIG_SYS_MALLOC_LEN大于等于512KB,下面两个没有要求我也给改了。

#define CONFIG_SYS_MALLOC_LEN             (CONFIG_ENV_SIZE+  512*1024)

如果没改的话会报错。

这个时候就可以make 了,如果顺利的话会编译出uboot-bin在根目录下。

到这里uboot的UBI移植完成了。

 

下载文件系统到flash

 

使用默认的分区对nand进行分区:mtdpart default

1)擦除root分区 nand erase root

2)对root分区进行ubi格式化 ubi part root

 

AM3517_SHAW # ubi part root

Creating 1 MTD partitions on "nand0":

0x000000780000-0x000010000000 : "mtd=4"

UBI: attaching mtd1 to ubi0

UBI: physical eraseblock size:   131072 bytes (128 KiB)

UBI: logical eraseblock size:    129024 bytes

UBI: smallest flash I/O unit:    2048

UBI: sub-page size:              512

UBI: VID header offset:          512 (aligned 512)

UBI: data offset:                2048

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=4"

UBI: MTD device size:            248 MiB

UBI: number of good PEBs:        1984

UBI: number of bad PEBs:         4

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

3)创建rootfs     ubi create rootfs-nand

AM3517_SHAW # ubi create rootfs-nand

Creating dynamic volume rootfs of size 253016064

4)将文件系统下载到内存 tftpboot 0x82000000 ubifs.img

AM3517_SHAW # tftpboot 0x82000000 ubifs.img

Using DaVinci EMAC device

TFTP from server 192.168.1.119; our IP address is 192.168.1.10

Filename 'ubi.img'.

Load address: 0x82000000

Loading: #################################################################

 #################################################################

 #####################

done

Bytes transferred = 18743296 (11e0000 hex)

5)将文件系统烧写到rootfs 

AM3517_SHAW # ubi write 0x82000000 rootfs-nand 0x11e0000 (分区名称与内核保持一致)

Volume "rootfs" found at volume id 0

Cannot start volume update

exit not allowed from main input shell.

 

操作不成功!发现原因为,下面这个宏定义的值不够大,改为1024*1024后,可正常烧写正常!

#define CONFIG_SYS_MALLOC_LEN             (CONFIG_ENV_SIZE+ 1024*1024)

 

到此,uboot关于ubi的修改工作全部完成,下面是启动内核的相关工作了。

setenv bootargs mem=256M console=ttyO2,115200n8 noinitrd ip=off    omap_vout.vid1_static_vrfb_alloc=y rw ubi.mtd=4,512 rootfstype=ubifs root=ubi0:rootfs-nand rootdelay=2 vram=8M omapfb.vram=0:8M

我的板子的启动参数,其中mtd=4,512要注意,是vid head的偏移!

 

注意烧写的文件 一定要对,uboot烧写ubifs.img 而不是ubi.img !!!

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值