Chinaunix首页 | 论坛 | 博客
  • 博客访问: 672923
  • 博文数量: 6
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 95
  • 用 户 组: 普通用户
  • 注册时间: 2019-03-06 14:11
个人简介

我,并不比别人差。

文章分类
文章存档

2021年(1)

2020年(2)

2019年(3)

我的朋友

分类: LINUX

2019-05-21 20:14:56

开发环境:
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宏,增加新的分区

点击(此处)折叠或打开

  1. #if 0
  2. #define DFU_ALT_INFO_NAND \
  3.     "SPL part 0 1;" \
  4.     "u-boot part 0 2;" \
  5.     "kernel part 0 4;" \
  6.     "rootfs part 0 5;" \
  7.     "local part 0 6;" \
  8.     "data part 0 7"
  9. #else
  10. #define DFU_ALT_INFO_NAND \
  11.     "SPL part 0 1;" \
  12.     "u-boot part 0 2;" \
  13.     "kernel part 0 4;" \
  14.     "rootfs part 0 5;" \
  15.     "local part 0 6;" \
  16.     "data part 0 7;" \
  17.     "para part 0 8"    /* 新增 */ 
  18. #endif
2.修改MTDPARTS_DEFAULT宏,定义分区大小,其中下面最后的-表示使用剩余容量

点击(此处)折叠或打开

  1. #if 0
  2. #define MTDPARTS_DEFAULT        "mtdparts=omap2-nand.0:128k(SPL)," \
  3.                     "2m(u-boot)," \
  4.                     "128k(u-boot-env),5m(kernel),128m(rootfs)," \
  5.                     "256m(local),-(data)"
  6. #else
  7. #define MTDPARTS_DEFAULT        "mtdparts=omap2-nand.0:128k(SPL)," \
  8.                     "2m(u-boot)," \
  9.                     "128k(u-boot-env),5m(kernel),128m(rootfs)," \
  10.                     "256m(local),,116(data),-(para),"
  11. #endif
二、修改kernel配置项
内核的分区配置信息位于kernel/arch/arm,TI平台的AM335X相关配置位于kernel/arch/arm/mach-omap2/文件夹,找到对应板子使用的文件,如我这边使用的是board-am335x_wld.c,修改分区结构体am335x_nand_partition

  1. 点击(此处)折叠或打开

    1. /* NAND partition information */
    2. static struct mtd_partition am335x_nand_partitions[] = {
    3. /* All the partition sizes are listed in terms of NAND block size */
    4.     {
    5.                 .name = "SPL",
    6.                 .offset = 0, /* Offset = 0x0 */
    7.                 .size = SZ_128K, /* size = 128K */
    8.         },
    9.         {
    10.                 .name = "U-Boot",
    11.                 .offset = MTDPART_OFS_APPEND, /* offset = 0x20000 */
    12.                 .size = 16*SZ_128K, /* size = 2M */
    13.         },
    14.         {
    15.                 .name = "U-Boot Env",
    16.                 .offset = MTDPART_OFS_APPEND, /* offset = 0x220000 */
    17.                 .size = SZ_128K, /* size = 128K */
    18.         },
    19.         {
    20.                 .name = "Kernel",
    21.                 .offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */
    22.                 .size = 40 * SZ_128K, /* size = 5M */
    23.         },
    24.         {
    25.                 .name = "File System",
    26.                 .offset = MTDPART_OFS_APPEND, /* Offset = 0x740000 */
    27.                 .size = SZ_128M, /* size = 128M */
    28.         },
    29.         {
    30.                 .name = "UsrLocal",
    31.                 .offset = MTDPART_OFS_APPEND, /* Offset = 0x8740000 */
    32.                 .size = SZ_256M, /* size = 256M */
    33.         },
    34.         {
    35.                 .name = "WorkData",
    36.                 .offset = MTDPART_OFS_APPEND, /* Offset = 0x18740000 */
    37.                 .size = SZ_4M * 29, /* size = 116M */
    38.         },
    39.         {
    40.                 .name = "para", /* 新增 */
    41.                 .offset = MTDPART_OFS_APPEND, /* Offset = 0x1FC0 0000 */
    42.                 .size = MTDPART_SIZ_FULL, /* size = 4M */
    43.         },

    44. };


然后重编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"

阅读(3692) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~