Skip to content

S340 for nrf52840 feather #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 46 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
9b3cace
Adding support for s340 SD
orrmany Jan 23, 2020
309712b
fix prepoc. definition
orrmany Apr 30, 2020
8f537a6
Honoring @cujomalainey's request, flipping preproc. conditional, see:…
orrmany Apr 30, 2020
0851dd4
.
orrmany Dec 4, 2020
8a9b169
.
orrmany Dec 4, 2020
f1cf86b
ignoring build dir
orrmany Apr 10, 2022
ef9f181
update action script in build ci, use toolchain cache
hathach May 17, 2022
5e6e04a
more ci update
hathach May 17, 2022
daabc3d
clean up
hathach May 17, 2022
150a8a5
Merge pull request #266 from adafruit/fix-ci
hathach May 17, 2022
503609f
Added Challenger 840 BLE board
PontusO Jun 23, 2022
cf96394
Updated README
PontusO Jun 23, 2022
f390e75
Added Challenger 840 BLE to CI
PontusO Jun 24, 2022
4e839b1
Removed extroneous blank lines
PontusO Jun 26, 2022
dc41079
Renamed board init function.
PontusO Jun 27, 2022
787de9b
Updated missed reference.
PontusO Jun 27, 2022
e75aa4f
Merge pull request #267 from PontusO/master
hathach Jun 27, 2022
9e396b0
carlosperate/arm-none-eabi-gcc-action with 10-2020-q4 (same as curren…
hathach Jun 27, 2022
597dc6f
Merge pull request #268 from adafruit/action-gcc
hathach Jun 27, 2022
6c0bb9d
clean up makefile
hathach Jul 12, 2022
0811a47
fix -Wcast-function-type warnings
hathach Jul 12, 2022
dbeaafa
added feather 833
hathach Jul 12, 2022
cda1798
clean up
hathach Jul 13, 2022
c9a548f
more clean up
hathach Jul 13, 2022
90c856e
fix build with 832
hathach Jul 13, 2022
f4b503e
Merge pull request #270 from adafruit/feather-833
hathach Jul 13, 2022
b60ef5c
use s140 7.3.0 for feather 833
hathach Jul 13, 2022
b36925d
correct DFU_DEV_REV for 833 to 52833 (previously 52840)
hathach Jul 13, 2022
6f86906
Merge pull request #271 from adafruit/more-833
hathach Jul 13, 2022
c42dce0
add debug linker when building with DEBUG=1
hathach Jul 14, 2022
5217eb6
fix error: array subscript 0 is outside array bounds for newer gcc ve…
gibbz00 Aug 29, 2022
de32e8c
Merge pull request #273 from whiz00/build-fix
hathach Sep 8, 2022
3af7f74
add temp flash-skip-crc target
hathach Oct 16, 2022
7229caf
Merge branch 'master' into add-debug-build
hathach Oct 16, 2022
0cb582d
Merge pull request #280 from adafruit/add-debug-build
hathach Oct 16, 2022
d2977b1
update readme doc
hathach Oct 16, 2022
b55f516
Merge pull request #281 from adafruit/update-doc
hathach Oct 16, 2022
4f908f3
Initial commit of reformatted pillbug defines
kylemccreery Nov 10, 2022
da70d4a
Merge pull request #284 from kylemccreery/pillbug
hathach Nov 18, 2022
e052885
Ignoring s340 copyrighted files
orrmany Nov 29, 2022
1e1db14
Adding support for s340 SD
orrmany Jan 23, 2020
00f2d86
Updated submodules
orrmany Nov 29, 2022
9eab5dd
Merge branch 's340-for-nrf52840-Feather' of https://github.com/orrman…
orrmany Nov 29, 2022
5dc6685
Revert "Updated submodules"
orrmany Nov 29, 2022
babf82c
Trying to fix submodules barnches
orrmany Nov 29, 2022
18ed5c9
Revert "Trying to fix submodules barnches"
orrmany Nov 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions .github/workflows/githubci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- 'circuitplayground_nrf52840'
- 'clue_nrf52840'
- 'feather_nrf52832'
- 'feather_nrf52833_express'
- 'feather_nrf52840_express'
- 'feather_nrf52840_sense'
- 'itsybitsy_nrf52840_express'
Expand All @@ -34,6 +35,7 @@ jobs:
- 'bast_ble'
- 'bluemicro_nrf52833'
- 'bluemicro_nrf52840'
- 'challenger_840_ble'
- 'ebyte_e104_bt5032a'
- 'ebyte_e73_tbb'
- 'electronut_labs_papyr'
Expand All @@ -59,41 +61,40 @@ jobs:

steps:
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v3

- name: Setup Node.js
uses: actions/setup-node@v1

- name: Checkout Code
uses: actions/checkout@v1
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true

- name: Checkout linkermap
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: hathach/linkermap
path: linkermap

- name: Install Toolchains

- name: Install ARM GCC
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: '10-2020-q4'

- name: Install Tools
run: |
pip3 install adafruit-nrfutil uritemplate requests intelhex
pip3 install linkermap/
npm install --global xpm
# 9.3.1-1.2.1 is xpack modified version which significantly increased compiled size to 6-7KB and cause flash overflow.
# Skip this version for now, we will try again with next official release from ARM
xpm install --global @xpack-dev-tools/[email protected]
echo `echo $HOME/.local/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin` >> $GITHUB_PATH


- name: Build
run: |
arm-none-eabi-gcc --version
make BOARD=${{ matrix.board }} all
make BOARD=${{ matrix.board }} copy-artifact

- name: Linker Map
run: make BOARD=${{ matrix.board }} linkermap
- uses: actions/upload-artifact@v2

- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.board }}
path: _bin/${{ matrix.board }}
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,10 @@ TAGS

