Skip to content

Commit

Permalink
Merge pull request #270 from adafruit/feather-833
Browse files Browse the repository at this point in the history
Add Feather nRF52833
  • Loading branch information
hathach authored Jul 13, 2022
2 parents 597dc6f + 90c856e commit f4b503e
Show file tree
Hide file tree
Showing 14 changed files with 260 additions and 259 deletions.
1 change: 1 addition & 0 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 Down
111 changes: 61 additions & 50 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 @@ -37,7 +39,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 @@ -208,39 +210,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 +262,7 @@ CFLAGS += \
-mcpu=cortex-m4 \
-mfloat-abi=hard \
-mfpu=fpv4-sp-d16 \
-ggdb \
-Os \
-ffunction-sections \
-fdata-sections \
Expand All @@ -272,15 +282,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 @@ -332,6 +338,7 @@ LIBS += -lm -lc
#------------------------------------------------------------------------------
# Assembler flags
#------------------------------------------------------------------------------

ASFLAGS += $(CFLAGS)

#function for removing duplicates in a list
Expand All @@ -356,7 +363,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 +438,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,29 +449,31 @@ __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

Expand Down
52 changes: 28 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,57 +121,62 @@ both bootloader and the Nordic SoftDevice, you can freely upgrade/downgrade to a
You should only continue if you are looking to develop bootloader for your own.
You must have have a J-Link available to "unbrick" your device.
Prerequisites
### Prerequisites
- ARM GCC
To install for macos
```bash
brew tap ArmMbed/homebrew-formulae
brew install arm-none-eabi-gcc
brew link --overwrite arm-none-eabi-gcc # if a prior version was present
```

- Nordic's [nRF5x Command Line Tools](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools)
- [Python IntelHex](https://pypi.org/project/IntelHex/)
To build:
### Build:
```
make BOARD=feather_nrf52840_express all
```
To flash the bootloader with JLink:
For the list of supported boards, run `make` without `BOARD=` :
```
$ make
You must provide a BOARD parameter with 'BOARD='
Supported boards are: feather_nrf52840_express feather_nrf52840_express pca10056
Makefile:90: *** BOARD not defined. Stop
```
### Flash
To flash the bootloader (without softdevice/mbr) using JLink:
```
make BOARD=feather_nrf52840_express flash
```
If you are using pyocd as debugger, add `FLASHER=pyocd` to make command:
```
make BOARD=feather_nrf52840_express FLASHER=pyocd flash
```
To upgrade the bootloader using DFU Serial via port /dev/ttyACM0
```
make BOARD=feather_nrf52840_express SERIAL=/dev/ttyACM0 dfu-flash
make BOARD=feather_nrf52840_express SERIAL=/dev/ttyACM0 flash-dfu
```
To flash SoftDevice (and chip erase):
To flash SoftDevice (will also erase chip):
```
make BOARD=feather_nrf52840_express sd
make BOARD=feather_nrf52840_express flash-sd
```
For the list of supported boards, run `make` without `BOARD=` :
To flash MBR only
```
$ make
You must provide a BOARD parameter with 'BOARD='
Supported boards are: feather_nrf52840_express feather_nrf52840_express pca10056
Makefile:90: *** BOARD not defined. Stop
make BOARD=feather_nrf52840_express flash-mbr
```
### Common makefile problems
#### 1. `arm-none-eabi-gcc`: No such file or directory
#### `arm-none-eabi-gcc`: No such file or directory
If you get the following error ...
Expand All @@ -190,16 +195,15 @@ $ make CROSS_COMPILE=/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi- B
For other compile errors, check the gcc version with `arm-none-eabi-gcc --version` to insure it is at least 9.x.
#### 2. `ModuleNotFoundError: No module named 'intelhex'`
#### `ModuleNotFoundError: No module named 'intelhex'`
Install python-intelhex with
```
pip install intelhex
```

#### 3. `make: nrfjprog: No such file or directory`
#### `make: nrfjprog: No such file or directory`
Make sure that `nrfjprog` is available from the command-line. This binary is
part of Nordic's nRF5x Command Line Tools.
9 changes: 8 additions & 1 deletion linker/nrf52833.ld
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ MEMORY
* those values do not match. The check is performed in main.c, see
* APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
*/
FLASH (rx) : ORIGIN = 0x74000, LENGTH = 0x7E000-0x74000 /* 40 KB */
FLASH (rx) : ORIGIN = 0x74000, LENGTH = 0x7E000-0x74000-2K /* 38 KB */

BOOTLOADER_CONFIG (r): ORIGIN = 0x7E000 - 2K, LENGTH = 2K

/** Location of mbr params page in flash. */
MBR_PARAMS_PAGE (rw) : ORIGIN = 0x0007E000, LENGTH = 0x1000
Expand Down Expand Up @@ -50,6 +52,11 @@ SECTIONS
PROVIDE( __stop_fs_data = .);
} = 0

.bootloaderConfig :
{
KEEP(*(.bootloaderConfig))
} > BOOTLOADER_CONFIG

/* Place the bootloader settings page in flash. */
.bootloaderSettings(NOLOAD) :
{
Expand Down
Loading

0 comments on commit f4b503e

Please sign in to comment.