141 lines
4.5 KiB
Makefile
141 lines
4.5 KiB
Makefile
# #############################################
|
|
# (2014) Benjamin Krill <benjamin@krll.de>
|
|
# #############################################
|
|
PWD = $(shell pwd)
|
|
ifndef TOP
|
|
TOP = $(shell while ! test -d syn; do cd .. ; done; pwd)
|
|
export TOP
|
|
endif
|
|
|
|
PROJECT := sockit
|
|
BUILD_DIR := $(PWD)/build_$(PROJECT)
|
|
BUILD_QUARTUS_DIR := $(BUILD_DIR)/quartus
|
|
|
|
##### SOURCE FILES ############################
|
|
SOURCE_QIP = $(TOP)/top/$(PROJECT).qip
|
|
|
|
##### DEFAULT #################################
|
|
.PHONY: default
|
|
default: help
|
|
|
|
##### QSYS ####################################
|
|
.PHONY: qsys-generate qsys-edit
|
|
|
|
QSYS_FILE := $(TOP)/soc/soc_system.qsys
|
|
QSYS_BASE := $(basename $(notdir $(QSYS_FILE)))
|
|
QSYS_OUTDIR := $(BUILD_DIR)/$(QSYS_BASE)
|
|
QSYS_QIP := $(QSYS_OUTDIR)/$(QSYS_BASE).qip
|
|
QSYS_SOPCINFO := $(QSYS_OUTDIR)/$(QSYS_BASE).sopcinfo
|
|
SOURCE_QIP += $(QSYS_QIP)
|
|
|
|
$(QSYS_QIP) qsys-generate: config $(QSYS_FILE)
|
|
ip-generate \
|
|
--component-file=$(QSYS_FILE) \
|
|
--file-set=QUARTUS_SYNTH \
|
|
--output-name=$(QSYS_BASE) \
|
|
--output-directory=$(QSYS_OUTDIR) \
|
|
--reportfile=sopcinfo:$(QSYS_SOPCINFO) \
|
|
--reportfile=qip:$(QSYS_QIP) \
|
|
--language=vhdl
|
|
touch $(QSYS_QIP)
|
|
|
|
qsys-edit: $(QSYS_FILE)
|
|
qsys-edit $^ &
|
|
|
|
HELP_TARGETS += qsys-generate qsys-edit
|
|
qsys-generate.HELP := Generate current QSYS implementation
|
|
qsys-edit.HELP := Edit QSYS implementation
|
|
|
|
##### QUARTUS ###################################
|
|
QUARTUS_QPF := $(PROJECT).qpf
|
|
QUARTUS_QSF := $(PROJECT).qsf
|
|
|
|
tcl: $(BUILD_QUARTUS_DIR)/$(PROJECT).qsf $(BUILD_QUARTUS_DIR)/$(PROJECT).qpf
|
|
@cd $(BUILD_QUARTUS_DIR) && for pin_assign_tcl_file in $$(find $(BUILD_DIR) -name '*_pin_assignments.tcl'); do \
|
|
quartus_map $(QUARTUS_QPF); \
|
|
echo "Applying $${pin_assign_tcl_file} to $(QUARTUS_QPF)..."; \
|
|
quartus_sta -t $${pin_assign_tcl_file} $(QUARTUS_QPF); \
|
|
done
|
|
|
|
$(BUILD_QUARTUS_DIR)/output_files/sockit.sof quartus: tcl
|
|
cd $(BUILD_QUARTUS_DIR) && quartus_sh --flow compile $(QUARTUS_QPF)
|
|
|
|
HELP_TARGETS += quartus
|
|
quartus.HELP := Geneate SOF bitfile
|
|
|
|
##### UBOOT / PRELOADER #########################
|
|
.PHONY: preloader
|
|
PRELOADER_DIR := $(BUILD_DIR)/software/preloader
|
|
QSYS_HPS_INST_NAME := hps_0
|
|
PRELOADER_HANDOFF := $(BUILD_QUARTUS_DIR)/hps_isw_handoff/$(QSYS_BASE)_$(QSYS_HPS_INST_NAME)/
|
|
PRELOADER_ID := $(PRELOADER_HANDOFF)/id
|
|
PRELOADER_DEPS := $(PRELOADER_ID) quartus
|
|
|
|
preloader $(PRELOADER_DIR)/Makefile:
|
|
mkdir -p $(PRELOADER_DIR)
|
|
cd $(PRELOADER_DIR) && bsp-create-settings \
|
|
--type spl \
|
|
--bsp-dir . \
|
|
--preloader-settings-dir "$(PRELOADER_HANDOFF)" \
|
|
--settings settings.bsp \
|
|
--set spl.boot.WATCHDOG_ENABLE false
|
|
make -C $(PRELOADER_DIR)
|
|
|
|
uboot: $(PRELOADER_DIR)/Makefile
|
|
make -C $(PRELOADER_DIR) uboot
|
|
|
|
bsp-edit: $(BUILD_DIR)/software/preloader/settings.bsp
|
|
bsp-editor --settings $^ &
|
|
|
|
HELP_TARGETS += bsp-edit preloader uboot
|
|
bsp-edit.HELP = Edit BSP settings file
|
|
preloader.HELP = Build SoC preloader
|
|
uboot.HELP = Build UBoot
|
|
|
|
##### Device Tree ###############################
|
|
.PHONY: dtb dts
|
|
DTS_BOARDINFO := $(TOP)/soc/soc_system_board_info.xml
|
|
DEVICE_TREE_SOURCE := $(patsubst %.sopcinfo,%.dts,$(QSYS_SOPCINFO))
|
|
DEVICE_TREE_BLOB := $(patsubst %.dts,%.dtb,$(DEVICE_TREE_SOURCE))
|
|
|
|
$(DEVICE_TREE_SOURCE): %.dts: %.sopcinfo
|
|
sopc2dts --input $< --output $@ --board $(DTS_BOARDINFO)
|
|
|
|
$(DEVICE_TREE_BLOB): %.dtb: %.dts
|
|
dtc -I dts -O dtb -o $@ $<
|
|
|
|
dts: $(DEVICE_TREE_SOURCE)
|
|
dtb: $(DEVICE_TREE_BLOB)
|
|
|
|
HELP_TARGETS += dts
|
|
dts.HELP := Generate a device tree for this qsys design (alpha)
|
|
HELP_TARGETS += dtb
|
|
dtb.HELP := Generate a device tree blob for this qsys design (alpha)
|
|
|
|
##### CONFIGURE BUILD ###########################
|
|
.PHONY: config
|
|
config $(BUILD_QUARTUS_DIR)/$(PROJECT).qsf:
|
|
mkdir -p $(BUILD_QUARTUS_DIR)
|
|
cp $(PROJECT).qpf_tmpl $(BUILD_QUARTUS_DIR)/$(PROJECT).qpf
|
|
cp $(PROJECT).qsf_tmpl $(BUILD_QUARTUS_DIR)/$(PROJECT).qsf
|
|
for I in $(SOURCE_QIP); do \
|
|
echo "set_global_assignment -name QIP_FILE $$I" >> $(BUILD_QUARTUS_DIR)/$(PROJECT).qsf; \
|
|
done
|
|
|
|
HELP_TARGETS += config
|
|
config.HELP := create build sandbox
|
|
|
|
##### HELP ######################################
|
|
.PHONY: $(HELP_TARGETS_X) help
|
|
HELP_TARGETS += help
|
|
help.HELP := Displays this info (i.e. the available targets)
|
|
|
|
help: help-header help-targets
|
|
HELP_TARGETS_X := $(patsubst %,help-%,$(sort $(HELP_TARGETS)))
|
|
help-targets: $(HELP_TARGETS_X)
|
|
$(HELP_TARGETS_X): help-%:
|
|
@printf "\t%20s\t - %s\n" $* "$($*.HELP)"
|
|
help-header:
|
|
@printf "\t%20s\t - %s\n" target description\n
|
|
@printf "\t------------------------------------------------------------------------------\n"
|