2015-02-06 09:35:48 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-10-28 06:09:45 -04:00
|
|
|
if [ "$#" -ne 1 ]; then
|
|
|
|
echo "Usage: bootgen.sh *build dir*"
|
2015-02-28 06:20:04 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-10-28 06:09:45 -04:00
|
|
|
BUILD=$1
|
2015-02-28 06:20:04 -05:00
|
|
|
|
2015-02-06 09:35:48 -05:00
|
|
|
# Re-locator Path
|
|
|
|
RELOCATOR=bootmgr/relocator
|
|
|
|
|
2015-10-28 06:09:45 -04:00
|
|
|
# Build location
|
|
|
|
BOOTMGR=${BUILD}
|
2015-02-06 09:35:48 -05:00
|
|
|
|
|
|
|
# Check for re-locator binary
|
|
|
|
if [ ! -f $RELOCATOR/relocator.bin ]; then
|
|
|
|
|
|
|
|
echo "Error : Relocator Not found!"
|
2015-02-21 04:52:19 -05:00
|
|
|
exit 1
|
2015-02-06 09:35:48 -05:00
|
|
|
else
|
|
|
|
echo "Relocator found..."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check for boot manager binary
|
|
|
|
if [ ! -f $BOOTMGR/bootmgr.bin ]; then
|
|
|
|
|
|
|
|
echo "Error : Boot Manager Not found!"
|
2015-02-21 04:52:19 -05:00
|
|
|
exit 1
|
2015-02-06 09:35:48 -05:00
|
|
|
else
|
|
|
|
echo "Boot Manager found..."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# echo
|
|
|
|
echo "Generating bootloader..."
|
|
|
|
|
|
|
|
# Generate an all 0 bin file
|
|
|
|
dd if=/dev/zero of=__tmp.bin ibs=1 count=256 conv=notrunc >/dev/null 2>&1
|
|
|
|
|
2015-02-21 04:52:19 -05:00
|
|
|
# Generate a 0 padded version of the relocator
|
2015-02-06 09:35:48 -05:00
|
|
|
dd if=$RELOCATOR/relocator.bin of=__tmp.bin ibs=1 conv=notrunc >/dev/null 2>&1
|
|
|
|
|
2015-02-21 04:52:19 -05:00
|
|
|
# Concatenate the re-locator and the boot-manager
|
2015-02-06 09:35:48 -05:00
|
|
|
cat __tmp.bin $BOOTMGR/bootmgr.bin > $BOOTMGR/bootloader.bin
|
|
|
|
|
|
|
|
# Remove the tmp files
|
|
|
|
rm -f __tmp.bin
|
|
|
|
|
|
|
|
# Remove bootmgr.bin
|
|
|
|
rm -f $BOOTMGR/bootmgr.bin
|