]> git.donarmstrong.com Git - kiibohd-controller.git/blob - Bootloader/Scripts/generateManufacturingImage.bash
ef46e2dcec49217f3d6422671d2d1dc2c80de21b
[kiibohd-controller.git] / Bootloader / Scripts / generateManufacturingImage.bash
1 #!/bin/bash
2 # Combines a given bootloader image and firmware image into a single firmware binary
3 # Manufacturing deliverable
4
5 # Args
6 # Argument #1 Path to bootloader binary
7 # Argument #2 Path to firmware binary
8 # Argument #3 Memory location of the firmware binary (bootloader always starts at address 0x0) in bytes (hex or decimal)
9
10 # Must have three args
11 if [ "$#" -ne 3 ]; then
12         echo "Usage:   `basename $0` <bootloader binary> <firmware binary> <memory address of firmware>"
13         echo "Example: `basename $0` kiibohd_bootloader.bin kiibohd.dfu.bin 4096"
14         echo "Creates a file called 'kiibohd_manufacturing_<date>.bin'"
15         echo "WARNING: Make sure bootloader is smaller than or equal to the memory address of the firmware binary."
16         exit 1
17 fi
18
19 # Copy images to /tmp
20 cp "$1" /tmp/.
21 cp "$2" /tmp/.
22
23 bootloader=$(basename "$1")
24 firmware=$(basename "$2")
25
26 # Pad bootloader binary to given address
27 truncate -s "$3" /tmp/"$bootloader"
28
29 # Concatenate firmware image onto newly sized bootloader
30 cat /tmp/"$bootloader" /tmp/"$firmware" > kiibohd_manufacturing_$(date +%Y-%m-%d).bin
31