| 1 |
# Select the board to build for: |
| 2 |
ifdef BOARD_DIR |
| 3 |
# Custom board path - remove trailing slash and get the final component of |
| 4 |
# the path as the board name. |
| 5 |
BOARD ?= $(notdir $(BOARD_DIR:/=)) |
| 6 |
else |
| 7 |
# If not given on the command line, then default to RA6M2_EK. |
| 8 |
BOARD ?= EK_RA6M2 |
| 9 |
BOARD_DIR ?= boards/$(BOARD) |
| 10 |
endif |
| 11 |
|
| 12 |
ifeq ($(wildcard $(BOARD_DIR)/.),) |
| 13 |
$(error Invalid BOARD specified: $(BOARD_DIR)) |
| 14 |
endif |
| 15 |
|
| 16 |
# If the build directory is not given, make it reflect the board name. |
| 17 |
BUILD ?= build-$(BOARD) |
| 18 |
|
| 19 |
# select use wrapper function of FSP library |
| 20 |
USE_FSP_FLASH = 1 |
| 21 |
|
| 22 |
include ../../py/mkenv.mk |
| 23 |
-include mpconfigport.mk |
| 24 |
include $(BOARD_DIR)/mpconfigboard.mk |
| 25 |
|
| 26 |
USE_FSP_LPM ?= 1 |
| 27 |
USE_FSP_QSPI ?= 0 |
| 28 |
FSP_BOARD_NAME ?= $(shell echo $(BOARD) | tr '[:upper:]' '[:lower:]') |
| 29 |
|
| 30 |
# qstr definitions (must come before including py.mk) |
| 31 |
QSTR_DEFS += qstrdefsport.h |
| 32 |
|
| 33 |
# Files that are generated and needed before the QSTR build. |
| 34 |
QSTR_GLOBAL_DEPENDENCIES += mpconfigboard_common.h $(BOARD_DIR)/mpconfigboard.h |
| 35 |
|
| 36 |
# MicroPython feature configurations |
| 37 |
MICROPY_ROM_TEXT_COMPRESSION ?= 1 |
| 38 |
|
| 39 |
# File containing description of content to be frozen into firmware. |
| 40 |
FROZEN_MANIFEST ?= boards/manifest.py |
| 41 |
|
| 42 |
# include py core make definitions |
| 43 |
include $(TOP)/py/py.mk |
| 44 |
include $(TOP)/extmod/extmod.mk |
| 45 |
|
| 46 |
GIT_SUBMODULES += lib/fsp lib/tinyusb |
| 47 |
|
| 48 |
MCU_SERIES_UPPER = $(shell echo $(MCU_SERIES) | tr '[:lower:]' '[:upper:]') |
| 49 |
CMSIS_MCU_LOWER = $(shell echo $(CMSIS_MCU) | tr '[:upper:]' '[:lower:]') |
| 50 |
|
| 51 |
LD_DIR=boards |
| 52 |
CMSIS_DIR=lib/cmsis/inc |
| 53 |
HAL_DIR=lib/fsp |
| 54 |
STARTUP_FILE ?= lib/fsp/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.o |
| 55 |
SYSTEM_FILE ?= lib/fsp/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/system.o |
| 56 |
|
| 57 |
# Select the cross compile prefix |
| 58 |
CROSS_COMPILE ?= arm-none-eabi- |
| 59 |
|
| 60 |
INC += -imacros boards/compiler_barrier.h |
| 61 |
INC += -I. |
| 62 |
INC += -Ifsp_cfg |
| 63 |
INC += -I$(TOP) |
| 64 |
INC += -I$(BUILD) |
| 65 |
INC += -I$(TOP)/$(CMSIS_DIR) |
| 66 |
INC += -I$(TOP)/$(HAL_DIR) |
| 67 |
INC += -I$(TOP)/$(HAL_DIR)/ra/fsp/inc |
| 68 |
INC += -I$(TOP)/$(HAL_DIR)/ra/fsp/inc/api |
| 69 |
INC += -I$(TOP)/$(HAL_DIR)/ra/fsp/inc/instances |
| 70 |
INC += -I$(TOP)/$(HAL_DIR)/ra/fsp/src/bsp/cmsis/Device/RENESAS/Include |
| 71 |
INC += -I$(TOP)/lib/tinyusb/hw |
| 72 |
INC += -I$(TOP)/lib/tinyusb/src |
| 73 |
INC += -I$(TOP)/shared/tinyusb |
| 74 |
INC += -Ilwip_inc |
| 75 |
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA4M1 RA4W1 RA6M1 RA6M2 RA6M5)) |
| 76 |
INC += -Ira |
| 77 |
endif |
| 78 |
INC += -I$(BOARD_DIR)/ra_gen |
| 79 |
INC += -I$(BOARD_DIR)/ra_cfg/driver |
| 80 |
INC += -I$(BOARD_DIR)/ra_cfg/fsp_cfg |
| 81 |
INC += -I$(BOARD_DIR)/ra_cfg/fsp_cfg/bsp |
| 82 |
INC += -Idebug |
| 83 |
|
| 84 |
CFLAGS += -D$(CMSIS_MCU) |
| 85 |
CFLAGS += -DRA_HAL_H='<$(CMSIS_MCU)_hal.h>' |
| 86 |
CFLAGS += -DRA_CFG_H='<$(FSP_BOARD_NAME)_conf.h>' |
| 87 |
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_RAXXX |
| 88 |
|
| 89 |
# Basic Cortex-M flags |
| 90 |
CFLAGS_CORTEX_M = -mthumb |
| 91 |
|
| 92 |
# Select hardware floating-point support |
| 93 |
SUPPORTS_HARDWARE_FP_SINGLE = 0 |
| 94 |
SUPPORTS_HARDWARE_FP_DOUBLE = 0 |
| 95 |
ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),m4)) |
| 96 |
CFLAGS_CORTEX_M += -mfpu=fpv4-sp-d16 -mfloat-abi=hard |
| 97 |
SUPPORTS_HARDWARE_FP_SINGLE = 1 |
| 98 |
endif |
| 99 |
|
| 100 |
ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),m33)) |
| 101 |
CFLAGS_CORTEX_M += -mfpu=fpv5-sp-d16 -mfloat-abi=hard |
| 102 |
SUPPORTS_HARDWARE_FP_SINGLE = 1 |
| 103 |
endif |
| 104 |
|
| 105 |
# Options for particular MCU series |
| 106 |
CFLAGS_MCU_RA4M1 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4 |
| 107 |
CFLAGS_MCU_RA4W1 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4 |
| 108 |
CFLAGS_MCU_RA6M1 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4 |
| 109 |
CFLAGS_MCU_RA6M2 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4 |
| 110 |
CFLAGS_MCU_RA6M5 = $(CFLAGS_CORTEX_M) -mtune=cortex-m33 -mcpu=cortex-m33 |
| 111 |
|
| 112 |
ASFLAGS += $(CFLAGS_CORTEX_M) -mcpu=cortex-$(MCU_SERIES) |
| 113 |
CFLAGS += $(INC) -Wall -Wpointer-arith -Werror -Wdouble-promotion -Wfloat-conversion -std=gnu99 -nostdlib $(CFLAGS_EXTRA) |
| 114 |
#CFLAGS += -D$(CMSIS_MCU) |
| 115 |
CFLAGS += $(CFLAGS_MCU_$(CMSIS_MCU)) |
| 116 |
CFLAGS += $(COPT) |
| 117 |
CFLAGS += -I$(BOARD_DIR) |
| 118 |
|
| 119 |
# Configure floating point support |
| 120 |
ifeq ($(MICROPY_FLOAT_IMPL),double) |
| 121 |
CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_DOUBLE |
| 122 |
else |
| 123 |
ifeq ($(MICROPY_FLOAT_IMPL),none) |
| 124 |
CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_NONE |
| 125 |
else |
| 126 |
CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT |
| 127 |
CFLAGS += -fsingle-precision-constant |
| 128 |
endif |
| 129 |
endif |
| 130 |
|
| 131 |
LDFLAGS += -nostdlib -L $(LD_DIR) $(addprefix -T,$(LD_FILES)) -Map=$(@:.elf=.map) --cref |
| 132 |
LDFLAGS += --defsym=_estack_reserve=8 |
| 133 |
LIBS += "$(shell $(CC) $(CFLAGS) -print-libgcc-file-name)" |
| 134 |
|
| 135 |
# Remove uncalled code from the final image. |
| 136 |
CFLAGS += -fdata-sections -ffunction-sections |
| 137 |
LDFLAGS += --gc-sections |
| 138 |
|
| 139 |
# Debugging/Optimization |
| 140 |
CFLAGS += -g # always include debug info in the ELF |
| 141 |
ifeq ($(DEBUG), 1) |
| 142 |
CFLAGS += -DPENDSV_DEBUG |
| 143 |
#COPT = -Og |
| 144 |
COPT = -Os |
| 145 |
# Disable text compression in debug builds |
| 146 |
MICROPY_ROM_TEXT_COMPRESSION = 0 |
| 147 |
else |
| 148 |
COPT += -Os -DNDEBUG |
| 149 |
endif |
| 150 |
|
| 151 |
# Flags for optional C++ source code |
| 152 |
CXXFLAGS += $(filter-out -Wmissing-prototypes -Wold-style-definition -std=gnu99,$(CFLAGS)) |
| 153 |
|
| 154 |
# TODO make this common -- shouldn't be using these "private" vars from py.mk |
| 155 |
ifneq ($(SRC_CXX)$(SRC_USERMOD_CXX)$(SRC_USERMOD_LIB_CXX),) |
| 156 |
LIBSTDCPP_FILE_NAME = "$(shell $(CXX) $(CXXFLAGS) -print-file-name=libstdc++.a)" |
| 157 |
LDFLAGS += -L"$(shell dirname $(LIBSTDCPP_FILE_NAME))" |
| 158 |
endif |
| 159 |
|
| 160 |
# Options for mpy-cross |
| 161 |
MPY_CROSS_FLAGS += -march=armv7m |
| 162 |
|
| 163 |
SHARED_SRC_C += $(addprefix shared/,\ |
| 164 |
libc/string0.c \ |
| 165 |
netutils/dhcpserver.c \ |
| 166 |
netutils/netutils.c \ |
| 167 |
netutils/trace.c \ |
| 168 |
readline/readline.c \ |
| 169 |
runtime/gchelper_native.c \ |
| 170 |
runtime/interrupt_char.c \ |
| 171 |
runtime/mpirq.c \ |
| 172 |
runtime/pyexec.c \ |
| 173 |
runtime/softtimer.c \ |
| 174 |
runtime/stdout_helpers.c \ |
| 175 |
runtime/sys_stdio_mphal.c \ |
| 176 |
timeutils/timeutils.c \ |
| 177 |
tinyusb/mp_usbd.c \ |
| 178 |
tinyusb/mp_usbd_cdc.c \ |
| 179 |
tinyusb/mp_usbd_descriptor.c \ |
| 180 |
) |
| 181 |
|
| 182 |
# TinyUSB Stack source |
| 183 |
TINYUSB_SRC_C += $(addprefix lib/tinyusb/,\ |
| 184 |
src/class/cdc/cdc_device.c \ |
| 185 |
src/class/dfu/dfu_rt_device.c \ |
| 186 |
src/class/hid/hid_device.c \ |
| 187 |
src/class/midi/midi_device.c \ |
| 188 |
src/class/msc/msc_device.c \ |
| 189 |
src/class/usbtmc/usbtmc_device.c \ |
| 190 |
src/class/vendor/vendor_device.c \ |
| 191 |
src/common/tusb_fifo.c \ |
| 192 |
src/device/usbd.c \ |
| 193 |
src/device/usbd_control.c \ |
| 194 |
src/portable/renesas/rusb2/dcd_rusb2.c \ |
| 195 |
src/portable/renesas/rusb2/hcd_rusb2.c \ |
| 196 |
src/portable/renesas/rusb2/rusb2_common.c \ |
| 197 |
src/tusb.c \ |
| 198 |
) |
| 199 |
|
| 200 |
ifeq ($(MICROPY_FLOAT_IMPL),double) |
| 201 |
LIBM_SRC_C += $(SRC_LIB_LIBM_DBL_C) |
| 202 |
ifeq ($(SUPPORTS_HARDWARE_FP_DOUBLE),1) |
| 203 |
LIBM_SRC_C += $(SRC_LIB_LIBM_DBL_SQRT_HW_C) |
| 204 |
else |
| 205 |
LIBM_SRC_C += $(SRC_LIB_LIBM_DBL_SQRT_SW_C) |
| 206 |
endif |
| 207 |
else |
| 208 |
LIBM_SRC_C += $(SRC_LIB_LIBM_C) |
| 209 |
ifeq ($(SUPPORTS_HARDWARE_FP_SINGLE),1) |
| 210 |
LIBM_SRC_C += $(SRC_LIB_LIBM_SQRT_HW_C) |
| 211 |
else |
| 212 |
LIBM_SRC_C += $(SRC_LIB_LIBM_SQRT_SW_C) |
| 213 |
endif |
| 214 |
endif |
| 215 |
|
| 216 |
DRIVERS_SRC_C += $(addprefix drivers/,\ |
| 217 |
bus/softspi.c \ |
| 218 |
bus/softqspi.c \ |
| 219 |
memory/spiflash.c \ |
| 220 |
dht/dht.c \ |
| 221 |
) |
| 222 |
|
| 223 |
SRC_C += \ |
| 224 |
boardctrl.c \ |
| 225 |
main.c \ |
| 226 |
ra_hal.c \ |
| 227 |
ra_it.c \ |
| 228 |
rng.c \ |
| 229 |
mphalport.c \ |
| 230 |
mpnetworkport.c \ |
| 231 |
mpthreadport.c \ |
| 232 |
irq.c \ |
| 233 |
pendsv.c \ |
| 234 |
systick.c \ |
| 235 |
powerctrl.c \ |
| 236 |
powerctrlboot.c \ |
| 237 |
pybthread.c \ |
| 238 |
factoryreset.c \ |
| 239 |
timer.c \ |
| 240 |
led.c \ |
| 241 |
uart.c \ |
| 242 |
gccollect.c \ |
| 243 |
help.c \ |
| 244 |
machine_dac.c \ |
| 245 |
machine_i2c.c \ |
| 246 |
machine_spi.c \ |
| 247 |
machine_pin.c \ |
| 248 |
machine_rtc.c \ |
| 249 |
machine_sdcard.c \ |
| 250 |
modrenesas.c \ |
| 251 |
extint.c \ |
| 252 |
usrsw.c \ |
| 253 |
flash.c \ |
| 254 |
flashbdev.c \ |
| 255 |
storage.c \ |
| 256 |
fatfs_port.c \ |
| 257 |
usbd.c \ |
| 258 |
$(wildcard $(BOARD_DIR)/*.c) |
| 259 |
|
| 260 |
SRC_C += $(addprefix $(BOARD_DIR)/ra_gen/,\ |
| 261 |
common_data.c \ |
| 262 |
hal_data.c \ |
| 263 |
pin_data.c \ |
| 264 |
vector_data.c \ |
| 265 |
) |
| 266 |
|
| 267 |
ifeq ($(MICROPY_SSL_MBEDTLS),1) |
| 268 |
LIB_SRC_C += mbedtls/mbedtls_port.c |
| 269 |
endif |
| 270 |
|
| 271 |
ifeq ($(MICROPY_PY_BLUETOOTH),1) |
| 272 |
SRC_C += mpbthciport.c |
| 273 |
endif |
| 274 |
|
| 275 |
ifeq ($(MICROPY_BLUETOOTH_NIMBLE),1) |
| 276 |
SRC_C += mpnimbleport.c |
| 277 |
endif |
| 278 |
|
| 279 |
SRC_O += \ |
| 280 |
$(STARTUP_FILE) \ |
| 281 |
$(SYSTEM_FILE) |
| 282 |
|
| 283 |
SRC_O += \ |
| 284 |
shared/runtime/gchelper_thumb2.o |
| 285 |
|
| 286 |
HAL_SRC_C += $(addprefix $(HAL_DIR)/ra/fsp/src/bsp/mcu/all/,\ |
| 287 |
bsp_clocks.c \ |
| 288 |
bsp_common.c \ |
| 289 |
bsp_delay.c \ |
| 290 |
bsp_group_irq.c \ |
| 291 |
bsp_guard.c \ |
| 292 |
bsp_io.c \ |
| 293 |
bsp_irq.c \ |
| 294 |
bsp_register_protection.c \ |
| 295 |
bsp_rom_registers.c \ |
| 296 |
bsp_sbrk.c \ |
| 297 |
bsp_security.c \ |
| 298 |
) |
| 299 |
|
| 300 |
HAL_SRC_C += $(addprefix $(HAL_DIR)/ra/fsp/src/,\ |
| 301 |
r_ioport/r_ioport.c \ |
| 302 |
r_sci_uart/r_sci_uart.c \ |
| 303 |
) |
| 304 |
|
| 305 |
CFLAGS_FSP = -Wno-unused-variable -Wno-unused-function |
| 306 |
$(BUILD)/lib/fsp/ra/fsp/src/r_sci_uart/r_sci_uart.o: CFLAGS += $(CFLAGS_FSP) |
| 307 |
|
| 308 |
ifeq ($(USE_FSP_QSPI), 1) |
| 309 |
CFLAGS += -DUSE_FSP_QSPI |
| 310 |
HAL_SRC_C += $(HAL_DIR)/ra/fsp/src/r_qspi/r_qspi.c |
| 311 |
endif |
| 312 |
|
| 313 |
ifeq ($(USE_FSP_SDHI), 1) |
| 314 |
CFLAGS += -DUSE_FSP_SDHI |
| 315 |
HAL_SRC_C += $(HAL_DIR)/ra/fsp/src/r_sdhi/r_sdhi.c \ |
| 316 |
$(HAL_DIR)/ra/fsp/src/r_dtc/r_dtc.c |
| 317 |
endif |
| 318 |
|
| 319 |
ifeq ($(USE_FSP_LPM), 1) |
| 320 |
CFLAGS += -DUSE_FSP_LPM |
| 321 |
HAL_SRC_C += $(HAL_DIR)/ra/fsp/src/r_lpm/r_lpm.c |
| 322 |
endif |
| 323 |
|
| 324 |
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA4M1 RA4W1)) |
| 325 |
ifeq ($(USE_FSP_FLASH), 1) |
| 326 |
CFLAGS += -DUSE_FSP_FLASH |
| 327 |
HAL_SRC_C += $(HAL_DIR)/ra/fsp/src/r_flash_lp/r_flash_lp.c |
| 328 |
endif |
| 329 |
endif |
| 330 |
|
| 331 |
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA6M1 RA6M2 RA6M5)) |
| 332 |
ifeq ($(USE_FSP_FLASH), 1) |
| 333 |
CFLAGS += -DUSE_FSP_FLASH |
| 334 |
HAL_SRC_C += $(HAL_DIR)/ra/fsp/src/r_flash_hp/r_flash_hp.c |
| 335 |
endif |
| 336 |
endif |
| 337 |
|
| 338 |
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA4M1 RA4W1 RA6M1 RA6M2 RA6M5)) |
| 339 |
HAL_SRC_C += $(addprefix ra/,\ |
| 340 |
ra_adc.c \ |
| 341 |
ra_dac.c \ |
| 342 |
ra_flash.c \ |
| 343 |
ra_gpio.c \ |
| 344 |
ra_i2c.c \ |
| 345 |
ra_icu.c \ |
| 346 |
ra_init.c \ |
| 347 |
ra_int.c \ |
| 348 |
ra_rtc.c \ |
| 349 |
ra_sci.c \ |
| 350 |
ra_spi.c \ |
| 351 |
ra_timer.c \ |
| 352 |
ra_gpt.c \ |
| 353 |
ra_utils.c \ |
| 354 |
) |
| 355 |
|
| 356 |
endif |
| 357 |
|
| 358 |
ifeq ($(MICROPY_HW_ENABLE_RNG),1) |
| 359 |
CRYPTO_DIR = ra/fsp/src/r_sce_protected/crypto_procedures_protected/src/sce9/ |
| 360 |
|
| 361 |
INC += -I$(TOP)/$(HAL_DIR)/$(CRYPTO_DIR)/inc |
| 362 |
INC += -I$(TOP)/$(HAL_DIR)/$(CRYPTO_DIR)/inc/api |
| 363 |
INC += -I$(TOP)/$(HAL_DIR)/$(CRYPTO_DIR)/private/inc |
| 364 |
INC += -I$(TOP)/$(HAL_DIR)/$(CRYPTO_DIR)/inc/instances |
| 365 |
|
| 366 |
# The following FSP files are required for the random number generator. |
| 367 |
HAL_SRC_C += $(addprefix $(HAL_DIR)/$(CRYPTO_DIR)/,\ |
| 368 |
public/r_sce.c \ |
| 369 |
public/r_sce_ecc.c \ |
| 370 |
public/r_sce_sha.c \ |
| 371 |
public/r_sce_aes.c \ |
| 372 |
private/r_sce_private.c \ |
| 373 |
primitive/r_sce_p00.c \ |
| 374 |
primitive/r_sce_p20.c \ |
| 375 |
primitive/r_sce_p26.c \ |
| 376 |
primitive/r_sce_p81.c \ |
| 377 |
primitive/r_sce_p82.c \ |
| 378 |
primitive/r_sce_p92.c \ |
| 379 |
primitive/r_sce_p40.c \ |
| 380 |
primitive/r_sce_func050.c \ |
| 381 |
primitive/r_sce_func051.c \ |
| 382 |
primitive/r_sce_func052.c \ |
| 383 |
primitive/r_sce_func053.c \ |
| 384 |
primitive/r_sce_func054.c \ |
| 385 |
primitive/r_sce_func100.c \ |
| 386 |
primitive/r_sce_func101.c \ |
| 387 |
primitive/r_sce_func040.c \ |
| 388 |
primitive/r_sce_func048.c \ |
| 389 |
primitive/r_sce_func102.c \ |
| 390 |
primitive/r_sce_func103.c \ |
| 391 |
primitive/r_sce_subprc01.c\ |
| 392 |
) |
| 393 |
endif |
| 394 |
|
| 395 |
OBJ += $(PY_O) |
| 396 |
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o)) |
| 397 |
OBJ += $(addprefix $(BUILD)/, $(LIBM_SRC_C:.c=.o)) |
| 398 |
OBJ += $(addprefix $(BUILD)/, $(SHARED_SRC_C:.c=.o)) |
| 399 |
OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o)) |
| 400 |
OBJ += $(addprefix $(BUILD)/, $(HAL_SRC_C:.c=.o)) |
| 401 |
OBJ += $(addprefix $(BUILD)/, $(TINYUSB_SRC_C:.c=.o)) |
| 402 |
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) |
| 403 |
OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o)) |
| 404 |
OBJ += $(addprefix $(BUILD)/, $(SRC_O)) |
| 405 |
OBJ += $(BUILD)/pins_$(BOARD).o |
| 406 |
|
| 407 |
ifeq ($(CMSIS_MCU),RA6M5) |
| 408 |
$(BUILD)/shared/runtime/gchelper_thumb2.o: $(TOP)/shared/runtime/gchelper_thumb2.s |
| 409 |
$(ECHO) "AS $<" |
| 410 |
$(Q)$(AS) $(ASFLAGS) -o $@ $< |
| 411 |
endif |
| 412 |
|
| 413 |
# This file contains performance critical functions so turn up the optimisation |
| 414 |
# level. It doesn't add much to the code size and improves performance a bit. |
| 415 |
# Don't use -O3 with this file because gcc tries to optimise memset in terms of itself. |
| 416 |
$(BUILD)/shared/libc/string0.o: COPT += -O2 |
| 417 |
|
| 418 |
# We put several files into the first 16K section with the ISRs. |
| 419 |
# If we compile these using -O0 then it won't fit. So if you really want these |
| 420 |
# to be compiled with -O0, then edit boards/common.ld (in the .isr_vector section) |
| 421 |
# and comment out the following lines. |
| 422 |
$(BUILD)/$(OOFATFS_DIR)/ff.o: COPT += -Os |
| 423 |
$(filter $(PY_BUILD)/../extmod/vfs_fat_%.o, $(PY_O)): COPT += -Os |
| 424 |
$(PY_BUILD)/formatfloat.o: COPT += -Os |
| 425 |
$(PY_BUILD)/parsenum.o: COPT += -Os |
| 426 |
$(PY_BUILD)/mpprint.o: COPT += -Os |
| 427 |
|
| 428 |
all: $(TOP)/lib/fsp/README.md $(BUILD)/firmware.hex $(BUILD)/firmware.bin |
| 429 |
|
| 430 |
# For convenience, automatically fetch required submodules if they don't exist |
| 431 |
$(TOP)/lib/fsp/README.md: |
| 432 |
$(ECHO) "fsp submodule not found, fetching it now..." |
| 433 |
(cd $(TOP) && git submodule update --init lib/fsp) |
| 434 |
|
| 435 |
define GENERATE_ELF |
| 436 |
$(ECHO) "LINK $(1)" |
| 437 |
$(Q)$(LD) $(LDFLAGS) -o $(1) $(2) $(LDFLAGS_MOD) $(LIBS) |
| 438 |
$(Q)$(SIZE) $(1) |
| 439 |
endef |
| 440 |
|
| 441 |
define GENERATE_BIN |
| 442 |
$(ECHO) "GEN $(1)" |
| 443 |
$(Q)$(OBJCOPY) -O binary -j .id_code $(2) $(BUILD)/id_code.bin |
| 444 |
$(Q)$(OBJCOPY) -O binary --remove-section=.id_code $(2) $(1) |
| 445 |
endef |
| 446 |
|
| 447 |
define GENERATE_HEX |
| 448 |
$(ECHO) "GEN $(1)" |
| 449 |
$(Q)$(OBJCOPY) -O ihex $(2) $(1) |
| 450 |
endef |
| 451 |
|
| 452 |
.PHONY: |
| 453 |
|
| 454 |
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf |
| 455 |
$(call GENERATE_BIN,$@,$^) |
| 456 |
|
| 457 |
$(BUILD)/firmware.hex: $(BUILD)/firmware.elf |
| 458 |
$(call GENERATE_HEX,$@,$^) |
| 459 |
|
| 460 |
$(BUILD)/firmware.elf: $(OBJ) |
| 461 |
$(call GENERATE_ELF,$@,$^) |
| 462 |
|
| 463 |
MAKE_PINS = boards/make-pins.py |
| 464 |
BOARD_PINS = $(BOARD_DIR)/pins.csv |
| 465 |
PREFIX_FILE = boards/ra_pin_prefix.c |
| 466 |
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA4M1)) |
| 467 |
AF_FILE = boards/ra4m1_af.csv |
| 468 |
endif |
| 469 |
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA4W1)) |
| 470 |
AF_FILE = boards/ra4w1_af.csv |
| 471 |
endif |
| 472 |
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA6M1)) |
| 473 |
AF_FILE = boards/ra6m1_af.csv |
| 474 |
endif |
| 475 |
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA6M2)) |
| 476 |
AF_FILE = boards/ra6m2_af.csv |
| 477 |
endif |
| 478 |
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),RA6M5)) |
| 479 |
AF_FILE = boards/ra6m5_af.csv |
| 480 |
endif |
| 481 |
GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c |
| 482 |
GEN_PINS_HDR = $(HEADER_BUILD)/pins.h |
| 483 |
|
| 484 |
FILE2H = $(TOP)/tools/file2h.py |
| 485 |
|
| 486 |
# List of sources for qstr extraction |
| 487 |
SRC_QSTR += $(SRC_C) $(SRC_CXX) $(SHARED_SRC_C) $(GEN_PINS_SRC) |
| 488 |
|
| 489 |
# Making OBJ use an order-only dependency on the generated pins.h file |
| 490 |
# has the side effect of making the pins.h file before we actually compile |
| 491 |
# any of the objects. The normal dependency generation will deal with the |
| 492 |
# case when pins.h is modified. But when it doesn't exist, we don't know |
| 493 |
# which source files might need it. |
| 494 |
$(OBJ): | $(GEN_PINS_HDR) |
| 495 |
|
| 496 |
# With conditional pins, we may need to regenerate qstrdefs.h when config |
| 497 |
# options change. |
| 498 |
$(HEADER_BUILD)/qstrdefs.generated.h: $(BOARD_DIR)/mpconfigboard.h |
| 499 |
|
| 500 |
# Use a pattern rule here so that make will only call make-pins.py once to make |
| 501 |
# both pins_$(BOARD).c and pins.h |
| 502 |
.PRECIOUS: $(GEN_PINS_SRC) |
| 503 |
$(BUILD)/%_$(BOARD).c $(HEADER_BUILD)/%.h: $(BOARD_DIR)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD) |
| 504 |
$(ECHO) "GEN $@" |
| 505 |
$(Q)$(PYTHON) $(MAKE_PINS) --board-csv $(BOARD_PINS) --af-csv $(AF_FILE) --prefix $(PREFIX_FILE) \ |
| 506 |
--output-source $(GEN_PINS_SRC) --output-header $(GEN_PINS_HDR) |
| 507 |
|
| 508 |
CMSIS_MCU_HDR = $(CMSIS_DIR)/$(CMSIS_MCU_LOWER).h |
| 509 |
|
| 510 |
include $(TOP)/py/mkrules.mk |