2023-08-09 23:00:44 +08:00
|
|
|
TARGET = firmware
|
|
|
|
|
2023-09-14 04:26:18 +08:00
|
|
|
ENABLE_AIRCOPY := 1
|
2023-09-14 23:32:21 +08:00
|
|
|
ENABLE_ALARM := 1
|
2023-09-14 05:55:14 +08:00
|
|
|
ENABLE_FMRADIO := 1
|
2023-09-14 18:30:08 +08:00
|
|
|
ENABLE_NOAA := 1
|
2023-09-14 04:26:18 +08:00
|
|
|
ENABLE_OVERLAY := 1
|
2023-09-16 07:27:18 +08:00
|
|
|
ENABLE_SWD := 0
|
2023-09-14 23:32:21 +08:00
|
|
|
ENABLE_TX1750 := 1
|
2023-09-14 04:26:18 +08:00
|
|
|
ENABLE_UART := 1
|
|
|
|
|
2023-08-09 23:00:44 +08:00
|
|
|
BSP_DEFINITIONS := $(wildcard hardware/*/*.def)
|
|
|
|
BSP_HEADERS := $(patsubst hardware/%,bsp/%,$(BSP_DEFINITIONS))
|
|
|
|
BSP_HEADERS := $(patsubst %.def,%.h,$(BSP_HEADERS))
|
|
|
|
|
|
|
|
OBJS =
|
|
|
|
# Startup files
|
|
|
|
OBJS += start.o
|
|
|
|
OBJS += init.o
|
2023-09-14 04:26:18 +08:00
|
|
|
ifeq ($(ENABLE_OVERLAY),1)
|
2023-09-02 02:20:08 +08:00
|
|
|
OBJS += sram-overlay.o
|
2023-09-14 04:26:18 +08:00
|
|
|
endif
|
2023-08-14 19:00:08 +08:00
|
|
|
OBJS += external/printf/printf.o
|
2023-08-09 23:00:44 +08:00
|
|
|
|
|
|
|
# Drivers
|
2023-08-10 18:42:41 +08:00
|
|
|
OBJS += driver/adc.o
|
2023-09-14 04:26:18 +08:00
|
|
|
ifeq ($(ENABLE_UART),1)
|
2023-09-01 19:27:10 +08:00
|
|
|
OBJS += driver/aes.o
|
2023-09-14 04:26:18 +08:00
|
|
|
endif
|
2023-08-13 00:40:05 +08:00
|
|
|
OBJS += driver/backlight.o
|
2023-09-14 05:55:14 +08:00
|
|
|
ifeq ($(ENABLE_FMRADIO),1)
|
2023-08-10 18:46:22 +08:00
|
|
|
OBJS += driver/bk1080.o
|
2023-09-14 05:55:14 +08:00
|
|
|
endif
|
2023-08-10 18:57:44 +08:00
|
|
|
OBJS += driver/bk4819.o
|
2023-09-14 04:26:18 +08:00
|
|
|
ifeq ($(filter $(ENABLE_AIRCOPY) $(ENABLE_UART),1),1)
|
2023-08-09 23:00:44 +08:00
|
|
|
OBJS += driver/crc.o
|
2023-09-14 04:26:18 +08:00
|
|
|
endif
|
2023-08-09 23:00:44 +08:00
|
|
|
OBJS += driver/eeprom.o
|
2023-09-14 04:26:18 +08:00
|
|
|
ifeq ($(ENABLE_OVERLAY),1)
|
2023-08-09 23:00:44 +08:00
|
|
|
OBJS += driver/flash.o
|
2023-09-14 04:26:18 +08:00
|
|
|
endif
|
2023-08-09 23:00:44 +08:00
|
|
|
OBJS += driver/gpio.o
|
|
|
|
OBJS += driver/i2c.o
|
2023-08-11 04:34:28 +08:00
|
|
|
OBJS += driver/keyboard.o
|
2023-08-09 23:00:44 +08:00
|
|
|
OBJS += driver/spi.o
|
|
|
|
OBJS += driver/st7565.o
|
|
|
|
OBJS += driver/system.o
|
|
|
|
OBJS += driver/systick.o
|
2023-09-14 04:26:18 +08:00
|
|
|
ifeq ($(ENABLE_UART),1)
|
2023-08-09 23:00:44 +08:00
|
|
|
OBJS += driver/uart.o
|
2023-09-14 04:26:18 +08:00
|
|
|
endif
|
2023-08-09 23:00:44 +08:00
|
|
|
|
|
|
|
# Main
|
2023-09-03 04:27:49 +08:00
|
|
|
OBJS += app/action.o
|
2023-09-14 04:26:18 +08:00
|
|
|
ifeq ($(ENABLE_AIRCOPY),1)
|
2023-08-29 01:24:16 +08:00
|
|
|
OBJS += app/aircopy.o
|
2023-09-14 04:26:18 +08:00
|
|
|
endif
|
2023-08-28 06:33:31 +08:00
|
|
|
OBJS += app/app.o
|
2023-08-31 21:22:08 +08:00
|
|
|
OBJS += app/dtmf.o
|
2023-09-14 05:55:14 +08:00
|
|
|
ifeq ($(ENABLE_FMRADIO),1)
|
2023-08-29 07:15:44 +08:00
|
|
|
OBJS += app/fm.o
|
2023-09-14 05:55:14 +08:00
|
|
|
endif
|
2023-08-28 01:18:28 +08:00
|
|
|
OBJS += app/generic.o
|
2023-08-28 03:47:55 +08:00
|
|
|
OBJS += app/main.o
|
2023-08-28 01:04:19 +08:00
|
|
|
OBJS += app/menu.o
|
2023-08-29 23:08:02 +08:00
|
|
|
OBJS += app/scanner.o
|
2023-09-14 04:26:18 +08:00
|
|
|
ifeq ($(ENABLE_UART),1)
|
2023-09-01 06:29:10 +08:00
|
|
|
OBJS += app/uart.o
|
2023-09-14 04:26:18 +08:00
|
|
|
endif
|
2023-08-13 04:33:27 +08:00
|
|
|
OBJS += audio.o
|
2023-08-15 20:57:20 +08:00
|
|
|
OBJS += bitmaps.o
|
2023-08-09 23:00:44 +08:00
|
|
|
OBJS += board.o
|
2023-08-11 22:41:23 +08:00
|
|
|
OBJS += dcs.o
|
2023-08-14 06:08:01 +08:00
|
|
|
OBJS += font.o
|
2023-08-11 00:51:57 +08:00
|
|
|
OBJS += frequencies.o
|
2023-08-14 05:40:33 +08:00
|
|
|
OBJS += functions.o
|
2023-08-29 03:13:33 +08:00
|
|
|
OBJS += helper/battery.o
|
2023-08-29 03:45:33 +08:00
|
|
|
OBJS += helper/boot.o
|
2023-08-11 00:51:57 +08:00
|
|
|
OBJS += misc.o
|
2023-08-11 18:51:17 +08:00
|
|
|
OBJS += radio.o
|
2023-08-15 06:38:59 +08:00
|
|
|
OBJS += scheduler.o
|
2023-08-11 00:51:57 +08:00
|
|
|
OBJS += settings.o
|
2023-09-14 04:26:18 +08:00
|
|
|
ifeq ($(ENABLE_AIRCOPY),1)
|
2023-08-29 01:24:16 +08:00
|
|
|
OBJS += ui/aircopy.o
|
2023-09-14 04:26:18 +08:00
|
|
|
endif
|
2023-08-29 03:13:33 +08:00
|
|
|
OBJS += ui/battery.o
|
2023-09-14 05:55:14 +08:00
|
|
|
ifeq ($(ENABLE_FMRADIO),1)
|
2023-08-29 01:24:16 +08:00
|
|
|
OBJS += ui/fmradio.o
|
2023-09-14 05:55:14 +08:00
|
|
|
endif
|
2023-08-29 01:24:16 +08:00
|
|
|
OBJS += ui/helper.o
|
2023-08-29 00:48:55 +08:00
|
|
|
OBJS += ui/inputbox.o
|
2023-08-29 03:13:33 +08:00
|
|
|
OBJS += ui/lock.o
|
2023-08-29 01:24:16 +08:00
|
|
|
OBJS += ui/main.o
|
|
|
|
OBJS += ui/menu.o
|
2023-08-29 02:44:58 +08:00
|
|
|
OBJS += ui/rssi.o
|
2023-08-29 01:24:16 +08:00
|
|
|
OBJS += ui/scanner.o
|
2023-08-29 03:13:33 +08:00
|
|
|
OBJS += ui/status.o
|
|
|
|
OBJS += ui/ui.o
|
|
|
|
OBJS += ui/welcome.o
|
2023-09-03 06:01:39 +08:00
|
|
|
OBJS += version.o
|
2023-08-15 06:38:59 +08:00
|
|
|
|
2023-08-09 23:00:44 +08:00
|
|
|
OBJS += main.o
|
|
|
|
|
2023-09-02 20:50:24 +08:00
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
TOP := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
|
|
|
|
else
|
2023-08-09 23:00:44 +08:00
|
|
|
TOP := $(shell pwd)
|
2023-09-02 20:50:24 +08:00
|
|
|
endif
|
2023-08-09 23:00:44 +08:00
|
|
|
|
2023-09-14 04:26:18 +08:00
|
|
|
AS = arm-none-eabi-gcc
|
2023-08-09 23:00:44 +08:00
|
|
|
CC = arm-none-eabi-gcc
|
|
|
|
LD = arm-none-eabi-gcc
|
|
|
|
OBJCOPY = arm-none-eabi-objcopy
|
2023-08-13 04:19:34 +08:00
|
|
|
SIZE = arm-none-eabi-size
|
2023-08-09 23:00:44 +08:00
|
|
|
|
2023-09-03 06:01:39 +08:00
|
|
|
GIT_HASH := $(shell git rev-parse --short HEAD)
|
|
|
|
|
2023-09-14 04:26:18 +08:00
|
|
|
ASFLAGS = -c -mcpu=cortex-m0
|
|
|
|
ifeq ($(ENABLE_OVERLAY),1)
|
|
|
|
ASFLAGS += -DENABLE_OVERLAY
|
|
|
|
endif
|
2023-09-02 04:45:57 +08:00
|
|
|
CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
|
2023-08-14 19:00:08 +08:00
|
|
|
CFLAGS += -DPRINTF_INCLUDE_CONFIG_H
|
2023-09-03 06:01:39 +08:00
|
|
|
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
|
2023-09-14 04:26:18 +08:00
|
|
|
ifeq ($(ENABLE_AIRCOPY),1)
|
|
|
|
CFLAGS += -DENABLE_AIRCOPY
|
|
|
|
endif
|
2023-09-14 23:32:21 +08:00
|
|
|
ifeq ($(ENABLE_ALARM),1)
|
|
|
|
CFLAGS += -DENABLE_ALARM
|
|
|
|
endif
|
2023-09-14 05:55:14 +08:00
|
|
|
ifeq ($(ENABLE_FMRADIO),1)
|
|
|
|
CFLAGS += -DENABLE_FMRADIO
|
|
|
|
endif
|
2023-09-14 18:30:08 +08:00
|
|
|
ifeq ($(ENABLE_NOAA),1)
|
|
|
|
CFLAGS += -DENABLE_NOAA
|
|
|
|
endif
|
2023-09-14 04:26:18 +08:00
|
|
|
ifeq ($(ENABLE_OVERLAY),1)
|
|
|
|
CFLAGS += -DENABLE_OVERLAY
|
|
|
|
endif
|
2023-09-16 07:27:18 +08:00
|
|
|
ifeq ($(ENABLE_SWD),1)
|
|
|
|
CFLAGS += -DENABLE_SWD
|
|
|
|
endif
|
2023-09-14 23:32:21 +08:00
|
|
|
ifeq ($(ENABLE_TX1750),1)
|
|
|
|
CFLAGS += -DENABLE_TX1750
|
|
|
|
endif
|
2023-09-14 04:26:18 +08:00
|
|
|
ifeq ($(ENABLE_UART),1)
|
|
|
|
CFLAGS += -DENABLE_UART
|
|
|
|
endif
|
2023-08-09 23:00:44 +08:00
|
|
|
LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
|
|
|
|
|
|
|
|
ifeq ($(DEBUG),1)
|
|
|
|
ASFLAGS += -g
|
|
|
|
CFLAGS += -g
|
|
|
|
LDFLAGS += -g
|
|
|
|
endif
|
|
|
|
|
|
|
|
INC =
|
|
|
|
INC += -I $(TOP)
|
|
|
|
INC += -I $(TOP)/external/CMSIS_5/CMSIS/Core/Include/
|
|
|
|
INC += -I $(TOP)/external/CMSIS_5/Device/ARM/ARMCM0/Include
|
|
|
|
|
|
|
|
LIBS =
|
|
|
|
|
|
|
|
DEPS = $(OBJS:.o=.d)
|
|
|
|
|
|
|
|
all: $(TARGET)
|
|
|
|
$(OBJCOPY) -O binary $< $<.bin
|
2023-09-06 06:13:46 +08:00
|
|
|
-python fw-pack.py $<.bin $(GIT_HASH) $<.packed.bin
|
|
|
|
-python3 fw-pack.py $<.bin $(GIT_HASH) $<.packed.bin
|
2023-08-13 04:19:34 +08:00
|
|
|
$(SIZE) $<
|
2023-08-09 23:00:44 +08:00
|
|
|
|
2023-08-30 07:02:37 +08:00
|
|
|
debug:
|
|
|
|
/opt/openocd/bin/openocd -c "bindto 0.0.0.0" -f interface/jlink.cfg -f dp32g030.cfg
|
|
|
|
|
|
|
|
flash:
|
|
|
|
/opt/openocd/bin/openocd -c "bindto 0.0.0.0" -f interface/jlink.cfg -f dp32g030.cfg -c "write_image firmware.bin 0; shutdown;"
|
|
|
|
|
2023-09-03 06:01:39 +08:00
|
|
|
version.o: .FORCE
|
|
|
|
|
2023-08-09 23:00:44 +08:00
|
|
|
$(TARGET): $(OBJS)
|
|
|
|
$(LD) $(LDFLAGS) $^ -o $@ $(LIBS)
|
|
|
|
|
|
|
|
bsp/dp32g030/%.h: hardware/dp32g030/%.def
|
|
|
|
|
|
|
|
%.o: %.c | $(BSP_HEADERS)
|
2023-09-01 23:53:58 +08:00
|
|
|
$(CC) $(CFLAGS) $(INC) -c $< -o $@
|
2023-08-09 23:00:44 +08:00
|
|
|
|
|
|
|
%.o: %.S
|
|
|
|
$(AS) $(ASFLAGS) $< -o $@
|
|
|
|
|
2023-09-03 06:01:39 +08:00
|
|
|
.FORCE:
|
|
|
|
|
2023-08-09 23:00:44 +08:00
|
|
|
-include $(DEPS)
|
|
|
|
|
|
|
|
clean:
|
2023-09-28 20:41:25 +08:00
|
|
|
rm -f $(TARGET).bin $(TARGET).packed.bin $(TARGET) $(OBJS) $(DEPS)
|
2023-08-09 23:00:44 +08:00
|
|
|
|