1#
2# Google Reference CHRE Implementation for MTK riscv (v55e300) Tinysys
3#
4
5include $(CHRE_PREFIX)/build/clean_build_template_args.mk
6
7TARGET_NAME = aosp_riscv55e300_tinysys
8ifneq ($(filter $(TARGET_NAME)% all, $(MAKECMDGOALS)),)
9
10ifeq ($(RISCV_TINYSYS_PREFIX),)
11$(error "The tinysys code directory needs to be exported as the RISCV_TINYSYS_PREFIX \
12         environment variable")
13endif
14
15TARGET_CFLAGS = $(TINYSYS_CFLAGS)
16TARGET_VARIANT_SRCS = $(TINYSYS_SRCS)
17TARGET_BIN_LDFLAGS = $(AOSP_RISCV_TINYSYS_BIN_LDFLAGS)
18TARGET_SO_EARLY_LIBS = $(AOSP_RISCV_TINYSYS_EARLY_LIBS)
19TARGET_SO_LATE_LIBS = $(AOSP_RISCV_TINYSYS_LATE_LIBS)
20TARGET_PLATFORM_ID = 0x476f6f676c003001
21
22# Macros #######################################################################
23
24TINYSYS_CFLAGS += -D__riscv
25TINYSYS_CFLAGS += -DMRV55
26TINYSYS_CFLAGS += -D_LIBCPP_HAS_NO_LONG_LONG
27
28TINYSYS_CFLAGS += --target=riscv32-unknown-elf
29TINYSYS_CFLAGS += -march=rv32imafcv
30TINYSYS_CFLAGS += -mcpu=MRV55E300
31
32# Word size for this architecture
33TARGET_CFLAGS += -DCHRE_32_BIT_WORD_SIZE
34
35# chre platform
36TARGET_CFLAGS += -DCHRE_FIRST_SUPPORTED_API_VERSION=CHRE_API_VERSION_1_7
37# TODO(b/254121302): Needs to confirm with MTK about the max message size below
38TARGET_CFLAGS += -DCHRE_MESSAGE_TO_HOST_MAX_SIZE=4096
39TARGET_CFLAGS += -DCHRE_USE_BUFFERED_LOGGING
40# TODO(b/256870101): create mutex on heap for now
41TARGET_CFLAGS += -DCHRE_CREATE_MUTEX_ON_HEAP
42
43# Compiling flags ##############################################################
44
45# -fpic and -shared are only needed for dynamic linking
46ifeq ($(IS_ARCHIVE_ONLY_BUILD),)
47TARGET_SO_LDFLAGS += -shared
48TARGET_CFLAGS += -fpic
49
50# Enable compiler-rt dependencies
51LLVM_RTLIB=$(RISCV_TOOLCHAIN_PATH)/lib/clang/12.0.0/libpic/riscv32/MRV55E300
52TARGET_SO_LDFLAGS += -L$(LLVM_RTLIB)
53TARGET_SO_LDFLAGS += -lclang_rt.builtins-riscv32
54endif
55
56ifneq ($(IS_NANOAPP_BUILD),)
57# Used to expose libc headers to nanoapps that aren't supported on the given platform
58TARGET_CFLAGS += -I$(CHRE_PREFIX)/platform/shared/include/chre/platform/shared/libc
59
60TARGET_VARIANT_SRCS += $(DSO_SUPPORT_LIB_SRCS)
61TARGET_CFLAGS += $(DSO_SUPPORT_LIB_CFLAGS)
62
63ifeq ($(CHRE_TCM_ENABLED),true)
64TARGET_CFLAGS += -DCHRE_TCM_ENABLED
65# Flags:
66# Signed                 = 0x00000001
67# TCM-capable            = 0x00000004
68TARGET_NANOAPP_FLAGS = 0x00000005
69endif
70endif
71
72# Other makefiles ##############################################################
73
74include $(CHRE_PREFIX)/platform/shared/mbedtls/mbedtls.mk
75include $(CHRE_PREFIX)/build/arch/riscv.mk
76include $(CHRE_PREFIX)/build/build_template.mk
77endif
78