• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (C) 2016 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17#find build target
18PLATFORM ?= stm32
19CHIP ?= stm32f411
20CPU ?= cortexm4
21VARIANT ?= lunchbox
22DEBUG ?= -DDEBUG
23OUT := out/nanohub/$(VARIANT)
24
25#bad words
26BADWORDS += strcpy strcat atoi
27BADWORDS += "rsaPrivOp=RSA private ops must never be compiled into firmware."
28
29#find makefiles
30MAKE_PLAT = os/platform/$(PLATFORM)/$(PLATFORM).mk
31MAKE_CPU = os/cpu/$(CPU)/$(CPU).mk
32
33ifndef VARIANT_PATH
34VARIANT_PATH := variant/$(VARIANT)
35endif
36
37MAKE_VAR = $(VARIANT_PATH)/$(VARIANT).mk
38
39#top make target
40SRCS_os :=
41SRCS_bl :=
42DELIVERABLES :=
43
44.PHONY: real all
45real: all
46
47#include makefiles for plat and cpu
48include $(MAKE_PLAT)
49include $(MAKE_CPU)
50include $(MAKE_VAR)
51
52FLAGS += -Ios/algos
53FLAGS += -Ios/cpu/$(CPU)/inc
54FLAGS += -Ios/inc
55FLAGS += -Ios/platform/$(PLATFORM)/inc
56FLAGS += -I$(VARIANT_PATH)/inc
57FLAGS += -Iexternal/freebsd/inc
58FLAGS += -I../lib/include
59FLAGS += -I../../../../system/chre/chre_api/include/chre_api
60
61FLAGS += -Wall -Werror
62#help avoid commmon embedded C mistakes
63FLAGS += -Wmissing-declarations -Wlogical-op -Waddress -Wempty-body -Wpointer-arith -Wenum-compare -Wdouble-promotion -Wfloat-equal -Wshadow -fno-strict-aliasing
64
65OSFLAGS += -g -ggdb3 -D_OS_BUILD_ -O2
66OSFLAGS_os += -DUSE_PRINTF_FLAG_CHARS
67
68#debug mode
69FLAGS += $(DEBUG)
70
71include firmware_conf.mk
72
73FLAGS += $(COMMON_FLAGS)
74
75#bootloader pieces
76SRCS_bl += ../lib/nanohub/sha2.c ../lib/nanohub/rsa.c ../lib/nanohub/aes.c os/core/seos.c
77
78#frameworks
79SRCS_os += os/core/printf.c os/core/timer.c os/core/seos.c os/core/heap.c os/core/slab.c os/core/spi.c os/core/trylock.c
80SRCS_os += os/core/hostIntf.c os/core/hostIntfI2c.c os/core/hostIntfSpi.c os/core/nanohubCommand.c os/core/sensors.c os/core/syscall.c
81SRCS_os += os/core/eventQ.c os/core/osApi.c os/core/appSec.c os/core/simpleQ.c os/core/floatRt.c os/core/nanohub_chre.c
82SRCS_os += os/algos/ap_hub_sync.c
83SRCS_bl += os/core/bl.c
84
85#some help for bootloader
86SRCS_bl += os/core/printf.c
87
88SRCS_os += ../lib/nanohub/softcrc.c
89
90#extra deps
91DEPS += $(wildcard inc/*.h)
92DEPS += $(wildcard ../inc/*.h)
93DEPS += $(wildcard ../inc/chre/*.h)
94DEPS += $(wildcard $(VARIANT_PATH)/inc/variant/*.h)
95DEPS += firmware.mk firmware_conf.mk $(MAKE_PLAT) $(MAKE_CPU) $(MAKE_VAR)
96DELIVERABLES += $(OUT)/full.bin
97
98all: $(DELIVERABLES)
99
100$(OUT)/bl.unchecked.elf: $(SRCS_bl) $(DEPS)
101	mkdir -p $(dir $@)
102	$(GCC) -o $@ $(SRCS_bl) $(OSFLAGS) $(OSFLAGS_bl) $(FLAGS)
103
104$(OUT)/os.unchecked.elf: $(SRCS_os) $(DEPS)
105	mkdir -p $(dir $@)
106	$(GCC) -o $@ $(SRCS_os) $(OSFLAGS) $(OSFLAGS_os) $(FLAGS)
107
108$(OUT)/%.checked.elf : $(OUT)/%.unchecked.elf  symcheck.sh
109	mkdir -p $(dir $@)
110	./symcheck.sh $< $@ $(BADWORDS)
111
112$(OUT)/full.bin: $(BL_FILE) $(OS_FILE)
113	mkdir -p $(dir $@)
114	cat $(BL_FILE) $(OS_FILE) > $@
115
116clean:
117	rm -rf $(OUT)
118
119.SECONDARY: $(OUT)/os.checked.elf
120