aboutsummaryrefslogtreecommitdiff
path: root/ports/teensy/add-memzip.sh
diff options
context:
space:
mode:
authorDamien George2017-09-06 13:40:51 +1000
committerDamien George2017-09-06 13:40:51 +1000
commit01dd7804b87d60b2deab16712eccb3b97351a9b7 (patch)
tree1aa21f38a872b8e62a3d4e4f74f68033c6f827e4 /ports/teensy/add-memzip.sh
parenta9862b30068fc9df1022f08019fb35aaa5085f64 (diff)
ports: Make new ports/ sub-directory and move all ports there.
This is to keep the top-level directory clean, to make it clear what is core and what is a port, and to allow the repository to grow with new ports in a sustainable way.
Diffstat (limited to 'ports/teensy/add-memzip.sh')
-rwxr-xr-xports/teensy/add-memzip.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/ports/teensy/add-memzip.sh b/ports/teensy/add-memzip.sh
new file mode 100755
index 000000000..a00489eff
--- /dev/null
+++ b/ports/teensy/add-memzip.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+if [ "$#" != 3 ]; then
+ echo "Usage: add-memzip.sh input.hex output.hex file-directory"
+ exit 1
+fi
+
+#set -x
+
+input_hex=$1
+output_hex=$2
+memzip_src_dir=$3
+
+input_bin=${input_hex}.bin
+output_bin=${output_hex}.bin
+zip_file=${output_hex}.zip
+zip_base=$(basename ${zip_file})
+zip_dir=$(dirname ${zip_file})
+abs_zip_dir=$(realpath ${zip_dir})
+
+rm -f ${zip_file}
+(cd ${memzip_src_dir}; zip -0 -r -D ${abs_zip_dir}/${zip_base} .)
+objcopy -I ihex -O binary ${input_hex} ${input_bin}
+cat ${input_bin} ${zip_file} > ${output_bin}
+objcopy -I binary -O ihex ${output_bin} ${output_hex}
+echo "Added ${memzip_src_dir} to ${input_hex} creating ${output_hex}"
+