From patchwork Thu Jan 7 15:21:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1423361 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=seco.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=secospa.onmicrosoft.com header.i=@secospa.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-secospa-onmicrosoft-com header.b=P9H2zh+C; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DBVNz2KFjz9sVt for ; Fri, 8 Jan 2021 02:23:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 32A20828C7; Thu, 7 Jan 2021 16:22:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=secospa.onmicrosoft.com header.i=@secospa.onmicrosoft.com header.b="P9H2zh+C"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E9858828A9; Thu, 7 Jan 2021 16:21:49 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on20611.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1a::611]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6C533828A8 for ; Thu, 7 Jan 2021 16:21:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YDcpuLIuPrhXUGiNMrzh248KdEF5OEqpS7AFgjbfSHOluCon9Wb+1hpcIfsjltBdMAIhLFVzYrukCG/nxlxDq4F79+2Dmhgc2XdBeftX4mQsQK5CgtH0L+SGnOFk0UMyGSA5Eh7TEs0pvfA2jjYOgxkBo2ZKrzgqx/jAY+yJVLz93SP9CEVsMXix1WoKmiarFrHciMNKg3YKifxVL1sO606BWI5VtDP7TV8bVOFgKEDgKZLaXO9H4+KRw4N9Sqne2NjPUFBZ3o++G0yAjINMkRYOOvLSALnE8+QoefE6CfPASqtG3bx0VvzcHiBU1/f2moTXGqcabAVZagpOBCsG/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bv9qw4E13c1mQDPNgC80tC9Oek1VPMfXSY9CTuBRgL8=; b=aIr8ogv6bBoYJNKsTuwGwSawk3WnbutTitEGTQQUtkQfFf85SUelu6XsaxYx7/0XnTBYxNiNbhP8fdRda4I6I8lZs/hKWdci0f/BMYNn22+6XaF5Mzu+VOQyVJPTEBcNAULrO9X6HREs6wEFA4d/RLxIqBAFJbTpRcEGk6INJ0V12kINcj25ApeF+pczagyP8u360jJvafXDdFGyeDGqA5jLms4ufNO04yJEOPltr9uaxKIl/ebgUGAiTGg5NReybGF7Hcikt4oL53zr3e4YumB021WYDpRgXQt5e2/zuewbxnnCBwuiJuPKtOAlMmJEBgMrtgxjWD5ccdqLcnfRPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bv9qw4E13c1mQDPNgC80tC9Oek1VPMfXSY9CTuBRgL8=; b=P9H2zh+CF1YnuOZtJD3Ya+WFchG2NowTbxRzckqBfA1Z5Xl5jrth4bymQwZs+wYOTnpk9wIDglnhy0X0EbP9FAjQZ+p3qGeUhvMH4R7X67Ivvyg6fLQ/F/s87NssKY5neIsy9kAkZhYhZ0DdZQVdkrWPvqNZXRNlxJRGu9OqGTo= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=seco.com; Received: from AM9PR03MB7251.eurprd03.prod.outlook.com (2603:10a6:20b:26e::16) by AM9PR03MB6930.eurprd03.prod.outlook.com (2603:10a6:20b:2d7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Thu, 7 Jan 2021 15:21:39 +0000 Received: from AM9PR03MB7251.eurprd03.prod.outlook.com ([fe80::a8f2:7dd:46e5:8526]) by AM9PR03MB7251.eurprd03.prod.outlook.com ([fe80::a8f2:7dd:46e5:8526%6]) with mapi id 15.20.3742.006; Thu, 7 Jan 2021 15:21:39 +0000 From: Sean Anderson To: u-boot@lists.denx.de Cc: Simon Glass , Sean Anderson , Filip Brozovic , mingming lee Subject: [PATCH v2 8/9] fastboot: Allow u-boot-style partitions Date: Thu, 7 Jan 2021 10:21:02 -0500 Message-Id: <20210107152104.1837414-9-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107152104.1837414-1-sean.anderson@seco.com> References: <20210107152104.1837414-1-sean.anderson@seco.com> X-Originating-IP: [50.195.82.171] X-ClientProxiedBy: MN2PR19CA0053.namprd19.prod.outlook.com (2603:10b6:208:19b::30) To AM9PR03MB7251.eurprd03.prod.outlook.com (2603:10a6:20b:26e::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR19CA0053.namprd19.prod.outlook.com (2603:10b6:208:19b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Thu, 7 Jan 2021 15:21:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d3c61f0c-d864-4204-41fb-08d8b31fee67 X-MS-TrafficTypeDiagnostic: AM9PR03MB6930: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LQIlv9W8MPDHABl1ucZFl2GIH5Mm++7uhwaWvBpXF2z/IAFhhIsr3DZbpUUPz8pMeJ7y1kVChnHJ2y+W3b/nru6otHdsRHVqJaqTctB0OfbGLSGdwZ33LWqiPlhoBvNgH3OIle/Y/GMDjtPSuqHgU7YC/54L0Im2ZzOGkYjcLLdueB7nRAPzR6jRKQf9GjUK3DhlQU+u4Ic8tjbbpGSFKuIQwPMzrx1HekOXFkOrgUUbumaBBjAK65I+Q5P3SY6pbGLfgz0gAL0d5pEqyv2Olh2qpFzZ+WoOIO2LJYlnvVpIU0S1Kt+PENGk8upCNUFbcswH83+dQ+Tmw+ZZ/xOhisUOkTP2LV7hIOpzJnNesMKLDiLg/qtzlGBNzrEyuur+zxeyXUgA+DlCLLc8Se4EMg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR03MB7251.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(136003)(396003)(376002)(366004)(39850400004)(66556008)(66476007)(66946007)(86362001)(6666004)(36756003)(478600001)(6486002)(16526019)(30864003)(956004)(5660300002)(8676002)(6916009)(6512007)(2906002)(26005)(8936002)(186003)(6506007)(2616005)(52116002)(1076003)(54906003)(83380400001)(4326008)(316002)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: NWiIfyQNQ9qCMJW9iBoVh4LtpW70h9L0g5H33QRtulBcL4iLDN0SJgS5up3tkT8B8VH8n197ch7lT6tFBYFJBYFt4BU/XMhCNtoCE3OajQj1kaLZupNCIlBMQcaHnn73oTCuhBi1vbwlQXojtBI3uL5gzQJ4o8Fkb9Pz5oMzBaqMXAOUcvzMMx/aEMt/80cU0ZZMdGfBQv9B2FLL9r+N+PWdHCx/z1cGO+Atjd0gAuXauHVB6cBLsXRKpu/k5hETxIIjUh4HKqeg390ZmjmZVL+NLnvOr6SvlF2KcxtZNZjFd0QTsE83I8wTDl4BmPx+3jxmP+9nCLoCRYH9JIwHEob2QBNXzHJwstpE92hjj/bgqb7luxWWDuKODISe3aZbPV1PUOcAd00dQ4apD3rLOf/CkyOxnisCC0CUmHIGX8iwZWs8hkHxEB/8GrxvdupLXs3qrQEYMLZhO2cqPmtEsYYmAs7Q32VJskB7BLGgqfvoL92PBTnLwWXniNk5xjbEZ56Uj5IPG3RI80SHwGEl7ohBSAoNtOOTCDW2Tq94MemDMy/lBZol8GJB22voL7cxiUGocC7RTc8iYaeFbj8FyZkuazkuuZ6i5xjX7NJAUnIS64XwY2uJ/0AvT0XM3VgwHtzTAK5+LcVybDaCoQkPyH4SoIbNFTPbmB+dLDZYuiBCTk0ccL5V09q1VNwwzxn212z1Su3pc/CB3oGYhYRoLxo7wzqA/WTj1QLdUpTwXoSkzg7ofYQCPr4lrXMbBo36ZLJ4UPHmIZRmZV6d335/291tIOAAAy/e+JNFmZhNrCRciexZJgmoPBAV2IckYdTFmv6OdUSwWc6vUw5y2ZYIGITNk7OwOEa6/cCGK7nv5zC0MlBeQlVIE2ZTQOyPnDogbXWJWKkEN+3NXZko4qBq80d4Y1kOBLkaTbRnRLKLyFekBJ2lsGEJ92okSlKg3otB/tTLzfL7R8UHhlEPcJo+TinADFCFkQW1AwpskXFen2JWADuSO1TjcDW/p6QbwsDW X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-AuthSource: AM9PR03MB7251.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2021 15:21:39.6902 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-Network-Message-Id: d3c61f0c-d864-4204-41fb-08d8b31fee67 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aVhE4w/GCsoq8mNLt8Apw/BV/gAWUJTaNhyTgyCV7FyYqiZw71uZmjxaBuue9eGw2XozvXa3hbvmwvwCSJGO5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR03MB6930 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean This adds support for partitions of the form "dev.hwpart:part" and "dev#partname". This allows one to flash to eMMC boot partitions without having to use CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT. It also allows one to flash to an entire device without needing CONFIG_FASTBOOT_MMC_USER_NAME. Lastly, one can also flash MMC devices other than CONFIG_FASTBOOT_FLASH_MMC_DEV. Because devices can be specified explicitly, CONFIG_FASTBOOT_FLASH_MMC_DEV is used only when necessary for existing functionality. For those cases, fastboot_mmc_get_dev has been added as a helper function. This allows There should be no conflicts with the existing system, but just in case, I have ordered detection of these names after all existing names. The fastboot_mmc_part test has been updated for these new names. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- Changes in v2: - Fix accidental reversion of earlier changes drivers/fastboot/fb_mmc.c | 147 +++++++++++++++++++++++--------------- test/dm/fastboot.c | 37 +++++++++- 2 files changed, 125 insertions(+), 59 deletions(-) diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c index b0610d3151..1b8d35877b 100644 --- a/drivers/fastboot/fb_mmc.c +++ b/drivers/fastboot/fb_mmc.c @@ -76,12 +76,37 @@ static int raw_part_get_info_by_name(struct blk_desc *dev_desc, return 0; } -static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc, - const char *name, struct disk_partition *info) +static int do_get_part_info(struct blk_desc **dev_desc, const char *name, + struct disk_partition *info) { int ret; - ret = part_get_info_by_name(dev_desc, name, info); + /* First try partition names on the default device */ + *dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV); + if (*dev_desc) { + ret = part_get_info_by_name(*dev_desc, name, info); + if (ret >= 0) + return ret; + + /* Then try raw partitions */ + ret = raw_part_get_info_by_name(*dev_desc, name, info); + if (ret >= 0) + return ret; + } + + /* Then try dev.hwpart:part */ + ret = part_get_info_by_dev_and_name_or_num("mmc", name, dev_desc, + info, true); + return ret; +} + +static int part_get_info_by_name_or_alias(struct blk_desc **dev_desc, + const char *name, + struct disk_partition *info) +{ + int ret; + + ret = do_get_part_info(dev_desc, name, info); if (ret < 0) { /* strlen("fastboot_partition_alias_") + PART_NAME_LEN + 1 */ char env_alias_name[25 + PART_NAME_LEN + 1]; @@ -92,8 +117,8 @@ static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc, strncat(env_alias_name, name, PART_NAME_LEN); aliased_part_name = env_get(env_alias_name); if (aliased_part_name != NULL) - ret = part_get_info_by_name(dev_desc, - aliased_part_name, info); + ret = do_get_part_info(dev_desc, aliased_part_name, + info); } return ret; } @@ -424,27 +449,49 @@ int fastboot_mmc_get_part_info(const char *part_name, struct blk_desc **dev_desc, struct disk_partition *part_info, char *response) { - int r = 0; + int ret; - *dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV); - if (!*dev_desc) { - fastboot_fail("block device not found", response); - return -ENOENT; - } if (!part_name || !strcmp(part_name, "")) { fastboot_fail("partition not given", response); return -ENOENT; } - if (raw_part_get_info_by_name(*dev_desc, part_name, part_info) < 0) { - r = part_get_info_by_name_or_alias(*dev_desc, part_name, part_info); - if (r < 0) { - fastboot_fail("partition not found", response); - return r; + ret = part_get_info_by_name_or_alias(dev_desc, part_name, part_info); + if (ret < 0) { + switch (ret) { + case -ENOSYS: + case -EINVAL: + fastboot_fail("invalid partition or device", response); + break; + case -ENODEV: + fastboot_fail("no such device", response); + break; + case -ENOENT: + fastboot_fail("no such partition", response); + break; + case -EPROTONOSUPPORT: + fastboot_fail("unknown partition table type", response); + break; + default: + fastboot_fail("unanticipated error", response); + break; } } - return r; + return ret; +} + +static struct blk_desc *fastboot_mmc_get_dev(char *response) +{ + struct blk_desc *ret = blk_get_dev("mmc", + CONFIG_FASTBOOT_FLASH_MMC_DEV); + + if (!ret || ret->type == DEV_TYPE_UNKNOWN) { + pr_err("invalid mmc device\n"); + fastboot_fail("invalid mmc device", response); + return NULL; + } + return ret; } /** @@ -461,17 +508,12 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer, struct blk_desc *dev_desc; struct disk_partition info; - dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV); - if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) { - pr_err("invalid mmc device\n"); - fastboot_fail("invalid mmc device", response); - return; - } - #ifdef CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT1_NAME) == 0) { - fb_mmc_boot1_ops(dev_desc, download_buffer, - download_bytes, response); + dev_desc = fastboot_mmc_get_dev(response); + if (dev_desc) + fb_mmc_boot1_ops(dev_desc, download_buffer, + download_bytes, response); return; } #endif @@ -483,6 +525,10 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer, if (strcmp(cmd, CONFIG_FASTBOOT_GPT_NAME) == 0 || strcmp(cmd, CONFIG_FASTBOOT_MMC_USER_NAME) == 0) { #endif + dev_desc = fastboot_mmc_get_dev(response); + if (!dev_desc) + return; + printf("%s: updating MBR, Primary and Backup GPT(s)\n", __func__); if (is_valid_gpt_buf(dev_desc, download_buffer)) { @@ -505,6 +551,10 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer, #if CONFIG_IS_ENABLED(DOS_PARTITION) if (strcmp(cmd, CONFIG_FASTBOOT_MBR_NAME) == 0) { + dev_desc = fastboot_mmc_get_dev(response); + if (!dev_desc) + return; + printf("%s: updating MBR\n", __func__); if (is_valid_dos_buf(download_buffer)) { printf("%s: invalid MBR - refusing to write to flash\n", @@ -526,19 +576,16 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer, #ifdef CONFIG_ANDROID_BOOT_IMAGE if (strncasecmp(cmd, "zimage", 6) == 0) { - fb_mmc_update_zimage(dev_desc, download_buffer, - download_bytes, response); + dev_desc = fastboot_mmc_get_dev(response); + if (dev_desc) + fb_mmc_update_zimage(dev_desc, download_buffer, + download_bytes, response); return; } #endif - if (raw_part_get_info_by_name(dev_desc, cmd, &info) != 0) { - if (part_get_info_by_name_or_alias(dev_desc, cmd, &info) < 0) { - pr_err("cannot find partition: '%s'\n", cmd); - fastboot_fail("cannot find partition", response); - return; - } - } + if (fastboot_mmc_get_part_info(cmd, &dev_desc, &info, response) < 0) + return; if (is_sparse_image(download_buffer)) { struct fb_mmc_sparse sparse_priv; @@ -581,23 +628,12 @@ void fastboot_mmc_erase(const char *cmd, char *response) lbaint_t blks, blks_start, blks_size, grp_size; struct mmc *mmc = find_mmc_device(CONFIG_FASTBOOT_FLASH_MMC_DEV); - if (mmc == NULL) { - pr_err("invalid mmc device\n"); - fastboot_fail("invalid mmc device", response); - return; - } - - dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV); - if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) { - pr_err("invalid mmc device\n"); - fastboot_fail("invalid mmc device", response); - return; - } - #ifdef CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT1_NAME) == 0) { /* erase EMMC boot1 */ - fb_mmc_boot1_ops(dev_desc, NULL, 0, response); + dev_desc = fastboot_mmc_get_dev(response); + if (dev_desc) + fb_mmc_boot1_ops(dev_desc, NULL, 0, response); return; } #endif @@ -605,6 +641,10 @@ void fastboot_mmc_erase(const char *cmd, char *response) #ifdef CONFIG_FASTBOOT_MMC_USER_NAME if (strcmp(cmd, CONFIG_FASTBOOT_MMC_USER_NAME) == 0) { /* erase EMMC userdata */ + dev_desc = fastboot_mmc_get_dev(response); + if (!dev_desc) + return; + if (fb_mmc_erase_mmc_hwpart(dev_desc)) fastboot_fail("Failed to erase EMMC_USER", response); else @@ -613,13 +653,8 @@ void fastboot_mmc_erase(const char *cmd, char *response) } #endif - if (raw_part_get_info_by_name(dev_desc, cmd, &info) != 0) { - if (part_get_info_by_name_or_alias(dev_desc, cmd, &info) < 0) { - pr_err("cannot find partition: '%s'\n", cmd); - fastboot_fail("cannot find partition", response); - return; - } - } + if (fastboot_mmc_get_part_info(cmd, &dev_desc, &info, response) < 0) + return; /* Align blocks to erase group size to avoid erasing other partitions */ grp_size = mmc->erase_grp_size; diff --git a/test/dm/fastboot.c b/test/dm/fastboot.c index 8f905d8fa8..e7f8c362b8 100644 --- a/test/dm/fastboot.c +++ b/test/dm/fastboot.c @@ -35,9 +35,12 @@ static int dm_test_fastboot_mmc_part(struct unit_test_state *uts) }, }; - ut_assertok(blk_get_device_by_str("mmc", - __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV), - &mmc_dev_desc)); + /* + * There are a lot of literal 0s I don't want to have to construct from + * MMC_DEV. + */ + ut_asserteq(0, CONFIG_FASTBOOT_FLASH_MMC_DEV); + ut_assertok(blk_get_device_by_str("mmc", "0", &mmc_dev_desc)); if (CONFIG_IS_ENABLED(RANDOM_UUID)) { gen_rand_uuid_str(parts[0].uuid, UUID_STR_FORMAT_STD); gen_rand_uuid_str(parts[1].uuid, UUID_STR_FORMAT_STD); @@ -59,6 +62,34 @@ static int dm_test_fastboot_mmc_part(struct unit_test_state *uts) &part_info, response)); ut_assertok(env_set(FB_ALIAS_PREFIX "test3", NULL)); + /* "New" partition labels */ + ut_asserteq(1, fastboot_mmc_get_part_info("#test1", &fb_dev_desc, + &part_info, response)); + ut_asserteq(1, fastboot_mmc_get_part_info("0#test1", &fb_dev_desc, + &part_info, response)); + ut_asserteq(1, fastboot_mmc_get_part_info("0.0#test1", &fb_dev_desc, + &part_info, response)); + ut_asserteq(1, fastboot_mmc_get_part_info("0:1", &fb_dev_desc, + &part_info, response)); + ut_asserteq(1, fastboot_mmc_get_part_info("0.0:1", &fb_dev_desc, + &part_info, response)); + ut_asserteq(1, fastboot_mmc_get_part_info("0", &fb_dev_desc, + &part_info, response)); + ut_asserteq(1, fastboot_mmc_get_part_info("0.0", &fb_dev_desc, + &part_info, response)); + ut_asserteq(0, fastboot_mmc_get_part_info("0:0", &fb_dev_desc, + &part_info, response)); + ut_asserteq(0, fastboot_mmc_get_part_info("0.0:0", &fb_dev_desc, + &part_info, response)); + ut_asserteq(0, fastboot_mmc_get_part_info("1", &fb_dev_desc, + &part_info, response)); + ut_asserteq(0, fastboot_mmc_get_part_info("1.0", &fb_dev_desc, + &part_info, response)); + ut_asserteq(1, fastboot_mmc_get_part_info(":1", &fb_dev_desc, + &part_info, response)); + ut_asserteq(0, fastboot_mmc_get_part_info(":0", &fb_dev_desc, + &part_info, response)); + return 0; } DM_TEST(dm_test_fastboot_mmc_part, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);