Dave Hylands | d80ee8b | 2014-01-08 01:00:22 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | if [ "$#" != 3 ]; then |
| 4 | echo "Usage: add-memzip.sh input.hex output.hex file-directory" |
| 5 | exit 1 |
| 6 | fi |
| 7 | |
| 8 | #set -x |
| 9 | |
| 10 | input_hex=$1 |
| 11 | output_hex=$2 |
| 12 | memzip_src_dir=$3 |
| 13 | |
| 14 | input_bin=${input_hex}.bin |
| 15 | output_bin=${output_hex}.bin |
| 16 | zip_file=${output_hex}.zip |
| 17 | zip_base=$(basename ${zip_file}) |
| 18 | zip_dir=$(dirname ${zip_file}) |
| 19 | abs_zip_dir=$(realpath ${zip_dir}) |
| 20 | |
| 21 | rm -f ${zip_file} |
| 22 | (cd ${memzip_src_dir}; zip -0 -r -D ${abs_zip_dir}/${zip_base} .) |
| 23 | objcopy -I ihex -O binary ${input_hex} ${input_bin} |
| 24 | cat ${input_bin} ${zip_file} > ${output_bin} |
| 25 | objcopy -I binary -O ihex ${output_bin} ${output_hex} |
| 26 | echo "Added ${memzip_src_dir} to ${input_hex} creating ${output_hex}" |
| 27 | |