48 lines
1.0 KiB
Makefile
48 lines
1.0 KiB
Makefile
|
# RISCV environment variable must be set
|
||
|
|
||
|
CC=$(RISCV)/bin/riscv64-unknown-elf-gcc
|
||
|
OBJCOPY=$(RISCV)/bin/riscv64-unknown-elf-objcopy
|
||
|
CFLAGS=-march=rv64imac -mcmodel=medany -O2 -std=gnu11 -Wall -nostartfiles
|
||
|
CFLAGS+= -fno-common -g -DENTROPY=0 -mabi=lp64 -DNONSMP_HART=0
|
||
|
CFLAGS+= -I $(BOOTROM_DIR)/include -I.
|
||
|
LFLAGS=-static -nostdlib -L $(BOOTROM_DIR)/linker -T sdboot.elf.lds
|
||
|
|
||
|
dtb := $(BUILD_DIR)/$(CONFIG).dtb
|
||
|
$(dtb): $(BUILD_DIR)/$(CONFIG).dts
|
||
|
dtc -I dts -O dtb -o $@ $<
|
||
|
|
||
|
.PHONY: dtb
|
||
|
dtb: $(dtb)
|
||
|
|
||
|
elf := $(BUILD_DIR)/sdboot.elf
|
||
|
$(elf): $(dtb) head.S kprintf.c sd.c
|
||
|
$(CC) $(CFLAGS) -DDEVICE_TREE='"$(dtb)"' $(LFLAGS) -o $@ head.S sd.c kprintf.c
|
||
|
|
||
|
.PHONY: elf
|
||
|
elf: $(elf)
|
||
|
|
||
|
bin := $(BUILD_DIR)/sdboot.bin
|
||
|
$(bin): $(elf)
|
||
|
$(OBJCOPY) -O binary $< $@
|
||
|
|
||
|
.PHONY: bin
|
||
|
bin: $(bin)
|
||
|
|
||
|
hex := $(BUILD_DIR)/sdboot.hex
|
||
|
$(hex): $(bin)
|
||
|
od -t x4 -An -w4 -v $< > $@
|
||
|
|
||
|
.PHONY: hex
|
||
|
hex: $(hex)
|
||
|
|
||
|
romgen := $(BUILD_DIR)/rom.v
|
||
|
$(romgen): $(hex)
|
||
|
$(rocketchip_dir)/scripts/vlsi_rom_gen $(ROMCONF) $< > $@
|
||
|
|
||
|
.PHONY: romgen
|
||
|
romgen: $(romgen)
|
||
|
|
||
|
.PHONY: clean
|
||
|
clean::
|
||
|
rm -rf $(hex) $(elf)
|