2023-08-02 19:28:17 +00:00
|
|
|
RISCV := /opt/riscv
|
|
|
|
BUILDROOT := ${RISCV}/buildroot
|
|
|
|
IMAGES := ${BUILDROOT}/output/images
|
2023-08-02 21:12:26 +00:00
|
|
|
WALLY := $(shell dirname $(shell pwd))
|
2023-08-02 19:28:17 +00:00
|
|
|
WALLYLINUX := $(shell pwd)
|
2023-08-05 18:28:33 +00:00
|
|
|
DIS := ${IMAGES}/disassembly
|
|
|
|
BRPACKAGES := $(WALLYLINUX)/buildroot-packages
|
|
|
|
|
|
|
|
# Buildroot Config Stuff
|
|
|
|
WALLYBOARDSRC := $(WALLYLINUX)/buildroot-config-src/wally
|
|
|
|
WALLYBOARD := $(BUILDROOT)/board/wally
|
|
|
|
|
|
|
|
# Buildroot Package Stuff
|
2023-08-02 19:56:23 +00:00
|
|
|
PACKAGE_SOURCE := ${WALLYLINUX}/buildroot-packages/package-source
|
|
|
|
FPGA_AXI_SDC := ${WALLYLINUX}/buildroot-packages/fpga-axi-sdc
|
2023-08-02 21:12:26 +00:00
|
|
|
DRIVER := ${PACKAGE_SOURCE}/fpga-axi-sdc.c
|
2023-08-05 18:28:33 +00:00
|
|
|
PATCHFILE := $(BRPACKAGES)/package.patch
|
2023-08-02 19:28:17 +00:00
|
|
|
|
2023-08-05 18:28:33 +00:00
|
|
|
# Device tree files
|
2023-08-04 18:56:03 +00:00
|
|
|
DTS ?= $(shell find -type f -regex ".*\.dts" | sort)
|
|
|
|
DTB := $(DTS:%.dts=%.dtb)
|
|
|
|
DTB := $(foreach name, $(DTB), $(IMAGES)/$(shell basename $(name)))
|
2023-08-02 19:28:17 +00:00
|
|
|
|
2023-08-05 18:28:33 +00:00
|
|
|
# Disassembly stuff
|
|
|
|
BINARIES := fw_jump.elf vmlinux busybox
|
|
|
|
BINARIES := $(foreach name, $(BINARIES), $(shell find -type f -regex ".*$(name)"))
|
|
|
|
OBJDUMPS := fw_jump.objdump vmlinux.objdump busybox.objdump
|
|
|
|
OBJDUMPS := $(foreach name, $(OBJDUMPS), $(DIS)/$(name))
|
|
|
|
|
2023-08-04 18:56:03 +00:00
|
|
|
.PHONY: generate cleanDriver patch clean
|
2023-08-03 00:26:35 +00:00
|
|
|
|
2023-08-04 18:56:03 +00:00
|
|
|
# Generate all device trees
|
|
|
|
# TODO: Add configuration for only generating device tree for specified
|
|
|
|
# supported FPGA.
|
2023-08-05 18:28:33 +00:00
|
|
|
test:
|
|
|
|
|
2023-08-04 18:56:03 +00:00
|
|
|
generate: $(DTB)
|
|
|
|
|
|
|
|
$(DTB): $(DTS)
|
|
|
|
dtc -I dts -O dtb $< > $@
|
2023-08-03 00:26:35 +00:00
|
|
|
|
|
|
|
disassemble:
|
2023-08-05 18:28:33 +00:00
|
|
|
mkdir -p $(DIS)
|
|
|
|
make -j $(OBJDUMPS)
|
|
|
|
|
|
|
|
$(OBJDUMPS): $(BINARIES)
|
|
|
|
riscv64-unknown-elf-objdump -DS $< >> $@
|
2023-08-03 00:26:35 +00:00
|
|
|
|
|
|
|
# Generating new Buildroot directories --------------------------------
|
2023-08-02 19:28:17 +00:00
|
|
|
|
2023-08-05 18:28:33 +00:00
|
|
|
# This directive should be run as: make newbr BUILDROOT=path/to/buildroot
|
|
|
|
newbr: $(BUILDROOT) $(DRIVER)
|
2023-08-02 21:24:20 +00:00
|
|
|
@ echo "Patching buildroot directory at: $<"
|
2023-08-03 00:26:35 +00:00
|
|
|
@ echo "Copying wally configuration files and rootfs_overlay to buildroot."
|
2023-08-02 19:28:17 +00:00
|
|
|
cp -r $(WALLYLINUX)/buildroot-config-src/wally $</board
|
2023-08-03 00:26:35 +00:00
|
|
|
|
2023-08-04 18:56:03 +00:00
|
|
|
@ echo "Moving fpga-axi-sdc driver package to buildroot"
|
2023-08-02 19:28:17 +00:00
|
|
|
cp -r $(WALLYLINUX)/buildroot-packages/fpga-axi-sdc $</package
|
2023-08-04 18:56:03 +00:00
|
|
|
|
|
|
|
@ echo "Package variable FPGA_AXI_SDC_SITE set to: $(PACKAGE_SOURCE)"
|
2023-08-02 19:56:23 +00:00
|
|
|
sed -i 's|FPGA_AXI_SDC_SITE =|FPGA_AXI_SDC_SITE = $(PACKAGE_SOURCE)|1' $(BUILDROOT)/package/fpga-axi-sdc/fpga-axi-sdc.mk
|
2023-08-04 18:56:03 +00:00
|
|
|
|
|
|
|
@ echo "Copying configurations to buildroot."
|
2023-08-05 18:28:33 +00:00
|
|
|
# cp $(WALLYLINUX)/buildroot-config-src/buildroot-2023.05.1/linux.config $</board/wally/linux.config
|
|
|
|
# cp $(WALLYLINUX)/buildroot-config-src/buildroot-2023.05.1/main.config $</board/wally/main.config
|
|
|
|
|
|
|
|
cp $(BRPACKAGES)/linux.config $</board/wally/linux.config
|
|
|
|
cp $(BRPACKAGES)/wally.config $</board/wally/main.config
|
2023-08-04 18:56:03 +00:00
|
|
|
|
|
|
|
@ echo "Patching buildroot directory."
|
2023-08-05 18:28:33 +00:00
|
|
|
# cd $<; git apply $(WALLYLINUX)/buildroot-packages/package-2023.05.1.patch
|
|
|
|
cd $<; git apply $(WALLYLINUX)/buildroot-packages/package.patch
|
2023-08-04 18:56:03 +00:00
|
|
|
|
|
|
|
@ echo "Copying main buildroot configuration as .config"
|
2023-08-02 21:12:26 +00:00
|
|
|
cd $<; cp $(BUILDROOT)/board/wally/main.config $(BUILDROOT)/.config
|
2023-08-02 19:28:17 +00:00
|
|
|
|
2023-08-05 18:28:33 +00:00
|
|
|
patch: $(BUILDROOT)/package/fpga-axi-sdc $(WALLYBOARD)/main.config $(WALLYBOARD)/linux.config
|
|
|
|
|
|
|
|
# CONFIG DEPENDENCIES 2021.05 -----------------------------------------
|
|
|
|
$(WALLYBOARD)/main.config: $(WALLYBOARD) $(BRPACKAGES)/wally.config
|
|
|
|
cp $(BRPACKAGES)/wally.config $@
|
|
|
|
|
|
|
|
$(WALLYBOARD)/linux.config: $(WALLYBOARD) $(BRPACKAGES)/linux.config
|
|
|
|
cp $(BRPACKAGES)/linux.config $@
|
|
|
|
|
|
|
|
$(WALLYBOARD): $(BUILDROOT)
|
|
|
|
cp -r $(WALLYBOARDSRC) $(BUILDROOT)/board
|
|
|
|
|
|
|
|
# Buildroot Package ---------------------------------------------------
|
|
|
|
$(BUILDROOT)/package/fpga-axi-sdc: $(BUILDROOT) $(PATCHFILE) $(BRPACKAGES)/fpga-axi-sdc
|
|
|
|
cp -r $(BRPACKAGES)/fpga-axi-sdc $(BUILDROOT)/package
|
|
|
|
sed -i 's|FPGA_AXI_SDC_SITE =|FPGA_AXI_SDC_SITE = $(PACKAGE_SOURCE)|1' $(BUILDROOT)/package/fpga-axi-sdc/fpga-axi-sdc.mk
|
|
|
|
cd $(BUILDROOT); git apply $(PATCHFILE)
|
|
|
|
|
2023-08-02 19:28:17 +00:00
|
|
|
$(BUILDROOT):
|
|
|
|
git clone https://github.com/buildroot/buildroot.git $@
|
2023-08-05 18:28:33 +00:00
|
|
|
# cd $@; git checkout 2023.05.x
|
|
|
|
cd $@; git checkout 2021.05
|
2023-08-02 19:28:17 +00:00
|
|
|
|
2023-08-02 21:12:26 +00:00
|
|
|
$(DRIVER):
|
|
|
|
@ if [ -d "$(WALLY)/addins/vivado-risc-v" ] ; then git submodule update --init $(WALLY)/addins/vivado-risc-v; fi
|
2023-08-02 21:24:20 +00:00
|
|
|
cp ../addins/vivado-risc-v/patches/fpga-axi-sdc.c $@
|
2023-08-05 18:28:33 +00:00
|
|
|
# For 2021.05
|
|
|
|
sed "s|card_hw_reset|hw_reset|1" ../addins/vivado-riscv/patches/fpga-axi-sdc.c
|
2023-08-02 21:12:26 +00:00
|
|
|
|
2023-08-02 23:59:42 +00:00
|
|
|
$(IMAGES):
|
|
|
|
@ echo "No output/images directory in buildroot."
|
2023-08-03 00:26:35 +00:00
|
|
|
@ echo "Run make --jobs in buildroot directory before generating device tree binaries."; exit 1
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
2023-08-02 23:59:42 +00:00
|
|
|
|
2023-08-03 00:26:35 +00:00
|
|
|
cleanDriver:
|
2023-08-02 23:59:42 +00:00
|
|
|
rm -f $(DRIVER)
|
2023-08-04 18:56:03 +00:00
|
|
|
|
|
|
|
clean:
|
|
|
|
ls $(IMAGES)
|
|
|
|
rm -rf $(IMAGES)/*.dtb
|
2023-08-05 18:28:33 +00:00
|
|
|
rm -rf $(DIS)
|
2023-08-04 18:56:03 +00:00
|
|
|
ls $(IMAGES)
|