mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-10-16 09:52:02 +00:00
Generate SPI flash image with Python, not dd/cat/head.
Addresses issue #42. Windows users now stand a chance of being able to build an image, and all these zero-byte HackRF binary issues should go away.
This commit is contained in:
@@ -23,11 +23,6 @@ PATH_BOOTSTRAP=bootstrap
|
||||
PATH_APPLICATION=application
|
||||
PATH_BASEBAND=baseband
|
||||
|
||||
# TODO: Pass these (as #defines?) to Makefiles, use values in code.
|
||||
PAD_BOOTSTRAP=0x10000
|
||||
PAD_HACKRF_FIRMWARE=65536
|
||||
PAD_BASEBAND=0x20000
|
||||
|
||||
TARGET=portapack-h1-firmware
|
||||
|
||||
TARGET_BOOTSTRAP=$(PATH_BOOTSTRAP)/bootstrap
|
||||
@@ -35,6 +30,8 @@ TARGET_HACKRF_FIRMWARE=hackrf_one_usb_ram
|
||||
TARGET_APPLICATION=$(PATH_APPLICATION)/build/application
|
||||
TARGET_BASEBAND=$(PATH_BASEBAND)/build/baseband
|
||||
|
||||
MAKE_SPI_IMAGE=tools/make_spi_image.py
|
||||
|
||||
DFU_HACKRF=hackrf_one_usb_ram.dfu
|
||||
LICENSE=../LICENSE
|
||||
|
||||
@@ -56,19 +53,14 @@ program: $(TARGET).bin
|
||||
sleep 1s
|
||||
hackrf_spiflash -w $(TARGET).bin
|
||||
|
||||
$(TARGET).bin: $(TARGET_BOOTSTRAP)_pad.bin $(TARGET_HACKRF_FIRMWARE)_dfu_pad.bin $(TARGET_BASEBAND)_pad.bin $(TARGET_APPLICATION).bin
|
||||
cat $(TARGET_BOOTSTRAP)_pad.bin $(TARGET_HACKRF_FIRMWARE)_dfu_pad.bin $(TARGET_BASEBAND)_pad.bin $(TARGET_APPLICATION).bin >$(TARGET).bin
|
||||
$(TARGET).bin: $(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND).bin $(TARGET_APPLICATION).bin
|
||||
$(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND).bin $(TARGET_APPLICATION).bin $(TARGET).bin
|
||||
|
||||
$(TARGET_BOOTSTRAP)_pad.bin: $(TARGET_BOOTSTRAP).elf
|
||||
$(CP) -O binary --pad-to $(PAD_BOOTSTRAP) $(TARGET_BOOTSTRAP).elf $(TARGET_BOOTSTRAP)_pad.bin
|
||||
$(TARGET_BOOTSTRAP).bin: $(TARGET_BOOTSTRAP).elf
|
||||
$(CP) -O binary $(TARGET_BOOTSTRAP).elf $(TARGET_BOOTSTRAP).bin
|
||||
|
||||
$(TARGET_HACKRF_FIRMWARE)_dfu_pad.bin: $(TARGET_HACKRF_FIRMWARE).dfu
|
||||
# TODO: Not confident this is reliable. It certainly won't work on Windows.
|
||||
# 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
|
||||
$(TARGET_BASEBAND).bin: $(TARGET_BASEBAND).elf
|
||||
$(CP) -O binary $(TARGET_BASEBAND).elf $(TARGET_BASEBAND).bin
|
||||
|
||||
$(TARGET_APPLICATION).bin: $(TARGET_APPLICATION).elf
|
||||
$(CP) -O binary $(TARGET_APPLICATION).elf $(TARGET_APPLICATION).bin
|
||||
@@ -84,8 +76,8 @@ $(TARGET_BOOTSTRAP).elf: always_check
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET).bin
|
||||
rm -f $(TARGET_BOOTSTRAP)_pad.bin
|
||||
rm -f $(TARGET_BASEBAND)_pad.bin
|
||||
rm -f $(TARGET_BOOTSTRAP).bin
|
||||
rm -f $(TARGET_BASEBAND).bin
|
||||
rm -f $(TARGET_APPLICATION).bin
|
||||
$(MAKE) -C $(PATH_BASEBAND) clean
|
||||
$(MAKE) -C $(PATH_APPLICATION) clean
|
||||
|
Reference in New Issue
Block a user