2023-11-22 02:21:26 +00:00
|
|
|
BUILDROOT := buildroot
|
2023-08-02 19:28:17 +00:00
|
|
|
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
|
2023-09-01 04:58:10 +00:00
|
|
|
BR2023 := $(WALLYLINUX)/buildroot-config-src/buildroot-2023.05.1
|
2023-08-05 18:28:33 +00:00
|
|
|
|
|
|
|
# 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-09-25 23:04:51 +00:00
|
|
|
PATCHFILE := $(BRPACKAGES)/package-2023.05.1.patch
|
2023-08-02 19:28:17 +00:00
|
|
|
|
2023-08-05 18:28:33 +00:00
|
|
|
# Device tree files
|
2023-11-22 03:20:11 +00:00
|
|
|
DTS ?= $(shell find devicetree -type f -regex ".*\.dts" | sort)
|
2023-08-04 18:56:03 +00:00
|
|
|
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
|
2023-08-09 17:31:14 +00:00
|
|
|
OBJDUMPS := $(foreach name, $(BINARIES), $(basename $(name) .elf))
|
|
|
|
OBJDUMPS := $(foreach name, $(OBJDUMPS), $(DIS)/$(name).objdump)
|
2023-08-05 18:28:33 +00:00
|
|
|
|
2024-07-24 07:22:28 +00:00
|
|
|
.PHONY: all generate disassemble install clean cleanDTB cleanDriver check_write_permissions
|
2023-08-03 00:26:35 +00:00
|
|
|
|
2024-07-24 07:22:28 +00:00
|
|
|
all: check_write_permissions clean download Image disassemble install dumptvs
|
2023-11-22 02:21:26 +00:00
|
|
|
|
2024-07-24 07:22:28 +00:00
|
|
|
check_write_permissions:
|
|
|
|
@mkdir -p $(RISCV)/.test || \
|
|
|
|
(echo "ERROR: Cannot write to '$(RISCV)'." \
|
|
|
|
"Make sure you have write permissions (you may need to run as sudo).'" \
|
|
|
|
&& exit 1)
|
|
|
|
@rm -r $(RISCV)/.test
|
2024-04-06 04:38:30 +00:00
|
|
|
|
2023-11-22 02:21:26 +00:00
|
|
|
Image:
|
2024-07-24 01:39:25 +00:00
|
|
|
bash -c "unset LD_LIBRARY_PATH; make -C $(BUILDROOT) --jobs ${shell nproc --ignore 1};"
|
2023-08-09 17:31:14 +00:00
|
|
|
$(MAKE) generate
|
|
|
|
|
2024-07-24 07:22:28 +00:00
|
|
|
install: check_write_permissions
|
2024-03-19 21:38:58 +00:00
|
|
|
rm -rf $(RISCV)/$(BUILDROOT)
|
|
|
|
mv $(BUILDROOT) $(RISCV)/$(BUILDROOT)
|
2023-11-22 02:21:26 +00:00
|
|
|
|
2024-07-24 07:22:28 +00:00
|
|
|
dumptvs: check_write_permissions
|
2024-04-06 03:44:11 +00:00
|
|
|
mkdir -p $(RISCV)/linux-testvectors
|
2024-03-26 17:28:50 +00:00
|
|
|
cd testvector-generation; ./genInitMem.sh
|
|
|
|
|
2023-08-09 05:22:20 +00:00
|
|
|
generate: $(DTB) $(IMAGES)
|
2023-08-04 18:56:03 +00:00
|
|
|
|
2023-08-09 05:22:20 +00:00
|
|
|
$(IMAGES)/%.dtb: ./devicetree/%.dts
|
2023-08-05 20:27:17 +00:00
|
|
|
dtc -I dts -O dtb $< > $@
|
|
|
|
|
|
|
|
$(IMAGES):
|
|
|
|
@ echo "No output/images directory in buildroot."
|
|
|
|
@ echo "Run make --jobs in buildroot directory before generating device tree binaries."; exit 1
|
2023-08-03 00:26:35 +00:00
|
|
|
|
2023-08-09 17:31:14 +00:00
|
|
|
$(RISCV):
|
|
|
|
@ echo "ERROR: No $(RISCV) directory. Make sure you have installed the Wally Toolchain."
|
|
|
|
@ echo "this can be done with <WALLY>/bin/wally-tool-chain-install.sh"
|
|
|
|
|
2023-08-09 05:22:20 +00:00
|
|
|
# Disassembly rules ---------------------------------------------------
|
|
|
|
|
2023-11-21 23:59:22 +00:00
|
|
|
|
2023-08-03 00:26:35 +00:00
|
|
|
disassemble:
|
2023-11-22 05:52:11 +00:00
|
|
|
rm -rf $(BUILDROOT)/output/images/disassembly
|
2023-11-22 02:47:57 +00:00
|
|
|
find $(BUILDROOT)/output/build/linux-* -maxdepth 1 -name "vmlinux" | xargs cp -t $(BUILDROOT)/output/images/
|
2023-08-05 18:28:33 +00:00
|
|
|
mkdir -p $(DIS)
|
|
|
|
make -j $(OBJDUMPS)
|
2023-11-22 14:28:38 +00:00
|
|
|
# extract rootfs
|
|
|
|
mkdir -p $(BUILDROOT)/output/images/disassembly/rootfs
|
|
|
|
echo "Ignore error about dev/console when extracting rootfs from rootfs.cpio"
|
|
|
|
-cpio -i -D $(BUILDROOT)/output/images/disassembly/rootfs < $(BUILDROOT)/output/images/rootfs.cpio
|
2023-08-05 18:28:33 +00:00
|
|
|
|
2023-08-09 05:22:20 +00:00
|
|
|
$(DIS)/%.objdump: $(IMAGES)/%.elf
|
2023-08-05 18:28:33 +00:00
|
|
|
riscv64-unknown-elf-objdump -DS $< >> $@
|
2023-11-22 04:00:53 +00:00
|
|
|
extractFunctionRadix.sh $@
|
2023-08-03 00:26:35 +00:00
|
|
|
|
2023-08-09 05:22:20 +00:00
|
|
|
$(DIS)/%.objdump: $(IMAGES)/%
|
|
|
|
riscv64-unknown-elf-objdump -S $< >> $@
|
2023-11-22 04:00:53 +00:00
|
|
|
extractFunctionRadix.sh $@
|
2023-08-09 05:22:20 +00:00
|
|
|
|
2023-09-26 20:16:45 +00:00
|
|
|
$(IMAGES)/vmlinux:
|
|
|
|
linuxDir=$$(find $(BUILDROOT)/output/build -maxdepth 2 -type d -regex ".*/linux-[0-9]+\.[0-9]+\.[0-9]+$$") ;\
|
|
|
|
cp $$linuxDir/vmlinux $@ ;\
|
2023-08-09 05:22:20 +00:00
|
|
|
|
2023-09-26 20:16:45 +00:00
|
|
|
$(IMAGES)/busybox:
|
|
|
|
busyboxDir=$$(find $(BUILDROOT)/output/build -maxdepth 2 -type d -regex ".*/busybox-[0-9]+\.[0-9]+\.[0-9]+$$") ;\
|
|
|
|
cp $$busyboxDir/busybox $@ ;\
|
2023-08-09 05:22:20 +00:00
|
|
|
|
2023-08-03 00:26:35 +00:00
|
|
|
# Generating new Buildroot directories --------------------------------
|
2023-08-02 19:28:17 +00:00
|
|
|
|
2023-08-09 05:22:20 +00:00
|
|
|
# This directive should be run as: make install BUILDROOT=path/to/buildroot
|
2023-11-22 02:21:26 +00:00
|
|
|
download: $(BUILDROOT)/package/fpga-axi-sdc $(WALLYBOARD)
|
2023-08-05 20:27:17 +00:00
|
|
|
cp $(WALLYBOARD)/main.config $(BUILDROOT)/.config
|
2023-08-05 18:28:33 +00:00
|
|
|
|
2023-09-01 04:58:10 +00:00
|
|
|
# CONFIG DEPENDENCIES 2023.05.1 ---------------------------------------
|
2023-08-05 18:28:33 +00:00
|
|
|
$(WALLYBOARD): $(BUILDROOT)
|
|
|
|
cp -r $(WALLYBOARDSRC) $(BUILDROOT)/board
|
2023-09-01 04:58:10 +00:00
|
|
|
cp $(BR2023)/main.config $(WALLYBOARD)/main.config
|
|
|
|
cp $(BR2023)/linux.config $(WALLYBOARD)/linux.config
|
2023-08-05 18:28:33 +00:00
|
|
|
|
|
|
|
# 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
|
2023-08-06 23:50:37 +00:00
|
|
|
cd $(BUILDROOT); if git apply --check $(PATCHFILE) > /dev/null ; then git apply $(PATCHFILE); fi
|
2023-08-05 18:28:33 +00:00
|
|
|
|
2023-08-05 20:27:17 +00:00
|
|
|
$(PATCHFILE):
|
|
|
|
cd $(BUILDROOT); git apply $(PATCHFILE)
|
|
|
|
|
2023-08-02 19:28:17 +00:00
|
|
|
$(BUILDROOT):
|
|
|
|
git clone https://github.com/buildroot/buildroot.git $@
|
2023-09-01 04:58:10 +00:00
|
|
|
cd $@; git checkout 2023.05.x
|
2023-08-03 00:26:35 +00:00
|
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
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
|
|
|
|
2023-08-09 05:22:20 +00:00
|
|
|
cleanDTB:
|
|
|
|
rm -f $(IMAGES)/*.dtb
|
|
|
|
|
2023-08-04 18:56:03 +00:00
|
|
|
clean:
|
2023-12-13 19:33:59 +00:00
|
|
|
rm -rf $(BUILDROOT)
|