diff options
author | Chunyi Chen <cchen@atmosic.com> | 2023-05-12 17:49:28 +0800 |
---|---|---|
committer | Chunyi Chen <cchen@atmosic.com> | 2023-05-16 11:49:02 +0800 |
commit | 208e1139d7a401b29d397e274d835e68b9b48201 (patch) | |
tree | 59fda1c7d4bd051d0d2fbf24abc160b2859f40ce /platform/atm2/ATM22xx-x1x/user | |
parent | c603c2df935a82347e2cd4fbd27ba80d05c3793d (diff) | |
download | atmosic-208e1139d7a401b29d397e274d835e68b9b48201.tar.gz |
Check in the RCU SDK based on Atmosic ATM2231 chipset, solution provided
by Atmosic Technologies
RCU SDK Version: 1.0
-) Support IR over BLE service
-) Support Voice over BLE service
-) Support NEC IR code override
-) Support RCU Wake Up service
Test: make run_all USE_LIB=1 CFG_ATVRC=1 USE_BD_ADDR:="AABBCCDDEEFF"
BYPASS_INCLUSIVE_LANGUAGE_REASON=existing methods
Change-Id: I9d7db82ff40f5552e8896b5356886982feb95ade
Diffstat (limited to 'platform/atm2/ATM22xx-x1x/user')
-rw-r--r-- | platform/atm2/ATM22xx-x1x/user/app.mk | 760 | ||||
-rw-r--r-- | platform/atm2/ATM22xx-x1x/user/cmsdk_cm0_flash_rom.ld | 17 | ||||
-rw-r--r-- | platform/atm2/ATM22xx-x1x/user/common.mk | 44 | ||||
-rw-r--r-- | platform/atm2/ATM22xx-x1x/user/flash_program.sh | 8 | ||||
-rw-r--r-- | platform/atm2/ATM22xx-x1x/user/framework.mk | 19 | ||||
-rw-r--r-- | platform/atm2/ATM22xx-x1x/user/layout_info.mk | 56 | ||||
-rw-r--r-- | platform/atm2/ATM22xx-x1x/user/lib-nosys.ld | 2 | ||||
-rw-r--r-- | platform/atm2/ATM22xx-x1x/user/memory_flash_rom.ld | 42 | ||||
-rw-r--r-- | platform/atm2/ATM22xx-x1x/user/nvds.mk | 503 | ||||
-rw-r--r-- | platform/atm2/ATM22xx-x1x/user/profiles.mk | 238 | ||||
-rw-r--r-- | platform/atm2/ATM22xx-x1x/user/sections.ld | 186 | ||||
-rw-r--r-- | platform/atm2/ATM22xx-x1x/user/tools.mk | 150 |
12 files changed, 2025 insertions, 0 deletions
diff --git a/platform/atm2/ATM22xx-x1x/user/app.mk b/platform/atm2/ATM22xx-x1x/user/app.mk new file mode 100644 index 0000000..45fc0a5 --- /dev/null +++ b/platform/atm2/ATM22xx-x1x/user/app.mk @@ -0,0 +1,760 @@ +################################################################################ +# +# @file app.mk +# +# @brief Application make helper +# +# Copyright (C) Atmosic 2018-2022 +# +################################################################################ + +ifndef __APP_MK__ +__APP_MK__ = 1 + +APP ?= $(notdir $(CURDIR)) + +# Watchdog default 5 sec +WDOG ?= 5 + +LIBRARIES += atm_utils_c atm_utils_math +DRIVERS += \ + heap \ + hw_cfg \ + pinmux \ + rf \ + watchdog \ + +ifdef UART_FLASH +# default 32K NVDS +UART_FLASH_NVDS_SIZE ?= 0x8000 +CFLAGS += -DUART_FLASH_NVDS_SIZE=$(UART_FLASH_NVDS_SIZE) + +# UART_FLASH=0 for using UART0 +# UART_FLASH=1 for using UART1 +ifeq ($(UART_FLASH),0) +CFLAGS += -DCFG_UART_FLASH_UART0 +else ifneq ($(UART_FLASH),1) +$(error "usage: make $(MAKECMDGOALS) UART_FLASH=<0|1>") +endif +DRIVERS += uart_flash +else ifndef RUN_IN_RAM +CFLAGS += -DCFG_EXT_FLASH +DRIVERS += ext_flash +endif # UART_FLASH + +ifndef NO_PMU +DRIVERS += pmu reset +INCLUDES += $(DRIVER_DIR)/wurx +endif + +# Enable Brownout by default +ifndef NO_BROWNOUT +DRIVERS += brwnout +endif + +ifdef FORCE_LPC_RCOS +CFLAGS += -DFORCE_LPC_RCOS +endif + +ifdef FPGA +DRIVERS += dtop_bypass +endif + +# Include board specific pin mapping +CFLAGS += -DPINMAP_BOARD=$(BOARD) +INCLUDES += pinmap + +# Code coverage for units under test +ifeq ($(TOOLSET),) +ifneq ($(and $(UU_TEST),$(filter -DAUTO_TEST,$(CFLAGS))),) +ifeq ($(filter -DIS_FOR_SIM,$(CFLAGS)),) +ifndef RUN_IN_RAM +COVERAGE ?= $(UU_TEST) +endif +endif # IS_FOR_SIM +endif # UU_TEST && AUTO_TEST +endif # TOOLSET + +.PHONY: all +all: $(APP).bin $(APP).asm + +include $(COMMON_USER_DIR)/tools.mk +include $(COMMON_USER_DIR)/nvds.mk +include $(if $(FLASHROM),$(LIB_DIR)/$(FLASHROM).mk,$(ROM_DIR)/rom_app.mk) + +ifdef FLASHROM +override undefine USE_LIB +FLASHOFF ?= 0x10000000 +endif + +ifndef NO_USER_INIT +C_SRCS += $(USER_DIR)/user_init.c +endif + +C_SRCS += $(wildcard $(APP).c) $(USER_DIR)/user_debug.c +CXX_SRCS += $(foreach e,$(CXX_EXT),$(wildcard $(APP).$e)) + +ifeq ($(TOOLSET),ARM) +C_SRCS += $(USER_DIR)/armcc/retarget.c +endif + +ifdef DEBUG +C_SRCS += $(USER_DIR)/hardfault_handler_armv6m.c +DRIVERS += swd_dbg +ifndef SKIP_TB +DRIVERS += arm_traceback +endif # SKIP_TB +ifdef RTT_DBG +DRIVERS += SEGGER_RTT +CFLAGS += -DRTT_DBG +C_SRCS += $(DRIVER_DIR)/SEGGER_RTT/SEGGER_RTT_printf.c +C_SRCS += $(DRIVER_DIR)/SEGGER_RTT/rtt_debug.c +ifdef RTT_DBG_ONLY +CFLAGS += -DRTT_DBG_ONLY +endif +endif +else # DEBUG +ifneq (,$(filter -DAUTO_TEST,$(CFLAGS))) +C_SRCS += $(USER_DIR)/hardfault_handler_armv6m.c +ifndef SKIP_TB +DRIVERS += arm_traceback +endif +endif # AUTO_TEST +override undefine RTT_DBG +endif # DEBUG + +ifdef COVERAGE +C_SRCS += $(USER_DIR)/user_gcov.c +endif + +ifdef LPC_RCOS +DRIVERS += lpc_rcos +CFLAGS += -DLPC_RCOS +endif + +LIBRARIES := $(sort $(LIBRARIES)) + +C_SRCS += $(addprefix $(ROM_DIR)/,$(ROM_ERRATA_SRC)) + +define include_driver +$(eval N := $(notdir $1)) +$(eval D := $(DRIVER_DIR)/$1) +INCLUDES += $D +-include $D/$N.mk +ifeq ($$(lastword $$(MAKEFILE_LIST)),$D/$N.mk) +C_SRCS += $$(addprefix $D/,$$($N.C_SRCS)) +INCLUDES += $$(addprefix $D/,$$($N.INCLUDES)) +LIBS += $$(addprefix $D/,$$($N.LIBS)) +CFLAGS += $$($N.CFLAGS) +else +C_SRCS += $D/$N.c +endif +endef +$(foreach d,$(DRIVERS),$(eval $(call include_driver,$d))) + +define include_library +$(eval N := $(notdir $1)) +$(eval L := $(LIB_DIR)/$1) +INCLUDES += $L +-include $L/$N.mk +ifeq ($$(lastword $$(MAKEFILE_LIST)),$L/$N.mk) +C_SRCS += $$(addprefix $L/,$$($N.C_SRCS)) +INCLUDES += $$(addprefix $L/,$$($N.INCLUDES)) +LIBS += $$(addprefix $L/,$$($N.LIBS)) +CFLAGS += $$($N.CFLAGS) +else +C_SRCS += $(wildcard $L/$N*.c) +endif +endef +$(foreach l,$(LIBRARIES),$(eval $(call include_library,$l))) + +EXCL_APP_LIB_ALL := $(EXCLUDE_APP_LIB_C_SRCS) $(APP).c +ifdef USE_LIB +C_SRCS := $(EXCL_APP_LIB_ALL) +else +S_SRCS += $(APP_USER_STARTUP) +endif + +OBJS += $(notdir $(S_SRCS:%.s=%.o) $(C_SRCS:%.c=%.o) \ + $(foreach f,$(CXX_SRCS),$(basename $f).o)) + +# Non-conforming compilation units. Needs to be cleaned up and removed. +FIXME_USES_BLE := \ + app_bass.c \ + app_diss.c \ + app_fio.c \ + app_gap.c \ + app_hrps.c \ + app_htpt.c \ + app_otaps.c \ + at_cmd_init.c \ + at_cmd_utils.c \ + atm_adv.c \ + atm_adv_param.c \ + atm_debug.c \ + atm_gap.c \ + atm_gap_param.c \ + atm_init.c \ + atm_init_param.c \ + atm_persync.c \ + atm_prfs.c \ + atm_prfs_task.c \ + atm_scan.c \ + atm_scan_param.c \ + bleadvdata.c \ + bleadvenable.c \ + bleadvlegacyparm.c \ + bleadvtxpwr.c \ + bleconntxpwr.c \ + blegapdevname.c \ + blegapdisconnect.c \ + blegapgetconnstat.c \ + blegapinit.c \ + blegapgetrssi.c \ + blegapgetpeerinfo.c \ + blegapcreateconn.c \ + blegapcancelcreateconn.c \ + blegapparnego.c \ + blescanenable.c \ + blescanfil.c \ + blescanfilrm.c \ + blegattaddchar.c \ + blegattadddesc.c \ + blegattadddescuserdfd.c \ + blegattaddservice.c \ + blegattdftchar1.c \ + blegattdftchar2.c \ + blegattdftserver.c \ + blegattdftservice.c \ + blegattmtuexchgreq.c \ + blegattmtuset.c \ + blegattdiscchar.c \ + blegattdiscchars.c \ + blegattdiscdescs.c \ + blegattdiscsvc.c \ + blegattdiscsvcs.c \ + blegattsvcactive.c \ + blegatttoble.c \ + blescanrspdata.c \ + blegapevtconn.c \ + blegapevtdisconn.c \ + blegapevtlinkinfo.c \ + blegapevtadvrpt.c \ + blegapevtpar.c \ + blegattmtuexchange.c \ + blegattread.c \ + blegattwrite.c \ + blegattnotify.c \ + blesmppairreq.c \ + blesmppairendind.c \ + sysbdaddr.c \ + sysfuncpin.c \ + syspm.c \ + sysnvds.c \ + blegattfromble.c \ + sysuart0raw.c \ + sysdfu.c \ + at_cmd_dfu_proc.c \ + +FIXME_EXAMPLE_USES_BLE := \ + atcmd_gap.c \ + ATM_ancsc.c \ + ATM_shub.c \ + attc_gatt.c \ + atts_gatt.c \ + atvrc_custom.c \ + BLE_adv.c \ + BLE_adv_scan.c \ + BLE_atcmd.c \ + BLE_att_client.c \ + BLE_att_server.c \ + BLE_bridge.c \ + BLE_harv_adv.c \ + BLE_scan_adv.c \ + BLE_scan.c \ + bridge_att.c \ + bridge_audio.c \ + bridge_gap.c \ + bridge_ir.c \ + bridge_mmi_client.c \ + bridge_mmi_server.c \ + button_demo.c \ + common.c \ + CT_adv.c \ + CT_button.c \ + CT_gatt.c \ + CT_nvds.c \ + CT_ota.c \ + CT_scan.c \ + CT_tracing.c \ + DTM.c \ + ESL_client.c \ + ESL_server.c \ + GPIO.c \ + HCI.c \ + HCI_vendor.c \ + HIB_restore.c \ + HID_keyboard.c \ + HID_mouse.c \ + HRP_sensor.c \ + HT_thermometer.c \ + ICM_sensor.c \ + kbd_gap.c \ + kbd_hogp.c \ + kbd_mmi.c \ + kbd_mmi_vkey.c \ + kbd_otaps.c \ + key_button.c \ + LECB_client.c \ + LECB_server.c \ + mbedtls_bist.c \ + mouse_hogp.c \ + mouse_gap.c \ + mouse_mmi.c \ + mouse_mmi_led.c \ + mouse_mmi_sensor.c \ + mouse_mmi_timer.c \ + mouse_otaps.c \ + per_sync.c \ + pm_demo.c \ + pvbcn_adv.c \ + pvbcn_gap.c \ + pvbcn_gatt.c \ + pvbcn_mmi.c \ + pvbcn_ota.c \ + PV_beacon.c \ + RAM_hibernate.c \ + rc_atvv.c \ + rc_gap.c \ + rc_hidau.c \ + rc_hogp.c \ + rc_ir.c \ + rc_mmi.c \ + rc_mmi_vkey.c \ + rc_ota.c \ + rc_pdm.c \ + rc_test_mode.c \ + RFsource_adv.c \ + RFsource_scan.c \ + swd_nego.c \ + tmp1075_sensor_adv.c \ + top_mmi.c \ + TPUTP_client.c \ + TPUTP_server.c \ + transceiver.c \ + uart0_raw_demo.c \ + vendor_specific.c \ + vkey_test.c \ + WURX_adv.c \ + WURX_scan_adv.c \ + +FIXME_DRIVER_USES_BLE := \ + atm_ble.c \ + atm_button.c \ + atm_pm.c \ + atm_vkey.c \ + bme680.c \ + dtop_bypass.c \ + ext_flash.c \ + gadc.c \ + hw_cfg.c \ + lpc_rcos.c \ + mouse.c \ + pmu.c \ + profiles.c \ + pseq.c \ + rf.c \ + shub.c \ + sw_event.c \ + sw_timer.c \ + trng.c \ + uart0.c \ + uart0_raw.c \ + uart_flash.c \ + uni_ir.c \ + wurx.c \ + +FRAMEWORK_UPPER_DIRS := $(wildcard $(LIB_DIR)/app_* $(LIB_DIR)/at_cmd* $(LIB_DIR)/atm_*) + +ABSTRACT_FILES := \ + $(notdir $(shell find $(FRAMEWORK_UPPER_DIRS) -name '*.c')) \ + $(notdir $(shell find $(EXAMPLE_DIR) -name '*.c')) \ + $(notdir $(shell find $(DRIVER_DIR) -name '*.c')) \ + +FILTERED_ABSTRACT_FILES := $(filter-out $(FIXME_USES_BLE) \ + $(FIXME_EXAMPLE_USES_BLE) $(FIXME_DRIVER_USES_BLE),$(ABSTRACT_FILES)) + +INCLUDES := \ + $(TOP_DIR) \ + $(INCLUDE_DIR) \ + $(INCLUDE_DIR)/reg \ + $(INCLUDE_DIR)/reg_ble \ + $(INCLUDE_DIR)/arm \ + $(INCLUDE_DIR)/ble \ + $(DRIVER_DIR)/spi \ + $(DRIVER_DIR)/timer \ + $(INCLUDES) + +BLE_ONLY_INCLUDES := \ + $(INCLUDE_DIR)/reg_ble \ + $(INCLUDE_DIR)/ble \ + $(LIB_DIR)/porting_ble \ + +EXT_INCLUDES := $(filter-out $(BLE_ONLY_INCLUDES),$(INCLUDES)) + +CFLAGS := \ + -D__MODULE__=\"$${<F}\" \ + -DFLASH_SIZE=$(if $(FLASH_SIZE),$(FLASH_SIZE),0x80000) \ + -DCORTEX_M0 \ + $(if $(FLASHROM),'-Dmain(...)=user_main(__VA_ARGS__)',-DCFG_USER) \ + $(if $(DEBUG),-DCFG_DBG) \ + $$(if $$(filter $(FILTERED_ABSTRACT_FILES),$$(<F)),\ + $(EXT_INCLUDES:%=-I%),\ + $($(if $(FLASHROM),FLASH)ROM_CFLAGS) $(INCLUDES:%=-I%)) \ + $(CFLAGS) + +ifeq ($(TOOLSET),IAR) +ASFLAGS := \ + --cpu cortex-m0 --thumb -r \ + $(ASFLAGS) + +CFLAGS := \ + --cpu cortex-m0 --thumb -Ohz \ + --vla \ + --debug \ + -e --warnings_are_errors \ + --diag_suppress Go029,Pa039,Pa082,Pa084,Pa089,Pa093,Pe111,Pe186,Pe188 \ + -I$(INCLUDE_DIR)/iccarm \ + $(CFLAGS) + +DEP_FLAGS := --dependencies=n + + +LDFLAGS := \ + --cpu cortex-m0 \ + -L$(USER_DIR) \ + $(if $(FLASH_SIZE),--config_def FLASH_SIZE=$(FLASH_SIZE)) \ + $(if $(USER_SIZE),--config_def USER_SIZE=$(USER_SIZE)) \ + $(if $(NVDS_SIZE),--config_def NVDS_SIZE=$(NVDS_SIZE)) \ + $(if $(URAM_START),--config_def URAM_START=$(URAM_START)) \ + $(if $(URAM_SIZE),--config_def URAM_SIZE=$(URAM_SIZE)) \ + $(if $(MPR_SIZE),--config_def MPR_SIZE=$(MPR_SIZE)) \ + --map=$(APP).map \ + $(LDFLAGS) +else +C_ONLY_FLAGS := \ + -Wstrict-prototypes \ + -Wold-style-definition \ + -Wmissing-prototypes \ + +comma := , + +ifeq ($(TOOLSET),ARM) +ASFLAGS := \ + --cpu=cortex-m0 --thumb -g \ + $(ASFLAGS) + +C_ONLY_FLAGS += -std=gnu17 + +CFLAGS := \ + -Oz \ + -fshort-enums \ + $(CFLAGS) + +LDFLAGS := -v \ + --cpu=cortex-m0 \ + $(if $(DEBUG),,--lto --lto_level=Oz) \ + --entry __main \ + --predefine="$(if $(FLASH_SIZE),-DFLASH_SIZE=$(FLASH_SIZE)) \ + $(if $(USER_SIZE),-DUSER_SIZE=$(USER_SIZE)) \ + $(if $(NVDS_SIZE),-DNVDS_SIZE=$(NVDS_SIZE)) \ + $(if $(URAM_START),-DURAM_START=$(URAM_START)) \ + $(if $(URAM_SIZE),-DURAM_SIZE=$(URAM_SIZE)) \ + $(if $(MPR_SIZE),-DMPR_SIZE=$(MPR_SIZE))" \ + --map --list=$(APP).map \ + --info unused \ + $(LDFLAGS) +else +ASFLAGS := \ + -mcpu=cortex-m0 -mthumb -g \ + $(ASFLAGS) + +C_ONLY_FLAGS += -std=c17 \ + -Wold-style-declaration \ + -Wmissing-parameter-type \ + +CFLAGS := \ + -Os \ + -Wformat-signedness -Wsuggest-attribute=noreturn \ + $(CFLAGS) + +LDFLAGS := \ + -Wl,--fatal-warnings,--warn-common -mthumb -mcpu=cortex-m0 \ + $(if $(FLASHROM),,-nostartfiles) -Wl,--gc-sections \ + $(if $(COVERAGE),-fprofile-arcs) \ + $(if $(DEBUG),,-flto) \ + -L$(USER_DIR) \ + $(if $(FLASH_SIZE),-Wl$(comma)--defsym=FLASH_SIZE=$(FLASH_SIZE)) \ + $(if $(USER_SIZE),-Wl$(comma)--defsym=USER_SIZE=$(USER_SIZE)) \ + $(if $(NVDS_SIZE),-Wl$(comma)--defsym=NVDS_SIZE=$(NVDS_SIZE)) \ + $(if $(URAM_START),-Wl$(comma)--defsym=URAM_START=$(URAM_START)) \ + $(if $(URAM_SIZE),-Wl$(comma)--defsym=URAM_SIZE=$(URAM_SIZE)) \ + $(if $(MPR_SIZE),-Wl$(comma)--defsym=MPR_SIZE=$(MPR_SIZE)) \ + -Xlinker -Map=$(APP).map \ + $(LDFLAGS) +endif + +CFLAGS := \ + -mcpu=cortex-m0 -mthumb -mlong-calls \ + -fms-extensions -ffunction-sections -fdata-sections \ + -fno-strict-aliasing -g3 $(if $(DEBUG),,-flto) \ + -Wall -Wchar-subscripts -Wformat \ + -Wuninitialized -Winit-self \ + -Wignored-qualifiers -Wswitch-default -Wswitch-enum -Wunused -Wundef \ + -Wnull-dereference -Wdouble-promotion \ + -Wwrite-strings -Wshadow -Wmissing-declarations -Wcast-qual \ + -Wpointer-arith \ + $(C_ONLY_FLAGS) -Werror \ + -I$(INCLUDE_DIR)/armgcc \ + $(CFLAGS) + +CXXFLAGS := $(filter-out $(C_ONLY_FLAGS),$(CFLAGS)) -std=c++17 +DEP_FLAGS := -MD +endif + +ifdef USER_SIZE +CFLAGS += -DUSER_SIZE=$(USER_SIZE) +endif + +ifdef MPR_SIZE +CFLAGS += -DMPR_SIZE=$(MPR_SIZE) +endif + +ifdef PMU_CFG +CFLAGS += -D$(PMU_CFG) +ifeq ($(filter-out VBAT_GT_1p8V_VDDIO_EXT VBAT_GT_1p8V_VDDIO_INT VBAT_LE_1p8V NO_VBAT,$(PMU_CFG)),) +else +$(warning Unknown PMU_CFG $(PMU_CFG)) +endif +endif # PMU_CFG + +define o_from_s_RULE +$(notdir $(1:%.s=%.o)): $(1) $(ASSEMBLE) + $(ASSEMBLE) $(ASFLAGS) $$< -o $$@ +endef +$(foreach src,$(S_SRCS),$(eval $(call o_from_s_RULE,$(src)))) + +define o_from_c_RULE +$(notdir $(1:%.c=%.o)): $(1) $(firstword $(COMPILE)) \ + | c_bindings + $(COMPILE) $(CFLAGS) $$(if $$(filter $(COVERAGE),\ + $$(basename $$@)),-fprofile-arcs -ftest-coverage) \ + $(DEP_FLAGS) -c $$< -o $$@ +ifneq (,$(filter -DAUTO_TEST,$(CFLAGS))) + -$$(if $$(filter $(ABSTRACT_FILES),$$(<F)),\ + ! grep $$(addprefix -e ,$(BLE_ONLY_INCLUDES)) $$(@:%.o=%.d)) +endif +endef +$(foreach src,$(C_SRCS),$(eval $(call o_from_c_RULE,$(src)))) + +define o_from_cxx_RULE +$(notdir $(basename $1).o): $(1) $(firstword $(CXX)) \ + | cpp_bindings + $(CXX) $(CXXFLAGS) $$(if $$(filter $(COVERAGE),\ + $$(basename $$@)),-fprofile-arcs -ftest-coverage) \ + $(DEP_FLAGS) -c $$< -o $$@ +endef +$(foreach src,$(CXX_SRCS),$(eval $(call o_from_cxx_RULE,$(src)))) + +-include *.d + +.PHONY: c_bindings cpp_bindings +c_bindings cpp_bindings:: + +ifdef RUST_LIBS +RUST_TARGET := thumbv6m-none-eabi + +define lib_from_rust_TEMPLATE +$(eval A := $1/target/$(RUST_TARGET)/$(if $(DEBUG),debug,release)/lib$1.rlib) +OBJS += $A +.PHONY: $A +$A: + $(if $(wildcard $1_wrapper.h),bindgen --use-core --ctypes-prefix cty \ + -o $1_bindings.rs $1_wrapper.h -- \ + --sysroot=$(BINUTILS_DIR)/../arm-none-eabi \ + -target $(RUST_TARGET) $(filter-out -W%,$(CFLAGS))) + cd $1 && cargo build --target $(RUST_TARGET) $(if $(DEBUG),,--release) +c_bindings:: + cbindgen -l c -o $1_bindings.h $1 +cpp_bindings:: + cbindgen -l c++ -o $1_bindings.hpp $1 +clean:: + cd $1 && cargo clean + rm -f $1/Cargo.lock + rm -f $1_bindings.rs $1_bindings.h $1_bindings.hpp +$(eval $(if $(filter undefine,$(.FEATURES)),undefine A,A :=)) +endef # lib_from_rust_TEMPLATE +$(foreach l,$(RUST_LIBS),$(eval $(call lib_from_rust_TEMPLATE,$l))) +endif # RUST_LIBS + +ifneq (,$(strip $(CXX_SRCS))) +LINK := $(CXX) +endif + +EXCLUDE_APP_SRC=$(notdir $(EXCL_APP_LIB_ALL)) +EXCLUDE_APP_OBJ+=$(patsubst %.c,%.o,$(EXCLUDE_APP_SRC)) + +ifdef FLASHROM +$(APP).elf: $(OBJS) $(firstword $(LINK)) + $(OBJCOPY) $(if $(COVERAGE),--redefine-syms $(ROM_DIR)/gcov.redef) \ + --redefine-syms $(ROM_DIR)/user.redef \ + $(LIB_DIR)/lib$(FLASHROM)$(if $(DEBUG),_dbg).a flashrom.a + $(LINK) -Tcmsdk_cm0_flash_rom.ld $(LDFLAGS) $(OBJS) $(LIBS) -o $@ \ + -Wl,-whole-archive flashrom.a -Wl,-no-whole-archive +else # FLASHROM +$(LIB_DIR)/app_lib/$(APP)$(if $(DEBUG),_dbg).a: $(OBJS) + mkdir -p $(@D) + $(AR) rcD --plugin=$(PLUGIN) $@ $(filter-out $(EXCLUDE_APP_OBJ),$(OBJS)) + $(RANLIB) -D --plugin=$(PLUGIN) $@ + $(AR) t $@ + +$(APP).elf: $(OBJS) $(firstword $(LINK)) \ + $(if $(BUILD_APP_LIB),$(LIB_DIR)/app_lib/$(APP)$(if $(DEBUG),_dbg).a) +ifeq ($(MAKECMDGOALS),build_info) + @echo IDE_LINK_CMD: +endif + $(LINK) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ +endif # FLASHROM + +ifeq ($(TOOLSET),ARM) +$(APP).bin: $(APP).elf + $(ARM_DIR)/fromelf --bin --output=$@ $< + +$(APP).ihex: $(APP).elf + $(ARM_DIR)/fromelf --i32 --output=$@ $< +else +$(APP).bin: $(APP).elf $(OBJCOPY) + $(OBJCOPY) -O binary $< $@ + +$(APP).ihex: $(APP).elf $(OBJCOPY) + $(OBJCOPY) -O ihex $< $@ +endif + +$(APP).bo: $(APP).bin $(OBJCOPY) + $(OBJCOPY) -I binary -O elf32-littlearm -B arm --rename-section .data=.rodata,alloc,load,readonly,data,contents $< $@ + +$(APP).hex: $(APP).ihex $(OBJCOPY) + $(OBJCOPY) -O verilog $< $@ + +$(APP).asm: $(APP).elf $(OBJDUMP) + $(OBJDUMP) -d $< >$@ + +.PHONY: program +program: $(APP).elf reset_target + $(OPENOCD) -c "init; verify_rom_version; sydney_load_flash $< $(if $(FLASH_START),$(FLASH_START) $(if $(NVDS_START),$(NVDS_START))); exit" + +.PHONY: program_all +program_all: $(if $(flash_nvds.data),build_flash_nvds push_flash_nvds) program + +.PHONY: verify +verify: $(APP).elf reset_target + $(OPENOCD) -c "init; verify_rom_version; sydney_verify_flash $<; exit" + +.PHONY: run.ram +run.ram: $(APP).bin reset_target + $(eval RUN_IN_RAM_HOOK:=$(shell $(NM) rom.elf | grep '\<run_in_ram_hook\>' | awk '{print "0x" $$1}'))\ + $(OPENOCD) -c "init; verify_rom_version; catch {sydney_erase_flash}; load_ram_image $(RUN_IN_RAM_HOOK) $< $(if $(URAM_START),$(URAM_START),0x20014000); resume $(if $(URAM_START),$(URAM_START),0x20014000); exit" + +.PHONY: run.flash +run.flash: $(APP).elf reset_target + $(OPENOCD) -c "init; verify_rom_version; sydney_load_flash $< \ + $(if $(FLASH_START),$(FLASH_START) $(if $(PRESERVE_USER),$(USER_START),$(if $(NVDS_START),$(NVDS_START)) $(if $(FLASHOFF),$(FLASHOFF)))); set _RESET_HARD_ON_EXIT 1; exit" + +.PHONY: run +run: run.$(if $(RUN_IN_RAM),ram,flash) + +.PHONY: run_all +run_all: $(if $(flash_nvds.data),build_flash_nvds push_flash_nvds) run + +.PHONY: pull_core +pull_core: check_openocd + $(OPENOCD) -c "init; get_coredump; exit" + +.PHONY: gcov +gcov: + $(GCOV) -ab *.gcda + +.PHONY: gdb +gdb: $(if $(NO_REBUILD),,$(APP).elf) $(GDB) + $(GDB) -x $(GDB_CFG_DIR)/atmx2.gdb $(APP).elf $(GDB_EXTRA) + +.PHONY: gdb_target +gdb_target: $(if $(NO_REBUILD),,$(APP).elf) $(GDB) + $(GDB) -x $(GDB_CFG_DIR)/atmx2.gdb $(APP).elf $(GDB_EXTRA) -ex "target remote $(GDB_REMOTE)" + +.PHONY: keil_gcc_gen +keil_gcc_gen: + python3 $(IDE_PRJ_GEN) $(CURDIR) -s ATMx2 -m $(MAKEOVERRIDES) + +.PHONY: keil_arm_gen +keil_arm_gen: + python3 $(IDE_PRJ_GEN) $(CURDIR) -s ATMx2 -i keil_arm -m $(MAKEOVERRIDES) + +.PHONY: ses_gen +ses_gen: + python3 $(IDE_PRJ_GEN) $(CURDIR) -s ATMx2 -i ses -m $(MAKEOVERRIDES) + +.PHONY: iar_gen +iar_gen: + python3 $(IDE_PRJ_GEN) $(CURDIR) -s ATMx2 -i iar -m $(MAKEOVERRIDES) + +.PHONY: build_info +build_info: all + @echo IDE_S_SRCS = $(S_SRCS) + @echo IDE_C_SRCS = $(C_SRCS) + @echo IDE_ASFLAGS = $(ASFLAGS) + @echo IDE_CFLAGS = $(CFLAGS) + @echo IDE_LIBS = $(LIBS) + +.PHONY: clean +clean:: + rm -f $(APP).{bin,elf,asm} + rm -f flashrom.a + -rm -f *.d *.o + -rm -f *.gcno *.gcda +ifndef COVERAGE + -rm -f *.gcov +endif + -rm -f *.map + +ARCH_FLASH_TYPE := bin + +ifeq ($(ARCH_FLASH_TYPE),bin) +# TODO: figure out a solution to avoid duplicating these platform-dependent +# values from <PLATFORM_DIR>/openocd/*_flash.tcl in Make. May require a change +# in archive format. +ATM_ISP_LOAD_FLASH_XARGS := \ + $(if $(FLASH_START),$(FLASH_START),0x0) \ + $(if $(NVDS_START),$(NVDS_START),0x78000) \ + 0x10000000 \ + $(if $(MPR_START), -mpr_start $(MPR_START)) \ + $(if $(MPR_SIZE), -mpr_size $(MPR_SIZE)) \ + $(if $(MPR_LOCK_SIZE), -mpr_lock_size $(MPR_LOCK_SIZE)) +else ifeq ($(ARCH_FLASH_TYPE),elf) +ATM_ISP_LOAD_FLASH_XARGS := $(if $(FLASH_START),$(FLASH_START) $(if $(NVDS_START),$(NVDS_START))) +else +$(error Unknown ARCH_FLASH_TYPE $(ARCH_FLASH_TYPE)) +endif + +.PHONY: arch_add_flash +arch_add_flash: $(APP).$(ARCH_FLASH_TYPE) + $(call ATM_ISP_LOAD,$< $(ATM_ISP_LOAD_FLASH_XARGS),Flash) + +build_archive: arch_add_flash + +.PHONY: info +info: $(APP).elf $(SIZE) + $(SIZE) $< + +include $(COMMON_USER_DIR)/layout_info.mk + +endif # __APP_MK__ diff --git a/platform/atm2/ATM22xx-x1x/user/cmsdk_cm0_flash_rom.ld b/platform/atm2/ATM22xx-x1x/user/cmsdk_cm0_flash_rom.ld new file mode 100644 index 0000000..274ab04 --- /dev/null +++ b/platform/atm2/ATM22xx-x1x/user/cmsdk_cm0_flash_rom.ld @@ -0,0 +1,17 @@ +/* + * cmsdk_cm0_flash_rom.ld + * Linker script for Sydney FLASHROM + * + * Copyright (C) Atmosic 2018-2019 + */ + +INCLUDE "lib-nosys.ld" +INCLUDE "memory_flash_rom.ld" + +__NVDS_Flash = ORIGIN(NVDS); +__NVDS_FlashEnd = ORIGIN(NVDS) + LENGTH(NVDS); + +__User_Flash = ORIGIN(USER); +__User_FlashEnd = ORIGIN(USER) + LENGTH(USER); + +INCLUDE "sections.ld" diff --git a/platform/atm2/ATM22xx-x1x/user/common.mk b/platform/atm2/ATM22xx-x1x/user/common.mk new file mode 100644 index 0000000..23d78ef --- /dev/null +++ b/platform/atm2/ATM22xx-x1x/user/common.mk @@ -0,0 +1,44 @@ + +ifndef __COMMON_MK__ +__COMMON_MK__ = 1 + +# First target +.PHONY: all +all: + +.PHONY: FORCE +FORCE: + +PLATFORM_DIR := $(realpath $(dir $(patsubst %/,%,$(dir $(lastword $(filter-out $(lastword $(MAKEFILE_LIST)), $(MAKEFILE_LIST))))))/../..) +TOP_DIR := $(realpath $(PLATFORM_DIR)/../../../) +COMMON_USER_DIR := $(PLATFORM_DIR)/user +USER_DIR := $(PLATFORM_DIR)/user +BLE_APP_DIR := $(PLATFORM_DIR)/app +DRIVER_DIR := $(PLATFORM_DIR)/driver +GDB_CFG_DIR := $(PLATFORM_DIR)/gdb +INCLUDE_DIR := $(PLATFORM_DIR)/include +OPENOCD_CFG_DIR := $(PLATFORM_DIR)/openocd +BLE_PRF_DIR := $(PLATFORM_DIR)/profiles +ROM_DIR := $(PLATFORM_DIR)/rom +PLAT_TOOLS_DIR := $(PLATFORM_DIR)/tools +LIB_DIR := $(PLATFORM_DIR)/lib +EXAMPLE_DIR := $(PLATFORM_DIR)/examples + +to_upper = $(shell echo $1 | tr '[:lower:]' '[:upper:]') + +wdog_val = $(shell printf "0x%08x" `expr $1 \* 16000000`) + +wdog_tag = $(shell printf "%02x " "$$(( $(call wdog_val,$1) & 0xFF ))" ; \ + printf "%02x " "$$(( ($(call wdog_val,$1) & 0xFF00) >> 8 ))" ; \ + printf "%02x " "$$(( ($(call wdog_val,$1) & 0xFF0000) >> 16))" ; \ + printf "%02x" "$$(( ($(call wdog_val,$1) & 0xFF000000) >> 24))" ) + +PLATFORM_NAME := $(notdir $(PLATFORM_DIR)) +PLATFORM_FAMILY := $(notdir $(realpath $(PLATFORM_DIR)/..)) + +BOARD ?= m2221 +ifneq (,$(filter-out m2201 m2202 m2221 m2231 m2251 m3201 m3202 m3221 m3231 x2xx_emu x2xx_mp,$(BOARD))) + $(error "usage: make $(MAKECMDGOALS) BOARD=<m2201|m2202|m2221|m2231|m2251|m3201|m3202|m3221|m3231") +endif + +endif # __COMMON_MK__ diff --git a/platform/atm2/ATM22xx-x1x/user/flash_program.sh b/platform/atm2/ATM22xx-x1x/user/flash_program.sh new file mode 100644 index 0000000..ed479ca --- /dev/null +++ b/platform/atm2/ATM22xx-x1x/user/flash_program.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +echo "" +echo "Flashing program from directory $1" +echo "" + +[ -d $1 ] && cd $1 && make program + diff --git a/platform/atm2/ATM22xx-x1x/user/framework.mk b/platform/atm2/ATM22xx-x1x/user/framework.mk new file mode 100644 index 0000000..a2caa24 --- /dev/null +++ b/platform/atm2/ATM22xx-x1x/user/framework.mk @@ -0,0 +1,19 @@ + +ifndef __FRAMEWORK_MK__ +__FRAMEWORK_MK__ = 1 + +CFLAGS += -DCFG_FRAMEWORK +LIBRARIES += framework_lib porting_ble ble_common + +# Add common framework modules +ifdef FRAMEWORK_MODULES +LIBRARIES += ble_module ble_task $(FRAMEWORK_MODULES) +endif + +ifneq (,$(filter at_cmd,$(LIBRARIES))) +include $(COMMON_USER_DIR)/atcmds.mk +endif + +include $(COMMON_USER_DIR)/app.mk + +endif # __FRAMEWORK_MK__ diff --git a/platform/atm2/ATM22xx-x1x/user/layout_info.mk b/platform/atm2/ATM22xx-x1x/user/layout_info.mk new file mode 100644 index 0000000..aeb8d4d --- /dev/null +++ b/platform/atm2/ATM22xx-x1x/user/layout_info.mk @@ -0,0 +1,56 @@ + +ifndef __LAYOUT_INFO_MK__ +__LAYOUT_INFO_MK__ = 1 + +.PHONY: layout_info +layout_info: + @echo "*────────────────────* $(FLASH_START)" + @echo "│░░░░░░░░░░░░░░░░░░░░│" + @echo "│░░░░░░░░░░░░░░░░░░░░│" + @echo "│░░░░░░░░░░░░░░░░░░░░│" + @echo "│░░░░░░UFLASH░░░░░░░░│($(if $(UFLASH_SIZE),$(UFLASH_SIZE),Default))" + @echo "│░░░░░░░░░░░░░░░░░░░░│" + @echo "│░░░░░░░░░░░░░░░░░░░░│" + @echo "│░░░░░░░░░░░░░░░░░░░░│" + @echo "│░░░░░░░░░░░░░░░░░░░░│" +ifdef USER_START + @echo "├────────────────────┤ $(USER_START)" + @echo "│░░░░░░░░░░░░░░░░░░░░│" + @echo "│░░░░░░░░USER░░░░░░░░│($(USER_SIZE))" + @echo "│░░░░░░░░░░░░░░░░░░░░│" +endif + @echo "├────────────────────┤ $(NVDS_START)" + @echo "│░░░░░░░░░░░░░░░░░░░░│" + @echo "│░░░░░░░░NVDS░░░░░░░░│($(if $(NVDS_SIZE),$(NVDS_SIZE),Default))" + @echo "│░░░░░░░░░░░░░░░░░░░░│" +ifneq (,$(filter OTAPS,$(PROFILES))) +ifdef MPR_START + @echo "├────────────────────┤ $(shell printf "0x%x" $$(($(NVDS_START) + $(NVDS_SIZE))))" + @echo "│░░░░░░░░░░░░░░░░░░░░│" + @echo "│░░░░░░reserved░░░░░░│($(MPR_SIZE))" + @echo "│░░░░░░░░░░░░░░░░░░░░│" + @echo "│░░░░░░Bank 0░░░░░░░░│" + @echo "├====================┤ $(FLASH_SIZE)" + @echo ".░░░░░░Bank 1░░░░░░░░." + @echo ".░░░░░░░░░░░░░░░░░░░░." + @echo ".░░░░░░░░░░░░░░░░░░░░." + @echo ".░░░░░░░░░░░░░░░░░░░░." + @echo "├────────────────────┤ $(MPR_START)" + @echo "│░░░░░░░░░░░░░░░░░░░░│" + @echo "│░░░░░░░░MPR░░░░░░░░░│($(MPR_SIZE))" + @echo "│░░░░░░░░░░░░░░░░░░░░│" + @echo "*────────────────────* $(shell printf "0x%x" $$(($(FLASH_SIZE)*2)))" +else + @echo "*────────────────────* $(FLASH_SIZE)" +endif # MPR_START +else +ifdef MPR_START + @echo "├────────────────────┤ $(MPR_START)" + @echo "│░░░░░░░░░░░░░░░░░░░░│" + @echo "│░░░░░░░░MPR░░░░░░░░░│($(MPR_SIZE))" + @echo "│░░░░░░░░░░░░░░░░░░░░│" +endif # MPR_START + @echo "*────────────────────* $(FLASH_SIZE)" +endif # OTAPS + +endif # __LAYOUT_INFO_MK__ diff --git a/platform/atm2/ATM22xx-x1x/user/lib-nosys.ld b/platform/atm2/ATM22xx-x1x/user/lib-nosys.ld new file mode 100644 index 0000000..64e5874 --- /dev/null +++ b/platform/atm2/ATM22xx-x1x/user/lib-nosys.ld @@ -0,0 +1,2 @@ +/* Library configurations */ +GROUP(libgcc.a libc.a libm.a libnosys.a) diff --git a/platform/atm2/ATM22xx-x1x/user/memory_flash_rom.ld b/platform/atm2/ATM22xx-x1x/user/memory_flash_rom.ld new file mode 100644 index 0000000..979ce8e --- /dev/null +++ b/platform/atm2/ATM22xx-x1x/user/memory_flash_rom.ld @@ -0,0 +1,42 @@ +/* + *----------------------------------------------------------------------------- + * The confidential and proprietary information contained in this file may + * only be used by a person authorised under and to the extent permitted + * by a subsisting licensing agreement from ARM Limited. + * + * (C) COPYRIGHT 2010-2013 ARM Limited. + * ALL RIGHTS RESERVED + * + * This entire notice must be reproduced on all copies of this file + * and copies of this file may only be made by a person if such person is + * permitted to do so under the terms of a subsisting license agreement + * from ARM Limited. + * + * SVN Information + * + * Checked In : $Date: $ + * + * Revision : $Revision: $ + * + * Release Information : Cortex-M System Design Kit-r1p0-00rel0 + *----------------------------------------------------------------------------- + */ +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ + +HIDDEN(USER_LEN = DEFINED(USER_SIZE) ? USER_SIZE : 0); +HIDDEN(NVDS_LEN = DEFINED(NVDS_SIZE) ? NVDS_SIZE : 0x2000); +HIDDEN(FLASH_LEN = (DEFINED(FLASH_SIZE) ? FLASH_SIZE : 0x80000) - NVDS_LEN - USER_LEN); + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = FLASH_LEN + USER (rwx) : ORIGIN = 0x0000000 + FLASH_LEN, LENGTH = USER_LEN + NVDS (rwx) : ORIGIN = FLASH_LEN + USER_LEN, LENGTH = NVDS_LEN + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x18000 /* 96K */ +} diff --git a/platform/atm2/ATM22xx-x1x/user/nvds.mk b/platform/atm2/ATM22xx-x1x/user/nvds.mk new file mode 100644 index 0000000..a051928 --- /dev/null +++ b/platform/atm2/ATM22xx-x1x/user/nvds.mk @@ -0,0 +1,503 @@ +################################################################################ +# +# @file nvds.mk +# +# @brief NVDS make helper +# +# Copyright (C) Atmosic 2018-2022 +# +################################################################################ + +ifndef __NVDS_MK__ +__NVDS_MK__ = 1 + +include $(COMMON_USER_DIR)/tools.mk +include $(ROM_DIR)/rom.mk + +DEF_MPR_BIN_FILE := flash_mpr_nvds.bin + +ifdef MPR_SIZE +ifneq ($(shell printf "%d" $$(($(MPR_SIZE)&0x0FFF))),0) +$(error "MPR_SIZE is not at 4K boundary") +endif + +ifndef FLASH_SIZE +$(error "usage: Need to compile with FLASH_SIZE. ex: make FLASH_SIZE=0x40000 MPR_SIZE=0x1000") +endif #FLASH_SIZE +endif + +ifneq ($(or $(MPR_SIZE),$(USER_SIZE),$(FLASH_SIZE),$(NVDS_SIZE)),) +FLASH_SIZE ?= 0x80000 +NVDS_SIZE ?= 0x8000 +MPR_SIZE ?= 0 +USER_SIZE ?= 0 +FLASH_MEM_BANK ?= "bank0" +FLASH_START := 0 + +ifeq ($(MPR_SIZE),0) +NVDS_START := $(shell printf "0x%x" $$(($(FLASH_SIZE) - $(NVDS_SIZE)))) +else +ifneq (,$(filter OTAPS,$(PROFILES))) +MPR_START := $(shell printf "0x%x" $$(($(FLASH_SIZE)*2 - $(MPR_SIZE)))) +NVDS_START := $(shell printf "0x%x" $$(($(FLASH_SIZE) - $(MPR_SIZE) - $(NVDS_SIZE)))) +else +MPR_START := $(shell printf "0x%x" $$(($(FLASH_SIZE) - $(MPR_SIZE)))) +NVDS_START := $(shell printf "0x%x" $$(($(MPR_START) - $(NVDS_SIZE)))) +endif #OTAPS +endif #MPR_SIZE + +ifneq ($(USER_SIZE),0) +USER_START := $(shell printf "0x%x" $$(($(NVDS_START) - $(USER_SIZE)))) +endif #USER_SIZE + +UFLASH_SIZE := $(shell printf "0x%x" $$(($(FLASH_SIZE) - $(NVDS_SIZE) - $(USER_SIZE) - $(MPR_SIZE)))) +endif + +TAG_DATA_DIR ?= tag_data + +.PHONY: all +all: + +$(TAG_DATA_DIR)/%.bin: $(TAG_DATA_DIR)/%.tds + sed 's,#.*$$,,' < $< | tr -d '[:space:]' | xxd -ps -r > $@ + +pre_bond_files := $(basename $(foreach file,$(TAG_DATA_DIR)/*,$(wildcard $(file)/*_pre_bond.tds))) +ifdef pre_bond_files +flash_nvds.data += $(foreach file,$(pre_bond_files),$(subst $(TAG_DATA_DIR)/,,$(file))) +endif + +ifdef WDOG +flash_nvds.data += b5-SYDNEY_TAG_WATCHDOG/wdog +otp_nvds.data += b5-SYDNEY_TAG_WATCHDOG/wdog +endif + +$(TAG_DATA_DIR)/18-PROG_DELAY: + mkdir -p $@ + +.PRECIOUS: $(TAG_DATA_DIR)/18-PROG_DELAY/%.tds +$(TAG_DATA_DIR)/18-PROG_DELAY/%.tds: | $(TAG_DATA_DIR)/18-PROG_DELAY + echo "# Programing delay (margin for programing the baseband in advance of each activity in half-slots)" > $@ + echo $(18-PROG_DELAY.$(@F)) >> $@ + +ifeq ($(filter 18-PROG_DELAY/%,$(flash_nvds.data)),) +18-PROG_DELAY.default.tds := "04" # 4 half slots (1250us) +flash_nvds.data += 18-PROG_DELAY/default +endif + +clean:: + rm -f $(TAG_DATA_DIR)/18-PROG_DELAY/default.tds + +$(TAG_DATA_DIR)/2e-SLEEP_ALGO_DUR: + mkdir -p $@ + +.PRECIOUS: $(TAG_DATA_DIR)/2e-SLEEP_ALGO_DUR/%.tds +$(TAG_DATA_DIR)/2e-SLEEP_ALGO_DUR/%.tds: | $(TAG_DATA_DIR)/2e-SLEEP_ALGO_DUR + echo $(2e-SLEEP_ALGO_DUR.$(@F)) > $@ + +ifeq ($(filter 2e-SLEEP_ALGO_DUR/%,$(flash_nvds.data)),) +2e-SLEEP_ALGO_DUR.sleep_algo.tds := "F4 01" # 500 half-us (250 us) +flash_nvds.data += 2e-SLEEP_ALGO_DUR/sleep_algo +otp_nvds.data += 2e-SLEEP_ALGO_DUR/sleep_algo +endif + +clean:: + rm -f $(TAG_DATA_DIR)/2e-SLEEP_ALGO_DUR/sleep_algo.tds + +ifdef LPC_RCOS +$(TAG_DATA_DIR)/0d-EXT_WAKEUP_TIME: + mkdir -p $@ + +.PRECIOUS: $(TAG_DATA_DIR)/0d-EXT_WAKEUP_TIME/%.tds +$(TAG_DATA_DIR)/0d-EXT_WAKEUP_TIME/%.tds: | $(TAG_DATA_DIR)/0d-EXT_WAKEUP_TIME + echo "# 9ms in us" > $@ + echo $(0d-EXT_WAKEUP_TIME.$(@F)) > $@ + +$(TAG_DATA_DIR)/0e-OSC_WAKEUP_TIME: + mkdir -p $@ + +.PRECIOUS: $(TAG_DATA_DIR)/0e-OSC_WAKEUP_TIME/%.tds +$(TAG_DATA_DIR)/0e-OSC_WAKEUP_TIME/%.tds: | $(TAG_DATA_DIR)/0e-OSC_WAKEUP_TIME + echo "# 9ms in us" > $@ + echo $(0e-OSC_WAKEUP_TIME.$(@F)) > $@ + +$(TAG_DATA_DIR)/2b-SLEEP_ADJ: + mkdir -p $@ + +.PRECIOUS: $(TAG_DATA_DIR)/2b-SLEEP_ADJ/%.tds +$(TAG_DATA_DIR)/2b-SLEEP_ADJ/%.tds: | $(TAG_DATA_DIR)/2b-SLEEP_ADJ + echo "# Number of half slots (312.5us)" > $@ + echo $(2b-SLEEP_ADJ.$(@F)) > $@ + +0d-EXT_WAKEUP_TIME.no_32KHz_xtal.tds := "28 23" +0e-OSC_WAKEUP_TIME.no_32KHz_xtal.tds := "28 23" +2b-SLEEP_ADJ.no_32KHz_xtal.tds := "02 00 00 00" + +flash_nvds.data += 0d-EXT_WAKEUP_TIME/no_32KHz_xtal \ + 0e-OSC_WAKEUP_TIME/no_32KHz_xtal \ + 2b-SLEEP_ADJ/no_32KHz_xtal \ + +clean:: + rm -f $(TAG_DATA_DIR)/0d-EXT_WAKEUP_TIME/no_32KHz_xtal.tds + rm -f $(TAG_DATA_DIR)/0e-OSC_WAKEUP_TIME/no_32KHz_xtal.tds + rm -f $(TAG_DATA_DIR)/2b-SLEEP_ADJ/no_32KHz_xtal.tds +endif # LPC_RCOS + +ifdef USER_BD_ADDR +flash_nvds.data += 01-BD_ADDRESS/user + +$(TAG_DATA_DIR)/01-BD_ADDRESS: + mkdir -p $@ + +.PHONY: $(TAG_DATA_DIR)/01-BD_ADDRESS/user.tds +$(TAG_DATA_DIR)/01-BD_ADDRESS/user.tds: | $(TAG_DATA_DIR)/01-BD_ADDRESS + echo $(USER_BD_ADDR) > $@ +endif + +$(TAG_DATA_DIR)/b3-FLASH_POWERUP_DELAY: + mkdir -p $@ + +.PRECIOUS: $(TAG_DATA_DIR)/b3-FLASH_POWERUP_DELAY/%.tds +$(TAG_DATA_DIR)/b3-FLASH_POWERUP_DELAY/%.tds: | $(TAG_DATA_DIR)/b3-FLASH_POWERUP_DELAY + echo $(b3-FLASH_POWERUP_DELAY.$(@F)) > $@ + +ifeq ($(filter b3-FLASH_POWERUP_DELAY/%,$(otp_nvds.data)),) +# Use Macronix delay as the superset default value +b3-FLASH_POWERUP_DELAY.macronix.tds := "1a 00" # 800us @ 32.768khz +otp_nvds.data += b3-FLASH_POWERUP_DELAY/macronix +endif + +clean:: + rm -f $(TAG_DATA_DIR)/b3-FLASH_POWERUP_DELAY/macronix.tds + +ifdef NVDS_APP +otp_nvds.data += b6-USER_APP/$(NVDS_APP) + +all: $(TAG_DATA_DIR)/b6-USER_APP/$(NVDS_APP).bin + +.PHONY: gdb_otp +gdb_otp: $(TAG_DATA_DIR)/b6-USER_APP/$(NVDS_APP).elf $(TAG_DATA_DIR)/b6-USER_APP/rom.elf $(GDB) + $(GDB) -x $(GDB_CFG_DIR)/sydney.gdb $< -ex "add-symbol-file $(TAG_DATA_DIR)/b6-USER_APP/rom.elf" + +.PHONY: gdb_otp_target +gdb_otp_target: $(TAG_DATA_DIR)/b6-USER_APP/$(NVDS_APP).elf $(TAG_DATA_DIR)/b6-USER_APP/rom.elf $(GDB) + $(GDB) -x $(GDB_CFG_DIR)/sydney.gdb $< -ex "add-symbol-file $(TAG_DATA_DIR)/b6-USER_APP/rom.elf" -ex "target remote $(GDB_REMOTE)" +endif + +NVDS_APP_INCLUDES := \ + $(INCLUDE_DIR) \ + $(INCLUDE_DIR)/armgcc \ + $(INCLUDE_DIR)/reg \ + $(INCLUDE_DIR)/reg_ble \ + $(INCLUDE_DIR)/arm \ + $(INCLUDE_DIR)/ble \ + $(DRIVER_DIR)/flash \ + $(DRIVER_DIR)/spi \ + $(DRIVER_DIR)/timer \ + $(LIB_DIR)/atm_utils_c \ + $(LIB_DIR)/atm_utils_math \ + $(NVDS_APP_INCLUDES) + +$(TAG_DATA_DIR)/b6-USER_APP/rom.elf: $(ROM_DIR)/fw.elf + $(OBJCOPY) $(NVDS_APP_ROMCOPY_FLAGS) $< $@ + +$(TAG_DATA_DIR)/b6-USER_APP/rom.o: $(TAG_DATA_DIR)/b6-USER_APP/rom.elf + $(COMMON_USER_DIR)/gen_symtab.py $< $@ + +.PRECIOUS: $(TAG_DATA_DIR)/b6-USER_APP/%.elf +$(TAG_DATA_DIR)/b6-USER_APP/%.elf: $(TAG_DATA_DIR)/b6-USER_APP/%.c \ + $(TAG_DATA_DIR)/b6-USER_APP/rom.o + cd $(@D) && $(GCC) -mcpu=cortex-m0 -Os -mthumb -mlong-calls \ + -fms-extensions -ffunction-sections -fdata-sections \ + -fno-strict-aliasing -g3 -flto \ + -Wall -Wchar-subscripts -Wformat -Wformat-signedness \ + -Wuninitialized -Winit-self \ + -Wignored-qualifiers -Wswitch-default -Wswitch-enum -Wunused -Wundef \ + -Wnull-dereference -Wsuggest-attribute=noreturn -Wdouble-promotion \ + -Wwrite-strings -Wshadow -Wcast-qual \ + -Wpointer-arith \ + -Wstrict-prototypes -Wold-style-declaration -Wold-style-definition \ + -Wmissing-parameter-type \ + -std=c17 -Werror \ + -DCORTEX_M0 $(ROM_CFLAGS) -DCFG_USER \ + $(NVDS_APP_CFLAGS) \ + $(NVDS_APP_INCLUDES:%=-I%) \ + -MD $(<F) \ + -Wl,--fatal-warnings,--warn-common \ + -nostdlib -Wl,--gc-sections \ + -L$(ROM_DIR) -L$(USER_DIR) -Tcmsdk_cm0_user_ram.ld \ + $(if $(NVDS_APP_URAM_SIZE),-Wl$(comma)--defsym=URAM_SIZE=$(NVDS_APP_URAM_SIZE)) \ + $(word 2,$(^F)) \ + -o $(@F) +-include $(TAG_DATA_DIR)/b6-USER_APP/*.d + +$(TAG_DATA_DIR)/b6-USER_APP/%.bin: $(TAG_DATA_DIR)/b6-USER_APP/%.elf + $(OBJCOPY) -O binary $< $@ + +$(TAG_DATA_DIR)/b5-SYDNEY_TAG_WATCHDOG: + mkdir -p $@ + +.PRECIOUS: $(TAG_DATA_DIR)/b5-SYDNEY_TAG_WATCHDOG/%.tds +$(TAG_DATA_DIR)/b5-SYDNEY_TAG_WATCHDOG/%.tds: | $(TAG_DATA_DIR)/b5-SYDNEY_TAG_WATCHDOG + echo $(call wdog_tag,$(WDOG)) > $@ + +clean:: + rm -f $(TAG_DATA_DIR)/b5-SYDNEY_TAG_WATCHDOG/wdog.tds + +$(TAG_DATA_DIR)/fe-MEM_RMW: + mkdir -p $@ + +.PRECIOUS: $(TAG_DATA_DIR)/fe-MEM_RMW/%.tds +$(TAG_DATA_DIR)/fe-MEM_RMW/%.tds: | $(TAG_DATA_DIR)/fe-MEM_RMW + echo $($(@F)) > $@ + +$(TAG_DATA_DIR)/fc-PMU_W: + mkdir -p $@ + +.PRECIOUS: $(TAG_DATA_DIR)/fc-PMU_W/%.tds +$(TAG_DATA_DIR)/fc-PMU_W/%.tds: | $(TAG_DATA_DIR)/fc-PMU_W + echo $($(@F)) > $@ + +data2deps = $(addprefix $(TAG_DATA_DIR)/,$(addsuffix .bin,$1)) +data2opts = $(foreach data,$1,-t $(firstword $(subst -, ,$(data))) -d $(TAG_DATA_DIR)/$(data).bin) + +HARV_CFG := $(filter -DCFG_NONRF_HARV -DCFG_RF_HARV,$(CFLAGS)) + +RECHARGE_BATT := $(filter -DCFG_RECHBATT,$(CFLAGS)) +ifneq ($(RECHARGE_BATT),) + +PMU13.tds := "093800000100" +otp_nvds.data += fc-PMU_W/PMU13 + +ifeq ($(PMU_CFG),VBAT_GT_1p8V_VDDIO_EXT) +otp_nvds.hw := OTP_BATT_TYPE:RECHARGE_VBAT_GT_1p8V OTP_DISABLE_VDDIO +else +otp_nvds.hw := OTP_BATT_TYPE:RECHARGE_VBAT_GT_1p8V +endif # VBAT_GT_1p8V_VDDIO_EXT + +SWREG_CTRL_5.tds := "0c141a0a4e01" +SWREG_CTRL_6.tds := "0c184d0a8c09" +otp_nvds.data += fc-PMU_W/SWREG_CTRL_5 +otp_nvds.data += fc-PMU_W/SWREG_CTRL_6 + +else # RECHARGE_BATT + +ifneq ($(PMU_CFG),) +ifeq ($(PMU_CFG),VBAT_GT_1p8V_VDDIO_EXT) +otp_nvds.hw := OTP_BATT_TYPE:VBAT_GT_1p8V OTP_DISABLE_VDDIO +else ifeq ($(PMU_CFG),VBAT_GT_1p8V_VDDIO_INT) +otp_nvds.hw := OTP_BATT_TYPE:VBAT_GT_1p8V +else ifeq ($(PMU_CFG),VBAT_LE_1p8V) +otp_nvds.hw := OTP_BATT_TYPE:VBAT_LE_1p8V +else ifeq ($(PMU_CFG),NO_VBAT) +ifeq ($(HARV_CFG),) +$(error No harvesting option specified when using NO_VBAT) +endif +otp_nvds.hw := OTP_BATT_TYPE:NO_VBAT +else +$(warning Unknown PMU_CFG $(PMU_CFG)) +endif +endif # PMU_CFG + +endif # RECHARGE_BATT + +ifneq ($(HARV_CFG),) +ifeq ($(HARV_CFG),-DCFG_NONRF_HARV) + +NONRF_HARV.tds := "09406E5a0000" +otp_nvds.data += fc-PMU_W/NONRF_HARV + +ifneq ($(filter -DVSTORE_MAX_EQ_3p0V,$(CFLAGS)),) +NONRF_VRANGE_1p1_1p4.tds := "0918211c1400" +NONRF_VRANGE_1p2_1p5.tds := "0918215c1600" +NONRF_VRANGE_1p3_1p6.tds := "0918219c1800" +NONRF_VRANGE_1p4_1p7.tds := "091821dc1a00" +NONRF_VRANGE_1p5_1p8.tds := "0918211c1d00" +NONRF_VRANGE_1p6_1p9.tds := "0918215c1f00" +else +NONRF_VRANGE_1p1_1p4.tds := "0918211e1400" +NONRF_VRANGE_1p2_1p5.tds := "0918215e1600" +NONRF_VRANGE_1p3_1p6.tds := "0918219e1800" +NONRF_VRANGE_1p4_1p7.tds := "091821de1a00" +NONRF_VRANGE_1p5_1p8.tds := "0918211e1d00" +NONRF_VRANGE_1p6_1p9.tds := "0918215e1f00" +endif # VSTORE_MAX_EQ_3p0V + +ifneq ($(filter -DCFG_NONRF_VRANGE_1p1_1p4,$(CFLAGS)),) +otp_nvds.data += fc-PMU_W/NONRF_VRANGE_1p1_1p4 +else ifneq ($(filter -DCFG_NONRF_VRANGE_1p2_1p5,$(CFLAGS)),) +otp_nvds.data += fc-PMU_W/NONRF_VRANGE_1p2_1p5 +else ifneq ($(filter -DCFG_NONRF_VRANGE_1p3_1p6,$(CFLAGS)),) +otp_nvds.data += fc-PMU_W/NONRF_VRANGE_1p3_1p6 +else ifneq ($(filter -DCFG_NONRF_VRANGE_1p4_1p7,$(CFLAGS)),) +otp_nvds.data += fc-PMU_W/NONRF_VRANGE_1p4_1p7 +else ifneq ($(filter -DCFG_NONRF_VRANGE_1p5_1p8,$(CFLAGS)),) +otp_nvds.data += fc-PMU_W/NONRF_VRANGE_1p5_1p8 +else ifneq ($(filter -DCFG_NONRF_VRANGE_1p6_1p9,$(CFLAGS)),) +otp_nvds.data += fc-PMU_W/NONRF_VRANGE_1p6_1p9 +else +$(error Voltage Range Config not defined in $(CFLAGS)) +endif # CFG_NONRF_VRANGE_XX_XX + +else # CFG_NONRF_HARV + +otp_nvds.hw += OTP_HARV_TYPE +MDM_AGCCNTL_CLR_PEAKDET.tds := "306000500000000001000000" +otp_nvds.data += fe-MEM_RMW/MDM_AGCCNTL_CLR_PEAKDET + +ifneq ($(filter -DVSTORE_MAX_EQ_3p0V,$(CFLAGS)),) +PMU5.tds := "0918215c1f00" +otp_nvds.data += fc-PMU_W/PMU5 +endif # VSTORE_MAX_EQ_3p0V + +endif # CFG_RF_HARV +endif # HARV_CFG + +BRWNOUT_OPT := $(filter -DBRWNOUT_THR%,$(CFLAGS)) +ifdef BRWNOUT_OPT +otp_nvds.hw += OTP_BROWNOUT_THR:$(BRWNOUT_OPT:-DBRWNOUT_THR%=%) +endif + +ifneq ($(or $(otp_nvds.data),$(otp_nvds.hw)),) + +nvds_tool_otp_args = $(call data2opts,$(otp_nvds.data)) $(if $(otp_nvds.hw),$(addprefix -w ,$(otp_nvds.hw))) + +.PHONY: build_archive_otp_nvds +build_archive_otp_nvds: $(NVDS_TOOL) $(call data2deps,$(otp_nvds.data)) + $< -i $(nvds_tool_otp_args) -b -o otp_nvds.nvm + +.PHONY: rebuild_otp_nvds +rebuild_otp_nvds: $(NVDS_TOOL) $(call data2deps,$(otp_nvds.data)) + $< -i -r otp_nvds.nvm $(nvds_tool_otp_args) -b -o otp_nvds_new.nvm + mv -f otp_nvds.nvm otp_nvds_$(shell $(MD5SUM) otp_nvds.nvm | cut -d " " -f 1).nvm + mv otp_nvds_new.nvm otp_nvds.nvm + +otp_nvds.nvm: + @echo "ERROR: Use build_archive_otp_nvds/rebuild_otp_nvds to make otp_nvds.nvm before invoking build_archive" + @exit 1 + +.PHONY: arch_add_otp_nvds +arch_add_otp_nvds: otp_nvds.nvm + $(call ATM_ISP_LOAD,$<,OtpNvds) + +ifdef ADD_OTP_TO_ARCHIVE +build_archive: arch_add_otp_nvds +endif +endif # otp_nvds.data + +NVDS_TOOL_F = $(if $(NVDS_SIZE),-f $(shell printf '%u' $(NVDS_SIZE))) +NVDS_TOOL_MPR_F = $(if $(MPR_SIZE),-f $(shell printf '%u' $(MPR_SIZE))) + +ifdef flash_nvds.data +.PHONY: build_flash_nvds +build_flash_nvds: $(NVDS_TOOL) $(call data2deps,$(flash_nvds.data)) + $< $(NVDS_TOOL_F) -b $(call data2opts,$(flash_nvds.data)) > flash_nvds.bin + +.PHONY: rebuild_flash_nvds +rebuild_flash_nvds: $(NVDS_TOOL) $(call data2deps,$(flash_nvds.data)) + $< $(NVDS_TOOL_F) -b -r flash_nvds.bin $(call data2opts,$(flash_nvds.data)) > flash_nvds_new.bin + mv -f flash_nvds.bin flash_nvds_$(shell $(MD5SUM) flash_nvds.bin | cut -d " " -f 1).bin + mv flash_nvds_new.bin flash_nvds.bin + +flash_nvds.bin: + @echo "ERROR: Use re/build_flash_nvds to make flash_nvds.bin before invoking build_archive" + @exit 1 + +.PHONY: arch_add_flash_nvds +arch_add_flash_nvds: flash_nvds.bin + $(call ATM_ISP_LOAD,$< $(if $(NVDS_START),$(NVDS_START) $(if $(NVDS_SIZE),$(NVDS_SIZE))),FlashNvds) + +build_archive: arch_add_flash_nvds +endif # flash_nvds.data + +.PHONY: pull_otp_nvds +pull_otp_nvds: reset_target + $(OPENOCD) -c "init; verify_rom_version; sydney_dump_nvm otp_nvds.nvm; exit" + +.PHONY: show_otp_nvds +show_otp_nvds: + $(NVDS_TOOL) -i -r otp_nvds.nvm -v + +.PHONY: show_pretty_otp_nvds +show_pretty_otp_nvds: $(NVDS_TOOL) + $(NVDS_TOOL) -i -r otp_nvds.nvm -p + + +.PHONY: show_otp_hw_cfg +show_otp_hw_cfg: + $(NVDS_TOOL) -i -r otp_nvds.nvm -v -N + +.PHONY: show_pretty_otp_hw_cfg +show_pretty_otp_hw_cfg: + $(NVDS_TOOL) -i -r otp_nvds.nvm -p -N + +.PHONY: split_otp_nvds +split_otp_nvds: + $(NVDS_TOOL) -i -r otp_nvds.nvm -S + +.PHONY: push_otp_nvds +push_otp_nvds: reset_target + $(OPENOCD) -c "init; verify_rom_version; sydney_burn_nvm otp_nvds.nvm; sydney_verify_nvm otp_nvds.nvm; exit" + +.PHONY: pull_flash_nvds +pull_flash_nvds: reset_target + $(OPENOCD) -c "init; verify_rom_version; sydney_dump_nvds flash_nvds.bin $(if $(NVDS_START),$(NVDS_START) $(if $(NVDS_SIZE),$(NVDS_SIZE) $(if $(FLASH_MEM_BANK),$(FLASH_MEM_BANK)))); exit" + +.PHONY: show_flash_nvds +show_flash_nvds: + $(NVDS_TOOL) $(NVDS_TOOL_F) -r flash_nvds.bin -v + +.PHONY: show_pretty_flash_nvds +show_pretty_flash_nvds: + $(NVDS_TOOL) $(NVDS_TOOL_F) -r flash_nvds.bin -p + +.PHONY: split_flash_nvds +split_flash_nvds: + $(NVDS_TOOL) $(NVDS_TOOL_F) -r flash_nvds.bin -S + +.PHONY: erase_flash_nvds +erase_flash_nvds: reset_target + $(OPENOCD) -c "init; verify_rom_version; sydney_erase_nvds $(if $(NVDS_START),$(NVDS_START) $(if $(NVDS_SIZE),$(NVDS_SIZE))); exit" + +.PHONY: push_flash_nvds +push_flash_nvds: reset_target + $(OPENOCD) -c "init; verify_rom_version; sydney_load_nvds flash_nvds.bin $(if $(NVDS_START),$(NVDS_START) $(if $(NVDS_SIZE),$(NVDS_SIZE))); exit" + +ifdef MPR_START +.PHONY: pull_mpr_nvds +pull_mpr_nvds: reset_target + $(OPENOCD) -c "init; verify_rom_version; sydney_dump_nvds $(DEF_MPR_BIN_FILE) $(if $(MPR_START),$(MPR_START) $(if $(MPR_SIZE),$(MPR_SIZE))); exit" + +.PHONY: show_mpr_nvds +show_mpr_nvds: + $(NVDS_TOOL) $(NVDS_TOOL_MPR_F) -r $(DEF_MPR_BIN_FILE) -v + +.PHONY: show_pretty_mpr_nvds +show_pretty_mpr_nvds: + $(NVDS_TOOL) $(NVDS_TOOL_MPR_F) -r $(DEF_MPR_BIN_FILE) -p +endif # MPR_START + +ifdef USER_START +.PHONY: erase_user +erase_user: check_openocd reset_target + $(OPENOCD) -c "init; verify_rom_version; sydney_erase_nvds $(USER_START) $(USER_SIZE); exit" +endif + +ifndef APP +.PHONY: iar_gen keil_arm_gen keil_gcc_gen ses_gen +iar_gen: ide_not_support +keil_arm_gen: ide_not_support +keil_gcc_gen: ide_not_support +ses_gen: ide_not_support +ide_not_support: + @echo "NVDS only application doesn't support IDE project generation" +endif + +.PHONY: clean +clean:: + -rm -f $(TAG_DATA_DIR)/*/*.bin + -rm -f $(TAG_DATA_DIR)/*/*_pre_bond.* + -rm -f $(TAG_DATA_DIR)/b6-USER_APP/*.o + -rm -f $(TAG_DATA_DIR)/b6-USER_APP/*.d + -rm -f $(TAG_DATA_DIR)/b6-USER_APP/*.elf + +endif # __NVDS_MK__ diff --git a/platform/atm2/ATM22xx-x1x/user/profiles.mk b/platform/atm2/ATM22xx-x1x/user/profiles.mk new file mode 100644 index 0000000..ba43def --- /dev/null +++ b/platform/atm2/ATM22xx-x1x/user/profiles.mk @@ -0,0 +1,238 @@ +################################################################################ +# +# @file profiles.mk +# +# @brief Common BLE profile build settings +# +# Copyright (C) Atmosic 2020-2021 +# +################################################################################ + +ifndef __PROFILE_MK__ +__PROFILE_MK__ = 1 + +ifdef PROFILES +# Enable the profiles framework +DRIVERS += profiles + +# $1 - common part of profile name +# $2 - client/server part of profile name +# $3 - common directory ($1 if empty) +# $4 - define (uppercase $1$2 if empty) +define profile_TEMPLATE +$(eval A := $(if $3,$3,$1)) +$(eval B := $(if $4,$4,$(call to_upper,$1$2))) +ifneq ($(filter $B,$(PROFILES)),) +C_SRCS += $(BLE_PRF_DIR)/$A/$1$2/src/$1$2.c \ + $(wildcard $(BLE_PRF_DIR)/$A/$1$2/src/$1$2_task.c) +INCLUDES += $(BLE_PRF_DIR)/$A $(BLE_PRF_DIR)/$A/$1$2/api +CFLAGS += -DCFG_PRF_$B +endif +$(eval $(if $(filter undefine,$(.FEATURES)),undefine A,A :=)) +$(eval $(if $(filter undefine,$(.FEATURES)),undefine B,B :=)) +endef + + +# +# Standard profiles +# + +# ANCSC Apple Notification Center Service Client +$(eval $(call profile_TEMPLATE,ancs,c)) + +# ANPC Alert Notification Client +$(eval $(call profile_TEMPLATE,anp,c)) +# ANPS Alert Notification Server +$(eval $(call profile_TEMPLATE,anp,s)) + +# BASC Battery Service Client +$(eval $(call profile_TEMPLATE,bas,c)) +# BASS Battery Service Server +$(eval $(call profile_TEMPLATE,bas,s)) + +# BLPC Blood Pressure collector +$(eval $(call profile_TEMPLATE,blp,c)) +# BLPS Blood Pressure Sensor +$(eval $(call profile_TEMPLATE,blp,s)) + +# BCSC Body Composition Client +$(eval $(call profile_TEMPLATE,bcs,c)) +# BCSS Body Composition Server +$(eval $(call profile_TEMPLATE,bcs,s)) + +# CGMC Continuous Glucose Monitoring Client +$(eval $(call profile_TEMPLATE,cgm,c)) +# CGMS Continuous Glucose Monitoring Server +$(eval $(call profile_TEMPLATE,cgm,s)) + +# CPPC Cycling Power Client +$(eval $(call profile_TEMPLATE,cpp,c)) +# CPPS Cycling Power Server +$(eval $(call profile_TEMPLATE,cpp,s)) + +# CSCPC Cycling Speed and Cadence Client +$(eval $(call profile_TEMPLATE,cscp,c)) +# CSCPS Cycling Speed and Cadence Server +$(eval $(call profile_TEMPLATE,cscp,s)) + +# DISC Device Information Service Client +$(eval $(call profile_TEMPLATE,dis,c)) +# DISS (Device Information Service) Server +$(eval $(call profile_TEMPLATE,dis,s)) + +# ENVC Environmental Sensing Client +$(eval $(call profile_TEMPLATE,env,c)) +# ENVS Environmental Sensing Server +$(eval $(call profile_TEMPLATE,env,s)) + +# FMPL Find me locator +$(eval $(call profile_TEMPLATE,find,l,,FMPL)) +# FMPT Find me target +$(eval $(call profile_TEMPLATE,find,t,,FMPT)) + +# GLPC Glucose Collector +$(eval $(call profile_TEMPLATE,glp,c)) +# GLPS Glucose Sensor +$(eval $(call profile_TEMPLATE,glp,s)) + +# HOGPD HID over GATT Profile Device +$(eval $(call profile_TEMPLATE,hogp,d)) +# HOGPBH HID Profile Boot Host +$(eval $(call profile_TEMPLATE,hogp,bh)) +# HOGPRH HID over GATT Report Profile Host +$(eval $(call profile_TEMPLATE,hogp,rh)) + +# HRPC Heart Rate collector +$(eval $(call profile_TEMPLATE,hrp,c)) +# HRPS Heart Rate Sensor +$(eval $(call profile_TEMPLATE,hrp,s)) + +# HTPC Health thermometer collector +$(eval $(call profile_TEMPLATE,htp,c)) +# HTPT Health Thermometer +$(eval $(call profile_TEMPLATE,htp,t)) + +# IPSC Internet Protocol Support Profile Client +$(eval $(call profile_TEMPLATE,ips,c)) +# IPSS Internet Protocol Support Profile Server +$(eval $(call profile_TEMPLATE,ips,s)) + +# LANC Location and Navigation Client +$(eval $(call profile_TEMPLATE,lan,c)) +# LANS Location and Navigation Server +$(eval $(call profile_TEMPLATE,lan,s)) + +# PASPC Phone Alert Status Client +$(eval $(call profile_TEMPLATE,pasp,c)) +# PASPS Phone Alert Status Server +$(eval $(call profile_TEMPLATE,pasp,s)) + +# PLXC Pulse Oximeter Profile Client +$(eval $(call profile_TEMPLATE,plx,c)) +# PLXS Pulse Oximeter Profile Server +$(eval $(call profile_TEMPLATE,plx,s)) + +# PXPM Proximity monitor +$(eval $(call profile_TEMPLATE,prox,m,,PXPM)) +# PXPR Proximity reporter +$(eval $(call profile_TEMPLATE,prox,r,,PXPR)) + +# RSCPC Running Speed and Cadence Client +$(eval $(call profile_TEMPLATE,rscp,c)) +# RSCPS Running Speed and Cadence Server +$(eval $(call profile_TEMPLATE,rscp,s)) + +# SCPPC Scan Parameter Client +$(eval $(call profile_TEMPLATE,scpp,c)) +# SCPPS Scan Parameter Server +$(eval $(call profile_TEMPLATE,scpp,s)) + +# TIPC Time Client +$(eval $(call profile_TEMPLATE,tip,c)) +# TIPS Time Server +$(eval $(call profile_TEMPLATE,tip,s)) + +# UDSC User Data Service Client +$(eval $(call profile_TEMPLATE,uds,c)) +# UDSS User Data Service Server +$(eval $(call profile_TEMPLATE,uds,s)) + +# WPTC Wireless Power Transfer Profile Client +$(eval $(call profile_TEMPLATE,wpt,c)) +# WPTS Wireless Power Transfer Profile Server +$(eval $(call profile_TEMPLATE,wpt,s)) + +# WSCC Weight Scale Client +$(eval $(call profile_TEMPLATE,wsc,c,wscp)) +# WSCS Weight Scale Server +$(eval $(call profile_TEMPLATE,wsc,s,wscp)) + +# +# Atmosic profiles +# + +# AGPC Atmosic Generic Client +$(eval $(call profile_TEMPLATE,agp,c)) +# AGPS Atmosic Generic Client +$(eval $(call profile_TEMPLATE,agp,s)) + +# ATVVS (Android TV Voice) Service +$(eval $(call profile_TEMPLATE,atvv,s)) + +# DTPS (Data Transfer Profile) Server +ifneq ($(filter DTPS,$(PROFILES)),) +C_SRCS += $(BLE_PRF_DIR)/dts/dts/src/dtps.c +CFLAGS += -DCFG_PRF_DTPS +DTS_SERVER_ROLE := 1 +endif # DTPS + +# OTAPS (Over the Air Upgrade Profile) Server +$(eval $(call profile_TEMPLATE,otap,s)) +ifneq ($(filter OTAPS,$(PROFILES)),) +CFLAGS += -DCFG_CRC +LIBRARIES += upgrade crc +DTS_SERVER_ROLE := 1 +ifdef OTA_DISCON_BEFORE_REBOOT +CFLAGS += -DCFG_UPGD_REBOOT_POSTPONED +endif +endif # OTAPS + +# TPUTPC Throughput Testing Client +$(eval $(call profile_TEMPLATE,tputp,c)) +ifneq ($(filter TPUTPC,$(PROFILES)),) +DTS_CLIENT_ROLE := 1 +DTS_UTILS := 1 +endif # TPUTPC + +# TPUTPS Throughput Testing Server +$(eval $(call profile_TEMPLATE,tputp,s)) +ifneq ($(filter TPUTPS,$(PROFILES)),) +DTS_SERVER_ROLE := 1 +DTS_UTILS := 1 +endif # TPUTPS + +# DTSS (Data Transfer Service) server role library +ifdef DTS_SERVER_ROLE +# DTS server role support +C_SRCS += $(BLE_PRF_DIR)/dts/dts/src/dts_server.c +INCLUDES += $(BLE_PRF_DIR)/dts/dts/api +endif # DTS_SERVER_ROLE + +# DTSC (Data Transfer Service) client role library +ifdef DTS_CLIENT_ROLE +C_SRCS += $(BLE_PRF_DIR)/dts/dts/src/dts_client.c +INCLUDES += $(BLE_PRF_DIR)/dts/dts/api +endif # DTS_CLIENT_ROLE + +# DTS utility library +ifdef DTS_UTILS +C_SRCS += $(BLE_PRF_DIR)/dts/dts/src/dts_utils.c +endif # DTS_UTILS + +ifneq (,$(or $(filter ANCSC BASS DISS HTPT OTAPS,$(PROFILES)),$(DTS_CLIENT_ROLE))) +LIBRARIES += prf +endif + +endif # PROFILES + +endif # __PROFILE_MK__ diff --git a/platform/atm2/ATM22xx-x1x/user/sections.ld b/platform/atm2/ATM22xx-x1x/user/sections.ld new file mode 100644 index 0000000..4329c79 --- /dev/null +++ b/platform/atm2/ATM22xx-x1x/user/sections.ld @@ -0,0 +1,186 @@ +/* + *----------------------------------------------------------------------------- + * The confidential and proprietary information contained in this file may + * only be used by a person authorised under and to the extent permitted + * by a subsisting licensing agreement from ARM Limited. + * + * (C) COPYRIGHT 2010-2013 ARM Limited. + * ALL RIGHTS RESERVED + * + * This entire notice must be reproduced on all copies of this file + * and copies of this file may only be made by a person if such person is + * permitted to do so under the terms of a subsisting license agreement + * from ARM Limited. + * + * SVN Information + * + * Checked In : $Date: $ + * + * Revision : $Revision: $ + * + * Release Information : Cortex-M System Design Kit-r1p0-00rel0 + *----------------------------------------------------------------------------- + */ +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + KEEP(*(.isr_vector)) + *(.text*) + KEEP(*(.KEEP.text*)) + + KEEP(*(.init)) + KEEP(*(.fini)) + + /* .ctors */ + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + + /* .dtors */ + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + + *(SORT_BY_ALIGNMENT(.rodata*)) + + KEEP(*(.eh_frame*)) + } > FLASH + + . = ALIGN(4); + __atm_module_start = .; + .ATM.module : + { + KEEP(*(SORT(.atm_module.*))) + } > FLASH + __atm_module_end = .; + + . = ALIGN(4); + __at_cmd_start = .; + .ATCOMMAND : + { + KEEP(*(SORT(.at_cmd.*))) + } > FLASH + __at_cmd_end = .; + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + .data : + { + __etext = LOADADDR(.data); + __data_start__ = .; + *(vtable) + *(SORT_BY_ALIGNMENT(.data*)) + + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + + KEEP(*(.jcr*)) + . = ALIGN(4); + /* All data end */ + __data_end__ = .; + + } >RAM AT>FLASH + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(SORT_BY_ALIGNMENT(.bss*)) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .uninit (NOLOAD) : + { + . = ALIGN(4); + *(SORT_BY_ALIGNMENT(.uninit*)) + . = ALIGN(4); + } > RAM + + .heap (COPY): + { + __end__ = .; + end = __end__; + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/platform/atm2/ATM22xx-x1x/user/tools.mk b/platform/atm2/ATM22xx-x1x/user/tools.mk new file mode 100644 index 0000000..b7c95eb --- /dev/null +++ b/platform/atm2/ATM22xx-x1x/user/tools.mk @@ -0,0 +1,150 @@ + +ifndef __TOOLS_MK__ +__TOOLS_MK__ = 1 + +ifeq ($(OS),Windows_NT) +MD5SUM := md5sum +SED := sed +else +ifeq ($(shell uname),Darwin) +OS := Darwin +MD5SUM := md5 -r +SED := gsed +else +OS := Linux +MD5SUM := md5sum +SED := sed +endif +endif + +TOOLS_DIR := $(realpath $(PLATFORM_DIR)/../../../tools) + +ifeq ($(ATM_SDK_TOOLS_IN_PATH),) +BINUTILS_DIR := $(TOOLS_DIR)/gcc-arm-none-eabi-10.3-2021.07/bin +ifeq ($(BINUTILS_DIR),) +$(error BINUTILS_DIR unset) +endif +endif + +BINUTILS_PREFIX_BASE := arm-none-eabi- +ifeq ($(ATM_SDK_TOOLS_IN_PATH),) +BINUTILS_PREFIX := $(BINUTILS_DIR)/$(BINUTILS_PREFIX_BASE) +else +BINUTILS_PREFIX := $(BINUTILS_PREFIX_BASE) +WHICH_GCC := $(shell which $(BINUTILS_PREFIX_BASE)gcc) +ifeq ($(OS),Windows_NT) +BINUTILS_DIR_TXT := directory of $(WHICH_GCC) +else +BINUTILS_DIR_TXT := $(dir $(WHICH_GCC)) +endif +endif + +ifeq ($(TOOLSET),IAR) +IAR_DIR := $(TOOLS_DIR)/bxarm-9.10.2/arm/bin +ASSEMBLE := $(IAR_DIR)/iasmarm +COMPILE := $(IAR_DIR)/iccarm +CXX := $(IAR_DIR)/iccarm --c++ +LINK := $(IAR_DIR)/ilinkarm +else ifeq ($(TOOLSET),ARM) +ARM_DIR := $(TOOLS_DIR)/ARMCompiler6.16/bin +ASSEMBLE := $(ARM_DIR)/armasm +COMPILE := $(ARM_DIR)/armclang --target=arm-arm-none-eabi +CXX := $(ARM_DIR)/armclang --target=arm-arm-none-eabi -x c++ +LINK := $(ARM_DIR)/armlink +else +ASSEMBLE := $(BINUTILS_PREFIX)as +COMPILE := $(BINUTILS_PREFIX)gcc +CXX := $(BINUTILS_PREFIX)c++ +GCOV := $(BINUTILS_PREFIX)gcov +LINK := $(BINUTILS_PREFIX)gcc +PLUGIN := $(shell $(COMPILE) --print-file-name=liblto_plugin$(if $(filter Windows_NT,$(OS)),-0.dll,.so)) +endif + +GCC := $(BINUTILS_PREFIX)gcc +GDB := $(BINUTILS_PREFIX)gdb +NM := $(BINUTILS_PREFIX)nm +OBJCOPY := $(BINUTILS_PREFIX)objcopy +OBJDUMP := $(BINUTILS_PREFIX)objdump +SIZE := $(BINUTILS_PREFIX)size +AR := $(BINUTILS_PREFIX)ar +RANLIB := $(BINUTILS_PREFIX)ranlib + +$(sort $(foreach t,ASSEMBLE COMPILE CXX GCOV LINK GCC GDB NM OBJCOPY OBJDUMP \ + SIZE AR RANLIB,$(firstword $($t)))): +ifneq ($(ATM_SDK_TOOLS_IN_PATH),) +$(info Getting bin utils from $(BINUTILS_DIR_TXT)) +else + @echo + @echo "ERROR: Failed to find $@" + @echo + @echo "ERROR: Toolchain not found - needs to be downloaded and extracted." + @echo "ERROR: See $(TOOLS_DIR)/README for instructions." + @echo + @exit 1 +endif + +# FIXME: C removed due to problems on case-insensitive filesystems +CXX_EXT := cc cp cxx cpp c++ + +GDB_REMOTE ?= localhost:3333 + +RTT_PORT ?= 9090 + +OPENOCD_DIR := $(TOOLS_DIR)/openocd +OPENOCD_EXE := $(OPENOCD_DIR)/bin/$(OS)/openocd +OPENOCD_FLAGS += -s $(OPENOCD_DIR)/tcl -s $(OPENOCD_CFG_DIR) +OPENOCD_FLAGS += -f atm2x_openocd.cfg +ifneq ($(OPENOCD_DEBUG),) +OPENOCD_FLAGS += -d +endif +OPENOCD := $(OPENOCD_EXE) $(OPENOCD_FLAGS) + +NVDS_TOOL := $(PLAT_TOOLS_DIR)/bin/$(OS)/nvds_tool + +ATM_ISP := $(TOOLS_DIR)/atm_isp + +IDE_PRJ_GEN := $(TOOLS_DIR)/ide_prj_gen/ide_prj_generator.py + +.PHONY: check_openocd +check_openocd: +ifeq ($(OS),Linux) + @if ! groups | grep -q plugdev; then \ + echo; \ + echo "ERROR: User $$USER is not a member of group plugdev."; \ + echo "ERROR: See $(TOOLS_DIR)/README for instructions."; \ + echo; \ + exit 1; \ + fi +endif + +.PHONY: openocd +openocd: check_openocd + HTTP_KEEP_GOING=1 HTTP_NVDS_TOOL=$(NVDS_TOOL) HTTP_ATM_ISP=$(ATM_ISP) $(OPENOCD) -f servers.tcl + +.PHONY: segger_rtt_server +segger_rtt_server: check_openocd + SWDIF=JLINK $(OPENOCD) -c 'init; rtt setup 0x20014000 0x4000 "SEGGER RTT"; rtt start; rtt server start $(RTT_PORT) 0' + +.PHONY: reset_target +reset_target: check_openocd + FTDI_BENIGN_BOOT=1 FTDI_HARD_RESET=1 $(OPENOCD) -c "init; release_reset; sleep 100; set_normal_boot; exit" + +ARCH_ATM := arch.atm + +.PHONY: truncate_arch +truncate_arch: + $(ATM_ISP) init -o $(ARCH_ATM) $(PLATFORM_FAMILY) $(PLATFORM_NAME) + +ATM_ISP_LOAD = $(if $1,$(ATM_ISP) load$2 $1 -i $(ARCH_ATM) -o $(ARCH_ATM)) + +.PHONY: build_archive +build_archive: truncate_arch + +.PHONY: show_archive +show_archive: + $(ATM_ISP) decode -i $(ARCH_ATM) + +burn_archive: + $(ATM_ISP) burn -r $(realpath $(PLATFORM_DIR)/../../../) -i $(ARCH_ATM) $(if $(BURN_ARCH_VERIFY),-c) $(if $(BURN_ARCH_DEBUG),-v) $(if $(BURN_ARCH_ERASE_WORKAROUNDS),-e) $(if $(BURN_ARCH_PROGRAM_ONLY),-p) $(if $(BURN_ARCH_DEST_DIR),-d $(BURN_ARCH_DEST_DIR)) + +endif # __TOOLS_MK__ |