Provide od+sed replacement for the bin2char helper

Using custom build-time tools is always more problematic, especially
for cross-compiling.

This alternative implementation assumes "od" (IEEE Std 1003.1-2001)
and sed are available which should be the case for any reasonably
modern system.

Change-Id: I0208f475648c78e7dca127ff4bab60d314b2bf53
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2139
Tested-by: jenkins
Reviewed-by: Fatih Aşıcı <fatih.asici@gmail.com>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
This commit is contained in:
Paul Fertser
2014-05-11 22:15:55 +04:00
committed by Andreas Fritiofson
parent e03eb89cfb
commit f1b04a20dc
6 changed files with 17 additions and 111 deletions

14
src/helper/bin2char.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/sh
[ $# = 0 ] && {
echo "Usage: $0 <varname>"
echo
echo "Read binary data from standard input and write it as a C character"
echo "array <varname> to standard output. Add a final NULL for terminating."
exit 1
}
echo "/* Autogenerated with $0 */"
echo "unsigned const char $1[] = {"
od -v -A n -t x1 | sed 's/ *\(..\) */0x\1,/g'
echo "0 /* NULL-terminated */ };"