Makefile can now build linux/bbl
This commit is contained in:
		
							
								
								
									
										34
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								Makefile
									
									
									
									
									
								
							@@ -4,6 +4,9 @@ CFLAGS=-O3 -Wall -I src
 | 
			
		||||
LDFLAGS=-lpthread
 | 
			
		||||
BUILD_DIR=build
 | 
			
		||||
 | 
			
		||||
# Risc-V toolchain
 | 
			
		||||
RV_LINUX_CCPREFIX=riscv32-unknown-linux-gnu-
 | 
			
		||||
 | 
			
		||||
C_FILES := $(shell find src/ -name '*.c')
 | 
			
		||||
 | 
			
		||||
all: $(BUILD_DIR)/$(NAME)
 | 
			
		||||
@@ -21,10 +24,37 @@ $(BUILD_DIR):
 | 
			
		||||
clean:
 | 
			
		||||
	rm -rf $(BUILD_DIR)
 | 
			
		||||
 | 
			
		||||
rungdb: all
 | 
			
		||||
	echo $(shell objdump -h ../riscv-pk/build/bbl | grep .payload | awk '{print $4}')
 | 
			
		||||
 | 
			
		||||
$(BUILD_DIR)/linux:
 | 
			
		||||
	cd $(BUILD_DIR) && git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git --depth 1 -b v6.6
 | 
			
		||||
 | 
			
		||||
$(BUILD_DIR)/linux/.config: hardware/linux.config
 | 
			
		||||
	cp hardware/linux.config $(BUILD_DIR)/linux/.config
 | 
			
		||||
 | 
			
		||||
$(BUILD_DIR)/linux/vmlinux: $(BUILD_DIR)/linux/.config | $(BUILD_DIR)/linux
 | 
			
		||||
	cd $(BUILD_DIR)/linux/ && make ARCH=riscv CROSS_COMPILE=$(RV_LINUX_CCPREFIX) -j7 vmlinux
 | 
			
		||||
 | 
			
		||||
$(BUILD_DIR)/riscv-pk:
 | 
			
		||||
	cd $(BUILD_DIR) && git clone https://github.com/riscv-software-src/riscv-pk --depth 1
 | 
			
		||||
 | 
			
		||||
$(BUILD_DIR)/riscv-pk/build: | $(BUILD_DIR)/riscv-pk
 | 
			
		||||
	mkdir $(BUILD_DIR)/riscv-pk/build
 | 
			
		||||
 | 
			
		||||
$(BUILD_DIR)/riscv-pk/build/bbl: $(BUILD_DIR)/linux/vmlinux hardware/vriscv.dts | $(BUILD_DIR)/riscv-pk/build
 | 
			
		||||
	cd $(BUILD_DIR)/riscv-pk/build && ../configure \
 | 
			
		||||
	--prefix=$(CURDIR)/$(BUILD_DIR)/riscv-pk/build/prefix \
 | 
			
		||||
	--host=riscv32-unknown-elf \
 | 
			
		||||
	--with-arch=rv32ima_zicsr_zifencei --with-abi=ilp32 \
 | 
			
		||||
	--with-dts=../../../hardware/vriscv.dts \
 | 
			
		||||
	--with-payload=../../linux/vmlinux
 | 
			
		||||
	cd $(BUILD_DIR)/riscv-pk/build && make && make install
 | 
			
		||||
 | 
			
		||||
.PHONY: run
 | 
			
		||||
.SILENT: run
 | 
			
		||||
run: all
 | 
			
		||||
	./$(BUILD_DIR)/$(NAME)
 | 
			
		||||
run: all $(BUILD_DIR)/riscv-pk/build/bbl
 | 
			
		||||
	./$(BUILD_DIR)/$(NAME) -m4096 $(BUILD_DIR)/riscv-pk/build/bbl
 | 
			
		||||
 | 
			
		||||
.PHONY: tests
 | 
			
		||||
.SILENT: tests
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user