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
|
|
|
|
2024-07-26 18:46:09 +00:00
|
|
|
# set sudo if needed depending on $RISCV
|
|
|
|
ifeq ($(shell mkdir -p $(RISCV)/.test > /dev/null 2>&1 ; echo $$?), 0)
|
|
|
|
SUDO :=
|
|
|
|
else
|
|
|
|
SUDO := sudo
|
|
|
|
endif
|
|
|
|
|
2023-08-05 18:28:33 +00:00
|
|
|
# Buildroot Config Stuff
|
|
|
|
WALLYBOARDSRC := $(WALLYLINUX)/buildroot-config-src/wally
|
|
|
|
WALLYBOARD := $(BUILDROOT)/board/wally
|
|
|
|
|
2024-07-26 18:46:09 +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:
|
2024-07-26 18:46:09 +00:00
|
|
|
ifeq ($(SUDO), sudo)
|
|
|
|
@echo "Cannot write to '$(RISCV)'." \
|
|
|
|
"Using sudo (you may be prompted for your password several times throughout the install)"
|
|
|
|
endif
|
|
|
|
@$(SUDO) mkdir -p $(RISCV)/.test || \
|
|
|
|
(echo "ERROR: Still unable to write to '$(RISCV)'." >&2 \
|
2024-07-24 07:22:28 +00:00
|
|
|
&& exit 1)
|
2024-07-26 18:46:09 +00:00
|
|
|
@$(SUDO) rm -r $(RISCV)/.test
|
2024-04-06 04:38:30 +00:00
|
|
|
|
2023-11-22 02:21:26 +00:00
|
|
|
Image:
|
2024-07-26 22:46:08 +00:00
|
|
|
bash -c "unset LD_LIBRARY_PATH; $(MAKE) -C $(BUILDROOT)"
|
2023-08-09 17:31:14 +00:00
|
|
|
$(MAKE) generate
|
2024-07-26 22:46:08 +00:00
|
|
|
@echo "Buildroot Image successfully generated."
|
2023-08-09 17:31:14 +00:00
|
|
|
|
2024-07-24 07:22:28 +00:00
|
|
|
install: check_write_permissions
|
2024-07-26 18:46:09 +00:00
|
|
|
$(SUDO) rm -rf $(RISCV)/$(BUILDROOT)
|
|
|
|
$(SUDO) mv $(BUILDROOT) $(RISCV)/$(BUILDROOT)
|
2024-07-26 22:46:08 +00:00
|
|
|
@echo "Buildroot successfully installed."
|
2023-11-22 02:21:26 +00:00
|
|
|
|
2024-07-24 07:22:28 +00:00
|
|
|
dumptvs: check_write_permissions
|
2024-07-26 18:46:09 +00:00
|
|
|
$(SUDO) mkdir -p $(RISCV)/linux-testvectors
|
2024-07-27 00:20:56 +00:00
|
|
|
cd testvector-generation; ./genInitMem.sh
|
2024-07-26 22:46:08 +00:00
|
|
|
@echo "Testvectors successfully generated."
|
2024-03-26 17:28:50 +00:00
|
|
|
|
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."
|
2024-07-24 08:09:12 +00:00
|
|
|
@ echo "and sourced setup.sh"
|
2023-08-09 17:31:14 +00:00
|
|
|
|
2023-08-09 05:22:20 +00:00
|
|
|
# Disassembly rules ---------------------------------------------------
|
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)
|
2024-07-26 22:46:08 +00:00
|
|
|
$(MAKE) $(OBJDUMPS)
|
2023-11-22 14:28:38 +00:00
|
|
|
# extract rootfs
|
|
|
|
mkdir -p $(BUILDROOT)/output/images/disassembly/rootfs
|
2024-07-26 22:46:08 +00:00
|
|
|
@echo "Ignore error about dev/console when extracting rootfs from rootfs.cpio"
|
2023-11-22 14:28:38 +00:00
|
|
|
-cpio -i -D $(BUILDROOT)/output/images/disassembly/rootfs < $(BUILDROOT)/output/images/rootfs.cpio
|
2024-07-26 22:46:08 +00:00
|
|
|
@echo "Disassembly successfully completed."
|
2023-08-05 18:28:33 +00:00
|
|
|
|
2023-08-09 05:22:20 +00:00
|
|
|
$(DIS)/%.objdump: $(IMAGES)/%.elf
|
2024-07-27 00:20:56 +00:00
|
|
|
riscv64-unknown-elf-objdump -DS $< >> $@
|
2024-07-27 01:33:09 +00:00
|
|
|
$(WALLY)/bin/extractFunctionRadix.sh $@
|
2023-08-03 00:26:35 +00:00
|
|
|
|
2023-08-09 05:22:20 +00:00
|
|
|
$(DIS)/%.objdump: $(IMAGES)/%
|
2024-07-27 00:20:56 +00:00
|
|
|
riscv64-unknown-elf-objdump -S $< >> $@
|
2024-07-27 01:33:09 +00:00
|
|
|
$(WALLY)/bin/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 --------------------------------
|
2024-08-06 21:57:57 +00:00
|
|
|
download: $(WALLYBOARD)
|
2023-08-05 20:27:17 +00:00
|
|
|
cp $(WALLYBOARD)/main.config $(BUILDROOT)/.config
|
2024-07-26 22:46:08 +00:00
|
|
|
@echo "Buildroot successfully download."
|
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
|
|
|
|
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)
|