void cmd_erase_emmc(const char *arg, void *data, unsigned sz)
{
#ifdef MTK_NEW_COMBO_EMMC_SUPPORT
    unsigned int part_id;
#endif
	unsigned long long ptn = 0;
	unsigned long long size = 0;
	int index = INVALID_PTN;
	int erase_ret = MMC_ERR_NONE;
	char msg[256];

	init_display_xy();
	dprintf (DBG_LV, "Enter cmd_erase()\n");

	index = partition_get_index(arg);
#ifdef MTK_NEW_COMBO_EMMC_SUPPORT
    part_id = partition_get_region(index);
#endif
	ptn = partition_get_offset(index);

	if(index == -1) {
		fastboot_fail_wrapper("Partition table doesn't exist");
		return;
	}
	if(!is_support_erase(index)){
		sprintf(msg,"partition '%s' not support erase\n",arg);
		fastboot_fail_wrapper(msg);
		return;
	}

	TIME_START;
	size = partition_get_size(index);
#ifdef MTK_NEW_COMBO_EMMC_SUPPORT
	erase_ret = emmc_erase(part_id, ptn, partition_get_size(index));
#else
	erase_ret = emmc_erase(ptn, partition_get_size(index));
#endif

	if(erase_ret  == MMC_ERR_NONE)
	{
		dprintf (DBG_LV, "emmc_erase() OK\n");
		fastboot_ok_wrapper("Erase EMMC", size);
	}
	else
	{
		dprintf (DBG_LV, "emmc_erase() Fail\n");
		snprintf(msg, sizeof(msg), "Erase error. code:%d", erase_ret);
		fastboot_fail_wrapper(msg);
	}


	return;
}
Example #2
0
static int fastboot_data_part_wipe()
{
    int ret = B_OK;
    int err;

    int index;
#ifdef MTK_NEW_COMBO_EMMC_SUPPORT
    unsigned int part_id;
#endif
    unsigned long long ptn; 
    unsigned long long size; 

    index = partition_get_index("userdata");

    if (index == -1 || !is_support_erase(index))
    {
        ret = PART_GET_INDEX_FAIL;
        return ret;
    }    

#ifdef MTK_NEW_COMBO_EMMC_SUPPORT
    part_id = partition_get_region(index);
#endif
    ptn = partition_get_offset(index);
    size = partition_get_size(index);

    set_env("unlock_erase", "start");

#ifdef MTK_EMMC_SUPPORT
#ifdef MTK_NEW_COMBO_EMMC_SUPPORT
    err = emmc_erase(part_id, ptn, size);
#else
    err = emmc_erase(ptn, size);
#endif
#else
    err = nand_erase(ptn,(u64)size);
#endif
    if (err)
    {    
        ret = PART_ERASE_FAIL;
        set_env("unlock_erase", "fail");
    } else
    {
        ret = B_OK;
        set_env("unlock_erase", "pass");
    }

    return ret;
}