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:
committed by
Andreas Fritiofson
parent
e03eb89cfb
commit
f1b04a20dc
14
src/helper/bin2char.sh
Executable file
14
src/helper/bin2char.sh
Executable 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 */ };"
|
||||
Reference in New Issue
Block a user