hello_world/Makefile: Add base address define. Add compiler define as gcc-8.
authorAndrey Miroshnikov <andrey@technepisteme.xyz>
Tue, 2 May 2023 16:53:21 +0000 (16:53 +0000)
committerAndrey Miroshnikov <andrey@technepisteme.xyz>
Tue, 2 May 2023 16:53:21 +0000 (16:53 +0000)
hello_world/powerpc.lds.S: Assembler for setting address offset in linker script
hello_world.elf|bin|hex: Removed as these compiled by the user.
Makefile: Set RESET_ADDRESS to 0. Add verilator thread count define (default 1)

Makefile
hello_world/Makefile
hello_world/hello_world.bin [deleted file]
hello_world/hello_world.elf [deleted file]
hello_world/hello_world.hex [deleted file]
hello_world/powerpc.lds [deleted file]
hello_world/powerpc.lds.S [new file with mode: 0644]

index 610f48d8c89be6d5b9902d7f1bf61f8b6d98ffc0..b764793fcdf5409be33a01f2440cea3717cb2a32 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -217,7 +217,7 @@ _fpga_files = fpga/soc_reset.vhdl \
 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)
@@ -249,10 +249,12 @@ microwatt.json: $(synth_files) $(RAM_INIT_FILE)
 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 \
index dd51bd38f9ae428328cb8f0d2c3eea479068d997..d84e7cda4746131e3948e8ebfed0a2b01ced78c3 100644 (file)
@@ -5,21 +5,39 @@ ifneq ("$(ARCH)", "ppc64le")
 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 $^ $@
@@ -28,7 +46,7 @@ hello_world.hex: hello_world.bin
        ../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 *~
 
