changeset 254:45cb81040110

Adding convenience scripts to build and load manufacturing image via SWD.
author Jacob Alexander <haata@kiibohd.com>
date Sun, 16 Nov 2014 13:03:31 -0800
parents e79f2b9c39cf
children 8d41330c194d
files Bootloader/Scripts/generateManufacturingImage.bash Bootloader/Scripts/swdLoad.bash
diffstat 2 files changed, 62 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Bootloader/Scripts/generateManufacturingImage.bash	Sun Nov 16 13:03:31 2014 -0800
@@ -0,0 +1,31 @@
+#!/bin/bash
+# Combines a given bootloader image and firmware image into a single firmware binary
+# Manufacturing deliverable
+
+# Args
+# Argument #1 Path to bootloader binary
+# Argument #2 Path to firmware binary
+# Argument #3 Memory location of the firmware binary (bootloader always starts at address 0x0) in bytes (hex or decimal)
+
+# Must have three args
+if [ "$#" -ne 3 ]; then
+	echo "Usage:   `basename $0` <bootloader binary> <firmware binary> <memory address of firmware>"
+	echo "Example: `basename $0` kiibohd_bootloader.bin kiibohd.dfu.bin 4096"
+	echo "Creates a file called 'kiibohd_manufacturing_<date>.bin'"
+	echo "WARNING: Make sure bootloader is smaller than or equal to the memory address of the firmware binary."
+	exit 1
+fi
+
+# Copy images to /tmp
+cp "$1" /tmp/.
+cp "$2" /tmp/.
+
+bootloader=$(basename "$1")
+firmware=$(basename "$2")
+
+# Pad bootloader binary to given address
+truncate -s "$3" /tmp/"$bootloader"
+
+# Concatenate firmware image onto newly sized bootloader
+cat /tmp/"$bootloader" /tmp/"$firmware" > kiibohd_manufacturing_$(date +%Y-%m-%d).bin
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Bootloader/Scripts/swdLoad.bash	Sun Nov 16 13:03:31 2014 -0800
@@ -0,0 +1,31 @@
+#!/bin/bash
+# Loads firmware image using an SWD Flasher
+# Uses MCHCK ruby flasher toolchain
+# NOTE: Only tested with a buspirate on Linux
+
+# Arg 1: Path to firmware image
+# Arg 2: Address to flash to (byte address)
+
+# Must have two args
+if [ "$#" -ne 2 ]; then
+	echo "Usage:   `basename $0` <firmware binary> <starting address>"
+	echo "Example: `basename $0` kiibohd_bootloader.bin 0"
+	exit 1
+fi
+
+# First check to see if the flasher toolchain is available
+if [ ! -d "programmer" ]; then
+	# Use git to download the toolchain
+	git clone https://github.com/mchck/programmer.git
+fi
+
+# Make sure the toolchain is up to date
+cd programmer
+git pull --rebase
+cd ..
+
+# Attempt to flash
+# Udev rules have been applied to name the buspirate as /dev/buspirate (instead of something like /dev/ttyUSB0)
+# By default only root can access serial devices on Linux
+ruby programmer/flash.rb name=buspirate:dev=/dev/buspirate "$1" "$2"
+