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
17GCC = $(CROSS_COMPILE)gcc
18OBJCOPY = $(CROSS_COMPILE)objcopy
19
20FLAGS += -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -mno-thumb-interwork -ffast-math -fsingle-precision-constant -DARM -DUSE_NANOHUB_FLOAT_RUNTIME
21
22LIB_PATH := lib
23
24#defines
25FLAGS += -DCPU_NUM_PERSISTENT_RAM_BITS=32
26
27#cpu runtime
28SRCS_os += \
29    os/cpu/$(CPU)/atomicBitset.c \
30    os/cpu/$(CPU)/cpu.c \
31    os/cpu/$(CPU)/pendsv.c \
32    os/cpu/$(CPU)/atomic.c \
33    os/cpu/$(CPU)/appSupport.c \
34    os/cpu/$(CPU)/cpuMath.c \
35
36#cpu runtime for bootloader
37SRCS_bl += os/cpu/$(CPU)/cpu.c
38
39#c runtime
40SRCS_os += \
41    $(LIB_PATH)/libc/memcpy-armv7m.S \
42    $(LIB_PATH)/libc/memset.c \
43    $(LIB_PATH)/libc/memcmp.c \
44    $(LIB_PATH)/libc/memmove.c \
45
46#c runtime for bootloader
47SRCS_bl += \
48    $(LIB_PATH)/libc/memcpy-armv7m.S \
49    $(LIB_PATH)/libc/memset.c \
50    $(LIB_PATH)/libc/memcmp.c \
51    $(LIB_PATH)/libc/memmove.c \
52
53#floating point runtime (ARM)
54SRCS_os += external/arm/arm_sin_cos_f32.c
55FLAGS += -DARM_MATH_CM4 -D__FPU_PRESENT
56
57#floating point runtime (FreeBSD)
58SRCS_os += \
59    external/freebsd/lib/msun/src/e_atan2f.c \
60    external/freebsd/lib/msun/src/e_expf.c \
61    external/freebsd/lib/msun/src/s_atanf.c \
62
63FLAGS += -DFLT_EVAL_METHOD -Iexternal/freebsd/lib/msun/src
64
65#extra deps
66DEPS += $(wildcard os/cpu/$(CPU)/inc/cpu/*.h)
67DEPS += $(wildcard os/cpu/$(CPU)/inc/cpu/cmsis/*.h)
68
69#bad words for C-M4F
70BADWORDS += "__floatundisf=When casting a uint64_t to float, use floatFromUint64"
71BADWORDS += "__floatdisf=When casting a int64_t to float, use floatFromInt64"
72BADWORDS += "__fixunssfdi=When casting a float to a uint64_t, use floatToUint64"
73BADWORDS += "__fixsfdi=When casting a float to a int64_t, use floatToInt64"
74BADWORDS += "__aeabi_uldivmod=Do not ever divide uint64_t by anything, see cpuMath.h"
75BADWORDS += "__aeabi_ldivmod=Do not ever divide int64_t by anything, see cpuMath.h"
76BADWORDS += "sinf=include nanohub_math.h before using sinf()"
77BADWORDS += "cosf=include nanohub_math.h before using cosf()"
78BADWORDS += "asinf=include nanohub_math.h before using asinf()"
79
80#all softfloat double funcs are forbidden
81BADWORDS += __muldf3 __divdf3 __subdf3 __adddf3 __truncdfsf2
82
83$(info Included CORTEX-M4 CPU)
84