From patchwork Sat Jul 18 20:51:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 1331614 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.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=orjIfKeT; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=F/b8xQ1A; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B8KxQ4c60z9sR4 for ; Sun, 19 Jul 2020 06:54:50 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=UBmlE/8lnTwT2UiYYBXBeo9pS5hl3/6aghS+lapS6Ug=; b=orjIfKeTVHtuAblE8Xc3Ql6P5 SvUOreMxRVcphtIg+Hhy7ebX2zPSO0ySQA6r3TGDBQgWucf737VMlGpeJvhxWBHwWQ4Lg2nbt4xTp 7N/WDrX2KPk2qjqF0xjlonZ/oyO8jQDGfNGZlrGPX2M9gFayCul5ASRq5dgTrvLlzvE8PpqmV1kde P7KsArFfSuahz0DfudJGynTQGOxyXHvX01tDZ8xfnTuZtdNfZIGKSpi9NTjaDGbfZjr5Zn1Kae71w FonyDCp76Nl78ahg99S5+fRNJsRZD1she+O5GB22EP1EaAwnBuNdzzEFXm1zmiJDClOOpWnD+nxx9 XqtD/G1dw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwtpM-0002uO-W1; Sat, 18 Jul 2020 20:53:01 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwtpI-0002t2-Px for openwrt-devel@lists.openwrt.org; Sat, 18 Jul 2020 20:52:57 +0000 Received: by mail-pf1-x443.google.com with SMTP id s26so7077150pfm.4 for ; Sat, 18 Jul 2020 13:52:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8tIwoeb1oDZsUtStlDhKczuaw83SeS1i+RbB3syvQq0=; b=F/b8xQ1AK5IUSX+JhfvMhHt9fCIgXzyISz1ufq3TMB3CZDHtjLuNUPGmuiFYFz4vKv pU8t4DODA52X/3w6TI2crkOg5FWz3jjBSdvdAUy57zs0y9Y9eNQ+8BbI944H4VUmqUg0 iaoLAbJD9Y59QrY2dRGKIb+lQYWqiZ2KyPJ9D6X3Gcv1eXm6up7Z4eDltX8zKfQFcLWx Fs27VkcLb8hPb4jk1Bptcf04yRXMS8F+pz98EX47qLzzAk4TYF5ik0TxgoAOyh0qDny0 T3OzdZfOHEsGY+8iaM1gGAyms/VbgSJqPti+PUs2V/QAFL49DIoa7jO4fAhEFPAg9KeL mRMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8tIwoeb1oDZsUtStlDhKczuaw83SeS1i+RbB3syvQq0=; b=h8SugryX5cGvd/6Pgko9qJSAH9D+T2wCTW95LXWrEqtcf1eurG7LdX6hgqSYnyXmth z3/tNYOHWsrb5pERkcUmQ0Qy6BRTvPqPm5TqW3/M2DEHR1OAmZtp8W6nuxC31UDcTp+G cBf3Orwovjn+CW7UFJkm061lpdlTBoyakjuGIWTwV0lIU8Gdt2oA/aJJOimafwePI4fA x3Y+2ZqLZOkGg87LovKShN2AaFCjwFbMVD8aiblyLfXatDzXQPaKi9dQlUtX8LrO1mRT wc7LZyg9fehH+Ft2nQQ4cbtTugYpHcsn1C505hZGeaaC0dNwby87X1zUSZhN7ei3tXGs dbYQ== X-Gm-Message-State: AOAM533P9je70/CtfawPWm9n2tihX5lBZjRAis9Y1gvBrFjKMZwDS2MR V1Cgq5pEWdnpV1BlbNDEeeyzq2LteiM= X-Google-Smtp-Source: ABdhPJzBuRzZy1Bqi+ZkqIUjV4Ax/F9jOieW+E6KLzsXo73I63mavVaja1w9V/4my7h1XZb2c3ri2g== X-Received: by 2002:a62:788d:: with SMTP id t135mr12371636pfc.315.1595105574106; Sat, 18 Jul 2020 13:52:54 -0700 (PDT) Received: from localhost ([2601:647:5800:8d47:9eef:d5ff:fefc:64ae]) by smtp.gmail.com with ESMTPSA id t187sm11082018pgb.76.2020.07.18.13.52.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Jul 2020 13:52:53 -0700 (PDT) From: Brian Norris To: openwrt-devel@lists.openwrt.org Subject: [RFC PATCH 1/5] firmware-utils/ptgen: add Chromium OS kernel partition support Date: Sat, 18 Jul 2020 20:51:44 +0000 Message-Id: <20200718205148.1743807-2-computersforpeace@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200718205148.1743807-1-computersforpeace@gmail.com> References: <20200718205148.1743807-1-computersforpeace@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200718_165256_933824_7924E364 X-CRM114-Status: GOOD ( 17.46 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:443 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [computersforpeace[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Brian Norris Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Chrom{ium,e} OS (shortened as "CrOS") bootloaders use a custom GPT partition type to locate their kernel(s), with custom attributes for noting properties around which partition(s) should be active and how many times they've been tried as part of their A/B in-place upgrade system. OpenWRT doesn't use A/B updates for upgrades (instead, just shutting things down far enough to reprogram the necessary partitions), so all we need to do is tell the bootloader which one is the kernel partition, and how to use it (i.e., set the "successful" and "priority" attributes). ptgen already supports some basic GPT partition creation, so just add support for a '-T ' argument. Currently, this only supports '-T cros_kernel', but it could be extended if there are other GPT partition types needed. For GPT attribute and GUID definitions, see the CrOS verified boot sources: https://chromium.googlesource.com/chromiumos/platform/vboot_reference/+/refs/heads/master/firmware/lib/cgptlib/include/cgptlib_internal.h https://chromium.googlesource.com/chromiumos/platform/vboot_reference/+/refs/heads/master/firmware/include/gpt.h The GUID is also recognized in fdisk, and likely other utilities, but creation/manipulation is typically done via the 'cgpt' utility, provided as part of the vboot_reference project. Signed-off-by: Brian Norris --- tools/firmware-utils/src/ptgen.c | 39 +++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c index 223ee295611f..bc1da6d64061 100644 --- a/tools/firmware-utils/src/ptgen.c +++ b/tools/firmware-utils/src/ptgen.c @@ -80,6 +80,10 @@ typedef struct { GUID_INIT( 0x21686148, 0x6449, 0x6E6F, \ 0x74, 0x4E, 0x65, 0x65, 0x64, 0x45, 0x46, 0x49) +#define GUID_PARTITION_CHROME_OS_KERNEL \ + GUID_INIT( 0xFE3A2A5D, 0x4F32, 0x41A7, \ + 0xB7, 0x25, 0xAC, 0xCC, 0x32, 0x85, 0xA3, 0x09) + #define GPT_HEADER_SIZE 92 #define GPT_ENTRY_SIZE 128 #define GPT_ENTRY_MAX 128 @@ -109,6 +113,9 @@ struct partinfo { unsigned long start; unsigned long size; int type; + bool has_gtype; + guid_t gtype; /* GPT partition type */ + uint64_t gattr; /* GPT partition attributes */ }; /* GPT Partition table header */ @@ -248,6 +255,19 @@ static inline int guid_parse(char *buf, guid_t *guid) return 0; } +/* Map GPT partition types to partition GUIDs. */ +static inline bool parse_gpt_parttype(const char *type, struct partinfo *part) +{ + if (!strcmp(type, "cros_kernel")) { + part->has_gtype = true; + part->gtype = GUID_PARTITION_CHROME_OS_KERNEL; + part->gattr = (1ULL << 48) | /* priority=1 */ + (1ULL << 56); /* success=1 */ + return true; + } + return false; +} + /* init an utf-16 string from utf-8 string */ static inline void init_utf16(char *str, uint16_t *buf, unsigned bufsize) { @@ -396,12 +416,15 @@ static int gen_gptable(uint32_t signature, guid_t guid, unsigned nr) gpte[i].end = cpu_to_le64(sect -1); gpte[i].guid = guid; gpte[i].guid.b[sizeof(guid_t) -1] += i + 1; - if (parts[i].type == 0xEF || (i + 1) == (unsigned)active) { + if (parts[i].has_gtype) { + gpte[i].type = parts[i].gtype; + } else if (parts[i].type == 0xEF || (i + 1) == (unsigned)active) { gpte[i].type = GUID_PARTITION_SYSTEM; init_utf16("EFI System Partition", (uint16_t *)gpte[i].name, GPT_ENTRY_NAME_SIZE / sizeof(uint16_t)); } else { gpte[i].type = GUID_PARTITION_BASIC_DATA; } + gpte[i].attr = parts[i].gattr; if (verbose) fprintf(stderr, "Partition %d: start=%" PRIu64 ", end=%" PRIu64 ", size=%" PRIu64 "\n", @@ -498,7 +521,9 @@ fail: static void usage(char *prog) { - fprintf(stderr, "Usage: %s [-v] [-n] [-g] -h -s -o [-a 0..4] [-l ] [-G ] [[-t ] -p [@]...] \n", prog); + fprintf(stderr, "Usage: %s [-v] [-n] [-g] -h -s -o \n" + " [-a 0..4] [-l ] [-G ]\n" + " [[-t | -T ] -p [@]...] \n", prog); exit(EXIT_FAILURE); } @@ -512,7 +537,7 @@ int main (int argc, char **argv) guid_t guid = GUID_INIT( signature, 0x2211, 0x4433, \ 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0x00); - while ((ch = getopt(argc, argv, "h:s:p:a:t:o:vngl:S:G:")) != -1) { + while ((ch = getopt(argc, argv, "h:s:p:a:t:T:o:vngl:S:G:")) != -1) { switch (ch) { case 'o': filename = optarg; @@ -560,6 +585,14 @@ int main (int argc, char **argv) case 'S': signature = strtoul(optarg, NULL, 0); break; + case 'T': + if (!parse_gpt_parttype(optarg, &parts[part])) { + fprintf(stderr, + "Invalid GPT partition type \"%s\"\n", + optarg); + exit(EXIT_FAILURE); + } + break; case 'G': if (guid_parse(optarg, &guid)) { fputs("Invalid guid string\n", stderr); From patchwork Sat Jul 18 20:51:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 1331615 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.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=aDrGyGna; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=rgkGcZJP; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B8KxX70vCz9sR4 for ; Sun, 19 Jul 2020 06:54:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=tLIt3aZX3DAQ1aKapqTJPcT22kc4E4FJ/atC/RVA9nQ=; b=aDrGyGna2SVeG9HIU3Cpg5Dup n1ndVDGJ1zQCTVLnGoi1z8LVeFK6psEhvGjU/Z9PqhYSKoutzOvpHtKIUmxl5q5Nma3sC8iAsF2x6 YvV401vydIpyQaqz3iEjcJFRQ2p+IDMEbE86ujefnHIx8urUFHIfcDZZ4+QlYl/DCsC1Dh6bl31dG f+udTGXNM//d4synjNPo3hz6aR9hMY9SXstw+fSwsVeoNEgcRnSBdiMGrIoA3wyM4Q7PvZUUEk8tO cxgwWQcV3zZbbl+MrRPrBEgFfAa4Rm90OL/TrhBZhzYHhE1LxJGfiLMZ7HTIOfkwCMHE39VnZPERZ foG1SNS2Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwtpT-0002w4-TE; Sat, 18 Jul 2020 20:53:07 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwtpK-0002tW-Dh for openwrt-devel@lists.openwrt.org; Sat, 18 Jul 2020 20:53:02 +0000 Received: by mail-pl1-x644.google.com with SMTP id k4so6880588pld.12 for ; Sat, 18 Jul 2020 13:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vXJgdnWI++JYs8hnSv3F7WyyLs54HiC0cVlGEt+Kmz8=; b=rgkGcZJPJe9S9wE9W0HeuzyvkABsCqvVTolho3gY/G2iu83+GKiUFyPwqWCBdfAOYX e21wpHLjOA31x52TrevtWRQLVTja7l+IT4jENFv2/fdqFY87cnPt1sF/f3g0o86GqoED KjtjPFrjPN6NtvKWBUnOENKb9y1kbNGNwcOqluJFw3A254/EMtu2OgCcFy++39ai4AQT XASvfxXVLEjmh+Y9X+iIs8Z0+vw7aIC5NkpHcQRYBMtYpTISBXmLMOrLwAvYEpk2M30I VTeYvhY4nkWy5p5uT0p+eR7Cywr2JqoRu1IsxPl7m1a50iEtul/FspRbH+gqlDh6aEll CSzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vXJgdnWI++JYs8hnSv3F7WyyLs54HiC0cVlGEt+Kmz8=; b=QOiQtxG8iPGRdMklS32f8s2mWmRBjeZ3h7GCDwaSpsHc4Ud2/IcdKXcLuQIoekdHIs p5Maqs6t/oa0c6i4nJe+svhl7exaTbWPwqHtwOUp6q0uNZbCkeeO65Lt1SHGM/eFXGuE 5yCXrk1WXtqjj+1+jafl0ZubBkn0dH5WApJH6YXkklIpw7lIAjHUZixC6mQzYwncDsry CMF/e2X3eyHMllmBCIfdnTMijZYI/+Rh7igdZM3BiHSV6U/YHBUDFicNS160sUpb3hIc i1dfWLLXBQ/ouBjb+CZGUjB9pou76wP/YrqM7Hf4PrhrvN30hDygBi6yhwwlehbh/+nA jlKw== X-Gm-Message-State: AOAM530C9iwgGdy0lELWAqOVR/0ig/rlnfpaRQZMb5xaUL9WXPr8Cb/Y xivPzwR9ocUBnNH+GTJRlOqJ0M/MEMU= X-Google-Smtp-Source: ABdhPJwsSSCCOq+Zl1dtCzYw2/OP+fwoLOHoguQRYz0S+dHmZ6evvWgq57/IzHRFxO9Jq8g8bucXDg== X-Received: by 2002:a17:90a:5208:: with SMTP id v8mr16647425pjh.29.1595105575600; Sat, 18 Jul 2020 13:52:55 -0700 (PDT) Received: from localhost ([2601:647:5800:8d47:9eef:d5ff:fefc:64ae]) by smtp.gmail.com with ESMTPSA id c132sm11376176pfb.112.2020.07.18.13.52.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Jul 2020 13:52:55 -0700 (PDT) From: Brian Norris To: openwrt-devel@lists.openwrt.org Subject: [RFC PATCH 2/5] firmware-utils/cros-vbutil: add Chrome OS vboot kernel-signing utility Date: Sat, 18 Jul 2020 20:51:45 +0000 Message-Id: <20200718205148.1743807-3-computersforpeace@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200718205148.1743807-1-computersforpeace@gmail.com> References: <20200718205148.1743807-1-computersforpeace@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200718_165258_747217_5CDF1C57 X-CRM114-Status: GOOD ( 24.00 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:644 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [computersforpeace[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Brian Norris Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Chrom{ium,e} OS based devices use a Coreboot+Depthcharge-based firmware, which verifies and loads a kernel packed in a verified-boot payload. The verification tooling (both for creating and verifying payloads) is implemented here: https://chromium.googlesource.com/chromiumos/platform/vboot_reference Devices running such bootloaders also tend to support a "developer mode," where a device can be unlocked to run arbitrary kernel payloads, using the same verified-boot format plus well-known developer keys. More information can be found here: https://chromium.googlesource.com/chromiumos/docs/+/master/developer_mode.md Rather than build and package the vboot_reference utilities as part of the base OpenWRT tools, I chose to reimplement just the portion that's required for signing payloads. I also embed the developer key directly in the source for convenience, though it's certainly possible to provide other keys too, if one were to build their own firmware that accepts it. This tool is essentially the same as running something like this, using the Chromium OS tooling: vbutil_kernel --pack kernel_partition.bin \ --keyblock /usr/share/vboot/devkeys/kernel.keyblock \ --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \ --version 1 \ --vmlinuz kernel.bin \ --bootloader zero.txt \ --config commnad_line.txt \ --arch ${ARCH} I have also packaged the Chromium OS vboot_reference tooling for the packages feed, as it can be useful beyond simply creating a bootable image (e.g., manipulating Chromium OS specific GPT attributes, handling other NVRAM attributes, vboot packing/unpacking/verifying): https://github.com/openwrt/packages/pull/12829 The vboot_reference tools are released by Google under a BSD 3-clause license. I've provided the original license text as well as a GPL-2 notice for my modifications (essentially just borrowing the data structures and rewriting everything else). Signed-off-by: Brian Norris --- tools/firmware-utils/Makefile | 1 + tools/firmware-utils/src/cros-vbutil.c | 609 +++++++++++++++++++++++++ 2 files changed, 610 insertions(+) create mode 100644 tools/firmware-utils/src/cros-vbutil.c diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile index 3dd9ac5c2cc1..8216c97e9cfc 100644 --- a/tools/firmware-utils/Makefile +++ b/tools/firmware-utils/Makefile @@ -29,6 +29,7 @@ define Host/Compile $(call cc,buffalo-enc buffalo-lib,-Wall) $(call cc,buffalo-tag buffalo-lib,-Wall) $(call cc,buffalo-tftp buffalo-lib,-Wall) + $(call cc,cros-vbutil,-lcrypto -lpthread) $(call cc,dgfirmware) $(call cc,dgn3500sum,-Wall) $(call cc,dns313-header,-Wall) diff --git a/tools/firmware-utils/src/cros-vbutil.c b/tools/firmware-utils/src/cros-vbutil.c new file mode 100644 index 000000000000..2040c5901985 --- /dev/null +++ b/tools/firmware-utils/src/cros-vbutil.c @@ -0,0 +1,609 @@ +/* + * cros-vbutil - Tool for signing kernels using the Chromium OS verified boot + * format, using widely-shared "developer" keys. The output of this tool is + * intended to be written to a GPT partition of type "Chrome OS Kernel", such + * that a Chromium OS bootloader can find it. + * + * Much of this is adapted from Google's vboot_reference project found here: + * https://chromium.googlesource.com/chromiumos/platform/vboot_reference + * + * Copyright (c) 2010 The Chromium OS Authors. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Rewritten: + * Copyright (c) 2020 Brian Norris + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#define BLOCK_PAD 65536 +/* Sections are aligned to 4K blocks */ +#define ALIGN 4096 +#define ROUNDUP(x) (((x) + (ALIGN-1)) & ~(ALIGN-1)) + +/* + * Signature size, in bytes. This is an RSA-2048 encryption of a SHA256 hash. + */ +#define SIG_SIZE (2048 / 8) + +/* + * From vboot_reference: tests/devkeys/kernel.keyblock + */ +static const unsigned char keyblock[] = { + 0x43, 0x48, 0x52, 0x4f, 0x4d, 0x45, 0x4f, 0x53, 0x02, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xb8, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xa0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x78, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x48, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x78, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0xcb, 0x02, 0x40, 0x41, + 0x1d, 0x2d, 0x86, 0x0f, 0x6d, 0x53, 0xcc, 0xcc, 0xa7, 0x9b, 0x1b, 0xca, + 0xdc, 0x22, 0xc4, 0x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xfe, 0x65, 0x86, 0x98, 0xa2, 0xa8, 0x49, 0x7d, 0x26, + 0x45, 0x14, 0x04, 0x10, 0xe3, 0x38, 0x4b, 0x66, 0x9c, 0x5c, 0x2c, 0xe8, + 0xd9, 0x06, 0xd4, 0xc3, 0x05, 0x94, 0x1c, 0x7b, 0x23, 0x89, 0x86, 0x1d, + 0x32, 0xbb, 0x23, 0x90, 0x2b, 0x72, 0xd7, 0x90, 0x53, 0x52, 0x10, 0x12, + 0xd0, 0xc2, 0xe2, 0x72, 0x81, 0x70, 0x3c, 0xb1, 0x27, 0x42, 0xec, 0xbf, + 0x2b, 0x54, 0xd6, 0xcb, 0x61, 0xea, 0xb4, 0xd4, 0xa8, 0xde, 0xf3, 0xdf, + 0x3d, 0xd1, 0x17, 0xde, 0x86, 0x89, 0xf4, 0xa1, 0x28, 0x5e, 0xda, 0xb4, + 0x47, 0x19, 0x9b, 0xc2, 0xce, 0x49, 0xea, 0x63, 0xda, 0x42, 0x1c, 0x85, + 0x1c, 0xab, 0x6c, 0xd7, 0xc2, 0xfd, 0x34, 0x1b, 0xd5, 0x11, 0xa2, 0x44, + 0xb7, 0x7a, 0x85, 0x61, 0x03, 0xba, 0xd4, 0x64, 0xe1, 0x49, 0x87, 0x92, + 0xe6, 0xdc, 0x39, 0x94, 0x9c, 0xba, 0xef, 0x58, 0x9e, 0x0e, 0x36, 0x98, + 0xd7, 0xd2, 0x4c, 0x14, 0x71, 0x94, 0x78, 0xaf, 0x86, 0xe7, 0x2f, 0xe9, + 0xf9, 0x20, 0x4d, 0xfe, 0xda, 0xd7, 0x3f, 0x89, 0xc1, 0x59, 0xae, 0xbd, + 0x60, 0x9b, 0x97, 0xa4, 0x66, 0x00, 0xbb, 0x7b, 0xd0, 0x49, 0x85, 0x6f, + 0x7b, 0x01, 0x24, 0xc3, 0x48, 0xe2, 0xc7, 0x61, 0x98, 0x9c, 0xe5, 0x93, + 0x87, 0x04, 0x09, 0x3a, 0x92, 0x54, 0x1f, 0xb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x7f, 0xc0, 0xf4, 0x6c, + 0x3c, 0x0b, 0x52, 0xe2, 0x07, 0xde, 0x70, 0x8b, 0xaf, 0x84, 0x95, 0x1b, + 0x46, 0x95, 0x69, 0x05, 0x92, 0xea, 0x36, 0xa5, 0xca, 0x50, 0xdb, 0x49, + 0xc8, 0x44, 0xee, 0x7c, 0x49, 0x40, 0x34, 0x05, 0xf3, 0x06, 0x1f, 0x1c, + 0xcc, 0x78, 0x62, 0x1b, 0x9d, 0xe2, 0x4f, 0x3e, 0x04, 0x96, 0xba, 0xd0, + 0xc7, 0xa2, 0x3a, 0xaa, 0xf7, 0xc3, 0xae, 0xc0, 0x6b, 0xca, 0xc8, 0x59, + 0x90, 0xe0, 0x45, 0x7b, 0x4b, 0x60, 0xbf, 0xae, 0x15, 0x25, 0xd0, 0xa2, + 0x2f, 0x95, 0x6a, 0x2e, 0x37, 0x24, 0x15, 0x69, 0x0e, 0x3a, 0x6d, 0x40, + 0x21, 0xf6, 0x74, 0x5c, 0xa6, 0x9f, 0xe0, 0x03, 0x60, 0x04, 0x59, 0x70, + 0x70, 0xa0, 0x46, 0xf4, 0xdf, 0x0a, 0x4b, 0x14, 0xab, 0x87, 0x0c, 0xaa, + 0x64, 0x9b, 0x82, 0xca, 0x21, 0xb0, 0x72, 0xfa, 0x8b, 0x37, 0xf5, 0x60, + 0xd7, 0xb7, 0x4e, 0x72, 0x5e, 0x13, 0x23, 0x73, 0x84, 0x6c, 0xd1, 0x8d, + 0x72, 0xa2, 0x15, 0x8b, 0x51, 0x38, 0x90, 0x68, 0x90, 0xd9, 0x8b, 0x65, + 0x30, 0x61, 0xdb, 0x51, 0x80, 0x58, 0xdd, 0xc3, 0xf0, 0x29, 0x33, 0xdc, + 0x39, 0x92, 0xbf, 0x27, 0xe6, 0xc7, 0x82, 0xf6, 0xea, 0xcf, 0x21, 0xd2, + 0xa0, 0x38, 0x02, 0x57, 0x52, 0xf5, 0xdd, 0x07, 0x99, 0xe3, 0x09, 0xd7, + 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f8, 0xbe, 0x4b, 0xa9, 0x04, 0xb4, 0xf9, 0x36, 0xcc, 0xd9, 0xd5, 0x91, + 0xac, 0x7e, 0xe9, 0x13, 0xc0, 0x7f, 0xca, 0xd7, 0xdc, 0xbe, 0xa9, 0xb0, + 0xd6, 0x28, 0x17, 0x2f, 0xd6, 0xdf, 0x0e, 0x6b, 0x48, 0x11, 0xd6, 0x51, + 0xc7, 0x6d, 0x87, 0xf6, 0x08, 0xb7, 0x6c, 0x69, 0xf7, 0xd6, 0x28, 0x50, + 0x7e, 0x74, 0xad, 0x96, 0x6a, 0x0c, 0xca, 0x6b, 0xb1, 0xf1, 0xde, 0xa3, + 0x5f, 0x23, 0xf5, 0x2a, 0x44, 0x11, 0x0f, 0xa3, 0xf7, 0x24, 0x36, 0x1b, + 0x33, 0xe6, 0x7e, 0xd9, 0x0e, 0xa5, 0x8b, 0xa0, 0xb8, 0x8b, 0x85, 0xee, + 0xd0, 0xe4, 0x69, 0x43, 0xc6, 0xf9, 0x5f, 0x27, 0xa5, 0xc9, 0x61, 0x3b, + 0x8e, 0xaf, 0x62, 0x77, 0x42, 0xb6, 0x27, 0x5f, 0xed, 0x96, 0x86, 0xb3, + 0xef, 0x32, 0x31, 0x43, 0x2e, 0x7b, 0xaf, 0x5b, 0xe2, 0x75, 0x82, 0x72, + 0xad, 0x3b, 0x5d, 0x92, 0xc1, 0x15, 0xaa, 0xfb, 0x21, 0x07, 0xe9, 0xaa, + 0xc4, 0xe2, 0xd7, 0x99, 0x83, 0x6c, 0x72, 0x39, 0x6f, 0x35, 0x20, 0x9d, + 0xe0, 0xd8, 0xf8, 0xdb, 0x72, 0x24, 0xe5, 0x8d, 0x29, 0xfd, 0x24, 0x7b, + 0xbc, 0x48, 0xe9, 0xbb, 0xc2, 0x84, 0xc7, 0xb9 +}; +static unsigned int keyblock_len = sizeof(keyblock); + +/* + * RSA 2048-bit key from vboot_reference: + * tests/devkeys/kernel_data_key.vbprivk, minus the 8-byte custom header. + */ +static const unsigned char privk[] = { + 0x30, 0x82, 0x04, 0xa3, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, + 0xcb, 0xd6, 0x54, 0x2b, 0xbf, 0xec, 0x42, 0x27, 0xb1, 0x3c, 0x70, 0x81, + 0x72, 0xe2, 0xc2, 0xd0, 0x12, 0x10, 0x52, 0x53, 0x90, 0xd7, 0x72, 0x2b, + 0x90, 0x23, 0xbb, 0x32, 0x1d, 0x86, 0x89, 0x23, 0x7b, 0x1c, 0x94, 0x05, + 0xc3, 0xd4, 0x06, 0xd9, 0xe8, 0x2c, 0x5c, 0x9c, 0x66, 0x4b, 0x38, 0xe3, + 0x10, 0x04, 0x14, 0x45, 0x26, 0x7d, 0x49, 0xa8, 0xa2, 0x98, 0x86, 0x65, + 0xfe, 0x2c, 0x3d, 0xe4, 0x1c, 0x76, 0xda, 0xda, 0xda, 0xd3, 0x6a, 0x37, + 0x88, 0xa2, 0xe5, 0x20, 0x11, 0x96, 0x40, 0x6b, 0x05, 0x02, 0xc5, 0x0a, + 0x5f, 0x09, 0xc6, 0xe6, 0x20, 0xc6, 0x01, 0xc6, 0x54, 0x08, 0x0b, 0x1e, + 0xb4, 0xa9, 0x3f, 0xc9, 0x67, 0x81, 0xd9, 0x2b, 0xd0, 0xdc, 0x7d, 0xa7, + 0x97, 0x6f, 0x8b, 0x78, 0x33, 0xb7, 0xd7, 0x52, 0x2a, 0x41, 0x69, 0x48, + 0x69, 0x96, 0x8f, 0xc5, 0x0a, 0x1b, 0x06, 0x88, 0x1f, 0xfb, 0xe8, 0xb0, + 0x97, 0xbd, 0x6d, 0x3d, 0x28, 0x82, 0xfe, 0xd5, 0x6e, 0xa1, 0x57, 0x1e, + 0xcb, 0x43, 0x7e, 0xba, 0x11, 0x8c, 0xc5, 0x6a, 0xf0, 0x92, 0x53, 0x7b, + 0xb2, 0x21, 0x26, 0xdb, 0xf8, 0x8c, 0x5a, 0x1b, 0x9f, 0x1d, 0x81, 0xa9, + 0xea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0x68, 0xe8, 0xd9, 0x4b, 0x7f, 0xbc, 0xca, + 0xb5, 0x84, 0x01, 0x71, 0x11, 0x33, 0x4d, 0xe1, 0x0a, 0xe8, 0xa7, 0x95, + 0xcc, 0x23, 0x59, 0x19, 0xb5, 0x82, 0xaa, 0xae, 0xe4, 0x90, 0x33, 0x95, + 0x20, 0x1a, 0xfd, 0xef, 0x8e, 0x36, 0xc1, 0x57, 0xde, 0x94, 0xdd, 0x99, + 0x6f, 0x14, 0x0c, 0x8e, 0x30, 0xe0, 0xe7, 0x64, 0x33, 0xa7, 0x1d, 0xfd, + 0x99, 0xdc, 0x58, 0x49, 0x4e, 0x56, 0x82, 0x43, 0xea, 0xd9, 0xf7, 0xcc, + 0x1a, 0xf5, 0x09, 0x38, 0x4c, 0xf6, 0x87, 0x8f, 0xa6, 0x40, 0x96, 0xd1, + 0x81, 0x62, 0xbb, 0x49, 0x53, 0x69, 0x56, 0xdf, 0x4a, 0x85, 0xfd, 0x72, + 0x34, 0x21, 0x56, 0xa3, 0x7b, 0xda, 0x50, 0x24, 0x88, 0xc6, 0x0b, 0x03, + 0x94, 0x0d, 0xe2, 0x03, 0x2a, 0x3c, 0x5a, 0xdd, 0x73, 0xe7, 0x07, 0x01, + 0x7d, 0xdd, 0x38, 0x81, 0x19, 0x02, 0x81, 0x81, 0x00, 0xd3, 0xeb, 0x72, + 0x3f, 0xf6, 0x9b, 0x03, 0x8c, 0xab, 0xd9, 0x41, 0x47, 0xbe, 0x6c, 0x07, + 0x7f, 0xd7, 0xcb, 0xee, 0xbf, 0x45, 0x13, 0x1e, 0x53, 0x35, 0xd2, 0xe4, + 0x6a, 0x13, 0xe9, 0xd8, 0xe3, 0xf4, 0x28, 0x5e, 0xeb, 0xd8, 0xd2, 0x87, + 0x60, 0xdc, 0xa7, 0x21, 0xd8, 0x33, 0xce, 0xca, 0x60, 0x50, 0x1b, 0x87, + 0xbf, 0x71, 0x88, 0x90, 0x71, 0x6f, 0xde, 0xdb, 0x33, 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ee, + 0x8e, 0x4e, 0xd2, 0x42, 0xa8, 0x6c, 0x82, 0x57, 0xf7, 0x34, 0xf6, 0x82, + 0x59, 0xe9, 0x75, 0x7a, 0x8f, 0x0a, 0x8d, 0x46, 0x1e, 0xa1, 0x77, 0xa1, + 0x4c, 0xb3, 0x9e, 0x86, 0x93, 0x18, 0xdf, 0x3e, 0xfb, 0x81, 0xd0, 0xbc, + 0x65, 0xa2, 0xb3, 0x80, 0xf0, 0x8f, 0x73, 0x2f, 0xb5, 0xc4, 0xc0, 0x03, + 0xac, 0x24, 0xfa, 0x4f, 0x05, 0xe3, 0x16, 0x29, 0x7c, 0xff, 0x63, 0xd5, + 0x0a, 0x0a, 0xbd, 0xd7, 0x65, 0x3a, 0xb5, 0x5e, 0xe7, 0x23, 0xfc, 0x3d, + 0x08, 0xea, 0x62, 0xc2, 0xe3, 0x4a, 0xbb, 0x86, 0x5a, 0xc5, 0x93, 0xd7, + 0xbc, 0xb4, 0x4c, 0xcf, 0xcf, 0x78, 0x9f, 0x52, 0x6e, 0xa1, 0x49, 0x21, + 0xf7, 0x20, 0x42 +}; +static const unsigned int privk_len = sizeof(privk); + +/* Signature data (a secure hash, possibly signed) */ +struct vb2_signature { + /* Offset of signature data from start of this struct */ + uint32_t sig_offset; + uint32_t reserved0; + + /* Size of signature data in bytes */ + uint32_t sig_size; + uint32_t reserved1; + + /* Size of the data block which was signed in bytes */ + uint32_t data_size; + uint32_t reserved2; +} __attribute__((packed)); + +/* + * Preamble block for kernel, version 2.2 + * + * This should be followed by: + * 1) The signature data for the kernel body, pointed to by + * body_signature.sig_offset. + * 2) The signature data for (vb2_kernel_preamble + body signature data), + * pointed to by preamble_signature.sig_offset. + * 3) The 16-bit vmlinuz header, which is used for reconstruction of + * vmlinuz image. + */ +struct vb2_kernel_preamble { + /* + * Size of this preamble, including keys, signatures, vmlinuz header, + * and padding, in bytes + */ + uint32_t preamble_size; + uint32_t reserved0; + + /* Signature for this preamble (header + body signature) */ + struct vb2_signature preamble_signature; + + /* Version of this header format */ + uint32_t header_version_major; + uint32_t header_version_minor; + + /* Kernel version */ + uint32_t kernel_version; + uint32_t reserved1; + + /* Load address for kernel body */ + uint64_t body_load_address; + + /* Address of bootloader, after body is loaded at body_load_address */ + uint64_t bootloader_address; + + /* Size of bootloader in bytes */ + uint32_t bootloader_size; + uint32_t reserved2; + + /* Signature for the kernel body */ + struct vb2_signature body_signature; + + /* Address of 16-bit header for vmlinuz reassembly. */ + uint64_t vmlinuz_header_address; + + /* Size of 16-bit header for vmlinuz in bytes. */ + uint32_t vmlinuz_header_size; + uint32_t reserved3; + + uint32_t flags; +} __attribute__((packed)); + +/* + * Order matters. |data| may overlap with |siginfo|, so we need to fill out + * |siginfo| before computing the signature. + */ +static int sign(const void *data, size_t len, struct vb2_signature *siginfo, + void *sigout) +{ + unsigned char hash[SHA256_DIGEST_LENGTH]; + SHA256_CTX sha256; + int ret; + + memset(siginfo, 0, sizeof(*siginfo)); + siginfo->sig_offset = (uintptr_t)(void *)sigout - (uintptr_t)(void *)siginfo; + siginfo->sig_size = SIG_SIZE; + siginfo->data_size = len; + + const unsigned char *p = privk; + char digest_info[] = { + 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, + 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20, + }; + + uint8_t digest[sizeof(digest_info) + sizeof(hash)]; + + SHA256_Init(&sha256); + SHA256_Update(&sha256, data, len); + SHA256_Final(hash, &sha256); + + memcpy(digest, digest_info, sizeof(digest_info)); + memcpy(digest + sizeof(digest_info), hash, sizeof(hash)); + + RSA *key = d2i_RSAPrivateKey(0, &p, privk_len); + if (!key) { + fprintf(stderr, "Failed d2i_RSAPrivateKey()\n"); + return -1; + } + + ret = RSA_private_encrypt(sizeof(digest), digest, sigout, key, + RSA_PKCS1_PADDING); + if (ret == -1) { + fprintf(stderr, "%s: RSA_private_encrypt() failed\n", __func__); + return -1; + } + + return 0; +} + +static struct vb2_kernel_preamble * +generate_preamble(const void *kblob, size_t kblob_len, + size_t kernel_len, size_t config_len) +{ + struct vb2_kernel_preamble *h; + uint32_t signed_size = sizeof(struct vb2_kernel_preamble) + SIG_SIZE; + uint32_t block_size = signed_size + SIG_SIZE; + int ret; + + if (block_size + keyblock_len < BLOCK_PAD) + block_size = BLOCK_PAD - keyblock_len; + h = (struct vb2_kernel_preamble *)calloc(block_size, 1); + if (!h) { + perror("calloc"); + return NULL; + } + + /* Sign the body, place the signature in the preamble */ + ret = sign(kblob, kblob_len, &h->body_signature, h + 1); + if (ret) { + fprintf(stderr, "sign() failed: %d\n", ret); + return NULL; + } + + h->header_version_major = 2; + h->header_version_minor = 2; + h->preamble_size = block_size; + h->kernel_version = 1; + h->body_load_address = 0x100000; + /* + * "Bootloder" area (currently empty) is after kernel + config + + * parameter page. + */ + h->bootloader_address = h->body_load_address + + ROUNDUP(kernel_len) + + ROUNDUP(config_len) + + ALIGN; + h->bootloader_size = 0x1000; + h->vmlinuz_header_address = 0; + h->vmlinuz_header_size = 0; + h->flags = 0; + + ret = sign(h, signed_size, &h->preamble_signature, + (void *)(h + 1) + SIG_SIZE); + if (ret) { + fprintf(stderr, "failed to sign preamble: %d\n", ret); + return NULL; + } + return h; +} + + +/* + * Distilled from vboot_reference futility/cmd_vbutil_kernel.c pack command. + * + * NB: "config" is the kernel cmdline + */ +static int vbutil_pack(const char *kernel, size_t kernel_len, + const char *config, size_t config_len, + void **out, size_t *out_len) +{ + int ret; + size_t kblob_len = ROUNDUP(kernel_len) + ROUNDUP(config_len) + ALIGN + ALIGN; + void *kblob = malloc(kblob_len); + if (!kblob) { + perror("malloc"); + return -1; + } + void *kp = kblob; + memset(kblob, 0, kblob_len); + + /* Kernel */ + memcpy(kp, kernel, kernel_len); + kp += ROUNDUP(kernel_len); + + /* Kernel command line */ + memcpy(kp, config, config_len); + kp += ROUNDUP(config_len); + + /* "Parameters" -- empty, 4K-aligned */ + /* "Bootloader" region -- empty, 4K-aligned */ + /* Vmlinuz header -- only for x86 (not currently supported), empty */ + + struct vb2_kernel_preamble *h; + h = generate_preamble(kblob, kblob_len, kernel_len, config_len); + if (!h) { + fprintf(stderr, "Failed to generate preamble\n"); + return -1; + } + size_t outlen = sizeof(keyblock) + h->preamble_size + kblob_len; + void *outbuf = malloc(outlen); + if (!outbuf) + return -1; + + void *p = outbuf; + memcpy(p, keyblock, sizeof(keyblock)); + p += sizeof(keyblock); + + memcpy(p, h, h->preamble_size); + p += h->preamble_size; + + memcpy(p, kblob, kblob_len); + p += kblob_len; + + if (outbuf) { + *out = outbuf; + *out_len = outlen; + } + + return 0; +} + +static void * read_file(const char *path, size_t *out_len) +{ + struct stat st; + int fd = open(path, O_RDONLY); + if (fd == -1) { + perror("failed to open"); + return NULL; + } + + if (fstat(fd, &st) < 0) { + perror("fstat"); + return NULL; + } + + size_t len = st.st_size; + void *p = malloc(len); + if (!p) + return NULL; + + size_t count = 0; + while (count < len) { + ssize_t ret = read(fd, p + count, len - count); + if (ret < 0) { + perror("read"); + return NULL; + } + count += ret; + } + + close(fd); + + *out_len = len; + return p; +} + +int main(int argc, char * const argv[]) +{ + int i, ret; + const char *kernel_file = NULL; + const char *out_file = NULL; + const char *cmdline = NULL; + size_t cmdline_len; + void *kernel; + size_t kernel_len; + void *out; + size_t out_len; + + int opt; + while ((opt = getopt(argc, argv, "k:c:o:")) != -1) { + switch (opt) { + case 'k': + kernel_file = optarg; + break; + case 'c': + cmdline = optarg; + break; + case 'o': + out_file = optarg; + break; + default: + fprintf(stderr, "Usage [-k ] [-c ] -o \n"); + return -1; + } + } + if (optind < argc) { + fprintf(stderr, "Unexpected args?\n"); + return -1; + } + if (!out_file || !cmdline || !kernel_file) { + fprintf(stderr, "Missing required argument\n"); + return -1; + } + + /* Include the \0 terminator */ + cmdline_len = strlen(cmdline) + 1; + + kernel = read_file(kernel_file, &kernel_len); + if (!kernel) { + fprintf(stderr, "failed to read kernel file: %s\n", kernel_file); + return -1; + } + + ret = vbutil_pack(kernel, kernel_len, cmdline, cmdline_len, &out, &out_len); + if (ret) + return ret; + + int fd = open(out_file, O_RDWR|O_CREAT, 0644); + if (fd == -1) { + perror("open"); + return -1; + } + + ret = write(fd, out, out_len); + if (ret == -1) { + perror("write"); + return -1; + } + close(fd); + + return 0; +} From patchwork Sat Jul 18 20:51:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 1331612 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.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=1Meov14t; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=KRzuVFom; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B8Kwz2p9rz9sTC for ; Sun, 19 Jul 2020 06:54:27 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RoGyPeMy2wsXaO6+KRed2t5XTXhjYDawu2yJC82uuiA=; b=1Meov14taDtQP4yAqQ7TC/oEX o6mu9UhtYRXkXHl/RvoIRuRq7zLonlo0CppUed9MkRU6iculHvilNz8hi8S1znPaKmSsUJLtk7P6a FMKlRv9MHbmOgk2MvadZujpCD5mqRBP+JxoQ6BIc72a0of1BouRj36siKJZNlHY+n/NZpD6bz0Q4J QbFQ4iIGhJ3Exxv73zywPIiX2MgQbcmtcZ0lNak8yjtJv/j8Vojhn2R9gJ+QvFobEUNfva/IFFh3u PlHQpksX3rO6sMAqr8LlE2XuQ3ImGsYqjgPP41zBfUCk/BdVWQCjotEs4IBfJjXYNz64atWt0b0Ud TYmlwIfAw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwtpQ-0002vW-9Q; Sat, 18 Jul 2020 20:53:04 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwtpL-0002tj-3l for openwrt-devel@lists.openwrt.org; Sat, 18 Jul 2020 20:53:00 +0000 Received: by mail-pf1-x443.google.com with SMTP id a23so5481840pfk.13 for ; Sat, 18 Jul 2020 13:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0rT3R/qZymfG+hIZwbaqBxsDbejj4KKZqupT77TxRtk=; b=KRzuVFomnWRlle+uoN5KuRw8EIxEMMGkbHfomvtnSXfJ/3FzGXSzAh0zp5r7tqkHO1 OM5NFWCWIK8k6fSJEDZ7TETbm8ilwrSr3iVjsl64VXhxZodTCbU/BnZ/P74iKlSTUonL lK4CjTK66ji56xQ3kTPXO98QJZ6jPibQDbfL68jCgqpmJYie9oU/QQNJt72U/wIfqhfT Uhndtmg+FNuX7g4R0dOHetb9OUuw88uzGC2ZGaImFtQuL421xunRx5WCUuqF/C5kIRZ+ 2wKjWElvjeRGoFRPfIHhB/i4h/z6HaoOLzSpnKg/z6OCwfMo5R2dUGsdTyQzw41silx3 4eyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0rT3R/qZymfG+hIZwbaqBxsDbejj4KKZqupT77TxRtk=; b=Pttj8SjlcUwPs2JYgBMEktvmp36+rs8rd+tQEEE2sYHN6uQFFgNXBBETffDZyOgsPS yDc/8fgfu15Cu2mAJu9B/whgUZX/fs/ZUNWzPJHQ0N4iadbkxpDie7/M203JoQ3y6+yw USeg3onMutFgTbZ9nNuU5GOsc+oCwh+xSNAlkNzCkGHtZvw68XV6hZiiOgXQtu2FtzCx SE35cIFySkOgfkUikm4dzJQOFb1PYGZd0HUZrVVRq25GnizkLFWcO7NphGfm2VejuIUP bY6QmYC5AbWlNmSxrqauKifzU1Nso0Vo9V4kUGWoUlQehJqE4RHtWQc8x6vONNq5h6l2 X6lQ== X-Gm-Message-State: AOAM532CEn4tzWvtzrrqgHg1+Z9gYsDbVROsVa+vlQElNkQeE0LrSD1u OQRxh2yI3WoTnN8nFApPsMRRW9n2Ei4= X-Google-Smtp-Source: ABdhPJxMsNuEfoQkRwpKPEu/XQIdC7biNdXhKU3iMQXUpReeLc4Vpj9AyfdcxNoVD8kHFUDvo4vAWA== X-Received: by 2002:aa7:9419:: with SMTP id x25mr13525391pfo.67.1595105577189; Sat, 18 Jul 2020 13:52:57 -0700 (PDT) Received: from localhost ([2601:647:5800:8d47:9eef:d5ff:fefc:64ae]) by smtp.gmail.com with ESMTPSA id 200sm11591653pfy.57.2020.07.18.13.52.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Jul 2020 13:52:56 -0700 (PDT) From: Brian Norris To: openwrt-devel@lists.openwrt.org Subject: [RFC PATCH 3/5] image-commands: support Chromium OS image-type creation Date: Sat, 18 Jul 2020 20:51:46 +0000 Message-Id: <20200718205148.1743807-4-computersforpeace@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200718205148.1743807-1-computersforpeace@gmail.com> References: <20200718205148.1743807-1-computersforpeace@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200718_165259_265487_787F1ABA X-CRM114-Status: GOOD ( 12.51 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:443 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [computersforpeace[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Brian Norris Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org See the previous patches, which implemented the cros-vbutil verified-boot payload-packing tool, and extended ptgen for the CrOS kernel partition type. With these, it's now possible to package kernel + rootfs to make disk images that can boot a Chrome OS-based system (e.g., Chromebooks, or even a few AP models). gen_image_vboot.sh borrows a bit of structure from gen_image_generic.sh, but I didn't feel it fit well to try and add new flags to the latter, given the difference in its FAT kernel packaging and our raw kernel partition packing. Signed-off-by: Brian Norris --- include/image-commands.mk | 17 +++++++++++++++++ scripts/gen_image_vboot.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100755 scripts/gen_image_vboot.sh diff --git a/include/image-commands.mk b/include/image-commands.mk index e7db7128b4ca..ca8e826ffb1e 100644 --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -164,6 +164,23 @@ define Build/fit @mv $@.new $@ endef +define Build/cros-image + $(SCRIPT_DIR)/gen_image_vboot.sh \ + $@ \ + $(CONFIG_TARGET_KERNEL_PARTSIZE) $(IMAGE_KERNEL) \ + $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) +endef + +# NB: Chrome OS bootloaders replace the '%U' in command lines with the UUID of +# the kernel partition it chooses to boot from. This gives a flexible way to +# consistently build and sign kernels that always use the subsequent +# (PARTNROFF=1) partition as their rootfs. +define Build/cros-vboot + $(STAGING_DIR_HOST)/bin/cros-vbutil \ + -k $@ -c "root=PARTUUID=%U/PARTNROFF=1" -o $@.new + @mv $@.new $@ +endef + define Build/lzma $(call Build/lzma-no-dict,-lc1 -lp2 -pb2 $(1)) endef diff --git a/scripts/gen_image_vboot.sh b/scripts/gen_image_vboot.sh new file mode 100755 index 000000000000..acded33de654 --- /dev/null +++ b/scripts/gen_image_vboot.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Copyright (C) 2020 OpenWrt.org +set -e -x +[ $# == 5 ] || { + echo "SYNTAX: $0 " + exit 1 +} + +OUTPUT="$1" +KERNELSIZE="$2" +KERNELIMAGE="$3" +ROOTFSSIZE="$4" +ROOTFSIMAGE="$5" + +rm -f "${OUTPUT}" + +head=16 +sect=63 + +# create partition table +set $(ptgen -o "$OUTPUT" -h $head -s $sect -g -T cros_kernel -p ${KERNELSIZE}m -p ${ROOTFSSIZE}m) + +KERNELOFFSET="$(($1 / 512))" +KERNELSIZE="$2" +ROOTFSOFFSET="$(($3 / 512))" +ROOTFSSIZE="$(($4 / 512))" + +dd if="${KERNELIMAGE}" of="${OUTPUT}" bs=512 seek="${KERNELOFFSET}" conv=notrunc +dd if="${ROOTFSIMAGE}" of="${OUTPUT}" bs=512 seek="${ROOTFSOFFSET}" conv=notrunc From patchwork Sat Jul 18 20:51:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 1331610 X-Patchwork-Delegate: chunkeey@googlemail.com 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.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=q4oS9ZJx; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=hzyeVmjT; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B8Kwx5B7Vz9sR4 for ; Sun, 19 Jul 2020 06:54:25 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VaMxuMlGkWhnKxvoB9aZIHF6SvF5BNpQu8A2a6ZupRo=; b=q4oS9ZJx+U7B10tFvepG645nu ZSt6m4I21yb37G4OUGan6Vs/AHJ64R93IKCPC3mijJTNL4X6ZeOlwoAWipFvKfTzrnxw8OApV6Pk0 IQQOajjEwH4j1zRnSo8zD8GDv7987Xgcci5xXvQTHzMcrd+jd+SyBUjToGI1G1w//Fk062qavQVvV h9KPboDSurAjhDKSpjve6OGHLG1BdvvTZEX1rCTZAg447OSoiJqMoGIz3ee5FxlX/9Kdd7V0xYYti Te7cNEfmTV7jBUaI/uD32y2Fs0TrQkg5kbEXOtzKqRwLdGwFvvdFP/b+vYaERnVqUvu31Dtn7P2JM vZCJ42isw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwtpR-0002vn-Q2; Sat, 18 Jul 2020 20:53:05 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwtpM-0002uI-Om for openwrt-devel@lists.openwrt.org; Sat, 18 Jul 2020 20:53:02 +0000 Received: by mail-pl1-x641.google.com with SMTP id l6so6884894plt.7 for ; Sat, 18 Jul 2020 13:53:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZlG3kvKE0tntYONJ1EDOc5hw3ZFPzqxk9Z5kuOb/cKc=; b=hzyeVmjTD759lbtCWiiw9Y1QKH/+zzEw0frkf/IYA+2Z2kYJ19PHv8NtpEqMYNooSc iSe8wAqXRXovMGvbpkG/uQ4jGEkAwthr6Ttqa35K+INBTzvz2fxac6yFmyh4YDhP85P5 SptfjumusFOv2UWo36Mmv5vgZNOhlFpRKwLarriH+G6e54of6VjEXvFSmNMgmkeM7Y9c FIJ01aCxvVI4oF2CU1yiw2oLkMnshkLbpyyss9TI9a77oOFT4hpAz2TPtTszktZTom/L t0jVvGB08KjCP7XyYOWf+VLrvz4ObJbAmb24ssSzDFiOFgfC9INBQOz+y4QjdzFky16L FDPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZlG3kvKE0tntYONJ1EDOc5hw3ZFPzqxk9Z5kuOb/cKc=; b=F4pWPD1Fvide4Da2hL8MJ8UmnJMu8/sXFm7ONT/kUUg6qh6+8e+Bw1+piR0N+YA3af ZAcASDl3nr55YroeSElePaj1bWQ3oFPxkA4sSz/iTcVLbtNxWjiEd1pLoyOtKaOVn2zv XomNCI66cd2a5vtx0mjKYTLETnuMlAVYgDpcoAreXgy+pF7o/ZWU4fwrP58BsMmf8MdS f80TBZVztHxhYkHvEjge/RsB2DFfGlXTLVn4P9zu4D23KJEhUv5avC7R01y+n0KolOUA WYPGjotM8rNMUFHcJhDVikgRnrd1bYYIYyWu58pbwkkFhrB7olHxPp5qvJif6QqCH7lG +j8Q== X-Gm-Message-State: AOAM533zL2InOl+jHxSBuIHj2VcIFfWnyZkIJBrHBnPd+sGYceEbYrOT QYfaygVHTK7ESs6EZhRwBmEZlX5tj3Q= X-Google-Smtp-Source: ABdhPJyChecZEgbyY+ad+So44l1VwXGawCzQ9n2cZLv+9YyycYivPiVJnKzlEBxnmNzTA7IQOExz7Q== X-Received: by 2002:a17:90a:266f:: with SMTP id l102mr15547967pje.144.1595105578670; Sat, 18 Jul 2020 13:52:58 -0700 (PDT) Received: from localhost ([2601:647:5800:8d47:9eef:d5ff:fefc:64ae]) by smtp.gmail.com with ESMTPSA id 144sm11667207pfb.31.2020.07.18.13.52.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Jul 2020 13:52:58 -0700 (PDT) From: Brian Norris To: openwrt-devel@lists.openwrt.org Subject: [RFC PATCH 4/5] ipq40xx: add open-drain support to pinctrl-msm Date: Sat, 18 Jul 2020 20:51:47 +0000 Message-Id: <20200718205148.1743807-5-computersforpeace@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200718205148.1743807-1-computersforpeace@gmail.com> References: <20200718205148.1743807-1-computersforpeace@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200718_165300_877922_5F2F7288 X-CRM114-Status: GOOD ( 15.89 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:641 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [computersforpeace[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Brian Norris Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Submitted upstream. Shouldn't affect existing devices, but enables new device support. https://lore.kernel.org/linux-gpio/20200703080646.23233-1-computersforpeace@gmail.com/ Currently queued for-next: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git/commit/?h=for-next&id=13355ca35cd16f5024655ac06e228b3c199e52a9 Signed-off-by: Brian Norris --- .../090-pinctrl-msm-open-drain.patch | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 target/linux/ipq40xx/patches-5.4/090-pinctrl-msm-open-drain.patch diff --git a/target/linux/ipq40xx/patches-5.4/090-pinctrl-msm-open-drain.patch b/target/linux/ipq40xx/patches-5.4/090-pinctrl-msm-open-drain.patch new file mode 100644 index 000000000000..9bb05f32844a --- /dev/null +++ b/target/linux/ipq40xx/patches-5.4/090-pinctrl-msm-open-drain.patch @@ -0,0 +1,90 @@ +From 5b08c1d567ee8e6af94696b3e549997cbdb2bb80 Mon Sep 17 00:00:00 2001 +From: Jaiganesh Narayanan +Date: Thu, 1 Sep 2016 10:40:38 +0530 +Subject: [PATCH] pinctrl: qcom: ipq4019: add open drain support + +Signed-off-by: Jaiganesh Narayanan +[ Brian: adapted from from the Chromium OS kernel used on IPQ4019-based + WiFi APs. ] +Signed-off-by: Brian Norris +--- +https://lore.kernel.org/linux-gpio/20200703080646.23233-1-computersforpeace@gmail.com/ + + drivers/pinctrl/qcom/pinctrl-ipq4019.c | 1 + + drivers/pinctrl/qcom/pinctrl-msm.c | 13 +++++++++++++ + drivers/pinctrl/qcom/pinctrl-msm.h | 2 ++ + 3 files changed, 16 insertions(+) + +diff --git a/drivers/pinctrl/qcom/pinctrl-ipq4019.c b/drivers/pinctrl/qcom/pinctrl-ipq4019.c +index 8bdb5bd393d2..63915cb210ff 100644 +--- a/drivers/pinctrl/qcom/pinctrl-ipq4019.c ++++ b/drivers/pinctrl/qcom/pinctrl-ipq4019.c +@@ -254,6 +254,7 @@ DECLARE_QCA_GPIO_PINS(99); + .mux_bit = 2, \ + .pull_bit = 0, \ + .drv_bit = 6, \ ++ .od_bit = 12, \ + .oe_bit = 9, \ + .in_bit = 0, \ + .out_bit = 1, \ +diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c +index 83b7d64bc4c1..dac0404dadf4 100644 +--- a/drivers/pinctrl/qcom/pinctrl-msm.c ++++ b/drivers/pinctrl/qcom/pinctrl-msm.c +@@ -233,6 +233,10 @@ static int msm_config_reg(struct msm_pinctrl *pctrl, + *bit = g->pull_bit; + *mask = 3; + break; ++ case PIN_CONFIG_DRIVE_OPEN_DRAIN: ++ *bit = g->od_bit; ++ *mask = 1; ++ break; + case PIN_CONFIG_DRIVE_STRENGTH: + *bit = g->drv_bit; + *mask = 7; +@@ -310,6 +314,12 @@ static int msm_config_group_get(struct pinctrl_dev *pctldev, + if (!arg) + return -EINVAL; + break; ++ case PIN_CONFIG_DRIVE_OPEN_DRAIN: ++ /* Pin is not open-drain */ ++ if (!arg) ++ return -EINVAL; ++ arg = 1; ++ break; + case PIN_CONFIG_DRIVE_STRENGTH: + arg = msm_regval_to_drive(arg); + break; +@@ -382,6 +392,9 @@ static int msm_config_group_set(struct pinctrl_dev *pctldev, + else + arg = MSM_PULL_UP; + break; ++ case PIN_CONFIG_DRIVE_OPEN_DRAIN: ++ arg = 1; ++ break; + case PIN_CONFIG_DRIVE_STRENGTH: + /* Check for invalid values */ + if (arg > 16 || arg < 2 || (arg % 2) != 0) +diff --git a/drivers/pinctrl/qcom/pinctrl-msm.h b/drivers/pinctrl/qcom/pinctrl-msm.h +index 9452da18a78b..dc7f8c84744b 100644 +--- a/drivers/pinctrl/qcom/pinctrl-msm.h ++++ b/drivers/pinctrl/qcom/pinctrl-msm.h +@@ -38,6 +38,7 @@ struct msm_function { + * @mux_bit: Offset in @ctl_reg for the pinmux function selection. + * @pull_bit: Offset in @ctl_reg for the bias configuration. + * @drv_bit: Offset in @ctl_reg for the drive strength configuration. ++ * @od_bit: Offset in @ctl_reg for controlling open drain. + * @oe_bit: Offset in @ctl_reg for controlling output enable. + * @in_bit: Offset in @io_reg for the input bit value. + * @out_bit: Offset in @io_reg for the output bit value. +@@ -75,6 +76,7 @@ struct msm_pingroup { + unsigned pull_bit:5; + unsigned drv_bit:5; + ++ unsigned od_bit:5; + unsigned oe_bit:5; + unsigned in_bit:5; + unsigned out_bit:5; +-- +2.17.1 + From patchwork Sat Jul 18 20:51:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 1331613 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.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=OuZylT2m; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=VY4208wO; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B8Kwz3WXpz9sTF for ; Sun, 19 Jul 2020 06:54:27 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Y0kdYHtzJBWxiGd3v86Bjgpk0MlaIEfhMYcRKyHXjY4=; b=OuZylT2mdz+9zjXm4dp5bAA+5 oOs+/1466iVJANKKmtHlQxA+N/aMRkx7sbStjmf+dqghwFZP2fuZQLHwptKIjBTZUjeBfJ0l1qlQi kALUuNayThB8AZeKXrju7dLNA2cBY7T5o+x1Gk9Zwk5rVubxa82IfcsAQJBAfwtC/kjwIAnPdgkuO yPbGlfC3ew90Yzihz1mhqaJKuNURZ2j/Oihzm7gunTHHy/W2h2a4xVegYyqX+4bX7oga/z/cZtctX XF9uZ8obW4FJNX9BwbDw7CPHtz+UqSLlSqW1oqrP9KL/+WNY1ZeqqWgB+A7X45R+fMCIMQh3wjvEM XM0tEVkdg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwtpY-0002xr-57; Sat, 18 Jul 2020 20:53:12 +0000 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwtpO-0002ut-NN for openwrt-devel@lists.openwrt.org; Sat, 18 Jul 2020 20:53:04 +0000 Received: by mail-pj1-x1041.google.com with SMTP id ch3so8108349pjb.5 for ; Sat, 18 Jul 2020 13:53:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xtw9MY7cvbRTckBUdtcDRUEi7b8OOdszS7HgXaWVqfk=; b=VY4208wOH9nVgGbAczBYGygyUr+0T0ZQhNEgmTdcpqEV6d+tAGmK6Cq8F/HRCuKXHq CbGKggOhuq/r9oAxdK2pN7KPYA6re1onZ5/Svaw0u3hMVE66Ve1igL/flPNMmw+7noSI QBjD252dSl47CTWXXKYhR6tpXAk1YErrDAn2MZcl+brdw4K/hS+vwpKn0MtuCnHX0Vpd P/QXHZ3W8d1T51TfpUEFRwKFVo5wHhzdAGsDuc1tRjqAYrorcmgjxbqHZPiPWoYzHmCl IHylMZMDq2UbUMgd+FGn9Y3BY5pSG+B37/haaKluHuGQ2A70cepD5S81wUsVhMtvgbmF 42lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xtw9MY7cvbRTckBUdtcDRUEi7b8OOdszS7HgXaWVqfk=; b=R7F/Cc2utvKkQ1FYhymNzT3fpLTkbhnTIj3DNHGyTQsZRpdf+Y5YEbmqu6wXtrUxHY QvBp2SLG4kWhBOpjOTARlyMkDTmFyTAWZ0i14XvcH0jQ/jrlAP+sqP8A/jV1LPHceGNi zbEuIKF6YAy4fbQfjo07zXCfX0HW9ZjHl2NDGo9SBmrZzeCFU+dvZ9lExQsj8N+SlFGQ 7+4fCyuDzTPPU3i0Ql815TYyMG796VLASK3kOOfk6QwpgZDWZuSgQTTxFatDU3JOHikR O9FdPogn3TamS9HDJ7OmbYe7tYzuWHxRInuHdMRjvR2+fRRpy5uYNaJGjb1YzBxtVzF0 6NNA== X-Gm-Message-State: AOAM532fkkhb8U1X6pTcWiAl81RQrTvOtXplVUmR0+GU3ds8CXrU4RmX FFSUoGb//09LTkEnk2KAtQFlpUkz2EE= X-Google-Smtp-Source: ABdhPJzKpMb2M9hAQrbMviakM9y+Ux0keQ1cKw96s6ETzTsemp2Zc/mFS2vyyoJTOioJgmme0ghyeA== X-Received: by 2002:a17:90a:916:: with SMTP id n22mr15159339pjn.78.1595105580347; Sat, 18 Jul 2020 13:53:00 -0700 (PDT) Received: from localhost ([2601:647:5800:8d47:9eef:d5ff:fefc:64ae]) by smtp.gmail.com with ESMTPSA id w12sm5954306pjb.18.2020.07.18.13.52.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Jul 2020 13:52:59 -0700 (PDT) From: Brian Norris To: openwrt-devel@lists.openwrt.org Subject: [RFC PATCH 5/5] ipq40xx: add target for Google WiFi (Gale) Date: Sat, 18 Jul 2020 20:51:48 +0000 Message-Id: <20200718205148.1743807-6-computersforpeace@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200718205148.1743807-1-computersforpeace@gmail.com> References: <20200718205148.1743807-1-computersforpeace@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200718_165302_928511_5FAD5221 X-CRM114-Status: GOOD ( 23.98 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1041 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [computersforpeace[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Brian Norris Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Google WiFi (codename: Gale) is an IPQ4019-based AP, with 2 Ethernet ports, 2x2 2.4+5GHz WiFi, 512 MB RAM, 4 GB eMMC, and a USB type C port. In its stock configuration, it runs a Chromium OS-based system, but you wouldn't know it, since you can only manage it via a "cloud" + mobile-app system. The "v2" label is coded into the bootloader, which prefers the "google,gale-v2" compatible string. I believe "v1" must have been pre-release hardware. Note: this is *not* the Google Nest WiFi, released in 2019. I include "factory.bin" support, where we generate a GPT-based disk image with 2 partitions -- a kernel partition (using the custom "Chrome OS kernel" GUID type) and a root filesystem partition. If the AP is in Developer Mode, the stock bootloader can boot it via a USB disk or (after gaining access via USB boot) flashed to the eMMC. Sysupgrade also seems to work OK, although I've omitted some of the (re)partitioning handling. I also hard-code /dev/mmcblk0 -- while MMC device numbering can technically change, there's no other MMC controller present (e.g., no SD card slot). "FEATURES=boot-part rootfs-part" is required to get kernel and rootfs partition sizes established. This adds extra (unused) configuration parameters for other ipq40xx targets, so I'm not sure if this is the "right" thing to do either. Features I have tested: * Ethernet, both WAN and LAN ports * eMMC * USB-C (hub, power-delivery, peripherals) * LED0 (R/G/B) * WiFi (limited testing) * SPI flash * Serial console: once in developer mode, console can be accessed via the USB-C port with SuzyQable, or other similar "Closed Case Debugging" tools: https://chromium.googlesource.com/chromiumos/third_party/hdctools/+/master/docs/ccd.md#suzyq-suzyqable Not tested: * TPM * LED1, LED2: I'm not even confident they are actually populated anywhere Known not working: * Reboot: this seems to require some additional TrustZone / SCM configuration; with additional local patches, I have this working, but I'm still trying to figure out exactly the right way I should integrate this. Ideally, I could propose it upstream, instead of just adding a custom OpenWRT patch. Without this patch, reboot just hangs the system. (NB: I've found at least one other user report of this on an "IPQ4019" device, but I don't know yet if that's the same.) * There's a single external button, and a few useful internal GPIO switches. I haven't hooked them up. Much of the DTS is pulled from the Chrome OS kernel 3.18 branch, which the manufacturer image uses. Note: the manufacturer bootloader knows how to patch in calibration data via the wifi{0,1} aliases in the DTB, so while these properties aren't present in the DTS, they are available at runtime: # ls -l /sys/firmware/devicetree/base/soc/wifi@a*/qcom,ath10k-pre-calibration-data -r--r--r-- 1 root root 12064 Jul 15 19:11 /sys/firmware/devicetree/base/soc/wifi@a000000/qcom,ath10k-pre-calibration-data -r--r--r-- 1 root root 12064 Jul 15 19:11 /sys/firmware/devicetree/base/soc/wifi@a800000/qcom,ath10k-pre-calibration-data Ethernet MAC addresses are similarly patched in via the ethernet{0,1} aliases. Signed-off-by: Brian Norris --- target/linux/ipq40xx/Makefile | 2 +- .../ipq40xx/base-files/etc/board.d/02_network | 1 + .../base-files/lib/upgrade/platform.sh | 13 + .../arm/boot/dts/qcom-ipq4019-gale-v2.dts | 402 ++++++++++++++++++ target/linux/ipq40xx/image/Makefile | 14 + .../901-arm-boot-add-dts-files.patch | 3 +- 6 files changed, 433 insertions(+), 2 deletions(-) create mode 100644 target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-gale-v2.dts diff --git a/target/linux/ipq40xx/Makefile b/target/linux/ipq40xx/Makefile index 94b47c4c96de..c114df620d5c 100644 --- a/target/linux/ipq40xx/Makefile +++ b/target/linux/ipq40xx/Makefile @@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk ARCH:=arm BOARD:=ipq40xx BOARDNAME:=Qualcomm Atheros IPQ40XX -FEATURES:=squashfs fpu ramdisk nand +FEATURES:=squashfs fpu ramdisk nand boot-part rootfs-part CPU_TYPE:=cortex-a7 CPU_SUBTYPE:=neon-vfpv4 SUBTARGETS:=generic diff --git a/target/linux/ipq40xx/base-files/etc/board.d/02_network b/target/linux/ipq40xx/base-files/etc/board.d/02_network index 61d02a17bcc9..f6b2f47e6ce6 100755 --- a/target/linux/ipq40xx/base-files/etc/board.d/02_network +++ b/target/linux/ipq40xx/base-files/etc/board.d/02_network @@ -38,6 +38,7 @@ ipq40xx_setup_interfaces() ;; asus,map-ac2200|\ cilab,meshpoint-one|\ + google,gale-v2|\ openmesh,a42|\ openmesh,a62) ucidef_set_interfaces_lan_wan "eth1" "eth0" diff --git a/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh b/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh index 5b89710a2255..9cc77e8cb4d0 100644 --- a/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh @@ -40,6 +40,16 @@ askey_do_upgrade() { nand_do_upgrade "$1" } +vboot_do_upgrade() { + local tar_file="$1" + + echo "Preparing to flash to /dev/mmcblk0p{1,2}" + ask_bool 0 "Abort" && exit 1 + + tar Oxf "${tar_file}" '*/kernel' | dd of=/dev/mmcblk0p1 bs=1M + tar Oxf "${tar_file}" '*/root' | dd of=/dev/mmcblk0p2 bs=1M +} + zyxel_do_upgrade() { local tar_file="$1" @@ -98,6 +108,9 @@ platform_do_upgrade() { compex,wpj419) nand_do_upgrade "$1" ;; + google,gale-v2) + vboot_do_upgrade "$1" + ;; linksys,ea6350v3 |\ linksys,ea8300) platform_do_upgrade_linksys "$1" diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-gale-v2.dts b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-gale-v2.dts new file mode 100644 index 000000000000..ce0d2b91d05a --- /dev/null +++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-gale-v2.dts @@ -0,0 +1,402 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2016, 2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2016 Google, Inc + */ + +#include "qcom-ipq4019.dtsi" +#include +#include + +&tlmm { + fw_pinmux { + wp { + pins = "gpio53"; + output-low; + }; + recovery { + pins = "gpio57"; + bias-none; + }; + developer { + pins = "gpio41"; + bias-none; + }; + }; + + reset802_15_4 { + pins = "gpio60"; + }; + + led_reset { + pins = "gpio22"; + output-high; + }; + + sys_reset { + pins = "gpio19"; + output-high; + }; + + rx_active { + pins = "gpio43"; + bias-pull,down; + }; + + spi_0_pins: spi_0_pinmux { + pinmux { + function = "blsp_spi0"; + pins = "gpio13", "gpio14","gpio15"; + }; + pinmux_cs { + function = "gpio"; + pins = "gpio12"; + }; + pinconf { + pins = "gpio13", "gpio14","gpio15"; + drive-strength = <12>; + bias-disable; + }; + pinconf_cs { + pins = "gpio12"; + drive-strength = <2>; + bias-disable; + output-high; + }; + }; + + spi_1_pins: spi_1_pinmux { + pinmux { + function = "blsp_spi1"; + pins = "gpio44", "gpio46","gpio47"; + }; + pinmux_cs { + function = "gpio"; + pins = "gpio45"; + }; + pinconf { + pins = "gpio44", "gpio46","gpio47"; + drive-strength = <12>; + bias-disable; + }; + pinconf_cs { + pins = "gpio45"; + drive-strength = <2>; + bias-disable; + output-high; + }; + }; + + serial_0_pins: serial0_pinmux { + mux { + pins = "gpio16", "gpio17"; + function = "blsp_uart0"; + bias-disable; + }; + }; + + serial_1_pins: serial1_pinmux { + mux { + pins = "gpio8", "gpio9", "gpio10", "gpio11"; + function = "blsp_uart1"; + bias-disable; + }; + }; + + i2c_0_pins: i2c_0_pinmux { + mux { + pins = "gpio20", "gpio21"; + function = "blsp_i2c0"; + drive-open-drain; + }; + }; + + i2c_1_pins: i2c_1_pinmux { + mux { + pins = "gpio34", "gpio35"; + function = "blsp_i2c1"; + drive-open-drain; + }; + }; + + sd_0_pins: sd_0_pinmux { + sd0 { + pins = "gpio23", "gpio24", "gpio25", "gpio26", "gpio29", "gpio30", "gpio31", "gpio32"; + function = "sdio"; + drive-strength = <10>; + bias-pull-up; + pull-up-res = <0>; + }; + sdclk { + pins = "gpio27"; + function = "sdio"; + drive-strength = <2>; + bias-pull-up; + pull-up-res = <0>; + }; + sdcmd { + pins = "gpio28"; + function = "sdio"; + drive-strength = <10>; + bias-pull-up; + pull-up-res = <0>; + }; + }; + + mdio_pins: mdio_pinmux { + mux_1 { + pins = "gpio6"; + function = "mdio"; + bias-disable; + }; + mux_2 { + pins = "gpio7"; + function = "mdc"; + bias-disable; + }; + mux_3 { + pins = "gpio40"; + function = "gpio"; + bias-disable; + output-high; + }; + }; + + wifi1_1_pins: wifi2_pinmux { + mux { + pins = "gpio58"; + output-low; + }; + }; +}; + +/ { + model = "Google IPQ4019/Gale"; + compatible = "google,gale-v2", "qcom,ipq4019"; + + chosen { + stdout-path = &blsp1_uart1; + }; + + memory { + device_type = "memory"; + reg = <0x80000000 0x20000000>; /* 512MB */ + }; + + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + rsvd@87000000 { + /* Reserved for other subsystem */ + reg = <0x87000000 0x01000000>; + no-map; + }; + }; + + soc { + blsp_dma: dma@7884000 { + status = "okay"; + }; + + usb3: usb3@8af8800 { + status = "okay"; + }; + + usb2: usb2@60f8800 { + status = "okay"; + }; + + rng@22000 { + status = "okay"; + }; + + ess-switch@c000000 { + status = "okay"; + }; + + edma@c080000 { + status = "okay"; + }; + + ess-psgmii@98000 { + status = "okay"; + }; + + watchdog@b017000 { + status = "okay"; + }; + }; +}; + +&blsp1_i2c3 { + pinctrl-0 = <&i2c_0_pins>; + pinctrl-names = "default"; + status = "okay"; + + trusted-platform-module@20 { + compatible = "infineon,slb9645tt"; + reg = <0x20>; + powered-while-suspended; + }; +}; + +&blsp1_i2c4 { + pinctrl-0 = <&i2c_1_pins>; + pinctrl-names = "default"; + status = "okay"; + + lp55231@32 { + compatible = "national,lp5523"; + reg = <0x32>; + clock-mode = [01]; + + chan0 { + chan-name = "LED0_Red"; + led-cur = [64]; + max-cur = [78]; + }; + + chan1 { + chan-name = "LED0_Green"; + led-cur = [64]; + max-cur = [78]; + }; + + chan2 { + chan-name = "LED0_Blue"; + led-cur = [64]; + max-cur = [78]; + }; + + chan3 { + chan-name = "LED1_Red"; + led-cur = [64]; + max-cur = [78]; + }; + + chan4 { + chan-name = "LED1_Green"; + led-cur = [64]; + max-cur = [78]; + }; + + chan5 { + chan-name = "LED1_Blue"; + led-cur = [64]; + max-cur = [78]; + }; + + chan6 { + chan-name = "LED2_Red"; + led-cur = [64]; + max-cur = [78]; + }; + + chan7 { + chan-name = "LED2_Green"; + led-cur = [64]; + max-cur = [78]; + }; + + chan8 { + chan-name = "LED2_Blue"; + led-cur = [64]; + max-cur = [78]; + }; + }; +}; + +&blsp1_spi1 { + pinctrl-0 = <&spi_0_pins>; + pinctrl-names = "default"; + status = "okay"; + cs-gpios = <&tlmm 12 0>; + + spidev@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <24000000>; + }; +}; + +&blsp1_spi2 { + pinctrl-0 = <&spi_1_pins>; + pinctrl-names = "default"; + status = "okay"; + cs-gpios = <&tlmm 45 0>; + + spidev@0 { + compatible = "spidev"; + reg = <0>; + spi-max-frequency = <24000000>; + }; +}; + +&blsp1_uart1 { + pinctrl-0 = <&serial_0_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&blsp1_uart2 { + pinctrl-0 = <&serial_1_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&gmac0 { + qcom,phy_mdio_addr = <4>; + qcom,poll_required = <1>; + qcom,forced_speed = <1000>; + qcom,forced_duplex = <1>; + vlan_tag = <2 0x20>; +}; + +&gmac1 { + qcom,phy_mdio_addr = <3>; + qcom,forced_duplex = <1>; + vlan_tag = <1 0x10>; +}; + +&mdio { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; +}; + +&sdhci { + status = "okay"; + pinctrl-0 = <&sd_0_pins>; + pinctrl-names = "default"; + clock-frequency = <192000000>; + vqmmc-supply = <&vqmmc>; + non-removable; +}; + +&usb2_hs_phy { + status = "okay"; +}; + +&usb3_ss_phy { + status = "okay"; +}; + +&usb3_hs_phy { + status = "okay"; +}; + +&vqmmc { + status = "okay"; +}; + +&wifi0 { + status = "okay"; +}; + +&wifi1 { + status = "okay"; + pinctrl-0 = <&wifi1_1_pins>; + pinctrl-names = "default"; +}; diff --git a/target/linux/ipq40xx/image/Makefile b/target/linux/ipq40xx/image/Makefile index 51e8bcc7e36d..83d148b90950 100644 --- a/target/linux/ipq40xx/image/Makefile +++ b/target/linux/ipq40xx/image/Makefile @@ -218,6 +218,20 @@ define Device/avm_fritzbox-4040 endef TARGET_DEVICES += avm_fritzbox-4040 +define Device/google_gale-v2 + DEVICE_VENDOR := Google + DEVICE_MODEL := WiFi (Gale) + SOC := qcom-ipq4019 + DEVICE_DTS := qcom-ipq4019-gale-v2 + KERNEL_SUFFIX := -fit-zImage.itb.vboot + KERNEL = kernel-bin | fit none $$(DTS_DIR)/$$(DEVICE_DTS).dtb | cros-vboot + KERNEL_NAME := zImage + IMAGES += factory.bin + IMAGE/factory.bin := cros-image + DEVICE_PACKAGES := partx-utils mkf2fs e2fsprogs +endef +TARGET_DEVICES += google_gale-v2 + define Device/avm_fritzbox-7530 $(call Device/FitImageLzma) DEVICE_VENDOR := AVM diff --git a/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch b/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch index d281bb468daf..04630a85d679 100644 --- a/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch +++ b/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch @@ -10,7 +10,7 @@ Signed-off-by: John Crispin --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile -@@ -837,11 +837,50 @@ dtb-$(CONFIG_ARCH_QCOM) += \ +@@ -837,11 +837,51 @@ dtb-$(CONFIG_ARCH_QCOM) += \ qcom-apq8074-dragonboard.dtb \ qcom-apq8084-ifc6540.dtb \ qcom-apq8084-mtp.dtb \ @@ -43,6 +43,7 @@ Signed-off-by: John Crispin + qcom-ipq4019-fritzbox-7530.dtb \ + qcom-ipq4019-fritzrepeater-1200.dtb \ + qcom-ipq4019-fritzrepeater-3000.dtb \ ++ qcom-ipq4019-gale-v2.dtb \ + qcom-ipq4019-map-ac2200.dtb \ + qcom-ipq4019-e2600ac-c1.dtb \ + qcom-ipq4019-e2600ac-c2.dtb \