From patchwork Mon Jan 30 02:12:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 92792 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1238866qgi; Sun, 29 Jan 2017 18:13:26 -0800 (PST) X-Received: by 10.28.8.213 with SMTP id 204mr12154269wmi.100.1485742405923; Sun, 29 Jan 2017 18:13:25 -0800 (PST) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id u66si14601229wrc.269.2017.01.29.18.13.25; Sun, 29 Jan 2017 18:13:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 755074AC0C; Mon, 30 Jan 2017 03:13:21 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GV7XZsiseWhO; Mon, 30 Jan 2017 03:13:21 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A8C664ACF9; Mon, 30 Jan 2017 03:13:15 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 12F474AAD2 for ; Mon, 30 Jan 2017 03:13:07 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I3pFWSlxGJDF for ; Mon, 30 Jan 2017 03:13:06 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by theia.denx.de (Postfix) with ESMTPS id 39F9E4AA22 for ; Mon, 30 Jan 2017 03:13:01 +0100 (CET) Received: from pug.jp.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id v0U2CAlr012402; Mon, 30 Jan 2017 11:12:11 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v0U2CAlr012402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1485742331; bh=IGm9PlIsv+EI4bRD13aW1YHVeIXoEubPahL8Dg95bVM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zy0ij+DzV3txLtii53OHfKO+GycD7cbQsO0IAv3v/BWlQNZ1aHDMU4wbBzNu2nS4Q JCYYTRftYttphCUGIoGy5JxNE0ynJDiwZ7XNNHI/cr9BXmztzYK6n0CfLgbKdvcbgz uT3ScFMQV3Ir/qz6N3mexmVJAYJ3HWF2mDQ/9x0W3emk5wyl6G8AQ8B3wD2/PkcsR4 f0yDpjEqZToA2bBWAyqVEdY9G/1nIs4CRAF0EG833joqjQWSVjClfuDgy4K8DJ1vlp 5PhW1ETUNYxecSSA7vr31pLGqBTpllNM55Buw7TwTx6Ruih4z1RvamCHefRuaySZm3 cD8qmu+QopTHw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Mon, 30 Jan 2017 11:12:06 +0900 Message-Id: <1485742328-32398-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485742328-32398-1-git-send-email-yamada.masahiro@socionext.com> References: <1485742328-32398-1-git-send-email-yamada.masahiro@socionext.com> Cc: Tom Rini Subject: [U-Boot] [PATCH v2 1/3] scripts: import bin2c.c from Linux 4.10-rc6 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Import scripts/basic/bin2c.c of Linux. In Linux Kernel, this file was moved to scripts/basic directory by commit 8370edea81e3 ("bin2c: move bin2c in scripts/basic"). In U-boot, we do not need to follow that commit. Just put it in the original directory "scripts". Signed-off-by: Masahiro Yamada --- Changes in v2: - Fix a typo in git-log. bin2header -> bin2c scripts/bin2c.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 scripts/bin2c.c -- 2.7.4 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot Reviewed-by: Simon Glass diff --git a/scripts/bin2c.c b/scripts/bin2c.c new file mode 100644 index 0000000..c3d7eef --- /dev/null +++ b/scripts/bin2c.c @@ -0,0 +1,36 @@ +/* + * Unloved program to convert a binary on stdin to a C include on stdout + * + * Jan 1999 Matt Mackall + * + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. + */ + +#include + +int main(int argc, char *argv[]) +{ + int ch, total = 0; + + if (argc > 1) + printf("const char %s[] %s=\n", + argv[1], argc > 2 ? argv[2] : ""); + + do { + printf("\t\""); + while ((ch = getchar()) != EOF) { + total++; + printf("\\x%02x", ch); + if (total % 16 == 0) + break; + } + printf("\"\n"); + } while (ch != EOF); + + if (argc > 1) + printf("\t;\n\n#include \n\nconst size_t %s_size = %d;\n", + argv[1], total); + + return 0; +}