2017-08-19 03:21:04 +02:00
|
|
|
# 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
|
|
|
|
|
2018-02-25 19:33:25 +01:00
|
|
|
dtb := $(BUILD_DIR)/$(CONFIG_PROJECT).$(CONFIG).dtb
|
|
|
|
$(dtb): $(BUILD_DIR)/$(CONFIG_PROJECT).$(CONFIG).dts
|
2017-08-19 03:21:04 +02:00
|
|
|
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)
|