Browse Source

projects/boot_stub: Add target to easily build bootloader

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Sylvain Munaut 4 years ago
parent
commit
1cdde8f8ea
1 changed files with 31 additions and 1 deletions
  1. 31 1
      projects/boot_stub/Makefile

+ 31 - 1
projects/boot_stub/Makefile

@@ -18,6 +18,7 @@ NEXTPNR_ARGS = --freq 48 --no-promote-globals
 include ../../build/project-rules.mk
 include ../../build/project-rules.mk
 
 
 # Custom rules
 # Custom rules
+	# Just bootstub in multi-boot image
 $(BUILD_TMP)/boot_mb.bin: $(BUILD_TMP)/$(PROJ).bin
 $(BUILD_TMP)/boot_mb.bin: $(BUILD_TMP)/$(PROJ).bin
 	./utils/mkmultiboot.py $@ $<
 	./utils/mkmultiboot.py $@ $<
 
 
@@ -30,4 +31,33 @@ sudo-prog-mb: $(BUILD_TMP)/boot_mb.bin
 	@echo 'Executing prog as root!!!'
 	@echo 'Executing prog as root!!!'
 	sudo $(ICEPROG) $<
 	sudo $(ICEPROG) $<
 
 
-.PHONY: build-mb prog-mb sudo-prog-mb
+	# Full DFU bootloader image
+DFU_PROJ_BASE=$(realpath $(BUILD_TMP)/../../riscv_usb)
+
+$(BUILD_TMP)/bootloader.bin: $(BUILD_TMP)/$(PROJ).bin $(DFU_PROJ_BASE)/build-tmp/riscv_usb.bin $(DFU_PROJ_BASE)/fw/fw_dfu.bin
+	./utils/mkmultiboot.py $@ $(BUILD_TMP)/$(PROJ).bin $(DFU_PROJ_BASE)/build-tmp/riscv_usb.bin:$(DFU_PROJ_BASE)/fw/fw_dfu.bin
+
+$(DFU_PROJ_BASE)/build-tmp/riscv_usb.bin:
+	make -C $(DFU_PROJ_BASE) BOOT_CODE=dfu
+
+$(DFU_PROJ_BASE)/fw/fw_dfu.bin:
+	make -C $(DFU_PROJ_BASE)/fw fw_dfu.bin
+
+bootloader-clean:
+	if [ "$(PRE_CLEAN)" == "1" ]; then \
+		make clean; \
+		make -C $(DFU_PROJ_BASE) clean; \
+		make -C $(DFU_PROJ_BASE)/fw clean; \
+	fi
+
+bootloader: bootloader-clean $(BUILD_TMP)/bootloader.bin
+
+prog-bootloader: bootloader
+	$(ICEPROG) $(BUILD_TMP)/bootloader.bin
+
+sudo-prog-bootloader: bootloader
+	@echo 'Executing prog as root!!!'
+	sudo $(ICEPROG) $(BUILD_TMP)/bootloader.bin
+
+
+.PHONY: build-mb prog-mb sudo-prog-mb bootloader-clean bootloader prog-bootloader sudo-prog-bootloader