.DS_Store
Makefile.user

# Ignore S340 SoftDevice due to license restrictions
bootloader/feather_nrf52840_express/feather_nrf52840_express_bootloader-*_s340_6.1.1.*
cores/nRF5/nordic/softdevice/s340_nrf52_6.1.1_API/*
_build-feather_nrf52840_express/*
_build/*
lib/softdevice/s340_nrf52_6.1.1/*
156 changes: 99 additions & 57 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# - SD_HEX : to bootloader hex binary
#------------------------------------------------------------------------------

# local customization
-include Makefile.user

SDK_PATH = lib/sdk/components
Expand All @@ -15,8 +16,9 @@ TUSB_PATH = lib/tinyusb/src
NRFX_PATH = lib/nrfx
SD_PATH = lib/softdevice/$(SD_FILENAME)

# SD_VERSION can be overwritten by board.mk
ifndef SD_VERSION
SD_VERSION = 6.1.1
SD_VERSION = 6.1.1
endif

SD_FILENAME = $(SD_NAME)_nrf52_$(SD_VERSION)
Expand All @@ -25,10 +27,14 @@ SD_HEX = $(SD_PATH)/$(SD_FILENAME)_softdevice.hex
MBR_HEX = lib/softdevice/mbr/hex/mbr_nrf52_2.4.1_mbr.hex

# linker by MCU eg. nrf52840.ld
LD_FILE = linker/$(MCU_SUB_VARIANT).ld
ifeq ($(DEBUG), 1)
LD_FILE = linker/$(MCU_SUB_VARIANT)_debug.ld
else
LD_FILE = linker/$(MCU_SUB_VARIANT).ld
endif

GIT_VERSION := $(shell git describe --dirty --always --tags)
GIT_SUBMODULE_VERSIONS := $(shell git submodule status | cut -d" " -f3,4 | paste -s -d" " -)
GIT_VERSION = $(shell git describe --dirty --always --tags)
GIT_SUBMODULE_VERSIONS = $(shell git submodule status | cut -d" " -f3,4 | paste -s -d" " -)

# compiled file name
OUT_NAME = $(BOARD)_bootloader-$(GIT_VERSION)
Expand All @@ -37,7 +43,7 @@ OUT_NAME = $(BOARD)_bootloader-$(GIT_VERSION)
MERGED_FILE = $(OUT_NAME)_$(SD_NAME)_$(SD_VERSION)

#------------------------------------------------------------------------------
# Tool configure
# Tool Configure
#------------------------------------------------------------------------------

# Toolchain commands
Expand Down Expand Up @@ -107,20 +113,26 @@ ifeq ($(MCU_SUB_VARIANT),nrf52)
SD_NAME = s132
DFU_DEV_REV = 0xADAF
CFLAGS += -DNRF52 -DNRF52832_XXAA -DS132
CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
DFU_APP_DATA_RESERVED=7*4096
else ifeq ($(MCU_SUB_VARIANT),nrf52833)
SD_NAME = s140
DFU_DEV_REV = 52840
DFU_DEV_REV = 52833
CFLAGS += -DNRF52833_XXAA -DS140
CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
DFU_APP_DATA_RESERVED=7*4096
else ifeq ($(MCU_SUB_VARIANT),nrf52840)
SD_NAME = s140
DFU_DEV_REV = 52840
CFLAGS += -DNRF52840_XXAA -DS140
CFLAGS += -DDFU_APP_DATA_RESERVED=10*4096
DFU_APP_DATA_RESERVED=10*4096
else
$(error Sub Variant $(MCU_SUB_VARIANT) is unknown)
endif
ifdef USE_S340
#if S340 then adjust SD_NAME, undefine S140 and define S340
SD_NAME = s340
MCU_FLAGS = -DNRF52840_XXAA -DS340
# CFLAGS+ = -US140 -DS340
endif

#------------------------------------------------------------------------------
# SOURCE FILES
Expand Down Expand Up @@ -208,39 +220,46 @@ ASM_SRC = $(NRFX_PATH)/mdk/gcc_startup_$(MCU_SUB_VARIANT).S
#------------------------------------------------------------------------------

# src
IPATH += src
IPATH += src/boards
IPATH += src/boards/$(BOARD)
IPATH += src/cmsis/include
IPATH += src/usb
IPATH += $(TUSB_PATH)
IPATH += \
src \
src/boards \
src/boards/$(BOARD) \
src/cmsis/include \
src/usb \
$(TUSB_PATH)

# nrfx
IPATH += $(NRFX_PATH)
IPATH += $(NRFX_PATH)/mdk
IPATH += $(NRFX_PATH)/hal
IPATH += $(NRFX_PATH)/drivers/include
IPATH += $(NRFX_PATH)/drivers/src

IPATH += $(SDK11_PATH)/libraries/bootloader_dfu/hci_transport
IPATH += $(SDK11_PATH)/libraries/bootloader_dfu
IPATH += $(SDK11_PATH)/drivers_nrf/pstorage
IPATH += $(SDK11_PATH)/ble/common
IPATH += $(SDK11_PATH)/ble/ble_services/ble_dfu
IPATH += $(SDK11_PATH)/ble/ble_services/ble_dis

IPATH += $(SDK_PATH)/libraries/timer
IPATH += $(SDK_PATH)/libraries/scheduler
IPATH += $(SDK_PATH)/libraries/crc16
IPATH += $(SDK_PATH)/libraries/util
IPATH += $(SDK_PATH)/libraries/hci/config
IPATH += $(SDK_PATH)/libraries/uart
IPATH += $(SDK_PATH)/libraries/hci
IPATH += $(SDK_PATH)/drivers_nrf/delay

# Softdevice
IPATH += $(SD_PATH)/$(SD_FILENAME)_API/include
IPATH += $(SD_PATH)/$(SD_FILENAME)_API/include/nrf52
IPATH += \
$(NRFX_PATH) \
$(NRFX_PATH)/mdk \
$(NRFX_PATH)/hal \
$(NRFX_PATH)/drivers/include \
$(NRFX_PATH)/drivers/src

# sdk11 for cdc/ble dfu
IPATH += \
$(SDK11_PATH)/libraries/bootloader_dfu/hci_transport \
$(SDK11_PATH)/libraries/bootloader_dfu \
$(SDK11_PATH)/drivers_nrf/pstorage \
$(SDK11_PATH)/ble/common \
$(SDK11_PATH)/ble/ble_services/ble_dfu \
$(SDK11_PATH)/ble/ble_services/ble_dis

# later sdk with updated drivers
IPATH += \
$(SDK_PATH)/libraries/timer \
$(SDK_PATH)/libraries/scheduler \
$(SDK_PATH)/libraries/crc16 \
$(SDK_PATH)/libraries/util \
$(SDK_PATH)/libraries/hci/config \
$(SDK_PATH)/libraries/uart \
$(SDK_PATH)/libraries/hci \
$(SDK_PATH)/drivers_nrf/delay

# SoftDevice
IPATH += \
$(SD_PATH)/$(SD_FILENAME)_API/include \
$(SD_PATH)/$(SD_FILENAME)_API/include/nrf52

#------------------------------------------------------------------------------
# Compiler Flags
Expand All @@ -253,6 +272,7 @@ CFLAGS += \
-mcpu=cortex-m4 \
-mfloat-abi=hard \
-mfpu=fpv4-sp-d16 \
-ggdb \
-Os \
-ffunction-sections \
-fdata-sections \
Expand All @@ -272,15 +292,11 @@ CFLAGS += \
-Wsign-compare \
-Wmissing-format-attribute \
-Wno-endif-labels \
-Wunreachable-code \
-ggdb
-Wunreachable-code

# Suppress warning caused by SDK
CFLAGS += -Wno-unused-parameter -Wno-expansion-to-defined

# TinyUSB tusb_hal_nrf_power_event
CFLAGS += -Wno-cast-function-type

# Nordic Softdevice SDK header files contains inline assembler that has
# broken constraints. As a result the IPA-modref pass, introduced in gcc-11,
# is able to "prove" that arguments to wrapper functions generated with
Expand Down Expand Up @@ -315,6 +331,21 @@ ifeq ($(DEBUG), 1)
RTT_SRC = lib/SEGGER_RTT
IPATH += $(RTT_SRC)/RTT
C_SRC += $(RTT_SRC)/RTT/SEGGER_RTT.c
DFU_APP_DATA_RESERVED = 0

# expand bootloader address to 28KB of reserved app
ifeq ($(MCU_SUB_VARIANT),nrf52840)
CFLAGS += -DBOOTLOADER_REGION_START=0xED000
else
CFLAGS += -DBOOTLOADER_REGION_START=0x6D000
endif
endif

CFLAGS += -DDFU_APP_DATA_RESERVED=$(DFU_APP_DATA_RESERVED)

# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
ifneq ($(findstring 12.,$(shell $(CC) --version 2>/dev/null)),)
CFLAGS += --param=min-pagesize=0
endif

#------------------------------------------------------------------------------
Expand All @@ -332,6 +363,7 @@ LIBS += -lm -lc
#------------------------------------------------------------------------------
# Assembler flags
#------------------------------------------------------------------------------

ASFLAGS += $(CFLAGS)

#function for removing duplicates in a list
Expand All @@ -356,7 +388,7 @@ INC_PATHS = $(addprefix -I,$(IPATH))
# BUILD TARGETS
#------------------------------------------------------------------------------

.PHONY: all clean flash dfu-flash sd gdbflash gdb
.PHONY: all clean flash flash-dfu flash-sd flash-mbr dfu-flash sd mbr gdbflash gdb

# default target to build
all: $(BUILD)/$(OUT_NAME).out $(BUILD)/$(OUT_NAME)_nosd.hex $(BUILD)/update-$(OUT_NAME)_nosd.uf2 $(BUILD)/$(MERGED_FILE).hex $(BUILD)/$(MERGED_FILE).zip
Expand Down Expand Up @@ -431,7 +463,9 @@ copy-artifact: $(BIN)
@$(CP) $(BUILD)/$(MERGED_FILE).hex $(BIN)
@$(CP) $(BUILD)/$(MERGED_FILE).zip $(BIN)

#------------------- Flash target -------------------
#--------------------------------------
# Flash Target
#--------------------------------------

check_defined = \
$(strip $(foreach 1,$1, \
Expand All @@ -440,31 +474,39 @@ __check_defined = \
$(if $(value $1),, \
$(error Undefined make flag: $1$(if $2, ($2))))

# erase chip
erase:
@echo Erasing flash
$(call FLASH_ERASE_CMD)

# Flash the compiled
flash: $(BUILD)/$(OUT_NAME)_nosd.hex
@echo Flashing: $(notdir $<)
$(call FLASH_CMD,$<)

erase:
@echo Erasing flash
$(call FLASH_ERASE_CMD)

# flash SD only
sd:
sd: flash-sd
flash-sd:
@echo Flashing: $(SD_HEX)
$(call FLASH_NOUICR_CMD,$(SD_HEX))

# flash MBR only
mbr:
mbr: flash-mbr
flash-mbr:
@echo Flashing: $(MBR_HEX)
$(call FLASH_NOUICR_CMD,$(MBR_HEX))

#------------------- Flash with NRFUTIL via DFU -------------------

# dfu using CDC interface
dfu-flash: $(BUILD)/$(MERGED_FILE).zip
# dfu with adafruit-nrfutil using CDC interface
dfu-flash: flash-dfu
flash-dfu: $(BUILD)/$(MERGED_FILE).zip
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
$(NRFUTIL) --verbose dfu serial --package $< -p $(SERIAL) -b 115200 --singlebank --touch 1200

# flash skip crc magic ( app valid = 0x0001, crc = 0x0000 )
#flash-skip-crc:
# nrfjprog --memwr $(BOOT_SETTING_ADDR) --val 0x00000001 -f nrf52
# nrfjprog --memwr 0xFF000 --val 0x00000001 -f nrf52
# nrfjprog --memwr 0x7F000 --val 0x00000001 -f nrf52

#------------------- Debugging -------------------

Expand Down
Loading