开发环境:
Ubuntu16.04 + arm-linux-gnueabihf-gcc(4.7.3)
核心板:AM335X-A8
内核版本: Linux version 3.2.0
原先使用的是1G Nand Flash,后来发现有很多剩余,于是就砍成了512M。所以得改uboot改内核。
上家公司使用的是海思SDK,海思SDK做的非常好,只需要配置一下uboot的启动参数即可,如(setenv bootargs8 'mem=260M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=squashfs mtdparts=hi_sfc:512K(boot),3584K(kernel),3584K(rootfs),
19520K(app)';)。但是TI的不行,没对比就没伤害,好了言归正传,下面说说具体如何配置。
原有分区:
root@iBRK:~# cat /proc/mtd
dev: size erasesize name
mtd0: 00020000 00020000 "SPL"
mtd1: 00200000 00020000 "U-Boot"
mtd2: 00020000 00020000 "U-Boot Env"
mtd3: 00500000 00020000 "Kernel"
mtd4: 08000000 00020000 "File System"
mtd5: 10000000 00020000 "UsrLocal"
mtd6: 078c0000 00020000 "WorkData"
在已有的基础上增加一个4M的para分区用于保存APP参数。
一、修改uboot环境参数 TI的环境变量和常用参数配置的文件位于uboot/include/configs/am335x_evm.h
1.修改DFU_ALT_INFO_NAND宏,增加新的分区
-
#if 0
-
#define DFU_ALT_INFO_NAND \
-
"SPL part 0 1;" \
-
"u-boot part 0 2;" \
-
"kernel part 0 4;" \
-
"rootfs part 0 5;" \
-
"local part 0 6;" \
-
"data part 0 7"
-
#else
-
#define DFU_ALT_INFO_NAND \
-
"SPL part 0 1;" \
-
"u-boot part 0 2;" \
-
"kernel part 0 4;" \
-
"rootfs part 0 5;" \
-
"local part 0 6;" \
-
"data part 0 7;" \
-
"para part 0 8" /* 新增 */
-
#endif
2.修改MTDPARTS_DEFAULT宏,定义分区大小,其中下面最后的-表示使用剩余容量
-
#if 0
-
#define MTDPARTS_DEFAULT "mtdparts=omap2-nand.0:128k(SPL)," \
-
"2m(u-boot)," \
-
"128k(u-boot-env),5m(kernel),128m(rootfs)," \
-
"256m(local),-(data)"
-
#else
-
#define MTDPARTS_DEFAULT "mtdparts=omap2-nand.0:128k(SPL)," \
-
"2m(u-boot)," \
-
"128k(u-boot-env),5m(kernel),128m(rootfs)," \
-
"256m(local),,116(data),-(para),"
-
#endif
二、修改kernel配置项
内核的分区配置信息位于
kernel/arch/arm,TI平台的AM335X相关配置位于kernel/arch/arm/mach-omap2/文件夹,找到对应板子使用的文件,如我这边使用的是board-am335x_wld.c,修改分区结构体am335x_nand_partition
-
-
/* NAND partition information */
-
static struct mtd_partition am335x_nand_partitions[] = {
-
/* All the partition sizes are listed in terms of NAND block size */
-
{
-
.name = "SPL",
-
.offset = 0, /* Offset = 0x0 */
-
.size = SZ_128K, /* size = 128K */
-
},
-
{
-
.name = "U-Boot",
-
.offset = MTDPART_OFS_APPEND, /* offset = 0x20000 */
-
.size = 16*SZ_128K, /* size = 2M */
-
},
-
{
-
.name = "U-Boot Env",
-
.offset = MTDPART_OFS_APPEND, /* offset = 0x220000 */
-
.size = SZ_128K, /* size = 128K */
-
},
-
{
-
.name = "Kernel",
-
.offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */
-
.size = 40 * SZ_128K, /* size = 5M */
-
},
-
{
-
.name = "File System",
-
.offset = MTDPART_OFS_APPEND, /* Offset = 0x740000 */
-
.size = SZ_128M, /* size = 128M */
-
},
-
{
-
.name = "UsrLocal",
-
.offset = MTDPART_OFS_APPEND, /* Offset = 0x8740000 */
-
.size = SZ_256M, /* size = 256M */
-
},
-
{
-
.name = "WorkData",
-
.offset = MTDPART_OFS_APPEND, /* Offset = 0x18740000 */
-
.size = SZ_4M * 29, /* size = 116M */
-
},
-
{
-
.name = "para", /* 新增 */
-
.offset = MTDPART_OFS_APPEND, /* Offset = 0x1FC0 0000 */
-
.size = MTDPART_SIZ_FULL, /* size = 4M */
-
},
-
-
};
然后重编uboot和kernel,烧录进去即可。
启动后再查看分区情况:
root@iBRK:~# cat /proc/mtd
dev: size erasesize name
mtd0: 00020000 00020000 "SPL"
mtd1: 00200000 00020000 "U-Boot"
mtd2: 00020000 00020000 "U-Boot Env"
mtd3: 00500000 00020000 "Kernel"
mtd4: 08000000 00020000 "File System"
mtd5: 10000000 00020000 "UsrLocal"
mtd6: 07400000 00020000 "WorkData"
mtd7: 004c0000 00020000 "para"
阅读(3789) | 评论(0) | 转发(0) |