diff --git a/hello_world/hello_world.bin b/hello_world/hello_world.bin
deleted file mode 100755 (executable)
index e4b14ca..0000000
Binary files a/hello_world/hello_world.bin and /dev/null differ
diff --git a/hello_world/hello_world.elf b/hello_world/hello_world.elf
deleted file mode 100755 (executable)
index 5eeedc4..0000000
Binary files a/hello_world/hello_world.elf and /dev/null differ
diff --git a/hello_world/hello_world.hex b/hello_world/hello_world.hex
deleted file mode 100644 (file)
index 763797e..0000000
+++ /dev/null
@@ -1,785 +0,0 @@
-000000004800012c
-0000000000000000
-4800002408000048
-01006b69a600607d
-a602487d05009f42
-a64b5a7d14004a39
-2402004ca64b7b7d
-00000000480000f4
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-4800002408000048
-01006b69a600607d
-a602487d05009f42
-a64b5a7d14004a39
-2402004ca64b7b7d
-3c20000048000004
-782107c660210000
-60211f0064210000
-618c00003d800000
-658c0000798c07c6
-7d8903a6618c1014
-480000004e800421
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000048000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-e8010010ebc1fff0
-7c0803a6ebe1fff8
-3c4000014e800020
-7c0802a638429800
-f8010010fbe1fff8
-480001edf821ffd1
-6000000060000000
-4800015538628000
-4800004960000000
-7c7f1b7860000000
-57ff063e5463063e
-60000000480000b9
-4082ffe02c1f000d
-480000a53860000a
-4bffffd060000000
-0100000000000000
-3c40000100000180
-6000000038429800
-6000000089228090
-2c09000039428088
-e92a000041820030
-7c0004ac39290014
-712900017d204eaa
-e86a00004182ffec
-7c601eaa7c0004ac
-4e8000205463063e
-39290010e92a0000
-7d204eea7c0004ac
-4082ffec71290001
-38630008e86a0000
-7c601eea7c0004ac
-000000004bffffd0
-0000000000000000
-384298003c400001
-8922809060000000
-3942808860000000
-4182002c2c090000
-39290014e92a0000
-7d204eaa7c0004ac
-4182ffec71290020
-7c0004ace92a0000
-4e8000207c604faa
-39290010e92a0000
-7d204eea7c0004ac
-4082ffec71290008
-e94a00005469063e
-7d2057ea7c0004ac
-000000004e800020
-0000000000000000
-384298003c400001
-fbe1fff87c0802a6
-3be3fffffbc1fff0
-f821ffd1f8010010
-2c3e00008fdf0001
-3821003040820010
-4bfffe4438600000
-4082000c281e000a
-4bffff453860000d
-4bffff3d7fc3f378
-000000004bffffd0
-0000028001000000
-386000007c691b78
-2c0a00007d4918ae
-386300014d820020
-000000004bfffff0
-0000000000000000
-384298003c400001
-614a00203d40c000
-7c0004ac794a0020
-3d20c0007d4056ea
-61290008794a0600
-7c0004ac79290020
-712900207d204eea
-3d20c00041820018
-7929002061290040
-7d204eea7c0004ac
-3d00c0007929f804
-6108200079290fc3
-6000000079080020
-3d00001cf9028088
-7d4a439261082000
-6000000041820084
-9922809039200001
-6108200c3d00c000
-790800203920ff80
-7d2047aa7c0004ac
-7c0004ace9228088
-e92280887d404faa
-39290004794ac202
-7d404faa7c0004ac
-39400003e9228088
-7c0004ac3929000c
-e92280887d404faa
-7c0004ac39290010
-e92280887d404faa
-3929000839400007
-7d404faa7c0004ac
-600000004e800020
-99228090394affff
-612920183d20c000
-7c0004ac79290020
-4e8000207d404fea
-0000000000000000
-3c40000100000000
-6000000038429800
-2c24000089228090
-600000002f890000
-419e0030e9228088
-3940000241820024
-418200082c230000
-39290004614a0001
-7d404faa7c0004ac
-394000004e800020
-418200084bffffe0
-3929002060630002
-7c604fea7c0004ac
-000000004e800020
-0000000000000000
-0000000000000010
-0141780400527a01
-0000001800010c1b
-fffffc4800000018
-300e460000000070
-000000019f7e4111
-0000000000000010
-0141780400527a01
-0000001000010c1b
-fffffc8800000018
-0000000000000084
-0000002c00000010
-00000080fffffcf8
-0000002800000000
-fffffd6400000040
-4109450000000060
-300e43029e019f00
-42000e0a447e4111
-0000000b4106dedf
-0000006c00000010
-00000028fffffd98
-0000001000000000
-fffffdac00000080
-000000000000012c
-0000009400000010
-00000074fffffec4
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-4f4f6f2e2020200a
-0a20202020202e6f
-2020202020222e20
-203b200a202e2220
-3b20202e776d2e20
-6f7263694d202020
-7469202c74746177
-0a2e736b726f7720
-27202027202e2020
-200a202020202e20
-2f207c7c205c2020
-2020200a20202020
-2020203b2e2e3b20
-202020200a202020
-202020203b2e2e3b
-60202020200a2020
-000a202020277777
diff --git a/hello_world/powerpc.lds b/hello_world/powerpc.lds
deleted file mode 100644 (file)
index 96bc6b9..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-SECTIONS
-{
-       _start = .;
-       . = 0;
-       .head : {
-               KEEP(*(.head))
-       }
-       . = 0x1000;
-       .text : { *(.text) }
-       . = 0x1800;
-       .data : { *(.data) }
-       .bss : { *(.bss) }
-}
diff --git a/hello_world/powerpc.lds.S b/hello_world/powerpc.lds.S
new file mode 100644 (file)
index 0000000..06cae4c
--- /dev/null
@@ -0,0 +1,16 @@
+SECTIONS
+{
+       . = BOOT_INIT_BASE;
+       _start = .;
+       start = _start;
+       . = BOOT_INIT_BASE;
+       .head : {
+               KEEP(*(.head))
+       }
+       . = BOOT_INIT_BASE + 0x1000;
+       .text : { *(.text) }
+       . = BOOT_INIT_BASE + 0x1800;
+       .data : { *(.data) }
+       .bss : { *(.bss) }
+}
+