version 1.2, 2005/02/15 08:18:56
|
version 1.4, 2005/02/15 09:30:43
|
|
|
#trunc=`sed -e "s/\./g" "$1"` | #trunc=`sed -e "s/\./g" "$1"` |
echo "Exports given file to <filename.ext.hex> - as a hex array" | echo "Exports given file to <filename.ext.hex> - as a hex array" |
echo "(c) Rizwan Kassim 2006" | echo "(c) Rizwan Kassim 2006" |
echo "Bugs - Appends to outputfile, doesn't check for validity" |
#echo "Bugs - Appends to outputfile, doesn't check for validity" |
#echo "needs to remove any . from the arrayname when writing " | #echo "needs to remove any . from the arrayname when writing " |
echo "and needs to remove final comma. " |
#echo "and needs to remove final comma. " |
echo "later, I realized that it would be much easier to do this " |
#echo "later, I realized that it would be much easier to do this " |
echo "in perl (see code for examples" |
#echo "in perl (see code for examples" |
echo "appending to $1.hex!" |
#echo "appending to $1.hex!" |
echo "DONT FORGET TO remove final ," |
#echo "DONT FORGET TO remove final ," |
echo " ============================================ " |
#echo " ============================================ " |
echo "static unsigned char file_$1 = {" >> $1.hex |
#echo "static unsigned char file_$1[] = {" >> $1.hex |
#| grep "s/cab/_/" | #| grep "s/cab/_/" |
od -h $1 | sed "s/^[0-9]\{7\}[ ]*//g" | sed "s/\([0-9a-f]\{2\}\)[ ]*/00x\U\1,/g" | sed "s/\([.]*\),$//" | sed "s/.*/&,/" | sed "s/^,$//g" | sed "/^$/d" >> $1.hex |
#od -h $1 | sed "s/^[0-9]\{7\}[ ]*//g" | sed "s/\([0-9a-f]\{2\}\)[ ]*/0x\U\1,/g" | sed "s/\([.]*\),$//" | sed "s/.*/&,/" | sed "s/^,$//g" | sed "/^$/d" >> $1.hex |
#doesnt just remove end of file but end of every line - sed "s/.$[^^]//" | sed "s/.$//" | | #doesnt just remove end of file but end of every line - sed "s/.$[^^]//" | sed "s/.$//" | |
echo "};" >> $1.hex |
#echo "};" >> $1.hex |
|
#echo "static int szfile_$1 = sizeof(file_$1);" >> $1.hex |
|
#sed -i "s/\./_/g" $1.hex |
|
|
|
echo "version 3 - finally moved the damn thing to perl" |
|
echo "after I realized that od -h doesn't output in left to right byte order " |
|
echo "for some reason! Endianness difference between od behavior?" |
|
echo "" |
|
echo "appending to $1.hex! (this version isn't very good about inserting LFs" |
|
echo " ============================================ " |
|
echo "static unsigned char file_$1[] =" >> $1.hex |
|
perl -0777 -ne 'print "{", join(", ", map sprintf("%#02.2x", ord), split //), "};\n"' < $1 | sed "s/00/0x00/g" >> $1.hex |
echo "static int szfile_$1 = sizeof(file_$1);" >> $1.hex | echo "static int szfile_$1 = sizeof(file_$1);" >> $1.hex |
sed -i "s/\./_/g" $1.hex | sed -i "s/\./_/g" $1.hex |
|
|