2018-05-01 06:15:48 +01:00
|
|
|
ifeq ($(strip $(DEVKITARM)),)
|
|
|
|
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
|
|
|
endif
|
|
|
|
|
2018-06-08 10:42:24 +01:00
|
|
|
include $(DEVKITARM)/base_rules
|
2018-05-01 06:15:48 +01:00
|
|
|
|
2019-03-07 22:19:04 +00:00
|
|
|
################################################################################
|
|
|
|
|
2019-02-24 00:43:13 +00:00
|
|
|
IPL_LOAD_ADDR := 0x40008000
|
2019-03-07 21:53:58 +00:00
|
|
|
IPL_MAGIC := 0x43544349 #"ICTC"
|
2019-12-11 09:22:11 +00:00
|
|
|
include ./Versions.inc
|
2019-02-24 00:43:13 +00:00
|
|
|
|
2019-03-07 22:19:04 +00:00
|
|
|
################################################################################
|
|
|
|
|
2019-02-24 00:43:13 +00:00
|
|
|
TARGET := hekate
|
2019-03-07 22:19:04 +00:00
|
|
|
BUILDDIR := build
|
|
|
|
OUTPUTDIR := output
|
2018-08-13 09:58:24 +01:00
|
|
|
SOURCEDIR = bootloader
|
2020-06-14 14:45:45 +01:00
|
|
|
BDKDIR := bdk
|
|
|
|
BDKINC := -I./$(BDKDIR)
|
2020-03-03 23:34:35 +00:00
|
|
|
VPATH = $(dir ./$(SOURCEDIR)/) $(dir $(wildcard ./$(SOURCEDIR)/*/)) $(dir $(wildcard ./$(SOURCEDIR)/*/*/))
|
2020-06-16 10:41:42 +01:00
|
|
|
VPATH += $(dir $(wildcard ./$(BDKDIR)/)) $(dir $(wildcard ./$(BDKDIR)/*/)) $(dir $(wildcard ./$(BDKDIR)/*/*/))
|
2018-08-07 15:53:58 +01:00
|
|
|
|
2019-03-07 22:19:04 +00:00
|
|
|
# Main and graphics.
|
|
|
|
OBJS = $(addprefix $(BUILDDIR)/$(TARGET)/, \
|
2020-04-30 01:25:22 +01:00
|
|
|
start.o exception_handlers.o \
|
2019-03-07 22:19:04 +00:00
|
|
|
main.o heap.o \
|
|
|
|
gfx.o tui.o \
|
|
|
|
fe_emmc_tools.o fe_info.o fe_tools.o \
|
|
|
|
)
|
|
|
|
|
|
|
|
# Hardware.
|
|
|
|
OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
|
2020-06-14 11:34:13 +01:00
|
|
|
bpmp.o ccplex.o clock.o di.o gpio.o i2c.o irq.o mc.o sdram.o \
|
2020-07-17 22:42:53 +01:00
|
|
|
pinmux.o pmc.o se.o smmu.o tsec.o uart.o \
|
2019-06-30 01:49:33 +01:00
|
|
|
fuse.o kfuse.o minerva.o \
|
2022-01-20 11:15:04 +00:00
|
|
|
sdmmc.o sdmmc_driver.o emmc.o sd.o emummc.o \
|
2019-03-07 22:19:04 +00:00
|
|
|
bq24193.o max17050.o max7762x.o max77620-rtc.o \
|
2018-11-27 09:45:43 +00:00
|
|
|
hw_init.o \
|
2018-05-01 06:15:48 +01:00
|
|
|
)
|
2018-08-07 15:53:58 +01:00
|
|
|
|
2019-03-07 22:19:04 +00:00
|
|
|
# Utilities.
|
|
|
|
OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
|
|
|
|
btn.o dirlist.o ianos.o util.o \
|
|
|
|
config.o ini.o \
|
|
|
|
)
|
|
|
|
|
|
|
|
# Horizon.
|
|
|
|
OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
|
2021-08-28 16:10:20 +01:00
|
|
|
hos.o hos_config.o pkg1.o pkg2.o pkg2_ini_kippatch.o fss.o secmon_exo.o \
|
2019-03-07 22:19:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Libraries.
|
|
|
|
OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
|
2020-07-04 19:58:21 +01:00
|
|
|
lz.o lz4.o blz.o \
|
2018-08-13 09:58:24 +01:00
|
|
|
diskio.o ff.o ffunicode.o ffsystem.o \
|
|
|
|
elfload.o elfreloc_arm.o \
|
|
|
|
)
|
2018-05-01 06:15:48 +01:00
|
|
|
|
2020-06-14 14:45:45 +01:00
|
|
|
GFX_INC := '"../$(SOURCEDIR)/gfx/gfx.h"'
|
|
|
|
FFCFG_INC := '"../$(SOURCEDIR)/libs/fatfs/ffconf.h"'
|
|
|
|
|
2019-03-07 22:19:04 +00:00
|
|
|
################################################################################
|
|
|
|
|
2019-12-08 00:23:03 +00:00
|
|
|
CUSTOMDEFINES := -DIPL_LOAD_ADDR=$(IPL_LOAD_ADDR) -DBL_MAGIC=$(IPL_MAGIC)
|
2019-12-11 09:22:11 +00:00
|
|
|
CUSTOMDEFINES += -DBL_VER_MJ=$(BLVERSION_MAJOR) -DBL_VER_MN=$(BLVERSION_MINOR) -DBL_VER_HF=$(BLVERSION_HOTFX) -DBL_RESERVED=$(BLVERSION_RSVD)
|
|
|
|
CUSTOMDEFINES += -DNYX_VER_MJ=$(NYXVERSION_MAJOR) -DNYX_VER_MN=$(NYXVERSION_MINOR) -DNYX_VER_HF=$(NYXVERSION_HOTFX) -DNYX_RESERVED=$(NYXVERSION_RSVD)
|
2022-01-20 11:15:04 +00:00
|
|
|
|
|
|
|
# BDK defines.
|
2022-01-28 23:29:39 +00:00
|
|
|
CUSTOMDEFINES += -DBDK_MC_ENABLE_AHB_REDIRECT -DBDK_EMUMMC_ENABLE
|
2020-06-14 14:45:45 +01:00
|
|
|
CUSTOMDEFINES += -DGFX_INC=$(GFX_INC) -DFFCFG_INC=$(FFCFG_INC)
|
2019-03-07 21:53:58 +00:00
|
|
|
|
|
|
|
#CUSTOMDEFINES += -DDEBUG
|
|
|
|
|
2020-12-11 16:14:00 +00:00
|
|
|
# UART Logging: Max baudrate 12.5M.
|
|
|
|
# DEBUG_UART_PORT - 0: UART_A, 1: UART_B, 2: UART_C.
|
|
|
|
#CUSTOMDEFINES += -DDEBUG_UART_BAUDRATE=115200 -DDEBUG_UART_INVERT=0 -DDEBUG_UART_PORT=0
|
|
|
|
|
2021-05-11 07:51:08 +01:00
|
|
|
#TODO: Considering reinstating some of these when pointer warnings have been fixed.
|
|
|
|
WARNINGS := -Wall -Wno-array-bounds -Wno-stringop-overread -Wno-stringop-overflow
|
|
|
|
|
2018-05-01 06:15:48 +01:00
|
|
|
ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork
|
2022-01-28 23:43:16 +00:00
|
|
|
CFLAGS = $(ARCH) -O2 -g -gdwarf-4 -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-inline -std=gnu11 $(WARNINGS) $(CUSTOMDEFINES)
|
2019-02-24 00:43:13 +00:00
|
|
|
LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections -Xlinker --defsym=IPL_LOAD_ADDR=$(IPL_LOAD_ADDR)
|
2018-05-01 06:15:48 +01:00
|
|
|
|
2018-08-07 15:53:58 +01:00
|
|
|
MODULEDIRS := $(wildcard modules/*)
|
2019-06-30 02:03:00 +01:00
|
|
|
NYXDIR := $(wildcard nyx)
|
2020-07-04 20:12:12 +01:00
|
|
|
LDRDIR := $(wildcard loader)
|
|
|
|
TOOLSLZ := $(wildcard tools/lz)
|
|
|
|
TOOLSB2C := $(wildcard tools/bin2c)
|
|
|
|
TOOLS := $(TOOLSLZ) $(TOOLSB2C)
|
2018-08-07 15:53:58 +01:00
|
|
|
|
2019-03-07 22:19:04 +00:00
|
|
|
################################################################################
|
|
|
|
|
2020-07-04 20:12:12 +01:00
|
|
|
.PHONY: all clean $(MODULEDIRS) $(NYXDIR) $(LDRDIR) $(TOOLS)
|
2018-05-01 06:15:48 +01:00
|
|
|
|
2020-07-04 20:12:12 +01:00
|
|
|
all: $(TARGET).bin $(LDRDIR)
|
2020-07-14 18:56:56 +01:00
|
|
|
@printf ICTC49 >> $(OUTPUTDIR)/$(TARGET).bin
|
|
|
|
@echo "--------------------------------------"
|
2020-07-04 20:12:12 +01:00
|
|
|
@echo -n "Uncompr size: "
|
|
|
|
$(eval BIN_SIZE = $(shell wc -c < $(OUTPUTDIR)/$(TARGET)_unc.bin))
|
|
|
|
@echo $(BIN_SIZE)" Bytes"
|
|
|
|
@echo "Uncompr Max: 140288 Bytes + 3 KiB BSS"
|
|
|
|
@if [ ${BIN_SIZE} -gt 140288 ]; then echo "\e[1;33mUncompr size exceeds limit!\e[0m"; fi
|
2020-07-14 18:56:56 +01:00
|
|
|
@echo -n "Payload size: "
|
2020-03-24 18:06:10 +00:00
|
|
|
$(eval BIN_SIZE = $(shell wc -c < $(OUTPUTDIR)/$(TARGET).bin))
|
2020-07-14 18:56:56 +01:00
|
|
|
@echo $(BIN_SIZE)" Bytes"
|
|
|
|
@echo "Payload Max: 126296 Bytes"
|
2020-03-24 18:06:10 +00:00
|
|
|
@if [ ${BIN_SIZE} -gt 126296 ]; then echo "\e[1;33mPayload size exceeds limit!\e[0m"; fi
|
2020-07-14 18:56:56 +01:00
|
|
|
@echo "--------------------------------------"
|
2018-05-01 06:15:48 +01:00
|
|
|
|
2020-12-26 14:17:03 +00:00
|
|
|
clean: $(TOOLS)
|
2018-05-01 06:15:48 +01:00
|
|
|
@rm -rf $(OBJS)
|
2019-03-07 22:19:04 +00:00
|
|
|
@rm -rf $(BUILDDIR)
|
|
|
|
@rm -rf $(OUTPUTDIR)
|
2018-08-07 15:53:58 +01:00
|
|
|
|
|
|
|
$(MODULEDIRS):
|
2020-07-14 18:56:56 +01:00
|
|
|
@$(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS) -$(MAKEFLAGS)
|
2018-05-01 06:15:48 +01:00
|
|
|
|
2019-06-30 02:03:00 +01:00
|
|
|
$(NYXDIR):
|
2020-07-14 18:56:56 +01:00
|
|
|
@$(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS) -$(MAKEFLAGS)
|
2019-06-30 02:03:00 +01:00
|
|
|
|
2020-07-04 20:12:12 +01:00
|
|
|
$(LDRDIR): $(TARGET).bin
|
|
|
|
@$(TOOLSLZ)/lz77 $(OUTPUTDIR)/$(TARGET).bin
|
|
|
|
mv $(OUTPUTDIR)/$(TARGET).bin $(OUTPUTDIR)/$(TARGET)_unc.bin
|
|
|
|
@mv $(OUTPUTDIR)/$(TARGET).bin.00.lz payload_00
|
|
|
|
@mv $(OUTPUTDIR)/$(TARGET).bin.01.lz payload_01
|
|
|
|
@$(TOOLSB2C)/bin2c payload_00 > $(LDRDIR)/payload_00.h
|
|
|
|
@$(TOOLSB2C)/bin2c payload_01 > $(LDRDIR)/payload_01.h
|
|
|
|
@rm payload_00
|
|
|
|
@rm payload_01
|
|
|
|
@$(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS) -$(MAKEFLAGS) PAYLOAD_NAME=$(TARGET)
|
|
|
|
|
|
|
|
$(TOOLS):
|
|
|
|
@$(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS) -$(MAKEFLAGS)
|
|
|
|
|
|
|
|
$(TARGET).bin: $(BUILDDIR)/$(TARGET)/$(TARGET).elf $(MODULEDIRS) $(NYXDIR) $(TOOLS)
|
2019-03-07 22:19:04 +00:00
|
|
|
$(OBJCOPY) -S -O binary $< $(OUTPUTDIR)/$@
|
2018-05-01 06:15:48 +01:00
|
|
|
|
2019-03-07 22:19:04 +00:00
|
|
|
$(BUILDDIR)/$(TARGET)/$(TARGET).elf: $(OBJS)
|
2020-06-13 16:39:17 +01:00
|
|
|
@$(CC) $(LDFLAGS) -T $(SOURCEDIR)/link.ld $^ -o $@
|
|
|
|
@echo "hekate was built with the following flags:\nCFLAGS: "$(CFLAGS)"\nLDFLAGS: "$(LDFLAGS)
|
2018-05-01 06:15:48 +01:00
|
|
|
|
2019-03-07 22:19:04 +00:00
|
|
|
$(BUILDDIR)/$(TARGET)/%.o: %.c
|
2020-06-13 16:39:17 +01:00
|
|
|
@echo Building $@
|
2020-06-14 14:45:45 +01:00
|
|
|
@$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@
|
2018-05-01 06:15:48 +01:00
|
|
|
|
2019-03-07 22:19:04 +00:00
|
|
|
$(BUILDDIR)/$(TARGET)/%.o: %.S
|
2020-06-13 16:39:17 +01:00
|
|
|
@echo Building $@
|
|
|
|
@$(CC) $(CFLAGS) -c $< -o $@
|
2020-03-03 23:34:35 +00:00
|
|
|
|
|
|
|
$(OBJS): $(BUILDDIR)/$(TARGET)
|
|
|
|
|
|
|
|
$(BUILDDIR)/$(TARGET):
|
2019-03-07 22:19:04 +00:00
|
|
|
@mkdir -p "$(BUILDDIR)"
|
|
|
|
@mkdir -p "$(BUILDDIR)/$(TARGET)"
|
|
|
|
@mkdir -p "$(OUTPUTDIR)"
|