EXTERNAL_CORE=false
# VHDL does not allow integers greater than 2^32, so shift down
# by 16 bits and add 16 bits zeros back on in soc-generic.vhdl
-RESET_ADDRESS=65280 # 0xff00_0000>>16
+RESET_ADDRESS=0 # 65280 # 0xff00_0000>>16
ifeq ($(EXTERNAL_CORE),false)
fpga_files = $(_fpga_files) $(_soc_files) $(core_files)
synth_files = $(core_files) $(soc_files) $(fpga_files) $(clkgen) $(toplevel) $(dmi_dtm)
microwatt.v: $(synth_files) $(RAM_INIT_FILE)
$(YOSYS) -m $(GHDLSYNTH) -p "ghdl --std=08 --no-formal $(GHDL_IMAGE_GENERICS) $(GHDL_TARGET_GENERICS) $(synth_files) -e toplevel; write_verilog $@"
+THREADS=1 # How many threads should be used for verilator binary
# Need to investigate why yosys is hitting verilator warnings, and eventually turn on -Wall
# --top-module toplevel
microwatt-verilator: microwatt.v verilator/microwatt-verilator.cpp verilator/uart-verilator.c
verilator -O3 -CFLAGS "-DCLK_FREQUENCY=$(CLK_FREQUENCY) -I../verilator" \
+ --threads $(THREADS) \
--assert \
--cc microwatt.v \
--exe verilator/microwatt-verilator.cpp verilator/uart-verilator.c \
endif
endif
-CC = $(CROSS_COMPILE)gcc
+#BOOT_INIT_BASE ?= 0xf0000000 # at QSPI address
+#BOOT_INIT_BASE ?= 0x00600000 # inside DRAM address space
+#BOOT_INIT_BASE ?= 0xff000000 # at ROM hi address (with coldboot firmware)
+BOOT_INIT_BASE ?= 0x0 # start at zero (usual)
+
+# Debian Buster install doesn't have
+# powerpc64le-linux-gnu-gcc, instead have to specify gcc-8
+COMPILER=gcc-8
+
+CC = $(CROSS_COMPILE)$(COMPILER)
LD = $(CROSS_COMPILE)ld
OBJCOPY = $(CROSS_COMPILE)objcopy
-CFLAGS = -Os -g -Wall -std=c99 -msoft-float -mno-string -mno-multiple -mno-vsx -mno-altivec -mlittle-endian -fno-stack-protector -mstrict-align -ffreestanding -fdata-sections -ffunction-sections -I../include
+CFLAGS = -Os -g -Wall -std=c99 -mabi=elfv2 -msoft-float -mno-string \
+ -mno-multiple -mno-vsx -mno-altivec -mlittle-endian \
+ -fno-stack-protector -mstrict-align -ffreestanding \
+ -fdata-sections -ffunction-sections -I../include \
+ -DBOOT_INIT_BASE=$(BOOT_INIT_BASE)
+
ASFLAGS = $(CFLAGS)
-LDFLAGS = -T powerpc.lds
+LDFLAGS = -static -nostdlib -T powerpc.lds --gc-sections
all: hello_world.hex
+powerpc.lds: powerpc.lds.S
+ $(CC) $(CFLAGS) -P -E powerpc.lds.S -o powerpc.lds
+
console.o: ../lib/console.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
-hello_world.elf: hello_world.o head.o console.o
- $(LD) $(LDFLAGS) -o $@ $^
+hello_world.elf: hello_world.o head.o console.o powerpc.lds
+ $(LD) $(LDFLAGS) -o $@ hello_world.o head.o console.o
+ powerpc64le-linux-gnu-objdump -D hello_world.elf > hello_world.as
hello_world.bin: hello_world.elf
$(OBJCOPY) -O binary $^ $@
../scripts/bin2hex.py $^ > $@
clean:
- @rm -f *.o hello_world.elf hello_world.bin hello_world.hex
+ @rm -f *.o hello_world.elf hello_world.bin hello_world.hex powerpc.lds
distclean: clean
rm -f *~