Kiibohd Controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

generateManufacturingImage.bash 1.1KB

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