|
| 1 | +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. |
| 2 | +# Copyright (c) 2016 Sandeep Mistry All right reserved. |
| 3 | +# Copyright (c) 2017 Adafruit Industries. All rights reserved. |
| 4 | +# |
| 5 | +# This library is free software; you can redistribute it and/or |
| 6 | +# modify it under the terms of the GNU Lesser General Public |
| 7 | +# License as published by the Free Software Foundation; either |
| 8 | +# version 2.1 of the License, or (at your option) any later version. |
| 9 | +# |
| 10 | +# This library is distributed in the hope that it will be useful, |
| 11 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | +# See the GNU Lesser General Public License for more details. |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU Lesser General Public |
| 16 | +# License along with this library; if not, write to the Free Software |
| 17 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | + |
| 19 | +name=Adafruit nRF52 Boards |
| 20 | +version=0.22.0 |
| 21 | + |
| 22 | +# Compile variables |
| 23 | +# ----------------- |
| 24 | + |
| 25 | +compiler.warning_flags=-w |
| 26 | +compiler.warning_flags.none=-w |
| 27 | +compiler.warning_flags.default= |
| 28 | +compiler.warning_flags.more=-Wall |
| 29 | +compiler.warning_flags.all=-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith |
| 30 | + |
| 31 | +# Allow changing optimization settings via platform.local.txt / boards.local.txt |
| 32 | +compiler.optimization_flag=-Ofast |
| 33 | + |
| 34 | +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ |
| 35 | +compiler.c.cmd=arm-none-eabi-gcc |
| 36 | +compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD |
| 37 | + |
| 38 | +# KH, Error here to use gcc, must use g++ |
| 39 | +#compiler.c.elf.cmd=arm-none-eabi-gcc |
| 40 | +compiler.c.elf.cmd=arm-none-eabi-g++ |
| 41 | + |
| 42 | +compiler.c.elf.flags={compiler.optimization_flag} -Wl,--gc-sections -save-temps |
| 43 | +compiler.S.cmd=arm-none-eabi-gcc |
| 44 | +compiler.S.flags=-mcpu={build.mcu} -mthumb -mabi=aapcs {compiler.optimization_flag} -g -c {build.float_flags} -x assembler-with-cpp |
| 45 | + |
| 46 | +compiler.cpp.cmd=arm-none-eabi-g++ |
| 47 | +compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD |
| 48 | +compiler.ar.cmd=arm-none-eabi-ar |
| 49 | +compiler.ar.flags=rcs |
| 50 | +compiler.objcopy.cmd=arm-none-eabi-objcopy |
| 51 | +compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 |
| 52 | +compiler.elf2bin.flags=-O binary |
| 53 | +compiler.elf2bin.cmd=arm-none-eabi-objcopy |
| 54 | +compiler.elf2hex.flags=-O ihex |
| 55 | +compiler.elf2hex.cmd=arm-none-eabi-objcopy |
| 56 | +compiler.ldflags=-mcpu={build.mcu} -mthumb {build.float_flags} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align --specs=nano.specs --specs=nosys.specs |
| 57 | +compiler.size.cmd=arm-none-eabi-size |
| 58 | + |
| 59 | +# this can be overriden in boards.txt |
| 60 | +build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float |
| 61 | +build.debug_flags=-DCFG_DEBUG=0 |
| 62 | +build.logger_flags=-DCFG_LOGGER=1 |
| 63 | +build.sysview_flags=-DCFG_SYSVIEW=0 |
| 64 | + |
| 65 | +# common compiler for nrf |
| 66 | +rtos.path={build.core.path}/freertos |
| 67 | +nordic.path={build.core.path}/nordic |
| 68 | + |
| 69 | +# build.logger_flags and build.sysview_flags are intentionally empty, |
| 70 | +# to allow modification via a user's own boards.local.txt or platform.local.txt files. |
| 71 | +build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 {compiler.optimization_flag} {build.debug_flags} {build.logger_flags} {build.sysview_flags} "-I{build.core.path}/cmsis/Core/Include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include/nrf52" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" |
| 72 | + |
| 73 | +# usb flags |
| 74 | +build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' |
| 75 | + |
| 76 | +# These can be overridden in platform.local.txt |
| 77 | +compiler.c.extra_flags= |
| 78 | +compiler.c.elf.extra_flags= |
| 79 | +compiler.cpp.extra_flags= |
| 80 | +compiler.S.extra_flags= |
| 81 | +compiler.ar.extra_flags= |
| 82 | +compiler.libraries.ldflags= |
| 83 | +compiler.elf2bin.extra_flags= |
| 84 | +compiler.elf2hex.extra_flags= |
| 85 | + |
| 86 | + |
| 87 | +# Compile patterns |
| 88 | +# ---------------- |
| 89 | + |
| 90 | +## Compile c files |
| 91 | +## KH Add -DBOARD_NAME="{build.board}" |
| 92 | +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" |
| 93 | + |
| 94 | +## Compile c++ files |
| 95 | +## KH Add -DBOARD_NAME="{build.board}" |
| 96 | +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" |
| 97 | + |
| 98 | +## Compile S files |
| 99 | +## KH Add -DBOARD_NAME="{build.board}" |
| 100 | +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}" |
| 101 | + |
| 102 | +## Create archives |
| 103 | +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" |
| 104 | + |
| 105 | +## Combine gc-sections, archives, and objects |
| 106 | +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-L{build.core.path}/linker" "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} -Wl,--start-group -lm "{build.path}/{archive_file}" {compiler.libraries.ldflags} -Wl,--end-group |
| 107 | + |
| 108 | +## Create output (bin file) |
| 109 | +#recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2bin.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" |
| 110 | + |
| 111 | +## Create output (hex file) |
| 112 | +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" |
| 113 | + |
| 114 | +## Create dfu package zip file |
| 115 | +recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --sd-req {build.sd_fwid} --application "{build.path}/{build.project_name}.hex" "{build.path}/{build.project_name}.zip" |
| 116 | + |
| 117 | +## Create uf2 file |
| 118 | +#recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex" |
| 119 | + |
| 120 | +## Save bin |
| 121 | +recipe.output.tmp_file_bin={build.project_name}.bin |
| 122 | +recipe.output.save_file_bin={build.project_name}.save.bin |
| 123 | + |
| 124 | +## Save hex |
| 125 | +recipe.output.tmp_file_hex={build.project_name}.hex |
| 126 | +recipe.output.save_file_hexu={build.project_name}.save.hex |
| 127 | + |
| 128 | +## Compute size |
| 129 | +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" |
| 130 | +recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).* |
| 131 | +recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* |
| 132 | + |
| 133 | +## Export Compiled Binary |
| 134 | +recipe.output.tmp_file={build.project_name}.hex |
| 135 | +recipe.output.save_file={build.project_name}.{build.variant}.hex |
| 136 | + |
| 137 | +#*************************************************** |
| 138 | +# adafruit-nrfutil for uploading |
| 139 | +# https://github.com/adafruit/Adafruit_nRF52_nrfutil |
| 140 | +# pre-built binaries are provided for macos and windows |
| 141 | +#*************************************************** |
| 142 | +tools.nrfutil.cmd=adafruit-nrfutil |
| 143 | +tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe |
| 144 | +tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil |
| 145 | + |
| 146 | +tools.nrfutil.upload.params.verbose=--verbose |
| 147 | +tools.nrfutil.upload.params.quiet= |
| 148 | +tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank |
| 149 | + |
| 150 | +#*************************************************** |
| 151 | +# Burning bootloader with either jlink or nrfutil |
| 152 | +#*************************************************** |
| 153 | + |
| 154 | +# Bootloader version |
| 155 | +tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.3.2_{build.sd_name}_{build.sd_version} |
| 156 | + |
| 157 | +tools.bootburn.bootloader.params.verbose= |
| 158 | +tools.bootburn.bootloader.params.quiet= |
| 159 | +tools.bootburn.bootloader.pattern={program.burn_pattern} |
| 160 | + |
| 161 | +# erase flash page while programming |
| 162 | +tools.bootburn.erase.params.verbose= |
| 163 | +tools.bootburn.erase.params.quiet= |
| 164 | +tools.bootburn.erase.pattern= |
| 165 | + |
0 commit comments