2024-05-17 12:59:52 +00:00
|
|
|
ifeq ($(ANDROID_NDK_ROOT),)
|
|
|
|
$(error Error : Set the env variable 'ANDROID_NDK_ROOT' with the path of the Android NDK (version 20))
|
|
|
|
endif
|
2024-01-14 08:20:28 +00:00
|
|
|
|
2024-05-17 12:59:52 +00:00
|
|
|
#ARM thumb mode
|
|
|
|
DEVKITARM := $(TOOLCHAINENV)/gcc-arm-none-eabi-10-2020-q4-major
|
2018-05-01 05:15:48 +00:00
|
|
|
|
|
|
|
CC = $(DEVKITARM)/bin/arm-none-eabi-gcc
|
|
|
|
LD = $(DEVKITARM)/bin/arm-none-eabi-ld
|
|
|
|
OBJCOPY = $(DEVKITARM)/bin/arm-none-eabi-objcopy
|
|
|
|
|
2024-01-14 08:20:28 +00:00
|
|
|
TARGET := bootloader
|
|
|
|
BUILD := build
|
|
|
|
SOURCEDIR := loader
|
2018-05-01 05:15:48 +00:00
|
|
|
OBJS = $(addprefix $(BUILD)/, \
|
2024-01-31 08:45:11 +00:00
|
|
|
stack.o \
|
2024-01-14 08:20:28 +00:00
|
|
|
main.o \
|
|
|
|
fuse.o \
|
|
|
|
usb.o \
|
|
|
|
util.o \
|
|
|
|
mc.o \
|
|
|
|
timer.o \
|
|
|
|
clock.o \
|
|
|
|
pinmux.o \
|
|
|
|
gpio.o \
|
2024-01-31 08:45:11 +00:00
|
|
|
heap.o \
|
|
|
|
uart.o \
|
2024-02-11 06:49:57 +00:00
|
|
|
sdram.o \
|
|
|
|
sdram_lp0.o \
|
|
|
|
io.o \
|
2024-01-14 08:20:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
OBJS += $(addprefix $(BUILD)/, \
|
|
|
|
printf.o \
|
2018-05-01 05:15:48 +00:00
|
|
|
)
|
|
|
|
|
2024-01-14 08:20:28 +00:00
|
|
|
INCLUDE:=-I lib/printf -I loader
|
2018-05-01 05:15:48 +00:00
|
|
|
ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork
|
2024-01-14 08:20:28 +00:00
|
|
|
CFLAGS = $(ARCH) $(INCLUDE) -fno-common -nostdlib -lnosys -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-inline -std=gnu11 -lgcc -Wl,--nmagic # -Wall
|
|
|
|
LDFLAGS = $(ARCH) -nostartfiles -lgcc -lnosys -Wl,--nmagic#do not use --gc-sections here,it will cause strange problem
|
2018-05-01 05:15:48 +00:00
|
|
|
|
|
|
|
.PHONY: all clean
|
|
|
|
|
|
|
|
all: $(BUILD)/$(TARGET)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
@rm -rf $(OBJS)
|
|
|
|
@rm -rf $(BUILD)/$(TARGET).elf
|
|
|
|
@rm -rf $(BUILD)/$(TARGET)
|
|
|
|
|
|
|
|
$(BUILD)/$(TARGET): $(BUILD)/$(TARGET).elf
|
|
|
|
$(OBJCOPY) -S -O binary $< $@
|
|
|
|
|
|
|
|
$(BUILD)/$(TARGET).elf: $(OBJS)
|
2024-01-14 08:20:28 +00:00
|
|
|
$(CC) $(LDFLAGS) -T loader/link.ld $^ -o $@
|
2018-05-01 05:15:48 +00:00
|
|
|
|
|
|
|
$(BUILD)/%.o: $(SOURCEDIR)/%.c
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
$(BUILD)/%.o: $(SOURCEDIR)/%.S
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
2024-01-14 08:20:28 +00:00
|
|
|
|
|
|
|
$(BUILD)/%.o: lib/printf/%.c
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|