From patchwork Mon Feb 1 16:37:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1434237 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; 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=Zs11AjFu; 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 4DTtrn41zBz9tkW for ; Tue, 2 Feb 2021 03:37:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6625E827EE; Mon, 1 Feb 2021 17:37:10 +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="Zs11AjFu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 03E3082802; Mon, 1 Feb 2021 17:37:09 +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.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on060e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0e::60e]) (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 9AB13827B5 for ; Mon, 1 Feb 2021 17:37:05 +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=n4Z6ElLy8uxtNkBYedICjZg3BLgZfuCpGnnKkkuqUnPXEANKT/5UY0q3JEJtmik8T8Mx6AecSNU9SEhLeQc1v2LbsSF8l2t61MBfhM5Si7wW/xBBKs8hGNRD34DpMkUbYsnn3NvAwC6ugxQ83uVNLmZP9CU1qyLTHrytpqDAEU/zO/Tk678tYyEqBWZSOjVPkvq7nsRvf4ocpdoqibJn27bolF+RHa4/iVBHORCYby24u8IKjAt5mKJmrx4lpKvhXxci+FZV64yTpo+ibubsqHGycNHL8Ik84lWppX8R9RGkNhYBTecXUrSXPnO6ctmCjMKVqkstJpEW486TiYxvtg== 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=LbPb0OQRgSXq7PFI+lNGVYnqjJVzW/vop2ufnRSpI+k=; b=UGvXExGJbLl0TLNNtESqE7GEogH7/Rad9WwI4nHNEoziWsbbeqh3uDE61lyl5awwN8FpDByLPuVYCzvj3wIUU3XpHppF1JZB46vBBmCUKi3OKrFCzOh8+gQKG/yMS6gBpTtOp5NJ+9K0EtFpu+mNXpEzawzFOiFYjTxGdxW4JippQmpsL9UVcn79LKlx4jySZtlIYdml422L/Fu0RjfR9Y4E3Xl+4D9NGK+kl4wUJSidUd0Ccu2A351OmvWyuYpE5E12BFkeg4Yo3KmPm9vF7TV/AE24f2Wv0H9Q3hTltDeyG0fm2RQGtOltOxYh+wuq36EcTgq85FvULO5Kv9oQkQ== 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=LbPb0OQRgSXq7PFI+lNGVYnqjJVzW/vop2ufnRSpI+k=; b=Zs11AjFu8WUyG0C2OkJGuC/NU6B5aTQ7qyC5LIh6Prh91eOdK78SY2sMUFWyPOG/RUMdbl8o8vZyd1gi7/QolSMRS+sNl529dmwQsr/OZB611EJ1R0EDNwRl2P5MrAyBKtsBOFnAnKYisgCKPzhfxHinciggnKjggV/9hRuoHVY= Authentication-Results: chromium.org; dkim=none (message not signed) header.d=none;chromium.org; dmarc=none action=none header.from=seco.com; Received: from AM9PR03MB7251.eurprd03.prod.outlook.com (2603:10a6:20b:26e::16) by AM0PR03MB6132.eurprd03.prod.outlook.com (2603:10a6:20b:145::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.19; Mon, 1 Feb 2021 16:37:04 +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.3805.025; Mon, 1 Feb 2021 16:37:04 +0000 Subject: [PATCH v3 2/9] test: dm: Add test for fastboot mmc partition naming From: Sean Anderson To: U Boot References: <2660a65f-8783-06ed-fe93-2d638ce3a842@seco.com> Cc: Mario Six , Lukasz Majewski , Simon Glass Message-ID: Date: Mon, 1 Feb 2021 11:37:00 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 In-Reply-To: <2660a65f-8783-06ed-fe93-2d638ce3a842@seco.com> Content-Language: en-US X-Originating-IP: [108.51.35.162] X-ClientProxiedBy: BLAPR03CA0121.namprd03.prod.outlook.com (2603:10b6:208:32e::6) To AM9PR03MB7251.eurprd03.prod.outlook.com (2603:10a6:20b:26e::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.201] (108.51.35.162) by BLAPR03CA0121.namprd03.prod.outlook.com (2603:10b6:208:32e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.19 via Frontend Transport; Mon, 1 Feb 2021 16:37:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3e6ba1b4-e076-42e7-b69d-08d8c6cf9bb7 X-MS-TrafficTypeDiagnostic: AM0PR03MB6132: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:209; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Sbwdw67n0L0qEyf7BxI8FU4AXYLPqyQufwgYxrspAWPX0GrQmNfqeqmDj0Si1s1yQ7h4XQgVkRUAcEmLMlQtjnnBg0Gh6EhdLayX+v1VNc75Akob0yZfC9xvvXcIG9dzc/JhxmsMK7/RPjU/Da/mN+fHGh4wGx3GD4fNDq/gULX8ZfgymKNr1ItjZS5L3l3c2zuXtbaB2WiY1TblzY+TKqpWUvs6b3zS6ALlNQQ8eQhYgoU3DSAG0OBt9KnBAfaKVEPHJpYzxBZ6Ii/eObh3Rjd47mKFbvbBOMTeNSIpTNWw39YmFeVgSTplrADjTH7KLxDp69wbcpKuV17cOXRPSqEDkwoaZ+r4+QD/1p9BB0HajPVZ1VL+LvW09ZMVKZbZtJZUDaZppZSsMLhnny2P7Kp8cS8XptbPVpeVBmDy8v20H+h6qq5UGRIRh8rPZ9EiZLn+V76UlcXfz92olannRKOx+PradY8ZbcBIOpphR+4pJATgvHCHO4wlGEIxGZQX4mgObOiKK3cR9SximGV4DRTNLcrLa6qvcsdu9OV+PvSPL3N8jVZNyN743llYvUWWm93ZnLEBgDQnUNfvfNgDbDt1JYrIp32tdQvyUFYdD0g= 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:(396003)(376002)(366004)(136003)(39850400004)(346002)(26005)(54906003)(956004)(478600001)(186003)(31696002)(16576012)(2906002)(316002)(36756003)(8676002)(8936002)(44832011)(52116002)(6486002)(16526019)(66946007)(66476007)(6916009)(5660300002)(83380400001)(31686004)(2616005)(66556008)(4326008)(86362001)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?KA+hysq83JWV1anHCXktX0qJteurNo?= =?utf-8?q?CQHWcyzco8YaIKAuRVtlJk1baEU5CUXA/4M+eBDEcYuZy05vnQlamMBDFIFhzu9eR?= =?utf-8?q?nLAgiKT5+ZAjZXMTi7Bt45uq/Hdo27o+wGPgIEJ26GETDHX7jKhiMD72iJ31OUbci?= =?utf-8?q?uwy/VkzHDbzLgnA++T7+ySYp3qtz1M/8UrhqFIAP49JHIV+ktqUkqAHySB8reMHfj?= =?utf-8?q?MXOthPtqzqdZxc+5jq6eg5uPIAXVfHazPKuF6Z1Lg/aA5NkzoUzr/jqpoXTZOg3yn?= =?utf-8?q?z9hIjIoLiGaFB/sw/qkM6yovq26/WuIVqGgE0fPSOgyUOoLHHgHJ9Jb62a19UmnP2?= =?utf-8?q?iuO7YAnYggYyIYea+4x04ShHaVm7o21ubRxPB45fz6wZLRvkaJMCabzX7GXCRUacj?= =?utf-8?q?vkbUNmidJ4HfL/PUdajZBV2ESNGNF0iX3BVw2CDKj6+lF/qzRKnxsBed9/1UrROyw?= =?utf-8?q?cAAGPb+QE3uXCaCy7p1dojF8swcVDgXmOH/GtUFJvwHZ9EcO2LDshKcYBeeDlNTv2?= =?utf-8?q?hoevaEu9gGLzblNbZTPvr1W0Pa1iJ1XDBuidQasEKdr/GzsRJ6a88UejfVG8xQ4hk?= =?utf-8?q?xHUPW2Pq8c1/ox1T+F5gSCawwnWvt2XbPbNi2ReqJtoiDAI7brrJtA4cVHf29px0F?= =?utf-8?q?n7H/vqUO64krYyM0SPzCBPFu4bKYWaSexpLpkbiiHGggMd/U0Iuoy1Qjmd4EjtSzb?= =?utf-8?q?r7ZEZsSK+xtfZdZQOy6Ye/c7ZCD0mDTTGj5+hvkNquXBe+oV1o6Z7XC/chNHBlXjP?= =?utf-8?q?nb5vXVv06s89BLcMCf9kWkftfl2VqC6WX+a8+nJQplArEN6EAnc4hUPpAXwyQTLJf?= =?utf-8?q?pKDq59pjy32Yqk4+548cYwnqTZPY5Jvs1+E+V6fw5lfD+173WxVeFP5dWeBILX5XG?= =?utf-8?q?KVPdSH+FyZa8/HSaltMSt/+Z/3ao6e5/TdqVPZp/DoL1c4cbbLe790EwxfVjffPN8?= =?utf-8?q?4DfdBKUq1wfAzDXDP5T04EK1cVYfIC4XyZyKQakV71lyEafrHkCGUzc8325oEEmD2?= =?utf-8?q?prwTG2cdPGeXfSRlmD?= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e6ba1b4-e076-42e7-b69d-08d8c6cf9bb7 X-MS-Exchange-CrossTenant-AuthSource: AM9PR03MB7251.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2021 16:37:04.6580 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: te+67Fg5y2yj2WO8rTG9wkkODtfy95ezy8ZnwpgHNTVHYaqf3A2/Gk6TtzZcDZJ+XeZIms9hMRl9ALUNf4X6tQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR03MB6132 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 test verifies the mapping between fastboot partitions and partitions as understood by U-Boot. It also tests the creation of GPT partitions, though that is not the primary goal. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- (no changes since v1) configs/sandbox64_defconfig | 2 ++ configs/sandbox_defconfig | 2 ++ test/dm/Makefile | 3 ++ test/dm/fastboot.c | 64 +++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 test/dm/fastboot.c diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index 4e67819559..9fe07f0c38 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -110,6 +110,8 @@ CONFIG_DM_DEMO=y CONFIG_DM_DEMO_SIMPLE=y CONFIG_DM_DEMO_SHAPE=y CONFIG_DFU_SF=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_GPIO_HOG=y CONFIG_DM_GPIO_LOOKUP_LABEL=y CONFIG_PM8916_GPIO=y diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 0c7674efc9..269288783f 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -135,6 +135,8 @@ CONFIG_DFU_SF=y CONFIG_DMA=y CONFIG_DMA_CHANNELS=y CONFIG_SANDBOX_DMA=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_GPIO_HOG=y CONFIG_DM_GPIO_LOOKUP_LABEL=y CONFIG_PM8916_GPIO=y diff --git a/test/dm/Makefile b/test/dm/Makefile index 46e076ed09..be4385c709 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -91,5 +91,8 @@ obj-$(CONFIG_SCMI_FIRMWARE) += scmi.o ifneq ($(CONFIG_PINMUX),) obj-$(CONFIG_PINCONF) += pinmux.o endif +ifneq ($(CONFIG_EFI_PARTITION)$(CONFIG_FASTBOOT_FLASH_MMC),) +obj-y += fastboot.o +endif endif endif # !SPL diff --git a/test/dm/fastboot.c b/test/dm/fastboot.c new file mode 100644 index 0000000000..8f905d8fa8 --- /dev/null +++ b/test/dm/fastboot.c @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2015 Google, Inc + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define FB_ALIAS_PREFIX "fastboot_partition_alias_" + +static int dm_test_fastboot_mmc_part(struct unit_test_state *uts) +{ + char response[FASTBOOT_RESPONSE_LEN] = {0}; + char str_disk_guid[UUID_STR_LEN + 1]; + struct blk_desc *mmc_dev_desc, *fb_dev_desc; + struct disk_partition part_info; + struct disk_partition parts[2] = { + { + .start = 48, /* GPT data takes up the first 34 blocks or so */ + .size = 1, + .name = "test1", + }, + { + .start = 49, + .size = 1, + .name = "test2", + }, + }; + + ut_assertok(blk_get_device_by_str("mmc", + __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV), + &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); + gen_rand_uuid_str(str_disk_guid, UUID_STR_FORMAT_STD); + } + ut_assertok(gpt_restore(mmc_dev_desc, str_disk_guid, parts, + ARRAY_SIZE(parts))); + + /* "Classic" partition labels */ + ut_asserteq(1, fastboot_mmc_get_part_info("test1", &fb_dev_desc, + &part_info, response)); + ut_asserteq(2, fastboot_mmc_get_part_info("test2", &fb_dev_desc, + &part_info, response)); + + /* Test aliases */ + ut_assertnull(env_get(FB_ALIAS_PREFIX "test3")); + ut_assertok(env_set(FB_ALIAS_PREFIX "test3", "test1")); + ut_asserteq(1, fastboot_mmc_get_part_info("test3", &fb_dev_desc, + &part_info, response)); + ut_assertok(env_set(FB_ALIAS_PREFIX "test3", NULL)); + + return 0; +} +DM_TEST(dm_test_fastboot_mmc_part, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);