Skip to content

Instantly share code, notes, and snippets.

@HepoH3
Created June 20, 2025 13:48
Show Gist options
  • Save HepoH3/c0005d711c1291e7a935d4d4488f4e59 to your computer and use it in GitHub Desktop.
Save HepoH3/c0005d711c1291e7a935d4d4488f4e59 to your computer and use it in GitHub Desktop.
CVA6-SDK Makefile patch for support custom buildroot output dir
diff --git a/Makefile b/Makefile
index a10e303..4207be7 100644
--- a/Makefile
+++ b/Makefile
@@ -6,8 +6,9 @@ RISCV := $(ROOT)/install$(XLEN)
DEST := $(abspath $(RISCV))
PATH := $(DEST)/bin:$(PATH)
GZIP_BIN ?= gzip
+BUILDROOT_OUT ?= $(ROOT)/buildroot/output
-TOOLCHAIN_PREFIX := $(ROOT)/buildroot/output/host/bin/riscv$(XLEN)-buildroot-linux-gnu-
+TOOLCHAIN_PREFIX := $(BUILDROOT_OUT)/host/bin/riscv$(XLEN)-buildroot-linux-gnu-
CC := $(TOOLCHAIN_PREFIX)gcc
OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy
MKIMAGE := u-boot/tools/mkimage
@@ -74,8 +75,8 @@ tests: install-dir $(CC)
cd $(ROOT)
$(CC): $(buildroot_defconfig) $(linux_defconfig) $(busybox_defconfig)
- make -C buildroot defconfig BR2_DEFCONFIG=../$(buildroot_defconfig)
- make -C buildroot host-gcc-final $(buildroot-mk)
+ make -C buildroot defconfig BR2_DEFCONFIG=../$(buildroot_defconfig) O=$(BUILDROOT_OUT)
+ make -C buildroot host-gcc-final $(buildroot-mk) O=$(BUILDROOT_OUT)
all: $(CC) isa-sim
@@ -91,8 +92,8 @@ rootfs/tetris: $(CC)
$(RISCV)/vmlinux: $(buildroot_defconfig) $(linux_defconfig) $(busybox_defconfig) $(CC) rootfs/cachetest.elf rootfs/tetris
mkdir -p $(RISCV)
- make -C buildroot $(buildroot-mk)
- cp buildroot/output/images/vmlinux $@
+ make -C buildroot $(buildroot-mk) O=$(BUILDROOT_OUT)
+ cp $(BUILDROOT_OUT)/images/vmlinux $@
$(RISCV)/Image: $(RISCV)/vmlinux
$(OBJCOPY) -O binary -R .note -R .comment -S $< $@
@@ -169,7 +170,7 @@ clean:
clean-all: clean
rm -rf $(RISCV) riscv-isa-sim/build riscv-tests/build
- make -C buildroot clean
+ make -C buildroot clean O=$(BUILDROOT_OUT)
.PHONY: gcc vmlinux images help fw_payload.bin uImage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment