diff mbox series

[v2,1/3] scripts: import bin2c.c from Linux 4.10-rc6

Message ID 1485742328-32398-2-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit 6fb631ecdee278b7524a47b02d6c78ce1e12fa17
Headers show
Series cmd: add "config" command, rework "license" command | expand

Commit Message

Masahiro Yamada Jan. 30, 2017, 2:12 a.m. UTC
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 <yamada.masahiro@socionext.com>

---

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

Comments

Simon Glass Feb. 6, 2017, 3:33 p.m. UTC | #1
On 29 January 2017 at 18:12, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> 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 <yamada.masahiro@socionext.com>

> ---

>

> 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


Reviewed-by: Simon Glass <sjg@chromium.org>

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Bin Meng Feb. 7, 2017, 2:38 a.m. UTC | #2
On Mon, Jan 30, 2017 at 10:12 AM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> 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


Sorry for jumping out late, but one nits:

U-boot -> U-Boot

> original directory "scripts".

>

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

> ---

>

> 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

>


[snip]

Regards,
Bin
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Masahiro Yamada Feb. 7, 2017, 12:23 p.m. UTC | #3
Hi Bin,

2017-02-07 11:38 GMT+09:00 Bin Meng <bmeng.cn@gmail.com>:
> On Mon, Jan 30, 2017 at 10:12 AM, Masahiro Yamada

> <yamada.masahiro@socionext.com> wrote:

>> 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

>

> Sorry for jumping out late, but one nits:

>

> U-boot -> U-Boot


Thanks for pointing this out.


Tom,
Could you fix s/U-boot/U-Boot/ when this patch is applied, please?





-- 
Best Regards
Masahiro Yamada
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Tom Rini Feb. 7, 2017, 12:26 p.m. UTC | #4
On Tue, Feb 07, 2017 at 09:23:38PM +0900, Masahiro Yamada wrote:
> Hi Bin,

> 

> 2017-02-07 11:38 GMT+09:00 Bin Meng <bmeng.cn@gmail.com>:

> > On Mon, Jan 30, 2017 at 10:12 AM, Masahiro Yamada

> > <yamada.masahiro@socionext.com> wrote:

> >> 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

> >

> > Sorry for jumping out late, but one nits:

> >

> > U-boot -> U-Boot

> 

> Thanks for pointing this out.

> 

> 

> Tom,

> Could you fix s/U-boot/U-Boot/ when this patch is applied, please?


I'll endeavor to remember :)

-- 
Tom
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Tom Rini Feb. 9, 2017, 3:01 a.m. UTC | #5
On Mon, Jan 30, 2017 at 11:12:06AM +0900, Masahiro Yamada wrote:

> 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 <yamada.masahiro@socionext.com>

> Reviewed-by: Simon Glass <sjg@chromium.org>


Applied to u-boot/master, thanks!

-- 
Tom
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
diff mbox series

Patch

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 <mpm@selenic.com>
+ *
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ */
+
+#include <stdio.h>
+
+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 <linux/types.h>\n\nconst size_t %s_size = %d;\n",
+		       argv[1], total);
+
+	return 0;
+}