Use head/cat, /dev/zero to pad HackRF firmware

dd approach didn't work for at least one user. Resolves #42.
This commit is contained in:
Jared Boone 2015-08-02 11:22:10 -07:00
parent 985cbb874c
commit 255de16d3e

View File

@ -25,7 +25,7 @@ PATH_BASEBAND=baseband
# TODO: Pass these (as #defines?) to Makefiles, use values in code.
PAD_BOOTSTRAP=0x10000
PAD_HACKRF_FIRMWARE=0x10000
PAD_HACKRF_FIRMWARE=65536
PAD_BASEBAND=0x20000
TARGET=portapack-h1-firmware
@ -64,8 +64,8 @@ $(TARGET_BOOTSTRAP)_pad.bin: $(TARGET_BOOTSTRAP).elf
$(TARGET_HACKRF_FIRMWARE)_dfu_pad.bin: $(TARGET_HACKRF_FIRMWARE).dfu
# TODO: Not confident this is reliable. It certainly won't work on Windows.
cp $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_HACKRF_FIRMWARE)_dfu_pad.bin
dd if=/dev/null of=$(TARGET_HACKRF_FIRMWARE)_dfu_pad.bin bs=1 count=1 seek=$(PAD_HACKRF_FIRMWARE)
# Pad the .dfu with zeros, then truncate to the desired length.
head -c $(PAD_HACKRF_FIRMWARE) /dev/zero | cat $(TARGET_HACKRF_FIRMWARE).dfu - | head -c $(PAD_HACKRF_FIRMWARE) >$(TARGET_HACKRF_FIRMWARE)_dfu_pad.bin
$(TARGET_BASEBAND)_pad.bin: $(TARGET_BASEBAND).elf
$(CP) -O binary --pad-to $(PAD_BASEBAND) $(TARGET_BASEBAND).elf $(TARGET_BASEBAND)_pad.bin