全志partition分区

partitions参数

[partition_start]

;------------------------------>mmcblk0p2/nanda
[partition]
    name         = bootloader
    size         = 65536
    downloadfile = "boot-resource.fex"
    user_type    = 0x8000

;------------------------------>mmcblk0p5/nandb
[partition]
    name         = env
    size         = 32768
    downloadfile = "env.fex"
    user_type    = 0x8000

;------------------------------>mmcblk0p6/nandc
[partition]
    name         = boot
    size         = 32768
    downloadfile = "boot.fex"
    user_type    = 0x8000

;------------------------------>mmcblk0p7/nandd
[partition]
    name         = system
    size         = 4194304
    downloadfile = "system.fex"
    user_type    = 0x8000


  • 生成sunxi_mbr.fex 供打包烧录用。
    brandy/pack_tools/create_mbr
    • uboot 中分析sys_partition.fex 第一个partition mmcblk0p2 ,最后一个mmcblk0p1 UDISK
        for(index = 0; index < part_total && index < SUNXI_MBR_MAX_PART_COUNT; index++)
        {
                sunxi_partition_get_name(index, &fb_part.name[0]);
                fb_part.start = sunxi_partition_get_offset(index) * 512;
                fb_part.length = sunxi_partition_get_size(index) * 512;
                fb_part.flags = 0;
                printf("%-12s: %-12x  %-12x\n", fb_part.name, fb_part.start, fb_part.length);

                memset(part_name, 0, 16);
                if(!storage_type)
                {
                        sprintf(part_name, "nand%c", 'a' + index);
                }
                else
                {
                        if(index == 0)
                        {
                                strcpy(part_name, "mmcblk0p2");
                        }
                        else if( (index+1)==part_total)
                        {
                                strcpy(part_name, "mmcblk0p1");
                        }
                        else
                        {
                                sprintf(part_name, "mmcblk0p%d", index + 4);
                        }
                }

cmdline参数

boot_type=2 disp_para=2 fb_base=0x0 config_size=40640 androidboot.serialno=882c9f98b78700000000 \
androidboot.hardware=sun8i console=ttyS0,115200 root=/dev/mmcblk0p7 init=/init ion_cma_list=120m,256m loglevel=6  \
partitions=bootloader@mmcblk0p2:env@mmcblk0p5:boot@mmcblk0p6:system@mmcblk0p7:misc@mmcblk0p8:recovery@mmcblk0p9:cache@mmcblk0p10:metadata@mmcblk0p11:private@mmcblk0p12:frp@mmcblk0p13:empty@mmcblk0p14:alog@mmcblk0p15:media_data@mmcblk0p16:UDISK@mmcblk0p1

kernel检测加载分区

              Device Boot      Start         End      Blocks  Id System
/dev/block/mmcblk0p1   *      397825      483328      684032   b Win95 FAT32
Partition 1 does not end on cylinder boundary
/dev/block/mmcblk0p2            4609        8704       32768   6 FAT16
Partition 2 does not end on cylinder boundary
/dev/block/mmcblk0p3               1      389121     3112960   5 Extended
Partition 3 does not end on cylinder boundary
/dev/block/mmcblk0p5            8705       10752       16384  83 Linux
/dev/block/mmcblk0p6           10753       12800       16384  83 Linux
/dev/block/mmcblk0p7           12801      274944     2097152  83 Linux
/dev/block/mmcblk0p8          274945      276992       16384  83 Linux
/dev/block/mmcblk0p9          276993      281088       32768  83 Linux
/dev/block/mmcblk0p10         281089      379392      786432  83 Linux
/dev/block/mmcblk0p11         379393      381440       16384  83 Linux
/dev/block/mmcblk0p12         381441      383488       16384  83 Linux
/dev/block/mmcblk0p13         383489      383552         512  83 Linux
/dev/block/mmcblk0p14         383553      385536       15872  83 Linux
/dev/block/mmcblk0p15         385537      395776       81920  83 Linux
/dev/block/mmcblk0p16         395777      397824       16384  83 Linux

struct parsed_partitions *
check_partition(struct gendisk *hd, struct block_device *bdev)
{
        struct parsed_partitions *state;
        int i, res, err;

        state = kzalloc(sizeof(struct parsed_partitions), GFP_KERNEL);
        if (!state)
                return NULL;
        state->pp_buf = (char *)__get_free_page(GFP_KERNEL);
        if (!state->pp_buf) {
                kfree(state);
                return NULL;
        }
        state->pp_buf[0] = '\0';

        state->bdev = bdev;
        disk_name(hd, 0, state->name);
        snprintf(state->pp_buf, PAGE_SIZE, " %s:", state->name);
        if (isdigit(state->name[strlen(state->name)-1]))
                sprintf(state->name, "p");

        state->limit = disk_max_parts(hd);
        i = res = err = 0;
        while (!res && check_part[i]) {
                memset(&state->parts, 0, sizeof(state->parts));
                res = check_part[i++](state);
                if (res < 0) {
                        /* We have hit an I/O error which we don't report now.
                        * But record it, and let the others do their job.
                        */
                        err = res;
                        res = 0;
                }

        }
        if (res > 0) {
                printk(KERN_INFO "%s", state->pp_buf);

                free_page((unsigned long)state->pp_buf);
                return state;
        }
        if (state->access_beyond_eod)
                err = -ENOSPC;
        if (err)
        /* The partition is unrecognized. So report I/O errors if there were any */
                res = err;
        if (!res)
                strlcat(state->pp_buf, " unknown partition table\n", PAGE_SIZE);
        else if (warn_no_part)
                strlcat(state->pp_buf, " unable to read partition table\n", PAGE_SIZE);

        printk(KERN_INFO "%s", state->pp_buf);

        free_page((unsigned long)state->pp_buf);
        kfree(state);
        return ERR_PTR(res);
}

byname

/dev/block/bootdevice/by-name/xxx,目录及后面的链接是init进程中创建出来的,init收到增加新分区的uevent事件后,构造出以上by-name下的文件.

    std::ifstream cmdline_fin("/proc/cmdline");
    if (getline(cmdline_fin, cmdline)) {
        std::string partname = find_partition_name(cmdline, uevent->device_name);
        if (partname.length() > 0) {
            if (asprintf(&links[link_num], "/dev/block/by-name/%s", partname.c_str()) > 0)
                link_num++;
            else
                links[link_num] = NULL;
        }
    }
lrwxrwxrwx root     root              1970-01-01 08:00 UDISK -> /dev/block/mmcblk0p1
lrwxrwxrwx root     root              1970-01-01 08:00 alog -> /dev/block/mmcblk0p15
lrwxrwxrwx root     root              1970-01-01 08:00 boot -> /dev/block/mmcblk0p6
lrwxrwxrwx root     root              1970-01-01 08:00 bootloader -> /dev/block/mmcblk0p2
lrwxrwxrwx root     root              1970-01-01 08:00 cache -> /dev/block/mmcblk0p10
lrwxrwxrwx root     root              1970-01-01 08:00 empty -> /dev/block/mmcblk0p14
lrwxrwxrwx root     root              1970-01-01 08:00 env -> /dev/block/mmcblk0p5
lrwxrwxrwx root     root              1970-01-01 08:00 frp -> /dev/block/mmcblk0p13
lrwxrwxrwx root     root              1970-01-01 08:00 media_data -> /dev/block/mmcblk0p16
lrwxrwxrwx root     root              1970-01-01 08:00 metadata -> /dev/block/mmcblk0p11
lrwxrwxrwx root     root              1970-01-01 08:00 misc -> /dev/block/mmcblk0p8
lrwxrwxrwx root     root              1970-01-01 08:00 private -> /dev/block/mmcblk0p12
lrwxrwxrwx root     root              1970-01-01 08:00 recovery -> /dev/block/mmcblk0p9
lrwxrwxrwx root     root              1970-01-01 08:00 system -> /dev/block/mmcblk0p7

你可能感兴趣的:(平台)