endif
endif
+BOOT_INIT_BASE ?= 0xf0000000 # at QSPI address
+# BOOT_INIT_BASE ?= 0xff000000 # at ROM hi address (with coldboot firmware)
+# BOOT_INIT_BASE ?= 0x0 # start at zero (usual)
+
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
OBJCOPY = $(CROSS_COMPILE)objcopy
-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
+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
hello_world.bin: hello_world.elf
$(OBJCOPY) -O binary $^ $@