Home | History | Annotate | Download | only in firmware
      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
     18 PLATFORM ?= stm32
     19 CHIP ?= stm32f411
     20 CPU ?= cortexm4
     21 VARIANT ?= lunchbox
     22 DEBUG ?= -DDEBUG
     23 OUT := out/nanohub/$(VARIANT)
     24 
     25 #bad words
     26 BADWORDS += strcpy strcat atoi
     27 BADWORDS += "rsaPrivOp=RSA private ops must never be compiled into firmware."
     28 
     29 #find makefiles
     30 MAKE_PLAT = os/platform/$(PLATFORM)/$(PLATFORM).mk
     31 MAKE_CPU = os/cpu/$(CPU)/$(CPU).mk
     32 
     33 ifndef VARIANT_PATH
     34 VARIANT_PATH := variant/$(VARIANT)
     35 endif
     36 
     37 MAKE_VAR = $(VARIANT_PATH)/$(VARIANT).mk
     38 
     39 #top make target
     40 SRCS_os :=
     41 SRCS_bl :=
     42 DELIVERABLES :=
     43 
     44 .PHONY: real all
     45 real: all
     46 
     47 #include makefiles for plat and cpu
     48 include $(MAKE_PLAT)
     49 include $(MAKE_CPU)
     50 include $(MAKE_VAR)
     51 
     52 FLAGS += -Ios/algos
     53 FLAGS += -Ios/cpu/$(CPU)/inc
     54 FLAGS += -Ios/inc
     55 FLAGS += -Ios/platform/$(PLATFORM)/inc
     56 FLAGS += -I$(VARIANT_PATH)/inc
     57 FLAGS += -Iexternal/freebsd/inc
     58 FLAGS += -I../lib/include
     59 FLAGS += -I../../../../system/chre/chre_api/include/chre_api
     60 
     61 FLAGS += -Wall -Werror
     62 #help avoid commmon embedded C mistakes
     63 FLAGS += -Wmissing-declarations -Wlogical-op -Waddress -Wempty-body -Wpointer-arith -Wenum-compare -Wdouble-promotion -Wfloat-equal -Wshadow -fno-strict-aliasing
     64 
     65 OSFLAGS += -g -ggdb3 -D_OS_BUILD_ -O2
     66 OSFLAGS_os += -DUSE_PRINTF_FLAG_CHARS
     67 
     68 #debug mode
     69 FLAGS += $(DEBUG)
     70 
     71 include firmware_conf.mk
     72 
     73 FLAGS += $(COMMON_FLAGS)
     74 
     75 #bootloader pieces
     76 SRCS_bl += ../lib/nanohub/sha2.c ../lib/nanohub/rsa.c ../lib/nanohub/aes.c os/core/seos.c
     77 
     78 #frameworks
     79 SRCS_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
     80 SRCS_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
     81 SRCS_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
     82 SRCS_os += os/algos/ap_hub_sync.c
     83 SRCS_bl += os/core/bl.c
     84 
     85 #some help for bootloader
     86 SRCS_bl += os/core/printf.c
     87 
     88 SRCS_os += ../lib/nanohub/softcrc.c
     89 
     90 #extra deps
     91 DEPS += $(wildcard inc/*.h)
     92 DEPS += $(wildcard ../inc/*.h)
     93 DEPS += $(wildcard ../inc/chre/*.h)
     94 DEPS += $(wildcard $(VARIANT_PATH)/inc/variant/*.h)
     95 DEPS += firmware.mk firmware_conf.mk $(MAKE_PLAT) $(MAKE_CPU) $(MAKE_VAR)
     96 DELIVERABLES += $(OUT)/full.bin
     97 
     98 all: $(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 
    116 clean:
    117 	rm -rf $(OUT)
    118 
    119 .SECONDARY: $(OUT)/os.checked.elf
    120