I.MX6 change boot partition 1 to User area

/************************************************************************************
 *                  I.MX6 change boot partition 1 to User area 
 * 说明:
 *     需要在eMMC中切换U-Boot所在的位置,看一下eMMC的驱动,测试一下效果。
 *
 *                                            2017-5-26 台湾 中和区 曾剑锋
 ***********************************************************************************/

一、参考文档:
    1. emmc boot1 boot2 partition
        http://www.cnblogs.com/helloworldtoyou/p/6053460.html

二、驱动参考代码(drivers/mmc/core/mmc.c):
    /* set up boot partitions */
    static ssize_t
    setup_boot_partitions(struct device *dev, struct device_attribute *attr,
            const char *buf, size_t count)
    {
        ...
        /* enable the boot partition in boot mode */
        /* boot enable be -
         * 0x00 - disable boot enable.
         * 0x08 - boot partition 1 is enabled for boot.
         * 0x10 - boot partition 2 is enabled for boot.
         * 0x38 - User area is enabled for boot.
         */
        switch (part & EXT_CSD_BOOT_PARTITION_ENABLE_MASK) {
        case 0:
            boot_config = (ext_csd[EXT_CSD_PART_CONFIG]
                    & ~EXT_CSD_BOOT_PARTITION_ENABLE_MASK
                    & ~EXT_CSD_BOOT_ACK_ENABLE);
            break;
        case EXT_CSD_BOOT_PARTITION_PART1:
            boot_config = ((ext_csd[EXT_CSD_PART_CONFIG]
                    & ~EXT_CSD_BOOT_PARTITION_ENABLE_MASK)
                    | EXT_CSD_BOOT_PARTITION_PART1
                    | EXT_CSD_BOOT_ACK_ENABLE);
            break;
        case EXT_CSD_BOOT_PARTITION_PART2:
            boot_config = ((ext_csd[EXT_CSD_PART_CONFIG]
                    & ~EXT_CSD_BOOT_PARTITION_ENABLE_MASK)
                    | EXT_CSD_BOOT_PARTITION_PART2
                    | EXT_CSD_BOOT_ACK_ENABLE);
            break;
        case EXT_CSD_BOOT_PARTITION_ENABLE_MASK:
            boot_config = ((ext_csd[EXT_CSD_PART_CONFIG]
                    | EXT_CSD_BOOT_PARTITION_ENABLE_MASK)
                    & ~EXT_CSD_BOOT_ACK_ENABLE);
            break;
        default:
            pr_err("%s: wrong boot config parameter" \
                " 00 (disable boot), 08 (enable boot1)," \
                "16 (enable boot2), 56 (User area)\n",
                mmc_hostname(card->host));
            err = -EINVAL;
            goto err_rtn;
        }
        ...
    }

三、操作流程:
    1. 删除User area区域的U-Boot,防止识别到U-Boot,而不进入烧录模式:
        dd if=/dev/zero of=/dev/block/mmcblk3  bs=1024 count=10240
    2. 切换eMMC启动到User area区域启动:
        echo 56 > /sys/block/mmcblk3/device/boot_config

 

posted on 2017-05-26 10:08  zengjf  阅读(474)  评论(0编辑  收藏  举报

导航