Permalink
Browse files

add script file for append image's crc and length to boot.bin

  • Loading branch information...
1 parent 4e53273 commit 3904fe866690dfefa2d85cb45f2f3a3a126a7d88 Xiangfu Liu committed Aug 2, 2011
Showing with 68 additions and 0 deletions.
  1. +68 −0 src/append_crc_len.sh
View
68 src/append_crc_len.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+CRC_LEN_TMP=`mktemp`
+
+FILENAMES=\
+standby.fpg,\
+soc-rescue.fpg,\
+bios-rescue.bin,\
+splash-rescue.raw,\
+flickernoise.fbi,\
+soc.fpg,\
+bios.bin,\
+splash.raw,\
+flickernoise.fbi
+
+IFS=',' FILES=( ${FILENAMES} )
+
+create_crc_len_file() {
+ CRC=`mkmmimg $1 | awk '{print $3}'`
+ LEN=`ls -l $1 | awk '{printf "%08x\n",$5}'`
+
+ if [ `basename "$1"` == "bios-rescue.bin" -o `basename "$1"` == "bios.bin" ]; then
+ CRC="00000000"
+ LEN=`ls -l $1 | awk '{printf "%08x\n",$5-4}'`
+ fi
+ if [ `basename "$1"` == "flickernoise.fbi" ]; then
+ CRC="00000000"
+ LEN="00000000"
+ fi
+ # 0 mean length/crc included by themself
+
+ CRC1=`echo $CRC | cut -b1-2`
+ CRC2=`echo $CRC | cut -b3-4`
+ CRC3=`echo $CRC | cut -b5-6`
+ CRC4=`echo $CRC | cut -b7-8`
+
+ LEN1=`echo $LEN | cut -b1-2`
+ LEN2=`echo $LEN | cut -b3-4`
+ LEN3=`echo $LEN | cut -b5-6`
+ LEN4=`echo $LEN | cut -b7-8`
+
+ printf "\\x$(printf "%x" 0x${CRC1})" > ${CRC_LEN_TMP}
+ printf "\\x$(printf "%x" 0x${CRC2})" >> ${CRC_LEN_TMP}
+ printf "\\x$(printf "%x" 0x${CRC3})" >> ${CRC_LEN_TMP}
+ printf "\\x$(printf "%x" 0x${CRC4})" >> ${CRC_LEN_TMP}
+
+ printf "\\x$(printf "%x" 0x${LEN1})" >> ${CRC_LEN_TMP}
+ printf "\\x$(printf "%x" 0x${LEN2})" >> ${CRC_LEN_TMP}
+ printf "\\x$(printf "%x" 0x${LEN3})" >> ${CRC_LEN_TMP}
+ printf "\\x$(printf "%x" 0x${LEN4})" >> ${CRC_LEN_TMP}
+}
+
+cp boot.bin boot.crc.bin
+
+for (( i=0; i<9; i++ ))
+do
+ if [ -e ${IMAGES_DIR}/${FILES[i]} ]; then
+ create_crc_len_file ${IMAGES_DIR}/${FILES[i]}
+ cp -f boot.crc.bin boot.bin.tmp
+ cat boot.bin.tmp ${CRC_LEN_TMP} > boot.crc.bin
+ else
+ echo "${IMAGES_DIR}/${FILES[i]} not exist, check IMAGES_DIR value"
+ exit 1
+ fi
+done
+
+echo "boot.crc.bin created"
+exit 0

0 comments on commit 3904fe8

Please sign in to comment.