From patchwork Tue Dec 7 12:00:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 1564675 X-Patchwork-Delegate: zajec5@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=xufJTLr3; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=UXothTXH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4J7f7H4CtJz9sXS for ; Tue, 7 Dec 2021 23:02:35 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=djNhsMS5UyHL7/y8FaERLHR1bFyjL1neG5+gKJ76114=; b=xufJTLr3eCcm5V lEWjXe+8OaLWidDiX3+VL6/2quEcOuljQy/Jo6yIbkqTfjMNDGfmO8RY+xC6mFUT7GLESSeE7U6po IlMOSq2nAXGnHY524z4Z7HyQC6IQ7D9vb08+DQ1mMi/HU9+hAA4i+JeOofBssUc3ANr1UiJ2dlUI3 FKYcRt8QbSsomdXi493OLlcalKgu9/ktb+BtYolrNhNuLUr+rcKBfSqWMWacEmm2Xz3r4EmQURUZQ U1p2LT3E27MJL+iDxfj1EoRoBXx4J8Cxa0d6DJRpSZ46+RY/HQdJmDeUZonYqe8Fss91M/9mDYpVG e0WvGdBOZoxG6UEidROw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1muZ9B-008KLS-4O; Tue, 07 Dec 2021 12:00:37 +0000 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1muZ8v-008KJJ-5n for openwrt-devel@lists.openwrt.org; Tue, 07 Dec 2021 12:00:22 +0000 Received: by mail-lj1-x236.google.com with SMTP id m12so26957682ljj.6 for ; Tue, 07 Dec 2021 04:00:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UApF3koxiXvzsvRyM+5z2XbFoVzEKrCSb3HA7gIGczU=; b=UXothTXHQTw1/jK01eHC7DKgW4HFfEo65dNqUfHCDB99XL2Q6suy267ks+Sz6huelJ 0q6LOHaqhjhJQ4aCdyafS7ueqq9feCwj2hWU1sEFISB9RhEFaB+NlJkVNGMKyH6CEiHu JVdDB1WohndFH+ny4EWycNCc25SBvSGo2iBIC2olZKxNVn33Q15p8eIdHZU8VMv5QXl1 K2FK5XN1ZUaXULoMxZ33wchIpfntzPMefMNSkNoTvUqsOvxLAZK4Etu/Wn4+6aWLqiqf GGJSkYSG/USJxHcoi4ZjhOZnplQn1H5j7AxDosvf5m6nPH3x6GtNHbbKY+fu6w7pdqG/ PZ0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UApF3koxiXvzsvRyM+5z2XbFoVzEKrCSb3HA7gIGczU=; b=Hu2UjFoTYGHezw9ifUzTQ/7HBLPYuWARCagCQD1a89LTbs2CBw/E8MXCCC552k+oqB PeJxpoM7F29XyQSXJkeLzKdmEL0vw5hy69lvXRuKoPZkpj/3Fb3JcfidED65frEg3sjI CqLq6UF1m+AuxMwZEz/0vgZsL8+QtAAo6N6T+S4QH2GPLupoFI59nH1T8ANx7y6cJYoI fKz0GC0nyb5nMV69abkvPByj1BEXeaSI40ZEpvanrNABR3cbubxnysSnpcXk+sz3pIiB lgJdewwLPEpywG0pEJEXjj0BgtSHdGgOr4OTOO43ByDoLTTrgMQpAP35RuO+WzvAmrnc zo2A== X-Gm-Message-State: AOAM531FcPks+9id70UkxpcdAU/bmIjf572AtrvzHaQYRUqTa5K2bV4a UNzJz3n6K1K+rzuSFGuuR2+/jDcU8xU= X-Google-Smtp-Source: ABdhPJw7XOD6FAwNQwVWdprV380Nc8QvIYUZsKTzEXjrHYE30u5Wyt4XEvHaT9AuoEt+LgSic8aETQ== X-Received: by 2002:a05:651c:235:: with SMTP id z21mr42602110ljn.473.1638878418321; Tue, 07 Dec 2021 04:00:18 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id c2sm1632486ljf.50.2021.12.07.04.00.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Dec 2021 04:00:17 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: openwrt-devel@lists.openwrt.org Cc: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Yousong Zhou Subject: [PATCH 2/2] dtc: support printing binary data with fdtget Date: Tue, 7 Dec 2021 13:00:02 +0100 Message-Id: <20211207120002.5764-2-zajec5@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211207120002.5764-1-zajec5@gmail.com> References: <20211207120002.5764-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211207_040021_244657_819E75E3 X-CRM114-Status: GOOD ( 18.38 ) X-Spam-Score: 0.1 (/) X-Spam-Report: =?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?= =?unknown-8bit?q?stem_=22bombadil=2Einfradead=2Eorg=22=2C?= =?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?= =?unknown-8bit?q?ginal?= =?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?= =?unknown-8bit?q?bel?= =?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_preview=3A__From=3A_Rafa=C5=82_Mi=C5=82ecki_It=27s?= =?unknown-8bit?q?_needed_for_extracting_binary_images=2E?= =?unknown-8bit?q?_Cc=3A_Yousong_Zhou_Signed-off-by=3A_Rafa=C5=82_Mi=C5=82eck?= =?unknown-8bit?q?i_---_=2E=2E=2Et-for-printing-raw-bytes-with-fdtget=2Epatc?= =?unknown-8bit?q?h?= =?unknown-8bit?q?_=7C_78_+++++++++++++++++++_1_file_changed=2C_78_insertions?= =?unknown-8bit?q?=28+=29_create_mode_100644?= =?unknown-8bit?q?_package/utils/dtc/pat_=5B=2E=2E=2E=5D_?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=280=2E1_points=2C_5=2E0_req?= =?unknown-8bit?q?uired=29?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_pts_rule_name______________description?= =?unknown-8bit?q?_----_----------------------_------------------------------?= =?unknown-8bit?q?--------------------?= =?unknown-8bit?q?_-0=2E0_RCVD=5FIN=5FDNSWL=5FNONE_____RBL=3A_Sender_listed_a?= =?unknown-8bit?q?t_https=3A//www=2Ednswl=2Eorg/=2C?= =?unknown-8bit?q?_no_trust?= =?unknown-8bit?b?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDoyMzYgbGlzdGVkIGluXQ==?= =?unknown-8bit?b?IFtsaXN0LmRuc3dsLm9yZ10=?= =?unknown-8bit?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_?= =?unknown-8bit?q?record?= =?unknown-8bit?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= =?unknown-8bit?q?_0=2E0_FREEMAIL=5FFROM__________Sender_email_is_commonly_ab?= =?unknown-8bit?q?used_enduser_mail?= =?unknown-8bit?q?_provider?= =?unknown-8bit?q?_=5Bzajec5=5Bat=5Dgmail=2Ecom=5D?= =?unknown-8bit?q?_0=2E2_FREEMAIL=5FENVFROM=5FEND=5FDIGIT_Envelope-from_freem?= =?unknown-8bit?q?ail_username_ends?= =?unknown-8bit?q?_in_digit?= =?unknown-8bit?q?_=5Bzajec5=5Bat=5Dgmail=2Ecom=5D?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FAU__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from?= =?unknown-8bit?q?_author=27s_domain?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID_____________Message_has_at_least_one_v?= =?unknown-8bit?q?alid_DKIM_or_DK_signature?= =?unknown-8bit?q?_0=2E1_DKIM=5FSIGNED____________Message_has_a_DKIM_or_DK_si?= =?unknown-8bit?q?gnature=2C_not_necessarily?= =?unknown-8bit?q?_valid?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FEF__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from?= =?unknown-8bit?q?_envelope-from_domain?= X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Rafał Miłecki It's needed for extracting binary images. Cc: Yousong Zhou Signed-off-by: Rafał Miłecki --- ...t-for-printing-raw-bytes-with-fdtget.patch | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 package/utils/dtc/patches/0001-Support-b-format-for-printing-raw-bytes-with-fdtget.patch diff --git a/package/utils/dtc/patches/0001-Support-b-format-for-printing-raw-bytes-with-fdtget.patch b/package/utils/dtc/patches/0001-Support-b-format-for-printing-raw-bytes-with-fdtget.patch new file mode 100644 index 0000000000..388b25e7a7 --- /dev/null +++ b/package/utils/dtc/patches/0001-Support-b-format-for-printing-raw-bytes-with-fdtget.patch @@ -0,0 +1,78 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Mon, 6 Dec 2021 16:41:11 +0100 +Subject: [PATCH] Support 'b' format for printing raw bytes with fdtget +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +FT is sometimes used for storing raw data. That is quite common for +U-Boot FIT images. + +Extracting such data is not trivial currently. Using type 's' (string) +will replace every 0x00 (NUL) with 0x20 (space). Using type 'x' will +print bytes but in xxd incompatible format. + +This commit adds support for 'b' (binary) format. Example usage: +fdtget -t b firmware.itb /images/foo data > image.raw + +Signed-off-by: Rafał Miłecki +--- + fdtget.c | 5 +++++ + util.c | 24 ++++++++++++++---------- + 2 files changed, 19 insertions(+), 10 deletions(-) + +--- a/fdtget.c ++++ b/fdtget.c +@@ -91,6 +91,11 @@ static int show_data(struct display_info + if (len == 0) + return 0; + ++ if (disp->type == 'b') { ++ fwrite(data, 1, len, stdout); ++ return 0; ++ } ++ + is_string = (disp->type) == 's' || + (!disp->type && util_is_printable_string(data, len)); + if (is_string) { +--- a/util.c ++++ b/util.c +@@ -340,24 +340,28 @@ int utilfdt_decode_type(const char *fmt, + + /* get the conversion qualifier */ + *size = -1; +- if (strchr("hlLb", *fmt)) { +- qualifier = *fmt++; +- if (qualifier == *fmt) { +- switch (*fmt++) { +-/* TODO: case 'l': qualifier = 'L'; break;*/ +- case 'h': ++ for (; *(fmt + 1); fmt++) { ++ if (!strchr("hlLb", *fmt)) ++ return -1; ++ if (qualifier) { ++ if (*fmt == 'h' && qualifier == 'h') + qualifier = 'b'; +- break; +- } ++ else ++ return -1; ++ } else { ++ qualifier = *fmt; + } + } + + /* we should now have a type */ +- if ((*fmt == '\0') || !strchr("iuxs", *fmt)) ++ if (!strchr("iuxsb", *fmt)) { ++ if (*fmt) ++ fprintf(stderr, "invalid type: %c\n", *fmt); + return -1; ++ } + + /* convert qualifier (bhL) to byte size */ +- if (*fmt != 's') ++ if (*fmt != 's' && *fmt != 'b') + *size = qualifier == 'b' ? 1 : + qualifier == 'h' ? 2 : + qualifier == 'l' ? 4 : -1;