|
| 1 | +#****************************************************************************** |
| 2 | +# |
| 3 | +# Makefile - Rules for building the libraries, examples and docs. |
| 4 | +# |
| 5 | +# Copyright (c) 2019, Ambiq Micro |
| 6 | +# All rights reserved. |
| 7 | +# |
| 8 | +# Redistribution and use in source and binary forms, with or without |
| 9 | +# modification, are permitted provided that the following conditions are met: |
| 10 | +# |
| 11 | +# 1. Redistributions of source code must retain the above copyright notice, |
| 12 | +# this list of conditions and the following disclaimer. |
| 13 | +# |
| 14 | +# 2. Redistributions in binary form must reproduce the above copyright |
| 15 | +# notice, this list of conditions and the following disclaimer in the |
| 16 | +# documentation and/or other materials provided with the distribution. |
| 17 | +# |
| 18 | +# 3. Neither the name of the copyright holder nor the names of its |
| 19 | +# contributors may be used to endorse or promote products derived from this |
| 20 | +# software without specific prior written permission. |
| 21 | +# |
| 22 | +# Third party software included in this distribution is subject to the |
| 23 | +# additional license terms as defined in the /docs/licenses directory. |
| 24 | +# |
| 25 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 26 | +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 27 | +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 28 | +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 29 | +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 30 | +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 31 | +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 32 | +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 33 | +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 34 | +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 35 | +# POSSIBILITY OF SUCH DAMAGE. |
| 36 | +# |
| 37 | +# This is part of revision 2.1.0 of the AmbiqSuite Development Package. |
| 38 | +# |
| 39 | +#****************************************************************************** |
| 40 | + |
| 41 | +# ARTEMIS_BIN2BOARD is the command to run the combined Ambiq tools (bin to ota blob, |
| 42 | +# ota blob to wired blob, wired update). You'll need to determine how to engage it |
| 43 | +# for your own system. (You might use pyinstaller to create a binary executable, or) |
| 44 | +# call it via python3 |
| 45 | +# Examples: |
| 46 | +# (via python) ARTEMIS_BIN2BOARD=python "path_to_tool/ambiq_bin2board.py" |
| 47 | +# (via executable [windows]) ARTEMIS_BIN2BOARD="path_to_tool/ambiq_bin2board_installed.exe" |
| 48 | +# (via executable [*nix]) ARTEMIS_BIN2BOARD=./path_to_tool/ambiq_bin2board_installed |
| 49 | +# (via executable on in the default search path) ARTEMIS_BIN2BOARD=ambiq_bin2board_installed |
| 50 | +ARTEMIS_SVL= |
| 51 | +# COM_PORT is the serial port to use for uploading. For example COM#### on Windows or /dev/cu.usbserial-#### on *nix |
| 52 | +COM_PORT= |
| 53 | +ifeq ($(ARTEMIS_SVL),) |
| 54 | + $(warning warning: you have not defined ARTEMIS_SVL so bootloading will not work) |
| 55 | +endif |
| 56 | +ifeq ($(COM_PORT),) |
| 57 | + $(warning warning: you have not defined COM_PORT so bootloading will not work) |
| 58 | +endif |
| 59 | + |
| 60 | +# SDKPATH =C:/Users/owen.lyke/AppData/Roaming/AmbiqSDK/AmbiqSuite-Rel2.1.0# Note that if you copy/paste a windows file path here you need to change backslashes to forward slashes |
| 61 | +SDKPATH = |
| 62 | +ifeq ($(SDKPATH),) |
| 63 | + SDKPATH =../../../../.. |
| 64 | + $(warning warning: you have not defined SDK_PATH so will continue assuming that the SDK root is at $(SDKPATH)) |
| 65 | + |
| 66 | +endif |
| 67 | + |
| 68 | +BOARDPATH =${SDKPATH}/boards/artemis# Set this as the path to the Artemis BSP (Board Support Package) directory. Initially assumes that you put the BSP under the 'boards' directory in the SDK |
| 69 | + |
| 70 | + |
| 71 | +USER_INCLUDE_DIRS = -I../src/svl_ringbuf |
| 72 | +USER_INCLUDE_DIRS += -I../src/svl_packet |
| 73 | +USER_INCLUDE_DIRS += -I../src/svl_uart |
| 74 | +USER_INCLUDE_DIRS += -I../src/svl_utils |
| 75 | + |
| 76 | +USER_SOURCEDIRS = ../src |
| 77 | +USER_SOURCEDIRS += ../src/svl_ringbuf |
| 78 | +USER_SOURCEDIRS += ../src/svl_packet |
| 79 | +USER_SOURCEDIRS += ../src/svl_uart |
| 80 | +USER_SOURCEDIRS += ../src/svl_utils |
| 81 | + |
| 82 | +USER_MAIN_SRC = main.c |
| 83 | +USER_SOURCE_FILES = svl_ringbuf.c |
| 84 | +USER_SOURCE_FILES += svl_packet.c |
| 85 | +USER_SOURCE_FILES += svl_uart.c |
| 86 | +USER_SOURCE_FILES += svl_utils.c |
| 87 | + |
| 88 | + |
| 89 | +#### Names #### |
| 90 | +TARGET := artemis_svl |
| 91 | +COMPILERNAME := gcc |
| 92 | +PROJECT := artemis_svl_gcc |
| 93 | +CONFIG := bin |
| 94 | + |
| 95 | +SHELL:=/bin/bash |
| 96 | +#### Setup #### |
| 97 | + |
| 98 | +TOOLCHAIN ?= arm-none-eabi |
| 99 | +PART = apollo3 |
| 100 | +CPU = cortex-m4 |
| 101 | +FPU = fpv4-sp-d16 |
| 102 | +# Default to FPU hardware calling convention. However, some customers and/or |
| 103 | +# applications may need the software calling convention. |
| 104 | +#FABI = softfp |
| 105 | +FABI = hard |
| 106 | + |
| 107 | +LINKER_FILE := ./artemis_svl_gcc.ld |
| 108 | +STARTUP_FILE := ./startup_$(COMPILERNAME).c |
| 109 | + |
| 110 | +#### Required Executables #### |
| 111 | +CC = $(TOOLCHAIN)-gcc |
| 112 | +GCC = $(TOOLCHAIN)-gcc |
| 113 | +CPP = $(TOOLCHAIN)-cpp |
| 114 | +LD = $(TOOLCHAIN)-ld |
| 115 | +CP = $(TOOLCHAIN)-objcopy |
| 116 | +OD = $(TOOLCHAIN)-objdump |
| 117 | +RD = $(TOOLCHAIN)-readelf |
| 118 | +AR = $(TOOLCHAIN)-ar |
| 119 | +SIZE = $(TOOLCHAIN)-size |
| 120 | +RM = $(shell which rm 2>/dev/null) |
| 121 | + |
| 122 | +EXECUTABLES = CC LD CP OD AR RD SIZE GCC |
| 123 | +K := $(foreach exec,$(EXECUTABLES),\ |
| 124 | + $(if $(shell which $($(exec)) 2>/dev/null),,\ |
| 125 | + $(info $(exec) not found on PATH ($($(exec))).)$(exec))) |
| 126 | +$(if $(strip $(value K)),$(info Required Program(s) $(strip $(value K)) not found)) |
| 127 | + |
| 128 | +ifneq ($(strip $(value K)),) |
| 129 | +all clean: |
| 130 | + $(info Tools $(TOOLCHAIN)-$(COMPILERNAME) not installed.) |
| 131 | + $(RM) -rf bin |
| 132 | +else |
| 133 | + |
| 134 | +DEFINES = -DPART_$(PART) |
| 135 | +DEFINES+= -DAM_PART_APOLLO3 |
| 136 | +DEFINES+= -DAM_PACKAGE_BGA |
| 137 | + |
| 138 | +# Includes from the SDK |
| 139 | +# INCLUDES+= -I../../../../.. # This one doesn't make much sense to me |
| 140 | +INCLUDES = -I${SDKPATH}/CMSIS/AmbiqMicro/Include |
| 141 | +INCLUDES+= -I${SDKPATH}/mcu/apollo3 |
| 142 | +INCLUDES+= -I${SDKPATH}/CMSIS/ARM/Include |
| 143 | +INCLUDES+= -I${SDKPATH}/utils |
| 144 | +INCLUDES+= -I${SDKPATH}/devices |
| 145 | + |
| 146 | +# Includes for the board you've chosen |
| 147 | +INCLUDES+= -I../src # This is where the source for the particular project is |
| 148 | +INCLUDES+= -I${BOARDPATH}/bsp |
| 149 | + |
| 150 | +INCLUDES+= ${USER_INCLUDE_DIRS} |
| 151 | + |
| 152 | +VPATH = ${SDKPATH}/devices |
| 153 | +VPATH+= ${SDKPATH}/utils |
| 154 | +VPATH+= ${USER_SOURCEDIRS} |
| 155 | + |
| 156 | +SRC = ${USER_MAIN_SRC} |
| 157 | +SRC += am_devices_led.c |
| 158 | +SRC += am_util_delay.c |
| 159 | +SRC += am_util_faultisr.c |
| 160 | +SRC += am_util_stdio.c |
| 161 | +SRC += am_util_id.c |
| 162 | +SRC += startup_gcc.c |
| 163 | +SRC += ${USER_SOURCE_FILES} |
| 164 | + |
| 165 | +CSRC = $(filter %.c,$(SRC)) |
| 166 | +ASRC = $(filter %.s,$(SRC)) |
| 167 | + |
| 168 | +OBJS = $(CSRC:%.c=$(CONFIG)/%.o) |
| 169 | +OBJS+= $(ASRC:%.s=$(CONFIG)/%.o) |
| 170 | + |
| 171 | +DEPS = $(CSRC:%.c=$(CONFIG)/%.d) |
| 172 | +DEPS+= $(ASRC:%.s=$(CONFIG)/%.d) |
| 173 | + |
| 174 | +LIBS = ../../../../../mcu/apollo3/hal/gcc/bin/libam_hal.a |
| 175 | +LIBS += ../../../bsp/gcc/bin/libam_bsp.a |
| 176 | + |
| 177 | +CFLAGS = -mthumb -mcpu=$(CPU) -mfpu=$(FPU) -mfloat-abi=$(FABI) |
| 178 | +CFLAGS+= -ffunction-sections -fdata-sections |
| 179 | +CFLAGS+= -MMD -MP -std=c99 -Wall -g |
| 180 | +CFLAGS+= -O1 |
| 181 | +# CFLAGS+= -O0 |
| 182 | +CFLAGS+= $(DEFINES) |
| 183 | +CFLAGS+= $(INCLUDES) |
| 184 | +CFLAGS+= |
| 185 | + |
| 186 | +LFLAGS = -mthumb -mcpu=$(CPU) -mfpu=$(FPU) -mfloat-abi=$(FABI) |
| 187 | +LFLAGS+= -nostartfiles -static |
| 188 | +LFLAGS+= -Wl,--gc-sections,--entry,Reset_Handler,-Map,$(CONFIG)/$(TARGET).map |
| 189 | +LFLAGS+= -Wl,--start-group -lm -lc -lgcc $(LIBS) -Wl,--end-group |
| 190 | +LFLAGS+= -specs=nano.specs -specs=nosys.specs |
| 191 | + |
| 192 | +# Additional user specified CFLAGS |
| 193 | +CFLAGS+=$(EXTRA_CFLAGS) |
| 194 | + |
| 195 | +CPFLAGS = -Obinary |
| 196 | + |
| 197 | +ODFLAGS = -S |
| 198 | + |
| 199 | +#### Rules #### |
| 200 | +all: directories $(CONFIG)/$(TARGET).bin |
| 201 | + |
| 202 | +directories: $(CONFIG) |
| 203 | + |
| 204 | +$(CONFIG): |
| 205 | + @mkdir -p $@ |
| 206 | + |
| 207 | +$(CONFIG)/%.o: %.c $(CONFIG)/%.d |
| 208 | + @echo " Compiling $(COMPILERNAME) $<" ;\ |
| 209 | + $(CC) -c $(CFLAGS) $< -o $@ |
| 210 | + |
| 211 | +$(CONFIG)/%.o: %.s $(CONFIG)/%.d |
| 212 | + @echo " Assembling $(COMPILERNAME) $<" ;\ |
| 213 | + $(CC) -c $(CFLAGS) $< -o $@ |
| 214 | + |
| 215 | +$(CONFIG)/$(TARGET).axf: $(OBJS) $(LIBS) |
| 216 | + @echo " Linking $(COMPILERNAME) $@" ;\ |
| 217 | + $(CC) -Wl,-T,$(LINKER_FILE) -o $@ $(OBJS) $(LFLAGS) |
| 218 | + |
| 219 | +$(CONFIG)/$(TARGET).bin: $(CONFIG)/$(TARGET).axf |
| 220 | + @echo " Copying $(COMPILERNAME) $@..." ;\ |
| 221 | + $(CP) $(CPFLAGS) $< $@ ;\ |
| 222 | + $(OD) $(ODFLAGS) $< > $(CONFIG)/$(TARGET).lst |
| 223 | + |
| 224 | +clean: |
| 225 | + @echo "Cleaning..." ;\ |
| 226 | + $(RM) -f $(OBJS) $(DEPS) \ |
| 227 | + $(CONFIG)/$(TARGET).bin $(CONFIG)/$(TARGET).axf \ |
| 228 | + $(CONFIG)/$(TARGET).lst $(CONFIG)/$(TARGET).map |
| 229 | + |
| 230 | +bootload: all |
| 231 | + C:\Users\owen.lyke\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\1.0.2/tools/ambiq/windows/ambiq_bin2board.exe --bin C:\Users\owen.lyke\AppData\Roaming\AmbiqSDK\AmbiqSuite-Rel2.2.0\boards\artemis\examples\!artemis_svl\gcc\bin\artemis_svl.bin --load-address-blob 0x20000 --magic-num 0xCB -o C:\Users\owen.lyke\AppData\Roaming\AmbiqSDK\AmbiqSuite-Rel2.2.0\boards\artemis\examples\!artemis_svl\gcc\bin\artemis_svl --version 0x0 --load-address-wired 0xC000 -i 6 --options 0x1 -b 115200 -port COM4 -r 2 -v |
| 232 | + |
| 233 | +$(CONFIG)/%.d: ; |
| 234 | + |
| 235 | +../../../../../mcu/apollo3/hal/gcc/bin/libam_hal.a: |
| 236 | + $(MAKE) -C ../../../../../mcu/apollo3/hal |
| 237 | + |
| 238 | +../../../bsp/gcc/bin/libam_bsp.a: |
| 239 | + $(MAKE) -C ../../../bsp |
| 240 | + |
| 241 | +# Automatically include any generated dependencies |
| 242 | +-include $(DEPS) |
| 243 | +endif |
| 244 | +.PHONY: all clean directories |
0 commit comments