Merge pull request #13 from jhbruhn/feature/nrf52833

Support for E73-2G4M08S1E (nrf52833) module
This commit is contained in:
rbaron 2021-09-02 21:02:57 +02:00 committed by GitHub
commit 5c71363258
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 190 additions and 25 deletions

View file

@ -1,17 +1,41 @@
# Supported platforms:
# * E73_2G4M08S1C (nrf2480, default)
# * E73_2G4M08S1E (nrf2833)
# note: the missing whitespace after the = is on purpose here
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 +63,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 +73,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 +111,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 +128,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 \
@ -211,20 +230,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 +256,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 +272,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 +285,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 +306,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 +334,4 @@ lint:
.PHONY: fix
lint-fix:
find src -iname *.h -o -iname *.c | xargs clang-format -i
find src -iname *.h -o -iname *.c | xargs clang-format -i

View file

@ -39,3 +39,23 @@ Sensor data is encoded in unsigned 16 bits (2 bytes), and whenever multiple
| 6-7 | Relative air humidity, scaled from 0 (0%) to 0xffff (100%) |
| 8-9 | Soil moisture, scaled from from 0 (0%) to 0xffff (100%) |
| 10-15 | b-parasite's own MAC address, big-endian format |
# Supported Modules
This code supports two E73 modules:
* E73-2G4M08S1C (nrf2480, default)
* E73-2G4M08S1E (nrf2833)
To choose for which one you want to compile, just pass PLATFORM as an env variable to make, and set it to the platform you want to use. For example, to compile for E73-2G4M08S1E:
```bash
SDK_ROOT=<...> PLATFORM=E73_2G4M08S1E make
```
and vice-versa for E73-2G4M08S1C, although that platform will be chosen as default anyways:
```bash
SDK_ROOT=<...> PLATFORM=E73_2G4M08S1C make
```

View file

@ -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"