X210开发板(S5PV210芯片)uboot中SD卡分区分析(init_raw_area_table函数)
Posted 正在起飞的蜗牛
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了X210开发板(S5PV210芯片)uboot中SD卡分区分析(init_raw_area_table函数)相关的知识,希望对你有一定的参考价值。
1、init_raw_area_table函数调用关系
start.s
start_armboot()
mmc_initialize()
mmc_init()
mmc_startup()
init_raw_area_table()
2、struct raw_area结构体 & struct member结构体
//这个结构体包含所有分区的信息
typedef struct raw_area
uint magic_number; /* to identify itself */
uint start_blk; /* compare with PT on coherency test */
uint total_blk;
uint next_raw_area; /* should be sector number */
char description[16];
member_t image[15]; //具体每个分区的描述信息
raw_area_t; /* 512 bytes */
//描述单个分区信息
typedef struct member
uint start_blk; //分区开始扇区号
uint used_blk; //分区总共的扇区数
uint size; //分区大小
uint attribute; //表示分区的用途:
char description[16]; //用字符串的方式表示分区用途
member_t; /* 32 bytes */
3、init_raw_area_table()函数功能分析
(1)主要是就是初始化全局变量raw_area_control的image成员变量,image数组里记录了每个分区的起始扇区、大小等信息;
(2)初始化image数组的宏定义在./include/movi.h中定义;
(3)uboot在读写分区时,就是按照iamge中描述的分区信息(扇区号、大小)进行操作;
4、init_raw_area_table()函数代码
//cmd_movi.c
raw_area_t raw_area_control;
int init_raw_area_table (block_dev_desc_t * dev_desc)
struct mmc *host = find_mmc_device(dev_desc->dev);
/* when last block does not have raw_area definition. */
if (raw_area_control.magic_number != MAGIC_NUMBER_MOVI)
int i = 0;
member_t *image;
u32 capacity;
if (host->high_capacity)
capacity = host->capacity;
else
capacity = host->capacity;
dev_desc->block_read(dev_desc->dev,
capacity - (eFUSE_SIZE/MOVI_BLKSIZE) - 1,
1, &raw_area_control);
if (raw_area_control.magic_number == MAGIC_NUMBER_MOVI)
return 0;
dbg("Warning: cannot find the raw area table(%p) %08x\\n",
&raw_area_control, raw_area_control.magic_number);
/* add magic number */
raw_area_control.magic_number = MAGIC_NUMBER_MOVI;
/* init raw_area will be 16MB */
raw_area_control.start_blk = 16*1024*1024/MOVI_BLKSIZE;
raw_area_control.total_blk = capacity;
raw_area_control.next_raw_area = 0;
strcpy(raw_area_control.description, "initial raw table");
/*开始初始化各个分区信息保存到raw_area_control.image数组*/
image = raw_area_control.image;
/* image 1 should be bl1 */
image[1].start_blk = (eFUSE_SIZE/MOVI_BLKSIZE);
image[1].used_blk = MOVI_BL1_BLKCNT;
image[1].size = SS_SIZE;
image[1].attribute = 0x1;
strcpy(image[1].description, "u-boot parted");
dbg("bl1: %d\\n", image[1].start_blk);
/* image 2 should be environment */
image[2].start_blk = image[1].start_blk + MOVI_BL1_BLKCNT;
image[2].used_blk = MOVI_ENV_BLKCNT;
image[2].size = CFG_ENV_SIZE;
image[2].attribute = 0x10;
strcpy(image[2].description, "environment");
dbg("env: %d\\n", image[2].start_blk);
/* image 3 should be bl2 */
image[3].start_blk = image[2].start_blk + MOVI_ENV_BLKCNT;
image[3].start_blk = image[2].start_blk - MOVI_BL2_BLKCNT;
image[3].used_blk = MOVI_BL2_BLKCNT;
image[3].size = PART_SIZE_BL;
image[3].attribute = 0x2;
strcpy(image[3].description, "u-boot");
dbg("bl2: %d\\n", image[3].start_blk);
/* image 4 should be kernel */
image[4].start_blk = image[3].start_blk + MOVI_BL2_BLKCNT;
image[4].used_blk = MOVI_ZIMAGE_BLKCNT;
image[4].size = PART_SIZE_KERNEL;
image[4].attribute = 0x4;
strcpy(image[4].description, "kernel");
dbg("knl: %d\\n", image[4].start_blk);
/* image 5 should be RFS */
image[5].start_blk = image[4].start_blk + MOVI_ZIMAGE_BLKCNT;
image[5].used_blk = MOVI_ROOTFS_BLKCNT;
image[5].size = PART_SIZE_ROOTFS;
image[5].attribute = 0x8;
strcpy(image[5].description, "rfs");
dbg("rfs: %d\\n", image[5].start_blk);
/*没用到的全部初始化为0*/
for (i=6; i<15; i++)
raw_area_control.image[i].start_blk = 0;
raw_area_control.image[i].used_blk = 0;
5、SD卡/iNand的分区情况
iamge数组 | 扇区号 | 分区名 | 大小 | 分区名 |
---|---|---|---|---|
0 | 0 | MBR | 512B | 引导扇区 |
1 | 1-16 | BL1 | 8KB | u-boot parted(BL1) |
2 | 17-48 | environment | 16KB | environment |
3 | 49-1072 | BL2 | 512KB | u-boot(BL2,完整的uboot) |
4 | 1073-9264 | kernel | 4MB | kernel |
5 | 9265-62512 | rootfs | 26MB | rfs |
6-14 | 62512-100% | 未分配 | 剩余全部 | 未分配 |
以上是关于X210开发板(S5PV210芯片)uboot中SD卡分区分析(init_raw_area_table函数)的主要内容,如果未能解决你的问题,请参考以下文章