diff --git a/code/b-parasite/Makefile b/code/b-parasite/Makefile index 5643a60..82040ca 100644 --- a/code/b-parasite/Makefile +++ b/code/b-parasite/Makefile @@ -1,17 +1,40 @@ +# Supported platforms: +# * E73_2G4M08S1C (nrf2480, default) +# * E73_2G4M08S1E (nrf2833) +PLATFORM ?= E73_2G4M08S1C + +ifeq ($(PLATFORM), E73_2G4M08S1E) + SRC_FILES += \ + $(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52833.S \ + $(SDK_ROOT)/modules/nrfx/mdk/system_nrf52833.c + TARGETS := nrf52833_xxaa + CFLAGS += -DNRF52833_XXAA + ASMFLAGS += -DNRF52833_XXAA + LINKER_SCRIPT := b_parasite_gcc_nrf52833.ld +HEAP_SIZE := 2048 +STACK_SIZE := 2048 +else ifeq ($(PLATFORM), E73_2G4M08S1C) + SRC_FILES += \ + $(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52840.S \ + $(SDK_ROOT)/modules/nrfx/mdk/system_nrf52840.c + TARGETS := nrf52840_xxaa + CFLAGS += -DNRF52840_XXAA + ASMFLAGS += -DNRF52840_XXAA + LINKER_SCRIPT := b_parasite_gcc_nrf52840.ld +HEAP_SIZE := 8192 +STACK_SIZE := 8192 +endif + + PROJECT_NAME := ble_app_beacon_pca10056_s140 -TARGETS := nrf52840_xxaa OUTPUT_DIRECTORY := _build # Set SDK_ROOT via env vars. # SDK_ROOT := ../../../.././.. PROJ_DIR := ./src -$(OUTPUT_DIRECTORY)/nrf52840_xxaa.out: \ - LINKER_SCRIPT := b_parasite_gcc_nrf52.ld - # Source files common to all targets SRC_FILES += \ - $(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52840.S \ $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_rtt.c \ $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_serial.c \ $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_uart.c \ @@ -39,8 +62,6 @@ SRC_FILES += \ $(SDK_ROOT)/components/libraries/experimental_section_vars/nrf_section_iter.c \ $(SDK_ROOT)/components/libraries/sortlist/nrf_sortlist.c \ $(SDK_ROOT)/components/libraries/strerror/nrf_strerror.c \ - $(SDK_ROOT)/modules/nrfx/mdk/system_nrf52840.c \ - $(SDK_ROOT)/components/boards/boards.c \ $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_clock.c \ $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_twi.c \ $(SDK_ROOT)/modules/nrfx/soc/nrfx_atomic.c \ @@ -51,7 +72,6 @@ SRC_FILES += \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_twi.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/prs/nrfx_prs.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_pwm.c \ - $(SDK_ROOT)/components/libraries/bsp/bsp.c \ $(PROJ_DIR)/main.c \ $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \ $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c \ @@ -90,7 +110,6 @@ INC_FOLDERS += \ $(SDK_ROOT)/components/libraries/gpiote \ $(SDK_ROOT)/components/libraries/bootloader/ble_dfu \ $(SDK_ROOT)/components/nfc/ndef/connection_handover/common \ - $(SDK_ROOT)/components/boards \ $(SDK_ROOT)/components/nfc/ndef/generic/record \ $(SDK_ROOT)/components/ble/ble_advertising \ $(SDK_ROOT)/external/utf_converter \ @@ -108,7 +127,6 @@ INC_FOLDERS += \ $(SDK_ROOT)/components/ble/common \ $(SDK_ROOT)/components/ble/ble_services/ble_lls \ $(SDK_ROOT)/components/nfc/platform \ - $(SDK_ROOT)/components/libraries/bsp \ $(SDK_ROOT)/components/nfc/ndef/connection_handover/ac_rec \ $(SDK_ROOT)/components/ble/ble_services/ble_bas \ $(SDK_ROOT)/components/libraries/mpu \ @@ -203,7 +221,7 @@ INC_FOLDERS += \ LIB_FILES += \ # Optimization flags -OPT = -O3 -g3 +OPT = -O0 -g3 # Uncomment the line below to enable link time optimization #OPT += -flto @@ -211,20 +229,18 @@ OPT = -O3 -g3 CFLAGS += $(OPT) CFLAGS += -DAPP_TIMER_V2 CFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED -CFLAGS += -DBOARD_PCA10056 CFLAGS += -DCONFIG_GPIO_AS_PINRESET CFLAGS += -DFLOAT_ABI_HARD -CFLAGS += -DNRF52840_XXAA CFLAGS += -DNRF_SD_BLE_API_VERSION=7 CFLAGS += -DS140 CFLAGS += -DSOFTDEVICE_PRESENT -CFLAGS += -DEBUG +CFLAGS += -DDEBUG # Setting -DDEBUG prints info via JLkinkRTTLogger, but hides the stack trace # when debugging with VSCode's Cortex Debug extension. # CFLAGS += -DDEBUG CFLAGS += -mcpu=cortex-m4 CFLAGS += -mthumb -mabi=aapcs -CFLAGS += -Wall -Werror +CFLAGS += -Wall -Werror -Wno-maybe-uninitialized CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 # keep every function in a separate section, this allows linker to discard unused ones CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing @@ -239,10 +255,8 @@ ASMFLAGS += -mthumb -mabi=aapcs ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 ASMFLAGS += -DAPP_TIMER_V2 ASMFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED -ASMFLAGS += -DBOARD_PCA10056 ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET ASMFLAGS += -DFLOAT_ABI_HARD -ASMFLAGS += -DNRF52840_XXAA ASMFLAGS += -DNRF_SD_BLE_API_VERSION=7 ASMFLAGS += -DS140 ASMFLAGS += -DSOFTDEVICE_PRESENT @@ -257,10 +271,10 @@ LDFLAGS += -Wl,--gc-sections # use newlib in nano version LDFLAGS += --specs=nano.specs -nrf52840_xxaa: CFLAGS += -D__HEAP_SIZE=8192 -nrf52840_xxaa: CFLAGS += -D__STACK_SIZE=8192 -nrf52840_xxaa: ASMFLAGS += -D__HEAP_SIZE=8192 -nrf52840_xxaa: ASMFLAGS += -D__STACK_SIZE=8192 +$(TARGETS): CFLAGS += -D__HEAP_SIZE=$(HEAP_SIZE) +$(TARGETS): CFLAGS += -D__STACK_SIZE=$(STACK_SIZE) +$(TARGETS): ASMFLAGS += -D__HEAP_SIZE=$(HEAP_SIZE) +$(TARGETS): ASMFLAGS += -D__STACK_SIZE=$(STACK_SIZE) # Add standard libraries at the very end of the linker input, after all objects # that may need symbols provided by these libraries. @@ -270,12 +284,12 @@ LIB_FILES += -lc -lnosys -lm .PHONY: default help # Default target - first one defined -default: nrf52840_xxaa +default: $(TARGETS) # Print all targets that can be built help: @echo following targets are available: - @echo nrf52840_xxaa + @echo $(TARGETS) @echo flash_softdevice @echo sdk_config - starting external tool for editing sdk_config.h @echo flash - flashing binary @@ -291,8 +305,8 @@ $(foreach target, $(TARGETS), $(call define_target, $(target))) # Flash the program flash: default - @echo Flashing: $(OUTPUT_DIRECTORY)/nrf52840_xxaa.hex - nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/nrf52840_xxaa.hex --sectorerase + @echo Flashing: $(OUTPUT_DIRECTORY)/$(TARGETS).hex + nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/$(TARGETS).hex --sectorerase nrfjprog -f nrf52 --reset # Flash softdevice @@ -319,4 +333,4 @@ lint: .PHONY: fix lint-fix: - find src -iname *.h -o -iname *.c | xargs clang-format -i \ No newline at end of file + find src -iname *.h -o -iname *.c | xargs clang-format -i diff --git a/code/b-parasite/b_parasite_gcc_nrf52833.ld b/code/b-parasite/b_parasite_gcc_nrf52833.ld new file mode 100644 index 0000000..9bd722d --- /dev/null +++ b/code/b-parasite/b_parasite_gcc_nrf52833.ld @@ -0,0 +1,130 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0x59000 + RAM (rwx) : ORIGIN = 0x20002300, LENGTH = 0x1dd00 +} + +SECTIONS +{ +} + +SECTIONS +{ + . = ALIGN(4); + .mem_section_dummy_ram : + { + } + .cli_sorted_cmd_ptrs : + { + PROVIDE(__start_cli_sorted_cmd_ptrs = .); + KEEP(*(.cli_sorted_cmd_ptrs)) + PROVIDE(__stop_cli_sorted_cmd_ptrs = .); + } > RAM + .fs_data : + { + PROVIDE(__start_fs_data = .); + KEEP(*(.fs_data)) + PROVIDE(__stop_fs_data = .); + } > RAM + .log_dynamic_data : + { + PROVIDE(__start_log_dynamic_data = .); + KEEP(*(SORT(.log_dynamic_data*))) + PROVIDE(__stop_log_dynamic_data = .); + } > RAM + .log_filter_data : + { + PROVIDE(__start_log_filter_data = .); + KEEP(*(SORT(.log_filter_data*))) + PROVIDE(__stop_log_filter_data = .); + } > RAM + +} INSERT AFTER .data; + +SECTIONS +{ + .mem_section_dummy_rom : + { + } + .sdh_ble_observers : + { + PROVIDE(__start_sdh_ble_observers = .); + KEEP(*(SORT(.sdh_ble_observers*))) + PROVIDE(__stop_sdh_ble_observers = .); + } > FLASH + .sdh_soc_observers : + { + PROVIDE(__start_sdh_soc_observers = .); + KEEP(*(SORT(.sdh_soc_observers*))) + PROVIDE(__stop_sdh_soc_observers = .); + } > FLASH + .sdh_req_observers : + { + PROVIDE(__start_sdh_req_observers = .); + KEEP(*(SORT(.sdh_req_observers*))) + PROVIDE(__stop_sdh_req_observers = .); + } > FLASH + .sdh_state_observers : + { + PROVIDE(__start_sdh_state_observers = .); + KEEP(*(SORT(.sdh_state_observers*))) + PROVIDE(__stop_sdh_state_observers = .); + } > FLASH + .sdh_stack_observers : + { + PROVIDE(__start_sdh_stack_observers = .); + KEEP(*(SORT(.sdh_stack_observers*))) + PROVIDE(__stop_sdh_stack_observers = .); + } > FLASH + .nrf_queue : + { + PROVIDE(__start_nrf_queue = .); + KEEP(*(.nrf_queue)) + PROVIDE(__stop_nrf_queue = .); + } > FLASH + .nrf_balloc : + { + PROVIDE(__start_nrf_balloc = .); + KEEP(*(.nrf_balloc)) + PROVIDE(__stop_nrf_balloc = .); + } > FLASH + .cli_command : + { + PROVIDE(__start_cli_command = .); + KEEP(*(.cli_command)) + PROVIDE(__stop_cli_command = .); + } > FLASH + .crypto_data : + { + PROVIDE(__start_crypto_data = .); + KEEP(*(SORT(.crypto_data*))) + PROVIDE(__stop_crypto_data = .); + } > FLASH + .pwr_mgmt_data : + { + PROVIDE(__start_pwr_mgmt_data = .); + KEEP(*(SORT(.pwr_mgmt_data*))) + PROVIDE(__stop_pwr_mgmt_data = .); + } > FLASH + .log_const_data : + { + PROVIDE(__start_log_const_data = .); + KEEP(*(SORT(.log_const_data*))) + PROVIDE(__stop_log_const_data = .); + } > FLASH + .log_backends : + { + PROVIDE(__start_log_backends = .); + KEEP(*(SORT(.log_backends*))) + PROVIDE(__stop_log_backends = .); + } > FLASH + +} INSERT AFTER .text + + +INCLUDE "nrf_common.ld" diff --git a/code/b-parasite/b_parasite_gcc_nrf52.ld b/code/b-parasite/b_parasite_gcc_nrf52840.ld similarity index 100% rename from code/b-parasite/b_parasite_gcc_nrf52.ld rename to code/b-parasite/b_parasite_gcc_nrf52840.ld