Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2221653/?format=api
{ "id": 2221653, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2221653/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20260410-fb_block-v1-1-68f0c976fe0e@oss.qualcomm.com/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/1.1/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null }, "msgid": "<20260410-fb_block-v1-1-68f0c976fe0e@oss.qualcomm.com>", "date": "2026-04-10T04:42:00", "name": "[1/2] fastboot: block: Add GPT/MBR support and device selection syntax", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "4f8b707153cdbd6bbb28b4aa99a4b2dc2e8a534b", "submitter": { "id": 90810, "url": "http://patchwork.ozlabs.org/api/1.1/people/90810/?format=api", "name": "Balaji Selvanathan", "email": "balaji.selvanathan@oss.qualcomm.com" }, "delegate": { "id": 117687, "url": "http://patchwork.ozlabs.org/api/1.1/users/117687/?format=api", "username": "mkorpershoek", "first_name": "Mattijs", "last_name": "Korpershoek", "email": "mkorpershoek@baylibre.com" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20260410-fb_block-v1-1-68f0c976fe0e@oss.qualcomm.com/mbox/", "series": [ { "id": 499389, "url": "http://patchwork.ozlabs.org/api/1.1/series/499389/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=499389", "date": "2026-04-10T04:41:59", "name": "fastboot: block: Add GPT/MBR and device selection", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/499389/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2221653/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2221653/checks/", "tags": {}, "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256\n header.s=qcppdkim1 header.b=BtpBnW3P;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n header.a=rsa-sha256 header.s=google header.b=f/aJbT4P;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=85.214.62.61; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)", "phobos.denx.de;\n dmarc=none (p=none dis=none) header.from=oss.qualcomm.com", "phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de", "phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=qualcomm.com header.i=@qualcomm.com\n header.b=\"BtpBnW3P\";\n\tdkim=pass (2048-bit key;\n unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n header.b=\"f/aJbT4P\";\n\tdkim-atps=neutral", "phobos.denx.de; dmarc=none (p=none dis=none)\n header.from=oss.qualcomm.com", "phobos.denx.de; spf=pass\n smtp.mailfrom=balaji.selvanathan@oss.qualcomm.com" ], "Received": [ "from phobos.denx.de (phobos.denx.de [85.214.62.61])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fsPKv40wwz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 14:42:27 +1000 (AEST)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 4B20C8414B;\n\tFri, 10 Apr 2026 06:42:19 +0200 (CEST)", "by phobos.denx.de (Postfix, from userid 109)\n id C4EBF84120; Fri, 10 Apr 2026 06:42:17 +0200 (CEST)", "from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com\n [205.220.168.131])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 8C2B184099\n for <u-boot@lists.denx.de>; Fri, 10 Apr 2026 06:42:14 +0200 (CEST)", "from pps.filterd (m0279867.ppops.net [127.0.0.1])\n by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 639Kh1aM1729917\n for <u-boot@lists.denx.de>; Fri, 10 Apr 2026 04:42:12 GMT", "from mail-pg1-f197.google.com (mail-pg1-f197.google.com\n [209.85.215.197])\n by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4deckxjpef-1\n (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT)\n for <u-boot@lists.denx.de>; Fri, 10 Apr 2026 04:42:12 +0000 (GMT)", "by mail-pg1-f197.google.com with SMTP id\n 41be03b00d2f7-c76bfd7b9cdso754849a12.3\n for <u-boot@lists.denx.de>; Thu, 09 Apr 2026 21:42:12 -0700 (PDT)", "from hu-bselvana-blr.qualcomm.com\n (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com. [103.229.18.19])\n by smtp.gmail.com with ESMTPSA id\n d2e1a72fcca58-82f0c4b3b29sm1198815b3a.36.2026.04.09.21.42.07\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 09 Apr 2026 21:42:10 -0700 (PDT)" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,\n RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED,\n SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2", "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h=\n cc:content-transfer-encoding:content-type:date:from:in-reply-to\n :message-id:mime-version:references:subject:to; s=qcppdkim1; bh=\n OXnYcTBC4HEfafJiJVVvbDvz0dAVoDd4Gq7qLw2NCn8=; b=BtpBnW3PRiRLRtsD\n pTlMVzdog78JHTL7J5CKfcadr/6Oyp2ClDjmWNcThXLQ140079fUBOhOD/TOgvjz\n 7x8HvPK5zFH+r2B/k9vn1gzNUkjGaJUZ2HmP5sopzNu9EMJu86TQGW8cKQH2p7iR\n HROe2LcUuwivm0zrUo5QOYyG866EvOTlrvwcLXJpCj25ihVoM5MOwxy9inJ/n/mO\n ESOCskGoZkQjaMnC6CjoCRT/yJY5U4cc5oI/EverFlE4uq7lZU4057o1Jnxhw/C1\n 6YKRsBmQnbPKR/QJhEbDyx+1GcoxKdLWMTbsJ64J7B2c8sRRQyVc8xBFmTtcfjbb\n fG6PPQ==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=oss.qualcomm.com; s=google; t=1775796132; x=1776400932; darn=lists.denx.de;\n h=cc:to:in-reply-to:references:message-id:content-transfer-encoding\n :mime-version:subject:date:from:from:to:cc:subject:date:message-id\n :reply-to; bh=OXnYcTBC4HEfafJiJVVvbDvz0dAVoDd4Gq7qLw2NCn8=;\n b=f/aJbT4P/TGXEPw02Dh/6FoIYBtqJXv0gGFFCkjUpCS87E6g42ox6j9erkBg9GGpmD\n MLcQHtIhcFVOupNV3rD9zq0n905I5+fY2pW01eLuWLekP6XPHTvUvTq9rvXY9z9jua/H\n HpOeLiYYLr2mHylIUQww7fdJxUPXR9d2BC9HqvbllM7RykZRvwH6590INTbIDb35Jdv0\n gHx8Ikz85ajJANEherrgSUyT2vKsBbqWjnY9igl0KEY5YMMnPdOoYjCrOcOiDhwlbxEe\n gHosOntbo+xV/PVyett2wCTqek6bvzcJ3a/A81x38SjX3YSZYs7MiNb/wzR3OsJ5tp9k\n JPFQ==" ], "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775796132; x=1776400932;\n h=cc:to:in-reply-to:references:message-id:content-transfer-encoding\n :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to\n :cc:subject:date:message-id:reply-to;\n bh=OXnYcTBC4HEfafJiJVVvbDvz0dAVoDd4Gq7qLw2NCn8=;\n b=LKmsPtyKzSS4D+5bpsUcQH7In/vzMK+Xc5JeVwkGyH/dI44FrgeDNFnhOrYEMFBzWl\n dbK2Hamuq1//vTt691Vy6cJQwh+XJ/+gmZ0qwG/z936wh9mFSHbarBKBDggSDQ5jxYw/\n pFzjG/vfPEUqicxw19gx5lQZ9dQcWvjh3vaL4aak5DJMUBmYZ4A+dJSZ2nNL8wWq52o8\n EfeY8i6j0aa5Xgg+lis18fXSLeVNBQgFQhicdH4gi4cK1ro9f3DYId4XctBCibG6JA65\n UI7FjEeuT3p4e1XDp4HcoXv8MKruUhZGszE1CqaRJ95OsecAAyssDpNdTiJOoo7Vlzng\n 4laA==", "X-Gm-Message-State": "AOJu0YwnRydCbCgqda8lYz0Ds4lwz/P1w4VngfN4Ffl753YfSbiEMEvj\n KQv2EtYjQ9qeDOjtnbd2aNG766/EBvrcGWYweTeSGK3IMBZLgifzom863yqKQIGy22QNmpO0re3\n XHNPdC9/h8o8kvo9nANx5UNLdmcX02r7JfsRkIBXMznf6x/ji7THYWz52", "X-Gm-Gg": "AeBDietCgr9v67vTY9VPfmycLi1DbfgpkyVO3njPuhKzXstQfOAcYCKiTGFCCqTRiuQ\n kMZdErszs32LmKXhvqC5Az7r7FzE2xIrRH0iDk2uxFyBfCmvx9EL9Jw/nPsXFVEEZJDOcvFoFVv\n iEgP3Bu/tp2/91ieVcuWaZcQrZpVyrCsBRUJ3mh0+s37Zjk+3IqFaTO240P6W3j21QEBv2aJkJW\n ar2w0iLc35/6luLsWFlE/lLTi7HdCARDGAehfjUcWhFgBH+m4zhHVwct5XrBghmFVx/zUaABnkG\n 9QOlOg5C2/L25waDcECBHWqJd9IVNeQkR5XvotvARXj5/ruG69G8zvRd99hTLBtSGCOJOaUIEIH\n k8g6U/iosKW1ON2f8wKkEMFG59ZJ4mP/C8xKXXZ3eUgfmfcYhYZF1ViAfTEBiKFogZG3TZXskru\n vIAzSNQ+FM1JCHawvbX39l+SVnLQu54SF9ss59X1vLLHKbv64MhA==", "X-Received": [ "by 2002:a05:6a00:2e9d:b0:82c:7767:5ba9 with SMTP id\n d2e1a72fcca58-82f0c2987a5mr1827723b3a.26.1775796131776;\n Thu, 09 Apr 2026 21:42:11 -0700 (PDT)", "by 2002:a05:6a00:2e9d:b0:82c:7767:5ba9 with SMTP id\n d2e1a72fcca58-82f0c2987a5mr1827701b3a.26.1775796131258;\n Thu, 09 Apr 2026 21:42:11 -0700 (PDT)" ], "From": "Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>", "Date": "Fri, 10 Apr 2026 10:12:00 +0530", "Subject": "[PATCH 1/2] fastboot: block: Add GPT/MBR support and device\n selection syntax", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20260410-fb_block-v1-1-68f0c976fe0e@oss.qualcomm.com>", "References": "<20260410-fb_block-v1-0-68f0c976fe0e@oss.qualcomm.com>", "In-Reply-To": "<20260410-fb_block-v1-0-68f0c976fe0e@oss.qualcomm.com>", "To": "u-boot@lists.denx.de", "Cc": "Mattijs Korpershoek <mkorpershoek@kernel.org>,\n Tom Rini <trini@konsulko.com>,\n Ariel D'Alessandro <ariel.dalessandro@collabora.com>,\n Jerome Forissier <jerome.forissier@arm.com>,\n Dmitrii Merkurev <dimorinny@google.com>, Michael Walle <mwalle@kernel.org>,\n Neil Armstrong <neil.armstrong@linaro.org>,\n Heiko Schocher <hs@nabladev.com>,\n Adrian Freihofer <adrian.freihofer@siemens.com>,\n Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>", "X-Mailer": "b4 0.14.3", "X-Developer-Signature": "v=1; a=ed25519-sha256; t=1775796123; l=9792;\n i=balaji.selvanathan@oss.qualcomm.com; s=20260213; h=from:subject:message-id;\n bh=UvAFFTtOej36I1FijaioxXa2XYPesSwOH6Q0n7gUmvc=;\n b=uFRludJJ0hhJZWlSsEFWN/hcGaPxPb12gzn8A73C3IKnEBcmOcGnKRQLiixnidV8KK2ld0LKc\n UtNXJVqgvvzDdHj/wIsgquldyNbduv5gEVXnHQE354RZHijzb66k51b", "X-Developer-Key": "i=balaji.selvanathan@oss.qualcomm.com; a=ed25519;\n pk=CDpYiUU3SH7KGEtsBvY2tBGPiWfMxqWJF0p2LftOfnc=", "X-Proofpoint-ORIG-GUID": "e6mFiJcFFwK7u8cAVzpKxT2fb9FDrAVH", "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjYwNDEwMDA0MCBTYWx0ZWRfX78WYv1AeUUdC\n 1dE4vrGewHRo7/rw81SDGoycWN1hrwwib0S4j/eoMlUVMbbN5GIy6WLRUdE2J2pZxZjNPRYDqAf\n KIWuyv30OoCvFOHLanKfSdDuaYVbqK3nXVX7Cqt95z8ICl+DjdW1J9LoyPJ49OxTpzcr3fM0J83\n e6yrVhCvVO+FC1oj1t5MfKXOWMDh/kFd6aiRJAUeeIjJK824Av4hVlFGEIrpmML2WPQk+d86bOv\n frZbC5JMTb2T6GjqgQYM6cxmkxoRzkwE9vFrOH0+3XLXEifum6lJDbInqDPG8tuNmaHCgg1ojuu\n zmnDN1hnEd6nvpmrZjR2vjPl5kDtwFOPy7Zwb9aQvHXOtx7UkQqszBGHS8afwiudHOFlin4aoR/\n 7OqcHaPfe+fEwqQsHGyhxAeu1BqqpV/4eLeLCmUa1HYIpRDmqd3BOcM+fiTZ4XUMBxGsD/oKkFd\n NlP6dCrsDDWmXFP+xlg==", "X-Authority-Analysis": "v=2.4 cv=OMcXGyaB c=1 sm=1 tr=0 ts=69d87fa4 cx=c_pps\n a=rz3CxIlbcmazkYymdCej/Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17\n a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10\n a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22\n a=EUspDBNiAAAA:8 a=mB1rp7TKJbXamDPS5sgA:9 a=QEXdDO2ut3YA:10\n a=bFCP_H2QrGi7Okbo017w:22", "X-Proofpoint-GUID": "e6mFiJcFFwK7u8cAVzpKxT2fb9FDrAVH", "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-04-10_01,2026-04-09_02,2025-10-01_01", "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n bulkscore=0 phishscore=0 clxscore=1015 impostorscore=0 spamscore=0\n priorityscore=1501 lowpriorityscore=0 suspectscore=0 malwarescore=0\n adultscore=0 classifier=typeunknown authscore=0 authtc= authcc=\n route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604010000\n definitions=main-2604100040", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.39", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<https://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>", "X-Virus-Scanned": "clamav-milter 0.103.8 at phobos.denx.de", "X-Virus-Status": "Clean" }, "content": "Implement device selection syntax allowing users to specify the\ntarget block device using \"N:partition\" format, where N is the\ndevice number. This enables operations like \"fastboot flash 0:gpt\"\nto write partition tables to specific devices. When no device is\nspecified, the default from CONFIG_FASTBOOT_FLASH_BLOCK_DEVICE_ID\nis used.\n\nExample usage for partition flashing:\n fastboot flash 0:boot boot.img # Flash to device 0\n fastboot flash 1:system system.img # Flash to device 1\n fastboot flash boot boot.img # Use default device\n\nExample usage for GPT/MBR operations:\n fastboot flash 0:gpt gpt.img # Write GPT to device 0\n fastboot flash 1:mbr mbr.img # Write MBR to device 1\n\nSigned-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>\n---\n drivers/fastboot/Kconfig | 4 +-\n drivers/fastboot/fb_block.c | 196 +++++++++++++++++++++++++++++++++++++++++---\n 2 files changed, 186 insertions(+), 14 deletions(-)", "diff": "diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig\nindex 576c3ef8a45..43d83265df4 100644\n--- a/drivers/fastboot/Kconfig\n+++ b/drivers/fastboot/Kconfig\n@@ -227,7 +227,7 @@ config FASTBOOT_FLASH_BLOCK_DEVICE_ID\n \n config FASTBOOT_GPT_NAME\n \tstring \"Target name for updating GPT\"\n-\tdepends on FASTBOOT_FLASH_MMC && EFI_PARTITION\n+\tdepends on (FASTBOOT_FLASH_MMC || FASTBOOT_FLASH_BLOCK) && EFI_PARTITION\n \tdefault \"gpt\"\n \thelp\n \t The fastboot \"flash\" command supports writing the downloaded\n@@ -240,7 +240,7 @@ config FASTBOOT_GPT_NAME\n \n config FASTBOOT_MBR_NAME\n \tstring \"Target name for updating MBR\"\n-\tdepends on FASTBOOT_FLASH_MMC && DOS_PARTITION\n+\tdepends on (FASTBOOT_FLASH_MMC || FASTBOOT_FLASH_BLOCK) && DOS_PARTITION\n \tdefault \"mbr\"\n \thelp\n \t The fastboot \"flash\" command allows to write the downloaded image\ndiff --git a/drivers/fastboot/fb_block.c b/drivers/fastboot/fb_block.c\nindex 51d1abb18c7..c2c3a285d77 100644\n--- a/drivers/fastboot/fb_block.c\n+++ b/drivers/fastboot/fb_block.c\n@@ -11,6 +11,7 @@\n #include <image-sparse.h>\n #include <malloc.h>\n #include <part.h>\n+#include <vsprintf.h>\n \n /**\n * FASTBOOT_MAX_BLOCKS_ERASE - maximum blocks to erase per derase call\n@@ -124,6 +125,79 @@ static lbaint_t fb_block_sparse_reserve(struct sparse_storage *info,\n \treturn blkcnt;\n }\n \n+/**\n+ * parse_device_partition() - Parse device:partition format\n+ * @part_name: Input string in format \"N:partition\" or \"partition\"\n+ * @device: Output device number\n+ * @partition_name: Output partition name pointer\n+ *\n+ * Parses the input string to extract device number and partition name.\n+ * If no device is specified, uses the default from config.\n+ */\n+static void parse_device_partition(const char *part_name, int *device,\n+\t\t\t\t const char **partition_name)\n+{\n+\tconst char *colon_pos;\n+\n+\t/* Default: no device specified, use config default */\n+\t*device = config_opt_enabled(CONFIG_FASTBOOT_FLASH_BLOCK,\n+\t\t\t\t CONFIG_FASTBOOT_FLASH_BLOCK_DEVICE_ID, -1);\n+\t*partition_name = part_name;\n+\n+\t/* Override if device:partition format detected */\n+\tcolon_pos = strchr(part_name, ':');\n+\tif (colon_pos && colon_pos > part_name) {\n+\t\t*device = simple_strtoul(part_name, NULL, 10);\n+\t\t*partition_name = colon_pos + 1;\n+\t}\n+}\n+\n+/**\n+ * get_block_device() - Get block device descriptor\n+ * @interface: Block interface name (e.g., \"mmc\", \"scsi\")\n+ * @device: Device number\n+ * @response: Fastboot response buffer\n+ *\n+ * Returns: Block device descriptor or NULL on error\n+ */\n+static struct blk_desc *get_block_device(const char *interface, int device,\n+\t\t\t\t\t char *response)\n+{\n+\tstruct blk_desc *dev_desc;\n+\n+\tif (!interface || !strcmp(interface, \"\")) {\n+\t\tfastboot_fail(\"block interface isn't provided\", response);\n+\t\treturn NULL;\n+\t}\n+\n+\tdev_desc = blk_get_dev(interface, device);\n+\tif (!dev_desc)\n+\t\tfastboot_fail(\"no such device\", response);\n+\n+\treturn dev_desc;\n+}\n+\n+/**\n+ * is_partition_table_name() - Check if name matches partition table target\n+ * @part_name: Partition name to check\n+ * @table_name: Config name for partition table (e.g., \"gpt\", \"mbr\")\n+ *\n+ * Returns: true if part_name matches table_name (with or without device prefix)\n+ */\n+static bool is_partition_table_name(const char *part_name, const char *table_name)\n+{\n+\tconst char *colon_pos;\n+\n+\tif (strcmp(part_name, table_name) == 0)\n+\t\treturn true;\n+\n+\tcolon_pos = strchr(part_name, ':');\n+\tif (colon_pos && strcmp(colon_pos + 1, table_name) == 0)\n+\t\treturn true;\n+\n+\treturn false;\n+}\n+\n int fastboot_block_get_part_info(const char *part_name,\n \t\t\t\t struct blk_desc **dev_desc,\n \t\t\t\t struct disk_partition *part_info,\n@@ -133,25 +207,21 @@ int fastboot_block_get_part_info(const char *part_name,\n \tconst char *interface = config_opt_enabled(CONFIG_FASTBOOT_FLASH_BLOCK,\n \t\t\t\t\t\t CONFIG_FASTBOOT_FLASH_BLOCK_INTERFACE_NAME,\n \t\t\t\t\t\t NULL);\n-\tconst int device = config_opt_enabled(CONFIG_FASTBOOT_FLASH_BLOCK,\n-\t\t\t\t\t CONFIG_FASTBOOT_FLASH_BLOCK_DEVICE_ID, -1);\n+\tint device;\n+\tconst char *partition_name;\n \n \tif (!part_name || !strcmp(part_name, \"\")) {\n \t\tfastboot_fail(\"partition not given\", response);\n \t\treturn -ENOENT;\n \t}\n-\tif (!interface || !strcmp(interface, \"\")) {\n-\t\tfastboot_fail(\"block interface isn't provided\", response);\n-\t\treturn -EINVAL;\n-\t}\n \n-\t*dev_desc = blk_get_dev(interface, device);\n-\tif (!dev_desc) {\n-\t\tfastboot_fail(\"no such device\", response);\n+\tparse_device_partition(part_name, &device, &partition_name);\n+\n+\t*dev_desc = get_block_device(interface, device, response);\n+\tif (!*dev_desc)\n \t\treturn -ENODEV;\n-\t}\n \n-\tret = part_get_info_by_name(*dev_desc, part_name, part_info);\n+\tret = part_get_info_by_name(*dev_desc, partition_name, part_info);\n \tif (ret < 0)\n \t\tfastboot_fail(\"failed to get partition info\", response);\n \n@@ -310,12 +380,114 @@ void fastboot_block_write_sparse_image(struct blk_desc *dev_desc, struct disk_pa\n \t\tfastboot_okay(NULL, response);\n }\n \n+#if CONFIG_IS_ENABLED(EFI_PARTITION)\n+/**\n+ * flash_gpt_partition_table() - Flash GPT partition table\n+ * @part_name: Partition name (format: \"gpt\" or \"N:gpt\")\n+ * @download_buffer: Buffer containing GPT data\n+ * @response: Fastboot response buffer\n+ */\n+static void flash_gpt_partition_table(const char *part_name, void *download_buffer,\n+\t\t\t\t char *response)\n+{\n+\tconst char *interface = config_opt_enabled(CONFIG_FASTBOOT_FLASH_BLOCK,\n+\t\t\t\t\t\t CONFIG_FASTBOOT_FLASH_BLOCK_INTERFACE_NAME,\n+\t\t\t\t\t\t NULL);\n+\tstruct blk_desc *dev_desc;\n+\tint device;\n+\tconst char *partition_name;\n+\n+\tparse_device_partition(part_name, &device, &partition_name);\n+\n+\tdev_desc = get_block_device(interface, device, response);\n+\tif (!dev_desc)\n+\t\treturn;\n+\n+\tprintf(\"%s: updating MBR, Primary and Backup GPT(s) on %s device %d\\n\",\n+\t __func__, interface, dev_desc->devnum);\n+\n+\tif (is_valid_gpt_buf(dev_desc, download_buffer)) {\n+\t\tprintf(\"%s: invalid GPT - refusing to write to flash\\n\", __func__);\n+\t\tfastboot_fail(\"invalid GPT partition\", response);\n+\t\treturn;\n+\t}\n+\n+\tif (write_mbr_and_gpt_partitions(dev_desc, download_buffer)) {\n+\t\tprintf(\"%s: writing GPT partitions failed\\n\", __func__);\n+\t\tfastboot_fail(\"writing GPT partitions failed\", response);\n+\t\treturn;\n+\t}\n+\n+\tpart_init(dev_desc);\n+\tprintf(\"........ success\\n\");\n+\tfastboot_okay(NULL, response);\n+}\n+#endif\n+\n+#if CONFIG_IS_ENABLED(DOS_PARTITION)\n+/**\n+ * flash_mbr_partition_table() - Flash MBR partition table\n+ * @part_name: Partition name (format: \"mbr\" or \"N:mbr\")\n+ * @download_buffer: Buffer containing MBR data\n+ * @response: Fastboot response buffer\n+ */\n+static void flash_mbr_partition_table(const char *part_name, void *download_buffer,\n+\t\t\t\t char *response)\n+{\n+\tconst char *interface = config_opt_enabled(CONFIG_FASTBOOT_FLASH_BLOCK,\n+\t\t\t\t\t\t CONFIG_FASTBOOT_FLASH_BLOCK_INTERFACE_NAME,\n+\t\t\t\t\t\t NULL);\n+\tstruct blk_desc *dev_desc;\n+\tint device;\n+\tconst char *partition_name;\n+\n+\tparse_device_partition(part_name, &device, &partition_name);\n+\n+\tdev_desc = get_block_device(interface, device, response);\n+\tif (!dev_desc)\n+\t\treturn;\n+\n+\tprintf(\"%s: updating MBR on %s device %d\\n\", __func__, interface,\n+\t dev_desc->devnum);\n+\n+\tif (is_valid_dos_buf(download_buffer)) {\n+\t\tprintf(\"%s: invalid MBR - refusing to write to flash\\n\", __func__);\n+\t\tfastboot_fail(\"invalid MBR partition\", response);\n+\t\treturn;\n+\t}\n+\n+\tif (write_mbr_sector(dev_desc, download_buffer)) {\n+\t\tprintf(\"%s: writing MBR partition failed\\n\", __func__);\n+\t\tfastboot_fail(\"writing MBR partition failed\", response);\n+\t\treturn;\n+\t}\n+\n+\tpart_init(dev_desc);\n+\tprintf(\"........ success\\n\");\n+\tfastboot_okay(NULL, response);\n+}\n+#endif\n+\n void fastboot_block_flash_write(const char *part_name, void *download_buffer,\n \t\t\t\tu32 download_bytes, char *response)\n {\n \tstruct blk_desc *dev_desc;\n \tstruct disk_partition part_info;\n \n+#if CONFIG_IS_ENABLED(EFI_PARTITION)\n+\tif (is_partition_table_name(part_name, CONFIG_FASTBOOT_GPT_NAME)) {\n+\t\tflash_gpt_partition_table(part_name, download_buffer, response);\n+\t\treturn;\n+\t}\n+#endif\n+\n+#if CONFIG_IS_ENABLED(DOS_PARTITION)\n+\tif (is_partition_table_name(part_name, CONFIG_FASTBOOT_MBR_NAME)) {\n+\t\tflash_mbr_partition_table(part_name, download_buffer, response);\n+\t\treturn;\n+\t}\n+#endif\n+\n \tif (fastboot_block_get_part_info(part_name, &dev_desc, &part_info, response) < 0)\n \t\treturn;\n \n@@ -326,4 +498,4 @@ void fastboot_block_flash_write(const char *part_name, void *download_buffer,\n \t\tfastboot_block_write_raw_image(dev_desc, &part_info, part_name,\n \t\t\t\t\t download_buffer, download_bytes, response);\n \t}\n-}\n+}\n\\ No newline at end of file\n", "prefixes": [ "1/2" ] }