mirror of
https://github.com/oltaco/Adafruit_nRF52_Bootloader_OTAFIX.git
synced 2026-10-24 10:43:28 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15e26618dc | ||
|
|
a1412543c8 | ||
|
|
01b032ee7d | ||
|
|
72160554dc | ||
|
|
eab7e687de | ||
|
|
b39cd8ff45 | ||
|
|
38ff498101 | ||
|
|
4199430fe6 | ||
|
|
6fc2145871 | ||
|
|
b960b99182 | ||
|
|
64ea299572 | ||
|
|
d19e26fc9b | ||
|
|
7963ebcad9 | ||
|
|
d7af151e72 | ||
|
|
771cabbf94 | ||
|
|
705990bce8 | ||
|
|
0443811140 | ||
|
|
d37a3ae640 | ||
|
|
f5a48c3356 | ||
|
|
88bc14bb4e | ||
|
|
18b6b44b1e | ||
|
|
035e5ba9ac | ||
|
|
e5e10260d7 | ||
|
|
7b86264376 | ||
|
|
3da8e987df | ||
|
|
093b0091b6 | ||
|
|
cf72b29e21 | ||
|
|
66097042bb | ||
|
|
35e8ad97ac | ||
|
|
73d5190081 | ||
|
|
8966b2077e | ||
|
|
e1339e9d45 | ||
|
|
27218de969 | ||
|
|
ef3341d43f | ||
|
|
5f39316cd9 | ||
|
|
11572aa83d | ||
|
|
33195c9db8 | ||
|
|
bf4e000e93 | ||
|
|
8b49f47cac | ||
|
|
9ad10c8b1b | ||
|
|
9ae36fe7e8 | ||
|
|
a5b78ff410 | ||
|
|
934d141b7e | ||
|
|
9d86c6b81e | ||
|
|
5b507ac126 | ||
|
|
bb3f0c8667 | ||
|
|
1fac639352 | ||
|
|
8ab7a41fab | ||
|
|
f22e19e81b | ||
|
|
43cfc4c0f0 | ||
|
|
86a6622724 | ||
|
|
307125255b | ||
|
|
75c89998c6 | ||
|
|
4263c8ff79 | ||
|
|
7d76c828ec | ||
|
|
791906ca32 | ||
|
|
2e5b45edfe | ||
|
|
6a092abb5e | ||
|
|
e843045f4d | ||
|
|
aa8cd83961 | ||
|
|
cb04d5338e | ||
|
|
1a138da50d | ||
|
|
dc90457828 | ||
|
|
b3a2afa5c5 | ||
|
|
0b3c515d9e | ||
|
|
73ec884012 | ||
|
|
0d13cb445c | ||
|
|
301e4ace3e | ||
|
|
764147d269 | ||
|
|
d790f4adc9 | ||
|
|
4c9df5bc41 | ||
|
|
35429d0f64 | ||
|
|
32a43b71e6 | ||
|
|
209c611a8b | ||
|
|
2118c82eaf | ||
|
|
8e52dd5e49 | ||
|
|
0b0677d0d7 | ||
|
|
2aad7be11b | ||
|
|
3512f27da5 | ||
|
|
10b470afad | ||
|
|
6642747a2d | ||
|
|
d7016237d2 | ||
|
|
6b4cf21ba2 | ||
|
|
7966e5e85c | ||
|
|
c7ec6baabe | ||
|
|
d6b28e6605 | ||
|
|
c6d9ca8082 | ||
|
|
4ba551827f | ||
|
|
6217eb9eeb | ||
|
|
28e09e0aba | ||
|
|
513cc7ab44 | ||
|
|
1b0816163b | ||
|
|
041defeb63 | ||
|
|
2c9826acd9 | ||
|
|
09697eb541 | ||
|
|
cc829aa405 | ||
|
|
614da97a4a | ||
|
|
00669e813e | ||
|
|
763c7df557 | ||
|
|
f157069595 | ||
|
|
947045239a | ||
|
|
da2aca70cc | ||
|
|
ff120ffadb | ||
|
|
2df81e6543 | ||
|
|
a4084e0f46 | ||
|
|
26e02484f3 | ||
|
|
148723984c | ||
|
|
62336dc766 | ||
|
|
316891dbd5 | ||
|
|
cf1ccfecad | ||
|
|
e6de13f679 | ||
|
|
7929dc3dae | ||
|
|
7c8e1e59e5 | ||
|
|
0e4995c680 | ||
|
|
29a62bc0ed | ||
|
|
d50796ff4c | ||
|
|
c41dd59b5f | ||
|
|
f841a4593d | ||
|
|
013458ad97 | ||
|
|
d594cbc1a4 | ||
|
|
27882cdce6 | ||
|
|
afeb645a87 | ||
|
|
46adc425a4 | ||
|
|
08c0f27f45 | ||
|
|
5ed4d509f5 | ||
|
|
cf4efa2c94 | ||
|
|
4bbdeab8d1 | ||
|
|
348f268113 | ||
|
|
72902e6931 | ||
|
|
6adf9810a6 | ||
|
|
609473760a | ||
|
|
54a0ad7070 | ||
|
|
447207b875 | ||
|
|
570bd5b664 | ||
|
|
99d31d2c82 | ||
|
|
dad8e10f6c | ||
|
|
f12c837479 | ||
|
|
bce102e34a | ||
|
|
d95684ce8b | ||
|
|
74c650851e | ||
|
|
af105128f3 | ||
|
|
ed7c5ac2f3 | ||
|
|
0b84f428d2 | ||
|
|
725c82c7e8 | ||
|
|
9f80139ee8 | ||
|
|
3426778a27 | ||
|
|
6ac95d3798 | ||
|
|
1dbe7c3b80 | ||
|
|
3ca3b92e2a | ||
|
|
1c1104e989 | ||
|
|
3bf0635676 | ||
|
|
630a271372 | ||
|
|
d142418b0f | ||
|
|
632e4611bf | ||
|
|
3ee1955e1b | ||
|
|
fe1a7ea4f2 | ||
|
|
795fd2ee17 | ||
|
|
b062026606 | ||
|
|
56c6378c39 | ||
|
|
2b5dd6c614 | ||
|
|
1c48833336 | ||
|
|
9a7eeeb499 | ||
|
|
e92937e9d5 | ||
|
|
8e85c9aa8a | ||
|
|
c467875ca3 | ||
|
|
79a6a0c4f7 | ||
|
|
392f69a2c3 | ||
|
|
f097cae0cd | ||
|
|
1db3ffe968 | ||
|
|
9ea3f08e23 | ||
|
|
2128d60cc9 | ||
|
|
6b3f70db47 | ||
|
|
09fdd7dee2 | ||
|
|
7438933f2f | ||
|
|
c0f75b21b0 | ||
|
|
98271c9f56 | ||
|
|
b91a76a16e | ||
|
|
b2d4b016a9 | ||
|
|
01ac2b3d46 | ||
|
|
79ae930f15 | ||
|
|
0516c2e247 | ||
|
|
487871db8e | ||
|
|
54ddaa142d | ||
|
|
e37c884463 | ||
|
|
5c5b9945bc | ||
|
|
f99645ede8 | ||
|
|
42734a1ab5 | ||
|
|
86809ca043 | ||
|
|
54f4fdab58 | ||
|
|
cb735eaf8b | ||
|
|
bfa269c55f | ||
|
|
74d5dac7a8 | ||
|
|
fb8c743d3b | ||
|
|
be87aac09d |
No files matched your search
@@ -1,20 +1,58 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
push:
|
||||
repository_dispatch:
|
||||
release:
|
||||
types: [published]
|
||||
types:
|
||||
- created
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
board:
|
||||
# Adafruit Boards
|
||||
- 'circuitplayground_nrf52840'
|
||||
- 'clue_nrf52840'
|
||||
- 'feather_nrf52832'
|
||||
- 'feather_nrf52840_express'
|
||||
- 'feather_nrf52840_sense'
|
||||
- 'itsybitsy_nrf52840_express'
|
||||
- 'metro_nrf52840_express'
|
||||
# Alphabetical order
|
||||
- 'ADM_B_NRF52840_1'
|
||||
- 'ae_bl652_bo'
|
||||
- 'aramcon_badge_2019'
|
||||
- 'arcade_feather_nrf52840_express'
|
||||
- 'arduino_nano_33_ble'
|
||||
- 'bast_ble'
|
||||
- 'bluemicro_nrf52840'
|
||||
- 'electronut_labs_papyr'
|
||||
- 'ikigaisense_vita'
|
||||
- 'mdk_nrf52840_dongle'
|
||||
- 'nice_nano'
|
||||
- 'nrf52840_m2'
|
||||
- 'ohs2020_badge'
|
||||
- 'particle_argon'
|
||||
- 'particle_boron'
|
||||
- 'particle_xenon'
|
||||
- 'pca10056'
|
||||
- 'pca10059'
|
||||
- 'pca10100'
|
||||
- 'pitaya_go'
|
||||
- 'raytac_mdbt50q_rx'
|
||||
- 'waveshare_nrf52840_eval'
|
||||
|
||||
steps:
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v1
|
||||
uses: actions/setup-python@v2
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v1.1.0
|
||||
uses: actions/setup-node@v1
|
||||
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v1
|
||||
@@ -23,22 +61,36 @@ jobs:
|
||||
|
||||
- name: Install Toolchains
|
||||
run: |
|
||||
pip3 install adafruit-nrfutil uritemplate requests
|
||||
wget https://www.nordicsemi.com/api/sitecore/Products/DownloadPlatform --post-data=fileid=8F19D314130548209E75EFFADD9348DB -O cli-tools.tar
|
||||
tar -xv -f cli-tools.tar
|
||||
echo "::add-path::$GITHUB_WORKSPACE/mergehex"
|
||||
pip3 install adafruit-nrfutil uritemplate requests intelhex
|
||||
npm install --global xpm
|
||||
xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest
|
||||
echo "::add-path::`echo $HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin`"
|
||||
# 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/arm-none-eabi-gcc@9.3.1-1.1.1
|
||||
echo `echo $HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin` >> $GITHUB_PATH
|
||||
|
||||
- name: Build
|
||||
run: python3 tools/build_all.py
|
||||
run: |
|
||||
make BOARD=${{ matrix.board }} all
|
||||
make BOARD=${{ matrix.board }} copy-artifact
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ matrix.board }}
|
||||
path: _bin/${{ matrix.board }}
|
||||
|
||||
- name: Creat Release Asset
|
||||
if: ${{ github.event_name == 'release' }}
|
||||
run: zip -jr ${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}.zip _bin/${{ matrix.board }}
|
||||
|
||||
- name: Upload Release Asset
|
||||
if: github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested')
|
||||
working-directory: tools
|
||||
id: upload-release-asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
UPLOAD_URL: ${{ github.event.release.upload_url }}
|
||||
ADABOT_GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: "[ -z \"$ADABOT_GITHUB_ACCESS_TOKEN\" ] || python3 -u upload_release_files.py"
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
if: ${{ github.event_name == 'release' }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_path: ${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}.zip
|
||||
asset_name: ${{ matrix.board }}_bootloader-${{ github.event.release.tag_name }}.zip
|
||||
asset_content_type: application/zip
|
||||
|
||||
+9
-2
@@ -36,6 +36,9 @@
|
||||
*.x86_64
|
||||
#*.hex
|
||||
|
||||
# VSCode files
|
||||
.vscode/
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
@@ -51,10 +54,14 @@ Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
src/segger/Output
|
||||
_build-*/
|
||||
segger/Output
|
||||
_build/
|
||||
bin/
|
||||
*.emSession
|
||||
*.jlink
|
||||
.idea/
|
||||
|
||||
TAGS
|
||||
|
||||
.DS_Store
|
||||
Makefile.user
|
||||
+5
-1
@@ -1,6 +1,10 @@
|
||||
[submodule "tinyusb"]
|
||||
[submodule "lib/tinyusb"]
|
||||
path = lib/tinyusb
|
||||
url = https://github.com/hathach/tinyusb.git
|
||||
[submodule "lib/nrfx"]
|
||||
path = lib/nrfx
|
||||
url = https://github.com/NordicSemiconductor/nrfx.git
|
||||
[submodule "lib/uf2"]
|
||||
path = lib/uf2
|
||||
url = https://github.com/microsoft/uf2.git
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
sudo: required
|
||||
dist: xenial
|
||||
language: c
|
||||
compiler:
|
||||
- gcc
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key: "$GITHUB_TOKEN"
|
||||
file_glob: true
|
||||
file: "$TRAVIS_BUILD_DIR/bin/*/*"
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
|
||||
before_script:
|
||||
- (wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2018q2-1~xenial1_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb)
|
||||
- (wget https://www.nordicsemi.com/api/sitecore/Products/DownloadPlatform --post-data=fileid=8F19D314130548209E75EFFADD9348DB -O cli-tools.tar && tar -xv -f cli-tools.tar && mv mergehex mergehex_all && mv mergehex_all/mergehex .)
|
||||
- export PATH=.:$PATH
|
||||
- mergehex --version
|
||||
|
||||
# report some good version numbers to the build
|
||||
- gcc --version
|
||||
- arm-none-eabi-gcc --version
|
||||
- python3 --version
|
||||
- python --version
|
||||
- sudo apt-get install -y python3-pip python3-setuptools
|
||||
- pip3 install --user adafruit-nrfutil
|
||||
|
||||
script:
|
||||
- python3 tools/build_all.py
|
||||
@@ -1,95 +1,100 @@
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
# CONFIGURE
|
||||
# - SDK_PATH : path to SDK directory
|
||||
# - SRC_PATH : path to src folder
|
||||
# - SDK_PATH : path to SDK directory
|
||||
#
|
||||
# - SD_NAME : e.g s132, s140
|
||||
# - SD_NAME : e.g s132, s140
|
||||
# - SD_VERSION : SoftDevice version e.g 6.0.0
|
||||
# - SD_HEX : to bootloader hex binary
|
||||
#******************************************************************************
|
||||
SRC_PATH = src
|
||||
# - SD_HEX : to bootloader hex binary
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
-include Makefile.user
|
||||
|
||||
SDK_PATH = lib/sdk/components
|
||||
SDK11_PATH = lib/sdk11/components
|
||||
SD_PATH = lib/softdevice/$(SD_FILENAME)
|
||||
|
||||
TUSB_PATH = lib/tinyusb/src
|
||||
NRFX_PATH = lib/nrfx
|
||||
SD_PATH = lib/softdevice/$(SD_FILENAME)
|
||||
|
||||
SD_VERSION = 6.1.1
|
||||
SD_FILENAME = $(SD_NAME)_nrf52_$(SD_VERSION)
|
||||
SD_API_PATH = $(SD_PATH)/$(SD_FILENAME)_API
|
||||
SD_HEX = $(SD_PATH)/$(SD_FILENAME)_softdevice.hex
|
||||
|
||||
LD_FILE = $(SRC_PATH)/linker/$(MCU_SUB_VARIANT)_$(SD_NAME)_v$(word 1, $(subst ., ,$(SD_VERSION))).ld
|
||||
MBR_HEX = lib/softdevice/mbr/hex/mbr_nrf52_2.4.1_mbr.hex
|
||||
|
||||
MERGED_FNAME = $(OUTPUT_FILENAME)_$(SD_NAME)_$(SD_VERSION)
|
||||
# linker by MCU eg. nrf52840.ld
|
||||
LD_FILE = linker/$(MCU_SUB_VARIANT).ld
|
||||
|
||||
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" " -)
|
||||
|
||||
OUTPUT_FILENAME = $(BOARD)_bootloader-$(GIT_VERSION)
|
||||
# compiled file name
|
||||
OUT_NAME = $(BOARD)_bootloader-$(GIT_VERSION)
|
||||
|
||||
#******************************************************************************
|
||||
# merged file = compiled + sd
|
||||
MERGED_FILE = $(OUT_NAME)_$(SD_NAME)_$(SD_VERSION)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Tool configure
|
||||
#******************************************************************************
|
||||
NRFUTIL = adafruit-nrfutil
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
ifneq ($(JLINK),)
|
||||
NRFJPROG = nrfjprog -s $(JLINK)
|
||||
# Toolchain commands
|
||||
# Should be added to your PATH
|
||||
CROSS_COMPILE ?= arm-none-eabi-
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
AS = $(CROSS_COMPILE)as
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
SIZE = $(CROSS_COMPILE)size
|
||||
GDB = $(CROSS_COMPILE)gdb
|
||||
|
||||
# Set make directory command, Windows tries to create a directory named "-p" if that flag is there.
|
||||
ifneq ($(OS), Windows_NT)
|
||||
MKDIR = mkdir -p
|
||||
else
|
||||
MKDIR = mkdir
|
||||
endif
|
||||
|
||||
RM = rm -rf
|
||||
CP = cp
|
||||
|
||||
# Flasher utility options
|
||||
NRFUTIL = adafruit-nrfutil
|
||||
NRFJPROG = nrfjprog
|
||||
FLASHER ?= nrfjprog
|
||||
PYOCD ?= pyocd
|
||||
|
||||
# Flasher will default to nrfjprog,
|
||||
# Check for pyocd, error on unexpected value.
|
||||
ifeq ($(FLASHER),nrfjprog)
|
||||
FLASH_CMD = $(NRFJPROG) --program $1 --sectoranduicrerase -f nrf52 --reset
|
||||
FLASH_NOUICR_CMD = $(NRFJPROG) --program $1 -f nrf52 --sectorerase --reset
|
||||
FLASH_ERASE_CMD = $(NRFJPROG) -f nrf52 --eraseall
|
||||
else ifeq ($(FLASHER),pyocd)
|
||||
FLASH_CMD = $(PYOCD) flash -t $(MCU_SUB_VARIANT) $1
|
||||
FLASH_NOUICR_CMD = $(PYOCD) flash -t $(MCU_SUB_VARIANT) $1
|
||||
FLASH_ERASE_CMD = $(PYOCD) erase -t $(MCU_SUB_VARIANT) --chip
|
||||
else
|
||||
$(error Unsupported flash utility: "$(FLASHER)")
|
||||
endif
|
||||
|
||||
# auto-detect BMP on macOS, otherwise have to specify
|
||||
BMP_PORT ?= $(shell ls -1 /dev/cu.usbmodem????????1 | head -1)
|
||||
GDB_BMP = $(GDB) -ex 'target extended-remote $(BMP_PORT)' -ex 'monitor swdp_scan' -ex 'attach 1'
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
PROGFILES = C:/Program Files (x86)
|
||||
GNU_INSTALL_ROOT = $(PROGFILES)/GNU Tools ARM Embedded/7 2018-q2-update/bin/
|
||||
endif
|
||||
|
||||
MK := mkdir
|
||||
RM := rm -rf
|
||||
|
||||
# Verbose mode (V=). 0: default, 1: print out CFLAG, LDFLAG 2: print all compile command
|
||||
ifeq ("$(V)","2")
|
||||
QUIET =
|
||||
else
|
||||
QUIET = @
|
||||
endif
|
||||
|
||||
GNU_PREFIX = arm-none-eabi
|
||||
|
||||
# Toolchain commands
|
||||
CC := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-gcc'
|
||||
AS := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-as'
|
||||
AR := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-ar' -r
|
||||
LD := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-ld'
|
||||
NM := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-nm'
|
||||
OBJDUMP := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-objdump'
|
||||
OBJCOPY := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-objcopy'
|
||||
SIZE := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-size'
|
||||
GDB := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-gdb'
|
||||
|
||||
GDB_BMP = arm-none-eabi-gdb -ex 'target extended-remote $(BMP_PORT)' -ex 'monitor swdp_scan' -ex 'attach 1'
|
||||
|
||||
#function for removing duplicates in a list
|
||||
remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1))))
|
||||
|
||||
#*********************************
|
||||
#---------------------------------
|
||||
# Select the board to build
|
||||
#*********************************
|
||||
BOARD_LIST = $(sort $(subst .h,,$(subst src/boards/,,$(wildcard src/boards/*))))
|
||||
#---------------------------------
|
||||
# Note: whitespace is not allowed in the filenames... it WILL break this part of the script
|
||||
BOARD_LIST = $(sort $(filter-out boards.h boards.c,$(notdir $(wildcard src/boards/*))))
|
||||
|
||||
ifeq ($(filter $(BOARD),$(BOARD_LIST)),)
|
||||
$(info You must provide a BOARD parameter with 'BOARD='. Supported boards are:)
|
||||
$(info $(BOARD_LIST))
|
||||
$(foreach b,$(BOARD_LIST),$(info - $(b)))
|
||||
$(error Invalid BOARD specified)
|
||||
endif
|
||||
|
||||
# Build directory
|
||||
BUILD = _build-$(BOARD)
|
||||
BUILD = _build/build-$(BOARD)
|
||||
BIN = _bin/$(BOARD)
|
||||
|
||||
# Board specific
|
||||
-include src/boards/$(BOARD)/board.mk
|
||||
@@ -98,107 +103,102 @@ BUILD = _build-$(BOARD)
|
||||
ifeq ($(MCU_SUB_VARIANT),nrf52)
|
||||
SD_NAME = s132
|
||||
DFU_DEV_REV = 0xADAF
|
||||
MCU_FLAGS = -DNRF52 -DNRF52832_XXAA -DS132
|
||||
CFLAGS += -DNRF52 -DNRF52832_XXAA -DS132
|
||||
else ifeq ($(MCU_SUB_VARIANT),nrf52833)
|
||||
SD_NAME = s140
|
||||
DFU_DEV_REV = 52840
|
||||
MCU_FLAGS = -DNRF52833_XXAA -DS140
|
||||
CFLAGS += -DNRF52833_XXAA -DS140
|
||||
else ifeq ($(MCU_SUB_VARIANT),nrf52840)
|
||||
SD_NAME = s140
|
||||
DFU_DEV_REV = 52840
|
||||
MCU_FLAGS = -DNRF52840_XXAA -DS140
|
||||
CFLAGS += -DNRF52840_XXAA -DS140
|
||||
else
|
||||
$(error Sub Variant $(MCU_SUB_VARIANT) is unknown)
|
||||
endif
|
||||
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
# SOURCE FILES
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# src
|
||||
C_SOURCE_FILES += $(SRC_PATH)/main.c
|
||||
C_SOURCE_FILES += $(SRC_PATH)/boards.c
|
||||
C_SOURCE_FILES += $(SRC_PATH)/flash_nrf5x.c
|
||||
C_SOURCE_FILES += $(SRC_PATH)/dfu_ble_svc.c
|
||||
C_SOURCE_FILES += $(SRC_PATH)/dfu_init.c
|
||||
# all files in src
|
||||
C_SRC += $(wildcard src/*.c)
|
||||
|
||||
# all files in boards
|
||||
C_SRC += $(wildcard src/boards/*.c)
|
||||
|
||||
# all sources files in specific board
|
||||
C_SOURCE_FILES += $(wildcard $(SRC_PATH)/boards/$(BOARD)/*.c)
|
||||
C_SRC += $(wildcard src/boards/$(BOARD)/*.c)
|
||||
|
||||
# nrfx
|
||||
C_SOURCE_FILES += $(NRFX_PATH)/drivers/src/nrfx_power.c
|
||||
C_SOURCE_FILES += $(NRFX_PATH)/drivers/src/nrfx_nvmc.c
|
||||
C_SOURCE_FILES += $(NRFX_PATH)/mdk/system_$(MCU_SUB_VARIANT).c
|
||||
C_SRC += $(NRFX_PATH)/drivers/src/nrfx_power.c
|
||||
C_SRC += $(NRFX_PATH)/drivers/src/nrfx_nvmc.c
|
||||
C_SRC += $(NRFX_PATH)/mdk/system_$(MCU_SUB_VARIANT).c
|
||||
|
||||
# SDK 11 files
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader.c
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader_settings.c
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader_util.c
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_transport_serial.c
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_transport_ble.c
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_single_bank.c
|
||||
# SDK 11 files: serial + OTA DFU
|
||||
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader.c
|
||||
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader_settings.c
|
||||
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader_util.c
|
||||
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_transport_serial.c
|
||||
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_transport_ble.c
|
||||
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_single_bank.c
|
||||
C_SRC += $(SDK11_PATH)/ble/ble_services/ble_dfu/ble_dfu.c
|
||||
C_SRC += $(SDK11_PATH)/ble/ble_services/ble_dis/ble_dis.c
|
||||
C_SRC += $(SDK11_PATH)/drivers_nrf/pstorage/pstorage_raw.c
|
||||
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/drivers_nrf/pstorage/pstorage_raw.c
|
||||
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/ble/ble_services/ble_dfu/ble_dfu.c
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/ble/ble_services/ble_dis/ble_dis.c
|
||||
|
||||
# Latest SDK files
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/timer/app_timer.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/scheduler/app_scheduler.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/util/app_error.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/util/app_util_platform.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/crc16/crc16.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/hci/hci_mem_pool.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/hci/hci_slip.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/hci/hci_transport.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/util/nrf_assert.c
|
||||
# Latest SDK files: peripheral drivers
|
||||
C_SRC += $(SDK_PATH)/libraries/timer/app_timer.c
|
||||
C_SRC += $(SDK_PATH)/libraries/scheduler/app_scheduler.c
|
||||
C_SRC += $(SDK_PATH)/libraries/util/app_error.c
|
||||
C_SRC += $(SDK_PATH)/libraries/util/app_util_platform.c
|
||||
C_SRC += $(SDK_PATH)/libraries/crc16/crc16.c
|
||||
C_SRC += $(SDK_PATH)/libraries/hci/hci_mem_pool.c
|
||||
C_SRC += $(SDK_PATH)/libraries/hci/hci_slip.c
|
||||
C_SRC += $(SDK_PATH)/libraries/hci/hci_transport.c
|
||||
C_SRC += $(SDK_PATH)/libraries/util/nrf_assert.c
|
||||
|
||||
# UART or USB Serial
|
||||
ifeq ($(MCU_SUB_VARIANT),nrf52)
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/uart/app_uart.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/uart/nrf_drv_uart.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/common/nrf_drv_common.c
|
||||
|
||||
C_SRC += $(SDK_PATH)/libraries/uart/app_uart.c
|
||||
C_SRC += $(SDK_PATH)/drivers_nrf/uart/nrf_drv_uart.c
|
||||
C_SRC += $(SDK_PATH)/drivers_nrf/common/nrf_drv_common.c
|
||||
|
||||
IPATH += $(SDK11_PATH)/libraries/util
|
||||
IPATH += $(SDK_PATH)/drivers_nrf/common
|
||||
IPATH += $(SDK_PATH)/drivers_nrf/uart
|
||||
|
||||
else
|
||||
# src
|
||||
C_SOURCE_FILES += $(SRC_PATH)/usb/usb_desc.c
|
||||
C_SOURCE_FILES += $(SRC_PATH)/usb/usb.c
|
||||
C_SOURCE_FILES += $(SRC_PATH)/usb/msc_uf2.c
|
||||
C_SOURCE_FILES += $(SRC_PATH)/usb/uf2/ghostfat.c
|
||||
|
||||
# USB Application ( MSC + UF2 )
|
||||
C_SRC += $(wildcard src/usb/*.c)
|
||||
C_SRC += $(wildcard src/usb/uf2/*.c)
|
||||
|
||||
# TinyUSB stack
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/portable/nordic/nrf5x/dcd_nrf5x.c
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/common/tusb_fifo.c
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/device/usbd.c
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/device/usbd_control.c
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/class/cdc/cdc_device.c
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/class/msc/msc_device.c
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/tusb.c
|
||||
C_SRC += $(TUSB_PATH)/portable/nordic/nrf5x/dcd_nrf5x.c
|
||||
C_SRC += $(TUSB_PATH)/common/tusb_fifo.c
|
||||
C_SRC += $(TUSB_PATH)/device/usbd.c
|
||||
C_SRC += $(TUSB_PATH)/device/usbd_control.c
|
||||
C_SRC += $(TUSB_PATH)/class/cdc/cdc_device.c
|
||||
C_SRC += $(TUSB_PATH)/class/msc/msc_device.c
|
||||
C_SRC += $(TUSB_PATH)/tusb.c
|
||||
|
||||
endif
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
# Assembly Files
|
||||
#******************************************************************************
|
||||
ASM_SOURCE_FILES = $(NRFX_PATH)/mdk/gcc_startup_$(MCU_SUB_VARIANT).S
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_SRC = $(NRFX_PATH)/mdk/gcc_startup_$(MCU_SUB_VARIANT).S
|
||||
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
# INCLUDE PATH
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# src
|
||||
IPATH += $(SRC_PATH)
|
||||
IPATH += $(SRC_PATH)/boards/$(BOARD)
|
||||
|
||||
IPATH += $(SRC_PATH)/cmsis/include
|
||||
IPATH += $(SRC_PATH)/usb
|
||||
IPATH += $(SRC_PATH)/boards
|
||||
IPATH += src
|
||||
IPATH += src/boards
|
||||
IPATH += src/boards/$(BOARD)
|
||||
IPATH += src/cmsis/include
|
||||
IPATH += src/usb
|
||||
IPATH += $(TUSB_PATH)
|
||||
|
||||
# nrfx
|
||||
@@ -225,79 +225,101 @@ IPATH += $(SDK_PATH)/libraries/hci
|
||||
IPATH += $(SDK_PATH)/drivers_nrf/delay
|
||||
|
||||
# Softdevice
|
||||
IPATH += $(SD_API_PATH)/include
|
||||
IPATH += $(SD_API_PATH)/include/nrf52
|
||||
IPATH += $(SD_PATH)/$(SD_FILENAME)_API/include
|
||||
IPATH += $(SD_PATH)/$(SD_FILENAME)_API/include/nrf52
|
||||
|
||||
INC_PATHS = $(addprefix -I,$(IPATH))
|
||||
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
# Compiler Flags
|
||||
# - Additional compiler flags
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Debug option use RTT for printf
|
||||
ifeq ($(DEBUG), 1)
|
||||
RTT_SRC = lib/SEGGER_RTT
|
||||
|
||||
CFLAGS += -DCFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
|
||||
IPATH += $(RTT_SRC)/RTT
|
||||
C_SRC += $(RTT_SRC)/RTT/SEGGER_RTT.c
|
||||
endif
|
||||
|
||||
#flags common to all targets
|
||||
CFLAGS += -mcpu=cortex-m4
|
||||
CFLAGS += -mthumb -mabi=aapcs --std=gnu99
|
||||
CFLAGS += -Wall -Werror -Os -g3
|
||||
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||
CFLAGS += \
|
||||
-mthumb \
|
||||
-mabi=aapcs \
|
||||
-mcpu=cortex-m4 \
|
||||
-mfloat-abi=hard \
|
||||
-mfpu=fpv4-sp-d16 \
|
||||
-Os \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
-fno-builtin \
|
||||
-fshort-enums \
|
||||
-fstack-usage \
|
||||
-fno-strict-aliasing \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Werror \
|
||||
-Wfatal-errors \
|
||||
-Werror-implicit-function-declaration \
|
||||
-Wfloat-equal \
|
||||
-Wundef \
|
||||
-Wshadow \
|
||||
-Wwrite-strings \
|
||||
-Wsign-compare \
|
||||
-Wmissing-format-attribute \
|
||||
-Wno-endif-labels \
|
||||
-Wunreachable-code \
|
||||
-ggdb
|
||||
|
||||
# keep every function in separate section. This will allow linker to dump unused functions
|
||||
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
|
||||
CFLAGS += -fno-builtin --short-enums -fstack-usage
|
||||
# Suppress warning caused by SDK
|
||||
CFLAGS += -Wno-unused-parameter -Wno-expansion-to-defined
|
||||
|
||||
# TinyUSB tusb_hal_nrf_power_event
|
||||
CFLAGS += -Wno-cast-function-type
|
||||
|
||||
# Defined Symbol (MACROS)
|
||||
CFLAGS += -D__HEAP_SIZE=0
|
||||
CFLAGS += -DCONFIG_GPIO_AS_PINRESET
|
||||
CFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS
|
||||
CFLAGS += -DBLE_STACK_SUPPORT_REQD
|
||||
CFLAGS += -DSWI_DISABLE0
|
||||
CFLAGS += -DSOFTDEVICE_PRESENT
|
||||
CFLAGS += -DFLOAT_ABI_HARD
|
||||
CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
|
||||
CFLAGS += $(MCU_FLAGS)
|
||||
|
||||
CFLAGS += -DUF2_VERSION='"$(GIT_VERSION) $(GIT_SUBMODULE_VERSIONS) $(SD_NAME) $(SD_VERSION)"'
|
||||
# Skip defining CONFIG_NFCT_PINS_AS_GPIOS if the device uses the NFCT.
|
||||
ifneq ($(USE_NFCT),yes)
|
||||
CFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS
|
||||
endif
|
||||
|
||||
CFLAGS += -DSOFTDEVICE_PRESENT
|
||||
CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
|
||||
|
||||
CFLAGS += -DUF2_VERSION='"$(GIT_VERSION) $(GIT_SUBMODULE_VERSIONS)"'
|
||||
CFLAGS += -DBLEDIS_FW_VERSION='"$(GIT_VERSION) $(SD_NAME) $(SD_VERSION)"'
|
||||
|
||||
_VER = $(subst ., ,$(word 1, $(subst -, ,$(GIT_VERSION))))
|
||||
CFLAGS += -DMK_BOOTLOADER_VERSION='($(word 1,$(_VER)) << 16) + ($(word 2,$(_VER)) << 8) + $(word 3,$(_VER))'
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
# Linker Flags
|
||||
#
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# keep every function in separate section. This will allow linker to dump unused functions
|
||||
LDFLAGS += -Xlinker -Map=$(BUILD)/$(OUTPUT_FILENAME).map
|
||||
LDFLAGS += -mthumb -mabi=aapcs -L$(SRC_PATH)/linker -T$(LD_FILE)
|
||||
LDFLAGS += -mcpu=cortex-m4
|
||||
LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||
LDFLAGS += \
|
||||
$(CFLAGS) \
|
||||
-Wl,-L,linker -Wl,-T,$(LD_FILE) \
|
||||
-Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections \
|
||||
-specs=nosys.specs -specs=nano.specs
|
||||
|
||||
# let linker to dump unused sections
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LIBS += -lm -lc
|
||||
|
||||
# use newlib in nano version
|
||||
LDFLAGS += --specs=nano.specs -lc -lnosys
|
||||
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
# Assembler flags
|
||||
#
|
||||
#******************************************************************************
|
||||
ASMFLAGS += -x assembler-with-cpp
|
||||
ASMFLAGS += -D__HEAP_SIZE=0
|
||||
ASMFLAGS += -DBLE_STACK_SUPPORT_REQD
|
||||
ASMFLAGS += -DSWI_DISABLE0
|
||||
ASMFLAGS += -DSOFTDEVICE_PRESENT
|
||||
ASMFLAGS += -DFLOAT_ABI_HARD
|
||||
ASMFLAGS += $(MCU_FLAGS)
|
||||
#------------------------------------------------------------------------------
|
||||
ASFLAGS += $(CFLAGS)
|
||||
|
||||
C_SOURCE_FILE_NAMES = $(notdir $(C_SOURCE_FILES))
|
||||
C_PATHS = $(call remduplicates, $(dir $(C_SOURCE_FILES) ) )
|
||||
#function for removing duplicates in a list
|
||||
remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1))))
|
||||
|
||||
C_SOURCE_FILE_NAMES = $(notdir $(C_SRC))
|
||||
C_PATHS = $(call remduplicates, $(dir $(C_SRC) ) )
|
||||
C_OBJECTS = $(addprefix $(BUILD)/, $(C_SOURCE_FILE_NAMES:.c=.o) )
|
||||
|
||||
ASM_SOURCE_FILE_NAMES = $(notdir $(ASM_SOURCE_FILES))
|
||||
ASM_PATHS = $(call remduplicates, $(dir $(ASM_SOURCE_FILES) ))
|
||||
ASM_SOURCE_FILE_NAMES = $(notdir $(ASM_SRC))
|
||||
ASM_PATHS = $(call remduplicates, $(dir $(ASM_SRC) ))
|
||||
ASM_OBJECTS = $(addprefix $(BUILD)/, $(ASM_SOURCE_FILE_NAMES:.S=.o) )
|
||||
|
||||
vpath %.c $(C_PATHS)
|
||||
@@ -305,25 +327,84 @@ vpath %.S $(ASM_PATHS)
|
||||
|
||||
OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS)
|
||||
|
||||
#******************************************************************************
|
||||
INC_PATHS = $(addprefix -I,$(IPATH))
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# BUILD TARGETS
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
ifeq ("$(V)","1")
|
||||
$(info CFLAGS $(CFLAGS))
|
||||
$(info )
|
||||
$(info LDFLAGS $(LDFLAGS))
|
||||
$(info )
|
||||
$(info ASMFLAGS $(ASMFLAGS))
|
||||
$(info )
|
||||
endif
|
||||
|
||||
.phony: all clean size flash sd erase
|
||||
.PHONY: all clean flash dfu-flash sd gdbflash gdb
|
||||
|
||||
# default target to build
|
||||
all: $(BUILD)/$(OUTPUT_FILENAME)-nosd.out size
|
||||
all: $(BUILD)/$(OUT_NAME).out $(BUILD)/$(OUT_NAME)_nosd.hex $(BUILD)/update-$(OUT_NAME)_nosd.uf2 $(BUILD)/$(MERGED_FILE).hex $(BUILD)/$(MERGED_FILE).zip
|
||||
|
||||
#******************* Flash target *******************
|
||||
# Print out the value of a make variable.
|
||||
# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile
|
||||
print-%:
|
||||
@echo $* = $($*)
|
||||
|
||||
#------------------- Compile rules -------------------
|
||||
|
||||
# Create build directories
|
||||
$(BUILD):
|
||||
@$(MKDIR) "$@"
|
||||
|
||||
clean:
|
||||
@$(RM) $(BUILD)
|
||||
@$(RM) $(BIN)
|
||||
|
||||
# Create objects from C SRC files
|
||||
$(BUILD)/%.o: %.c
|
||||
@echo CC $(notdir $<)
|
||||
@$(CC) $(CFLAGS) $(INC_PATHS) -c -o $@ $<
|
||||
|
||||
# Assemble files
|
||||
$(BUILD)/%.o: %.S
|
||||
@echo AS $(notdir $<)
|
||||
@$(CC) -x assembler-with-cpp $(ASFLAGS) $(INC_PATHS) -c -o $@ $<
|
||||
|
||||
# Link
|
||||
$(BUILD)/$(OUT_NAME).out: $(BUILD) $(OBJECTS)
|
||||
@echo LD $(notdir $@)
|
||||
@$(CC) -o $@ $(LDFLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group
|
||||
@$(SIZE) $@
|
||||
|
||||
#------------------- Binary generator -------------------
|
||||
|
||||
# Create hex file (no sd, no mbr)
|
||||
$(BUILD)/$(OUT_NAME).hex: $(BUILD)/$(OUT_NAME).out
|
||||
@echo Create $(notdir $@)
|
||||
@$(OBJCOPY) -O ihex $< $@
|
||||
|
||||
# Hex file with mbr (still no SD)
|
||||
$(BUILD)/$(OUT_NAME)_nosd.hex: $(BUILD)/$(OUT_NAME).hex
|
||||
@echo Create $(notdir $@)
|
||||
@python3 tools/hexmerge.py --overlap=replace -o $@ $< $(MBR_HEX)
|
||||
|
||||
# Bootolader self-update uf2
|
||||
$(BUILD)/update-$(OUT_NAME)_nosd.uf2: $(BUILD)/$(OUT_NAME)_nosd.hex
|
||||
@echo Create $(notdir $@)
|
||||
@python3 lib/uf2/utils/uf2conv.py -f 0xd663823c -c -o $@ $^
|
||||
|
||||
# merge bootloader and sd hex together
|
||||
$(BUILD)/$(MERGED_FILE).hex: $(BUILD)/$(OUT_NAME).hex
|
||||
@echo Create $(notdir $@)
|
||||
@python3 tools/hexmerge.py -o $@ $< $(SD_HEX)
|
||||
|
||||
# Create pkg zip file for bootloader+SD combo to use with DFU CDC
|
||||
$(BUILD)/$(MERGED_FILE).zip: $(BUILD)/$(OUT_NAME).hex
|
||||
@$(NRFUTIL) dfu genpkg --dev-type 0x0052 --dev-revision $(DFU_DEV_REV) --bootloader $< --softdevice $(SD_HEX) $@
|
||||
|
||||
#-------------- Artifacts --------------
|
||||
$(BIN):
|
||||
@$(MKDIR) -p $@
|
||||
|
||||
copy-artifact: $(BIN)
|
||||
@$(CP) $(BUILD)/update-$(OUT_NAME)_nosd.uf2 $(BIN)
|
||||
@$(CP) $(BUILD)/$(MERGED_FILE).hex $(BIN)
|
||||
@$(CP) $(BUILD)/$(MERGED_FILE).zip $(BIN)
|
||||
|
||||
#------------------- Flash target -------------------
|
||||
|
||||
check_defined = \
|
||||
$(strip $(foreach 1,$1, \
|
||||
@@ -333,78 +414,36 @@ __check_defined = \
|
||||
$(error Undefined make flag: $1$(if $2, ($2))))
|
||||
|
||||
# Flash the compiled
|
||||
flash: $(BUILD)/$(OUTPUT_FILENAME)-nosd.hex
|
||||
@echo Flashing: $<
|
||||
$(NRFJPROG) --program $< --sectoranduicrerase -f nrf52 --reset
|
||||
flash: $(BUILD)/$(OUT_NAME)_nosd.hex
|
||||
@echo Flashing: $(notdir $<)
|
||||
$(call FLASH_CMD,$<)
|
||||
|
||||
dfu-flash: $(BUILD)/$(MERGED_FNAME).zip
|
||||
erase:
|
||||
@echo Erasing flash
|
||||
$(call FLASH_ERASE_CMD)
|
||||
|
||||
# flash SD only
|
||||
sd:
|
||||
@echo Flashing: $(SD_HEX)
|
||||
$(call FLASH_NOUICR_CMD,$(SD_HEX))
|
||||
|
||||
# flash MBR only
|
||||
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
|
||||
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
|
||||
$(NRFUTIL) --verbose dfu serial --package $< -p $(SERIAL) -b 115200 --singlebank --touch 1200
|
||||
|
||||
sd:
|
||||
@echo Flashing: $(SD_HEX)
|
||||
$(NRFJPROG) --program $(SD_HEX) -f nrf52 --chiperase --reset
|
||||
#------------------- Debugging -------------------
|
||||
|
||||
erase:
|
||||
@echo Erasing chip
|
||||
$(NRFJPROG) --eraseall -f nrf52
|
||||
|
||||
gdbflash: $(BUILD)/$(MERGED_FNAME).hex
|
||||
gdbflash: $(BUILD)/$(MERGED_FILE).hex
|
||||
@echo Flashing: $<
|
||||
@$(GDB_BMP) -nx --batch -ex 'load $<' -ex 'compare-sections' -ex 'kill'
|
||||
|
||||
gdb: $(BUILD)/$(OUTPUT_FILENAME)-nosd.out
|
||||
gdb: $(BUILD)/$(OUT_NAME).out
|
||||
$(GDB_BMP) $<
|
||||
|
||||
#******************* Compile rules *******************
|
||||
|
||||
## Create build directories
|
||||
$(BUILD):
|
||||
@$(MK) $@
|
||||
|
||||
clean:
|
||||
@$(RM) $(BUILD)
|
||||
|
||||
# Create objects from C SRC files
|
||||
$(BUILD)/%.o: %.c
|
||||
@echo CC $(notdir $<)
|
||||
$(QUIET)$(CC) $(CFLAGS) $(INC_PATHS) -c -o $@ $<
|
||||
|
||||
# Assemble files
|
||||
$(BUILD)/%.o: %.S
|
||||
@echo AS $(notdir $<)
|
||||
$(QUIET)$(CC) $(ASMFLAGS) $(INC_PATHS) -c -o $@ $<
|
||||
|
||||
# Link
|
||||
$(BUILD)/$(OUTPUT_FILENAME)-nosd.out: $(BUILD) $(OBJECTS)
|
||||
@echo LD $(OUTPUT_FILENAME)-nosd.out
|
||||
$(QUIET)$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -lm -o $@
|
||||
|
||||
size: $(BUILD)/$(OUTPUT_FILENAME)-nosd.out
|
||||
-@echo ''
|
||||
$(QUIET)$(SIZE) $<
|
||||
-@echo ''
|
||||
|
||||
|
||||
#******************* Binary generator *******************
|
||||
.phony: genhex genpkg
|
||||
|
||||
## Create binary .hex file from the .out file
|
||||
genhex: $(BUILD)/$(OUTPUT_FILENAME)-nosd.hex
|
||||
|
||||
$(BUILD)/$(OUTPUT_FILENAME)-nosd.hex: $(BUILD)/$(OUTPUT_FILENAME)-nosd.out
|
||||
@echo CR $(OUTPUT_FILENAME)-nosd.hex
|
||||
$(QUIET)$(OBJCOPY) -O ihex $< $@
|
||||
|
||||
# merge bootloader and sd hex together
|
||||
combinehex: $(BUILD)/$(MERGED_FNAME).hex
|
||||
|
||||
$(BUILD)/$(MERGED_FNAME).hex: $(BUILD)/$(OUTPUT_FILENAME)-nosd.hex
|
||||
@echo CR $(MERGED_FNAME).hex
|
||||
@mergehex -q -m $< $(SD_HEX) -o $@
|
||||
|
||||
## Create pkg file for bootloader+SD combo to use with DFU
|
||||
genpkg: $(BUILD)/$(MERGED_FNAME).zip
|
||||
|
||||
$(BUILD)/$(MERGED_FNAME).zip: $(BUILD)/$(OUTPUT_FILENAME)-nosd.hex
|
||||
@$(NRFUTIL) dfu genpkg --dev-type 0x0052 --dev-revision $(DFU_DEV_REV) --bootloader $< --softdevice $(SD_HEX) $@
|
||||
@@ -11,8 +11,10 @@ This is a CDC/DFU/UF2 bootloader for nRF52 boards.
|
||||
- [Adafruit Feather nRF52840 Sense](https://www.adafruit.com/product/4516)
|
||||
- [Adafruit ItsyBitsy nRF52840 Express](https://www.adafruit.com/product/4481)
|
||||
- Adafruit Metro nRF52840 Express
|
||||
- [Akizukidenshi AE-BL652-BO](https://akizukidenshi.com/catalog/g/gK-15567/)
|
||||
- [Electronut Labs Papyr](https://docs.electronut.in/papyr/)
|
||||
- MakerDiary MDK nRF52840 USB Dongle
|
||||
- [MakerDiary MDK nRF52840 USB Dongle](https://makerdiary.com/products/nrf52840-mdk-usb-dongle)
|
||||
- [MakerDiary nRF52840 M.2 Module](https://makerdiary.com/products/nrf52840-m2-module)
|
||||
- [Nordic nRF52840DK PCA10056](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-DK)
|
||||
- [Nordic nRF52840DK PCA10059 ("Dongle")](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-Dongle)
|
||||
- Particle Argon
|
||||
@@ -20,33 +22,20 @@ This is a CDC/DFU/UF2 bootloader for nRF52 boards.
|
||||
- Particle Xenon
|
||||
|
||||
UF2 is an easy-to-use bootloader that appears as a flash drive. You can just copy `.uf2`-format
|
||||
application images to the flash drive to load new firmware.
|
||||
See https://github.com/Microsoft/uf2 and https://github.com/adafruit/uf2-samdx1
|
||||
for more information.
|
||||
application images to the flash drive to load new firmware. See https://github.com/Microsoft/uf2 and https://github.com/adafruit/uf2-samdx1 for more information.
|
||||
|
||||
[adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil),
|
||||
a modified version of [Nordic nrfutil](https://github.com/NordicSemiconductor/pc-nrfutil),
|
||||
is required to perform DFU.
|
||||
Install `python3` if it is not installed already and run this command to install adafruit-nrfutil from PyPi:
|
||||
[adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil), a modified version of [Nordic nrfutil](https://github.com/NordicSemiconductor/pc-nrfutil), is required to perform DFU. Install `python3` if it is not installed already and run this command to install adafruit-nrfutil from PyPi:
|
||||
|
||||
```
|
||||
$ pip3 install --user adafruit-nrfutil
|
||||
```
|
||||
|
||||
This repository depends on the following submodules:
|
||||
|
||||
- [tinyusb](https://github.com/hathach/tinyusb)
|
||||
- [nrfx](https://github.com/NordicSemiconductor/nrfx)
|
||||
|
||||
Note that `tinyusb` also includes `nrfx` as a submodule, so you need
|
||||
to initialize and update submodules with the `--recursive`` flag.
|
||||
|
||||
Clone this repo with following commands, or fork it for your own development
|
||||
|
||||
```
|
||||
git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader
|
||||
cd Adafruit_nRF52_Bootloader
|
||||
git submodule update --init --recursive
|
||||
git submodule update --init
|
||||
```
|
||||
|
||||
## Features
|
||||
@@ -63,7 +52,7 @@ There are two pins, `DFU` and `FRST` that bootloader will check upon reset/power
|
||||
- `Double Reset` Reset twice within 500 ms will enter DFU with UF2 and CDC support (only works with nRF52840)
|
||||
- `DFU = LOW` and `FRST = HIGH`: Enter bootloader with UF2 and CDC support
|
||||
- `DFU = LOW` and `FRST = LOW`: Enter bootloader with OTA, to upgrade with a mobile application such as Nordic nrfConnect/Toolbox
|
||||
- `DFU = HIGH` and `FRST = LOW`: Factory Reset mode: erase firmware application and its data
|
||||
- <s>`DFU = HIGH` and `FRST = LOW`: Factory Reset mode: erase firmware application and its data</s>
|
||||
- `DFU = HIGH` and `FRST = HIGH`: Go to application code if it is present, otherwise enter DFU with UF2
|
||||
- The `GPREGRET` register can also be set to force the bootloader can enter any of above modes (plus a CDC-only mode for Arduino).
|
||||
`GPREGRET` is set by the application before performing a soft reset.
|
||||
@@ -92,6 +81,12 @@ To create a UF2 image from a .hex file:
|
||||
uf2conv.py firmware.hex -c -f 0xADA52840
|
||||
```
|
||||
|
||||
To create a UF2 image for bootloader from a .hex file using separated family of **0xd663823c**
|
||||
|
||||
```
|
||||
uf2conv.py bootloader.hex -c -f 0xd663823c
|
||||
```
|
||||
|
||||
## Burn & Upgrade with pre-built binaries
|
||||
|
||||
You can burn and/or upgrade the bootloader with either a J-link or DFU (serial) to a specific pre-built binary version
|
||||
@@ -105,19 +100,18 @@ both bootloader and the Nordic SoftDevice, you can freely upgrade/downgrade to a
|
||||
## How to compile and build
|
||||
|
||||
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.
|
||||
|
||||
### Option 1: Build with Makefile
|
||||
You must have have a J-Link available to "unbrick" your device.
|
||||
|
||||
Prerequisites
|
||||
|
||||
- ARM GCC
|
||||
- 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:
|
||||
|
||||
```
|
||||
make BOARD=feather_nrf52840_express all combinehex
|
||||
make BOARD=feather_nrf52840_express all
|
||||
```
|
||||
|
||||
To flash the bootloader with JLink:
|
||||
@@ -138,12 +132,6 @@ To flash SoftDevice (and chip erase):
|
||||
make BOARD=feather_nrf52840_express sd
|
||||
```
|
||||
|
||||
To erase all of flash:
|
||||
|
||||
```
|
||||
make BOARD=feather_nrf52840_express erase
|
||||
```
|
||||
|
||||
For the list of supported boards, run `make` without `BOARD=` :
|
||||
|
||||
```
|
||||
@@ -167,39 +155,25 @@ make: *** [_build/main.o] Error 127
|
||||
```
|
||||
|
||||
... you may need to pass the location of the GCC ARM toolchain binaries to `make` using
|
||||
the variable `GNU_INSTALL_ROOT` as below:
|
||||
the variable `CROSS_COMPILE` as below:
|
||||
```
|
||||
$ make GNU_INSTALL_ROOT=/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/ BOARD=feather_nrf52832 all
|
||||
$ make CROSS_COMPILE=/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi- BOARD=feather_nrf52832 all
|
||||
```
|
||||
|
||||
_Please note that the path needs a trailing path separator (a `/`)_
|
||||
#### 2. `ModuleNotFoundError: No module named 'intelhex'`
|
||||
|
||||
Install python-intelhex with
|
||||
|
||||
```
|
||||
pip install intelhex
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### 2. `mergehex: No such file or directory`
|
||||
|
||||
Make sure that `mergehex` is available from the command-line. This binary is
|
||||
part of Nordic's nRF5x Command Line Tools.
|
||||
|
||||
#### 3. `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.
|
||||
|
||||
On POSIX-type systems you can temporarily add the path to `nrfjprog` via a
|
||||
variation on the following command:
|
||||
|
||||
```
|
||||
$ export PATH=$PATH:/location/of/nRF5x-Command-Line-Tools_9_7_2_OSX/nrfjprog
|
||||
```
|
||||
|
||||
### Option 2: Build using Segger Embedded Studio
|
||||
|
||||
For easier debugging you can also use [SES](https://www.segger.com/products/development-tools/embedded-studio/).
|
||||
The project file is located at `src/segger/Adafruit_nRF52_Bootloader.emProject`.
|
||||
|
||||
> **Note**: SES only flashes the bootloader when you click download, not the SoftDevice.
|
||||
You need to flash the SoftDevice beforehand if you haven't already done so.
|
||||
As mentioned above do something like:
|
||||
|
||||
```
|
||||
make BOARD=feather_nrf52840_express sd
|
||||
```
|
||||
@@ -1,5 +1,16 @@
|
||||
# Adafruit nRF52 Bootloader Changelog
|
||||
|
||||
## 0.4.0 - 2021.01.19
|
||||
|
||||
- Decouple bootloader and softdevice i.e bootloader will always work with and/or without softdevice present. This allows application to pack firmware + softdevice into an uf2/serial for DFU.
|
||||
- Add self-update feature with update-{board}.uf2. This allow bootloader to update itself easily (requires running bootloader with at least 0.4.0)
|
||||
- Enlarge the fake FAT disk to ~ 32MB to allow piggy-pack multiple application (different family ID) within the same uf2.
|
||||
- Support uf2 with family ID = vendor ID + product ID
|
||||
- Reset into application if there is no USB connection in ~3 seconds.
|
||||
- Remove DFU idle 300 seconds timeout
|
||||
- Support power supply configuration with `ENABLE_DCDC_0` and `ENABLE_DCDC_1`
|
||||
- Add new boards support: nice nano, bast ble, ikigaisense vita, nrf52840 M2, Pitaya Go, AE-BL652-BO, BlueMicro, ADM_B_NRF52840_1
|
||||
|
||||
## 0.3.2 - 2020.03.12
|
||||
|
||||
- Make sure all pins are in reset state when jumping to app mode.
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
Important - Read carefully:
|
||||
|
||||
SEGGER RTT - Real Time Transfer for embedded targets
|
||||
|
||||
All rights reserved.
|
||||
|
||||
SEGGER strongly recommends to not make any changes
|
||||
to or modify the source code of this software in order to stay
|
||||
compatible with the RTT protocol and J-Link.
|
||||
|
||||
Redistribution and use in source and binary forms, with or
|
||||
without modification, are permitted provided that the following
|
||||
condition is met:
|
||||
|
||||
o Redistributions of source code must retain the above copyright
|
||||
notice, this condition and the following disclaimer.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGE.
|
||||
|
||||
|
||||
(c) 2014 - 2016 SEGGER Microcontroller GmbH
|
||||
www.segger.com
|
||||
@@ -0,0 +1,20 @@
|
||||
README.txt for the SEGGER RTT Implementation Pack.
|
||||
|
||||
Included files:
|
||||
===============
|
||||
Root Directory
|
||||
- Examples
|
||||
- Main_RTT_InputEchoApp.c - Sample application which echoes input on Channel 0.
|
||||
- Main_RTT_MenuApp.c - Sample application to demonstrate RTT bi-directional functionality.
|
||||
- Main_RTT_PrintfTest.c - Sample application to test RTT small printf implementation.
|
||||
- Main_RTT_SpeedTestApp.c - Sample application for measuring RTT performance. embOS needed.
|
||||
- RTT
|
||||
- SEGGER_RTT.c - The RTT implementation.
|
||||
- SEGGER_RTT.h - Header for RTT implementation.
|
||||
- SEGGER_RTT_Conf.h - Pre-processor configuration for the RTT implementation.
|
||||
- SEGGER_RTT_Printf.c - Simple implementation of printf to write formatted strings via RTT.
|
||||
- Syscalls
|
||||
- RTT_Syscalls_GCC.c - Low-level syscalls to retarget printf() to RTT with GCC / Newlib.
|
||||
- RTT_Syscalls_IAR.c - Low-level syscalls to retarget printf() to RTT with IAR compiler.
|
||||
- RTT_Syscalls_KEIL.c - Low-level syscalls to retarget printf() to RTT with KEIL/uVision compiler.
|
||||
- RTT_Syscalls_SES.c - Low-level syscalls to retarget printf() to RTT with SEGGER Embedded Studio.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,321 @@
|
||||
/*********************************************************************
|
||||
* SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
**********************************************************************
|
||||
* *
|
||||
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
|
||||
* *
|
||||
* www.segger.com Support: support@segger.com *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* SEGGER RTT * Real Time Transfer for embedded targets *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* SEGGER strongly recommends to not make any changes *
|
||||
* to or modify the source code of this software in order to stay *
|
||||
* compatible with the RTT protocol and J-Link. *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or *
|
||||
* without modification, are permitted provided that the following *
|
||||
* condition is met: *
|
||||
* *
|
||||
* o Redistributions of source code must retain the above copyright *
|
||||
* notice, this condition and the following disclaimer. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
|
||||
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
|
||||
* DAMAGE. *
|
||||
* *
|
||||
**********************************************************************
|
||||
---------------------------END-OF-HEADER------------------------------
|
||||
File : SEGGER_RTT.h
|
||||
Purpose : Implementation of SEGGER real-time transfer which allows
|
||||
real-time communication on targets which support debugger
|
||||
memory accesses while the CPU is running.
|
||||
Revision: $Rev: 17697 $
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef SEGGER_RTT_H
|
||||
#define SEGGER_RTT_H
|
||||
|
||||
#include "SEGGER_RTT_Conf.h"
|
||||
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines, defaults
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
#ifndef RTT_USE_ASM
|
||||
#if (defined __SES_ARM) // SEGGER Embedded Studio
|
||||
#define _CC_HAS_RTT_ASM_SUPPORT 1
|
||||
#elif (defined __CROSSWORKS_ARM) // Rowley Crossworks
|
||||
#define _CC_HAS_RTT_ASM_SUPPORT 1
|
||||
#elif (defined __GNUC__) // GCC
|
||||
#define _CC_HAS_RTT_ASM_SUPPORT 1
|
||||
#elif (defined __clang__) // Clang compiler
|
||||
#define _CC_HAS_RTT_ASM_SUPPORT 1
|
||||
#elif (defined __IASMARM__) // IAR assembler
|
||||
#define _CC_HAS_RTT_ASM_SUPPORT 1
|
||||
#elif (defined __ICCARM__) // IAR compiler
|
||||
#define _CC_HAS_RTT_ASM_SUPPORT 1
|
||||
#else
|
||||
#define _CC_HAS_RTT_ASM_SUPPORT 0
|
||||
#endif
|
||||
#if (defined __ARM_ARCH_7M__) // Cortex-M3/4
|
||||
#define _CORE_HAS_RTT_ASM_SUPPORT 1
|
||||
#elif (defined __ARM_ARCH_7EM__) // Cortex-M7
|
||||
#define _CORE_HAS_RTT_ASM_SUPPORT 1
|
||||
#elif (defined __ARM_ARCH_8M_MAIN__) // Cortex-M33
|
||||
#define _CORE_HAS_RTT_ASM_SUPPORT 1
|
||||
#elif (defined __ARM7M__) // IAR Cortex-M3/4
|
||||
#if (__CORE__ == __ARM7M__)
|
||||
#define _CORE_HAS_RTT_ASM_SUPPORT 1
|
||||
#else
|
||||
#define _CORE_HAS_RTT_ASM_SUPPORT 0
|
||||
#endif
|
||||
#elif (defined __ARM7EM__) // IAR Cortex-M7
|
||||
#if (__CORE__ == __ARM7EM__)
|
||||
#define _CORE_HAS_RTT_ASM_SUPPORT 1
|
||||
#else
|
||||
#define _CORE_HAS_RTT_ASM_SUPPORT 0
|
||||
#endif
|
||||
#else
|
||||
#define _CORE_HAS_RTT_ASM_SUPPORT 0
|
||||
#endif
|
||||
//
|
||||
// If IDE and core support the ASM version, enable ASM version by default
|
||||
//
|
||||
#if (_CC_HAS_RTT_ASM_SUPPORT && _CORE_HAS_RTT_ASM_SUPPORT)
|
||||
#define RTT_USE_ASM (1)
|
||||
#else
|
||||
#define RTT_USE_ASM (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef SEGGER_RTT_ASM // defined when SEGGER_RTT.h is included from assembly file
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines, fixed
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Types
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
//
|
||||
// Description for a circular buffer (also called "ring buffer")
|
||||
// which is used as up-buffer (T->H)
|
||||
//
|
||||
typedef struct {
|
||||
const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
|
||||
char* pBuffer; // Pointer to start of buffer
|
||||
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
|
||||
unsigned WrOff; // Position of next item to be written by either target.
|
||||
volatile unsigned RdOff; // Position of next item to be read by host. Must be volatile since it may be modified by host.
|
||||
unsigned Flags; // Contains configuration flags
|
||||
} SEGGER_RTT_BUFFER_UP;
|
||||
|
||||
//
|
||||
// Description for a circular buffer (also called "ring buffer")
|
||||
// which is used as down-buffer (H->T)
|
||||
//
|
||||
typedef struct {
|
||||
const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
|
||||
char* pBuffer; // Pointer to start of buffer
|
||||
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
|
||||
volatile unsigned WrOff; // Position of next item to be written by host. Must be volatile since it may be modified by host.
|
||||
unsigned RdOff; // Position of next item to be read by target (down-buffer).
|
||||
unsigned Flags; // Contains configuration flags
|
||||
} SEGGER_RTT_BUFFER_DOWN;
|
||||
|
||||
//
|
||||
// RTT control block which describes the number of buffers available
|
||||
// as well as the configuration for each buffer
|
||||
//
|
||||
//
|
||||
typedef struct {
|
||||
char acID[16]; // Initialized to "SEGGER RTT"
|
||||
int MaxNumUpBuffers; // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2)
|
||||
int MaxNumDownBuffers; // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2)
|
||||
SEGGER_RTT_BUFFER_UP aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS]; // Up buffers, transferring information up from target via debug probe to host
|
||||
SEGGER_RTT_BUFFER_DOWN aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS]; // Down buffers, transferring information down from host via debug probe to target
|
||||
} SEGGER_RTT_CB;
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Global data
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
extern SEGGER_RTT_CB _SEGGER_RTT;
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT API functions
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int SEGGER_RTT_AllocDownBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
|
||||
int SEGGER_RTT_AllocUpBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
|
||||
int SEGGER_RTT_ConfigUpBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
|
||||
int SEGGER_RTT_ConfigDownBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
|
||||
int SEGGER_RTT_GetKey (void);
|
||||
unsigned SEGGER_RTT_HasData (unsigned BufferIndex);
|
||||
int SEGGER_RTT_HasKey (void);
|
||||
unsigned SEGGER_RTT_HasDataUp (unsigned BufferIndex);
|
||||
void SEGGER_RTT_Init (void);
|
||||
unsigned SEGGER_RTT_Read (unsigned BufferIndex, void* pBuffer, unsigned BufferSize);
|
||||
unsigned SEGGER_RTT_ReadNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize);
|
||||
int SEGGER_RTT_SetNameDownBuffer (unsigned BufferIndex, const char* sName);
|
||||
int SEGGER_RTT_SetNameUpBuffer (unsigned BufferIndex, const char* sName);
|
||||
int SEGGER_RTT_SetFlagsDownBuffer (unsigned BufferIndex, unsigned Flags);
|
||||
int SEGGER_RTT_SetFlagsUpBuffer (unsigned BufferIndex, unsigned Flags);
|
||||
int SEGGER_RTT_WaitKey (void);
|
||||
unsigned SEGGER_RTT_Write (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
unsigned SEGGER_RTT_WriteNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
unsigned SEGGER_RTT_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
unsigned SEGGER_RTT_ASM_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
unsigned SEGGER_RTT_WriteString (unsigned BufferIndex, const char* s);
|
||||
void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
unsigned SEGGER_RTT_PutChar (unsigned BufferIndex, char c);
|
||||
unsigned SEGGER_RTT_PutCharSkip (unsigned BufferIndex, char c);
|
||||
unsigned SEGGER_RTT_PutCharSkipNoLock (unsigned BufferIndex, char c);
|
||||
unsigned SEGGER_RTT_GetAvailWriteSpace (unsigned BufferIndex);
|
||||
unsigned SEGGER_RTT_GetBytesInBuffer (unsigned BufferIndex);
|
||||
//
|
||||
// Function macro for performance optimization
|
||||
//
|
||||
#define SEGGER_RTT_HASDATA(n) (_SEGGER_RTT.aDown[n].WrOff - _SEGGER_RTT.aDown[n].RdOff)
|
||||
|
||||
#if RTT_USE_ASM
|
||||
#define SEGGER_RTT_WriteSkipNoLock SEGGER_RTT_ASM_WriteSkipNoLock
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT transfer functions to send RTT data via other channels.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
unsigned SEGGER_RTT_ReadUpBuffer (unsigned BufferIndex, void* pBuffer, unsigned BufferSize);
|
||||
unsigned SEGGER_RTT_ReadUpBufferNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize);
|
||||
unsigned SEGGER_RTT_WriteDownBuffer (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
unsigned SEGGER_RTT_WriteDownBufferNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
|
||||
#define SEGGER_RTT_HASDATA_UP(n) (_SEGGER_RTT.aUp[n].WrOff - _SEGGER_RTT.aUp[n].RdOff)
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT "Terminal" API functions
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
int SEGGER_RTT_SetTerminal (unsigned char TerminalId);
|
||||
int SEGGER_RTT_TerminalOut (unsigned char TerminalId, const char* s);
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT printf functions (require SEGGER_RTT_printf.c)
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...);
|
||||
int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // ifndef(SEGGER_RTT_ASM)
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
//
|
||||
// Operating modes. Define behavior if buffer is full (not enough space for entire message)
|
||||
//
|
||||
#define SEGGER_RTT_MODE_NO_BLOCK_SKIP (0) // Skip. Do not block, output nothing. (Default)
|
||||
#define SEGGER_RTT_MODE_NO_BLOCK_TRIM (1) // Trim: Do not block, output as much as fits.
|
||||
#define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL (2) // Block: Wait until there is space in the buffer.
|
||||
#define SEGGER_RTT_MODE_MASK (3)
|
||||
|
||||
//
|
||||
// Control sequences, based on ANSI.
|
||||
// Can be used to control color, and clear the screen
|
||||
//
|
||||
#define RTT_CTRL_RESET "\x1B[0m" // Reset to default colors
|
||||
#define RTT_CTRL_CLEAR "\x1B[2J" // Clear screen, reposition cursor to top left
|
||||
|
||||
#define RTT_CTRL_TEXT_BLACK "\x1B[2;30m"
|
||||
#define RTT_CTRL_TEXT_RED "\x1B[2;31m"
|
||||
#define RTT_CTRL_TEXT_GREEN "\x1B[2;32m"
|
||||
#define RTT_CTRL_TEXT_YELLOW "\x1B[2;33m"
|
||||
#define RTT_CTRL_TEXT_BLUE "\x1B[2;34m"
|
||||
#define RTT_CTRL_TEXT_MAGENTA "\x1B[2;35m"
|
||||
#define RTT_CTRL_TEXT_CYAN "\x1B[2;36m"
|
||||
#define RTT_CTRL_TEXT_WHITE "\x1B[2;37m"
|
||||
|
||||
#define RTT_CTRL_TEXT_BRIGHT_BLACK "\x1B[1;30m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_RED "\x1B[1;31m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_GREEN "\x1B[1;32m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_YELLOW "\x1B[1;33m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_BLUE "\x1B[1;34m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_MAGENTA "\x1B[1;35m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_CYAN "\x1B[1;36m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_WHITE "\x1B[1;37m"
|
||||
|
||||
#define RTT_CTRL_BG_BLACK "\x1B[24;40m"
|
||||
#define RTT_CTRL_BG_RED "\x1B[24;41m"
|
||||
#define RTT_CTRL_BG_GREEN "\x1B[24;42m"
|
||||
#define RTT_CTRL_BG_YELLOW "\x1B[24;43m"
|
||||
#define RTT_CTRL_BG_BLUE "\x1B[24;44m"
|
||||
#define RTT_CTRL_BG_MAGENTA "\x1B[24;45m"
|
||||
#define RTT_CTRL_BG_CYAN "\x1B[24;46m"
|
||||
#define RTT_CTRL_BG_WHITE "\x1B[24;47m"
|
||||
|
||||
#define RTT_CTRL_BG_BRIGHT_BLACK "\x1B[4;40m"
|
||||
#define RTT_CTRL_BG_BRIGHT_RED "\x1B[4;41m"
|
||||
#define RTT_CTRL_BG_BRIGHT_GREEN "\x1B[4;42m"
|
||||
#define RTT_CTRL_BG_BRIGHT_YELLOW "\x1B[4;43m"
|
||||
#define RTT_CTRL_BG_BRIGHT_BLUE "\x1B[4;44m"
|
||||
#define RTT_CTRL_BG_BRIGHT_MAGENTA "\x1B[4;45m"
|
||||
#define RTT_CTRL_BG_BRIGHT_CYAN "\x1B[4;46m"
|
||||
#define RTT_CTRL_BG_BRIGHT_WHITE "\x1B[4;47m"
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/*************************** End of file ****************************/
|
||||
@@ -0,0 +1,235 @@
|
||||
/*********************************************************************
|
||||
* (c) SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
* www.segger.com *
|
||||
**********************************************************************
|
||||
|
||||
-------------------------- END-OF-HEADER -----------------------------
|
||||
|
||||
File : SEGGER_RTT_ASM_ARMv7M.S
|
||||
Purpose : Assembler implementation of RTT functions for ARMv7M
|
||||
|
||||
Additional information:
|
||||
This module is written to be assembler-independent and works with
|
||||
GCC and clang (Embedded Studio) and IAR.
|
||||
*/
|
||||
|
||||
#define SEGGER_RTT_ASM // Used to control processed input from header file
|
||||
#include "SEGGER_RTT.h"
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines, fixed
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
#define _CCIAR 0
|
||||
#define _CCCLANG 1
|
||||
|
||||
#if (defined __SES_ARM) || (defined __GNUC__) || (defined __clang__)
|
||||
#define _CC_TYPE _CCCLANG
|
||||
#define _PUB_SYM .global
|
||||
#define _EXT_SYM .extern
|
||||
#define _END .end
|
||||
#define _WEAK .weak
|
||||
#define _THUMB_FUNC .thumb_func
|
||||
#define _THUMB_CODE .code 16
|
||||
#define _WORD .word
|
||||
#define _SECTION(Sect, Type, AlignExp) .section Sect ##, "ax"
|
||||
#define _ALIGN(Exp) .align Exp
|
||||
#define _PLACE_LITS .ltorg
|
||||
#define _DATA_SECT_START
|
||||
#define _C_STARTUP _start
|
||||
#define _STACK_END __stack_end__
|
||||
#define _RAMFUNC
|
||||
//
|
||||
// .text => Link to flash
|
||||
// .fast => Link to RAM
|
||||
// OtherSect => Usually link to RAM
|
||||
// Alignment is 2^x
|
||||
//
|
||||
#elif defined (__IASMARM__)
|
||||
#define _CC_TYPE _CCIAR
|
||||
#define _PUB_SYM PUBLIC
|
||||
#define _EXT_SYM EXTERN
|
||||
#define _END END
|
||||
#define _WEAK _WEAK
|
||||
#define _THUMB_FUNC
|
||||
#define _THUMB_CODE THUMB
|
||||
#define _WORD DCD
|
||||
#define _SECTION(Sect, Type, AlignExp) SECTION Sect ## : ## Type ## :REORDER:NOROOT ## (AlignExp)
|
||||
#define _ALIGN(Exp) alignrom Exp
|
||||
#define _PLACE_LITS
|
||||
#define _DATA_SECT_START DATA
|
||||
#define _C_STARTUP __iar_program_start
|
||||
#define _STACK_END sfe(CSTACK)
|
||||
#define _RAMFUNC SECTION_TYPE SHT_PROGBITS, SHF_WRITE | SHF_EXECINSTR
|
||||
//
|
||||
// .text => Link to flash
|
||||
// .textrw => Link to RAM
|
||||
// OtherSect => Usually link to RAM
|
||||
// NOROOT => Allows linker to throw away the function, if not referenced
|
||||
// Alignment is 2^x
|
||||
//
|
||||
#endif
|
||||
|
||||
#if (_CC_TYPE == _CCIAR)
|
||||
NAME SEGGER_RTT_ASM_ARMv7M
|
||||
#else
|
||||
.syntax unified
|
||||
#endif
|
||||
|
||||
#if defined (RTT_USE_ASM) && (RTT_USE_ASM == 1)
|
||||
#define SHT_PROGBITS 0x1
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Public / external symbols
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
_EXT_SYM __aeabi_memcpy
|
||||
_EXT_SYM __aeabi_memcpy4
|
||||
_EXT_SYM _SEGGER_RTT
|
||||
|
||||
_PUB_SYM SEGGER_RTT_ASM_WriteSkipNoLock
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* SEGGER_RTT_WriteSkipNoLock
|
||||
*
|
||||
* Function description
|
||||
* Stores a specified number of characters in SEGGER RTT
|
||||
* control block which is then read by the host.
|
||||
* SEGGER_RTT_WriteSkipNoLock does not lock the application and
|
||||
* skips all data, if the data does not fit into the buffer.
|
||||
*
|
||||
* Parameters
|
||||
* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal").
|
||||
* pBuffer Pointer to character array. Does not need to point to a \0 terminated string.
|
||||
* NumBytes Number of bytes to be stored in the SEGGER RTT control block.
|
||||
* MUST be > 0!!!
|
||||
* This is done for performance reasons, so no initial check has do be done.
|
||||
*
|
||||
* Return value
|
||||
* 1: Data has been copied
|
||||
* 0: No space, data has not been copied
|
||||
*
|
||||
* Notes
|
||||
* (1) If there is not enough space in the "Up"-buffer, all data is dropped.
|
||||
* (2) For performance reasons this function does not call Init()
|
||||
* and may only be called after RTT has been initialized.
|
||||
* Either by calling SEGGER_RTT_Init() or calling another RTT API function first.
|
||||
*/
|
||||
_SECTION(.text, CODE, 2)
|
||||
_ALIGN(2)
|
||||
_THUMB_FUNC
|
||||
SEGGER_RTT_ASM_WriteSkipNoLock: // unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pData, unsigned NumBytes) {
|
||||
//
|
||||
// Cases:
|
||||
// 1) RdOff <= WrOff => Space until wrap-around is sufficient
|
||||
// 2) RdOff <= WrOff => Space after wrap-around needed (copy in 2 chunks)
|
||||
// 3) RdOff < WrOff => No space in buf
|
||||
// 4) RdOff > WrOff => Space is sufficient
|
||||
// 5) RdOff > WrOff => No space in buf
|
||||
//
|
||||
// 1) is the most common case for large buffers and assuming that J-Link reads the data fast enough
|
||||
//
|
||||
// Register usage:
|
||||
// R0 Temporary needed as RdOff, <Tmp> register later on
|
||||
// R1 pData
|
||||
// R2 <NumBytes>
|
||||
// R3 <Tmp> register. Hold free for subroutine calls
|
||||
// R4 <Rem>
|
||||
// R5 pRing->pBuffer
|
||||
// R6 pRing (Points to active struct SEGGER_RTT_BUFFER_DOWN)
|
||||
// R7 WrOff
|
||||
//
|
||||
PUSH {R4-R7}
|
||||
ADD R3,R0,R0, LSL #+1
|
||||
LDR.W R0,=_SEGGER_RTT // pRing = &_SEGGER_RTT.aUp[BufferIndex];
|
||||
ADD R0,R0,R3, LSL #+3
|
||||
ADD R6,R0,#+24
|
||||
LDR R0,[R6, #+16] // RdOff = pRing->RdOff;
|
||||
LDR R7,[R6, #+12] // WrOff = pRing->WrOff;
|
||||
LDR R5,[R6, #+4] // pRing->pBuffer
|
||||
CMP R7,R0
|
||||
BCC.N _CheckCase4 // if (RdOff <= WrOff) { => Case 1), 2) or 3)
|
||||
//
|
||||
// Handling for case 1, later on identical to case 4
|
||||
//
|
||||
LDR R3,[R6, #+8] // Avail = pRing->SizeOfBuffer - WrOff - 1u; => Space until wrap-around (assume 1 byte not usable for case that RdOff == 0)
|
||||
SUBS R4,R3,R7 // <Rem> (Used in case we jump into case 2 afterwards)
|
||||
SUBS R3,R4,#+1 // <Avail>
|
||||
CMP R3,R2
|
||||
BCC.N _CheckCase2 // if (Avail >= NumBytes) { => Case 1)?
|
||||
_Case4:
|
||||
ADDS R5,R7,R5 // pBuffer += WrOff
|
||||
ADDS R0,R2,R7 // v = WrOff + NumBytes
|
||||
//
|
||||
// 2x unrolling for the copy loop that is used most of the time
|
||||
// This is a special optimization for small SystemView packets and makes them even faster
|
||||
//
|
||||
_ALIGN(2)
|
||||
_LoopCopyStraight: // memcpy(pRing->pBuffer + WrOff, pData, NumBytes);
|
||||
LDRB R3,[R1], #+1
|
||||
STRB R3,[R5], #+1 // *pDest++ = *pSrc++
|
||||
SUBS R2,R2,#+1
|
||||
BEQ _CSDone
|
||||
LDRB R3,[R1], #+1
|
||||
STRB R3,[R5], #+1 // *pDest++ = *pSrc++
|
||||
SUBS R2,R2,#+1
|
||||
BNE _LoopCopyStraight
|
||||
_CSDone:
|
||||
STR R0,[R6, #+12] // pRing->WrOff = WrOff + NumBytes;
|
||||
MOVS R0,#+1
|
||||
POP {R4-R7}
|
||||
BX LR // Return 1
|
||||
_CheckCase2:
|
||||
ADDS R0,R0,R3 // Avail += RdOff; => Space incl. wrap-around
|
||||
CMP R0,R2
|
||||
BCC.N _Case3 // if (Avail >= NumBytes) { => Case 2? => If not, we have case 3) (does not fit)
|
||||
//
|
||||
// Handling for case 2
|
||||
//
|
||||
ADDS R0,R7,R5 // v = pRing->pBuffer + WrOff => Do not change pRing->pBuffer here because 2nd chunk needs org. value
|
||||
SUBS R2,R2,R4 // NumBytes -= Rem; (Rem = pRing->SizeOfBuffer - WrOff; => Space until end of buffer)
|
||||
_LoopCopyBeforeWrapAround: // memcpy(pRing->pBuffer + WrOff, pData, Rem); => Copy 1st chunk
|
||||
LDRB R3,[R1], #+1
|
||||
STRB R3,[R0], #+1 // *pDest++ = *pSrc++
|
||||
SUBS R4,R4,#+1
|
||||
BNE _LoopCopyBeforeWrapAround
|
||||
//
|
||||
// Special case: First check that assumed RdOff == 0 calculated that last element before wrap-around could not be used
|
||||
// But 2nd check (considering space until wrap-around and until RdOff) revealed that RdOff is not 0, so we can use the last element
|
||||
// In this case, we may use a copy straight until buffer end anyway without needing to copy 2 chunks
|
||||
// Therefore, check if 2nd memcpy is necessary at all
|
||||
//
|
||||
ADDS R4,R2,#+0 // Save <NumBytes> (needed as counter in loop but must be written to <WrOff> after the loop). Also use this inst to update the flags to skip 2nd loop if possible
|
||||
BEQ.N _No2ChunkNeeded // if (NumBytes) {
|
||||
_LoopCopyAfterWrapAround: // memcpy(pRing->pBuffer, pData + Rem, NumBytes);
|
||||
LDRB R3,[R1], #+1 // pData already points to the next src byte due to copy loop increment before this loop
|
||||
STRB R3,[R5], #+1 // *pDest++ = *pSrc++
|
||||
SUBS R2,R2,#+1
|
||||
BNE _LoopCopyAfterWrapAround
|
||||
_No2ChunkNeeded:
|
||||
STR R4,[R6, #+12] // pRing->WrOff = NumBytes; => Must be written after copying data because J-Link may read control block asynchronously while writing into buffer
|
||||
MOVS R0,#+1
|
||||
POP {R4-R7}
|
||||
BX LR // Return 1
|
||||
_CheckCase4:
|
||||
SUBS R0,R0,R7
|
||||
SUBS R0,R0,#+1 // Avail = RdOff - WrOff - 1u;
|
||||
CMP R0,R2
|
||||
BCS.N _Case4 // if (Avail >= NumBytes) { => Case 4) == 1) ? => If not, we have case 5) == 3) (does not fit)
|
||||
_Case3:
|
||||
MOVS R0,#+0
|
||||
POP {R4-R7}
|
||||
BX LR // Return 0
|
||||
_PLACE_LITS
|
||||
|
||||
#endif // defined (RTT_USE_ASM) && (RTT_USE_ASM == 1)
|
||||
_END
|
||||
|
||||
/*************************** End of file ****************************/
|
||||
@@ -0,0 +1,384 @@
|
||||
/*********************************************************************
|
||||
* SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
**********************************************************************
|
||||
* *
|
||||
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
|
||||
* *
|
||||
* www.segger.com Support: support@segger.com *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* SEGGER RTT * Real Time Transfer for embedded targets *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* SEGGER strongly recommends to not make any changes *
|
||||
* to or modify the source code of this software in order to stay *
|
||||
* compatible with the RTT protocol and J-Link. *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or *
|
||||
* without modification, are permitted provided that the following *
|
||||
* condition is met: *
|
||||
* *
|
||||
* o Redistributions of source code must retain the above copyright *
|
||||
* notice, this condition and the following disclaimer. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
|
||||
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
|
||||
* DAMAGE. *
|
||||
* *
|
||||
**********************************************************************
|
||||
---------------------------END-OF-HEADER------------------------------
|
||||
File : SEGGER_RTT_Conf.h
|
||||
Purpose : Implementation of SEGGER real-time transfer (RTT) which
|
||||
allows real-time communication on targets which support
|
||||
debugger memory accesses while the CPU is running.
|
||||
Revision: $Rev: 18601 $
|
||||
|
||||
*/
|
||||
|
||||
#ifndef SEGGER_RTT_CONF_H
|
||||
#define SEGGER_RTT_CONF_H
|
||||
|
||||
#ifdef __IAR_SYSTEMS_ICC__
|
||||
#include <intrinsics.h>
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines, configurable
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
#ifndef SEGGER_RTT_MAX_NUM_UP_BUFFERS
|
||||
#define SEGGER_RTT_MAX_NUM_UP_BUFFERS (3) // Max. number of up-buffers (T->H) available on this target (Default: 3)
|
||||
#endif
|
||||
|
||||
#ifndef SEGGER_RTT_MAX_NUM_DOWN_BUFFERS
|
||||
#define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (3) // Max. number of down-buffers (H->T) available on this target (Default: 3)
|
||||
#endif
|
||||
|
||||
#ifndef BUFFER_SIZE_UP
|
||||
#define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host (Default: 1k)
|
||||
#endif
|
||||
|
||||
#ifndef BUFFER_SIZE_DOWN
|
||||
#define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16)
|
||||
#endif
|
||||
|
||||
#ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE
|
||||
#define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64)
|
||||
#endif
|
||||
|
||||
#ifndef SEGGER_RTT_MODE_DEFAULT
|
||||
#define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0)
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT memcpy configuration
|
||||
*
|
||||
* memcpy() is good for large amounts of data,
|
||||
* but the overhead is big for small amounts, which are usually stored via RTT.
|
||||
* With SEGGER_RTT_MEMCPY_USE_BYTELOOP a simple byte loop can be used instead.
|
||||
*
|
||||
* SEGGER_RTT_MEMCPY() can be used to replace standard memcpy() in RTT functions.
|
||||
* This is may be required with memory access restrictions,
|
||||
* such as on Cortex-A devices with MMU.
|
||||
*/
|
||||
#ifndef SEGGER_RTT_MEMCPY_USE_BYTELOOP
|
||||
#define SEGGER_RTT_MEMCPY_USE_BYTELOOP 0 // 0: Use memcpy/SEGGER_RTT_MEMCPY, 1: Use a simple byte-loop
|
||||
#endif
|
||||
//
|
||||
// Example definition of SEGGER_RTT_MEMCPY to external memcpy with GCC toolchains and Cortex-A targets
|
||||
//
|
||||
//#if ((defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__)) && (defined (__ARM_ARCH_7A__))
|
||||
// #define SEGGER_RTT_MEMCPY(pDest, pSrc, NumBytes) SEGGER_memcpy((pDest), (pSrc), (NumBytes))
|
||||
//#endif
|
||||
|
||||
//
|
||||
// Target is not allowed to perform other RTT operations while string still has not been stored completely.
|
||||
// Otherwise we would probably end up with a mixed string in the buffer.
|
||||
// If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here.
|
||||
//
|
||||
// SEGGER_RTT_MAX_INTERRUPT_PRIORITY can be used in the sample lock routines on Cortex-M3/4.
|
||||
// Make sure to mask all interrupts which can send RTT data, i.e. generate SystemView events, or cause task switches.
|
||||
// When high-priority interrupts must not be masked while sending RTT data, SEGGER_RTT_MAX_INTERRUPT_PRIORITY needs to be adjusted accordingly.
|
||||
// (Higher priority = lower priority number)
|
||||
// Default value for embOS: 128u
|
||||
// Default configuration in FreeRTOS: configMAX_SYSCALL_INTERRUPT_PRIORITY: ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||
// In case of doubt mask all interrupts: 1 << (8 - BASEPRI_PRIO_BITS) i.e. 1 << 5 when 3 bits are implemented in NVIC
|
||||
// or define SEGGER_RTT_LOCK() to completely disable interrupts.
|
||||
//
|
||||
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
|
||||
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20)
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for SEGGER Embedded Studio,
|
||||
* Rowley CrossStudio and GCC
|
||||
*/
|
||||
#if ((defined(__SES_ARM) || defined(__SES_RISCV) || defined(__CROSSWORKS_ARM) || defined(__GNUC__) || defined(__clang__)) && !defined (__CC_ARM) && !defined(WIN32))
|
||||
#if (defined(__ARM_ARCH_6M__) || defined(__ARM_ARCH_8M_BASE__))
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
__asm volatile ("mrs %0, primask \n\t" \
|
||||
"movs r1, $1 \n\t" \
|
||||
"msr primask, r1 \n\t" \
|
||||
: "=r" (LockState) \
|
||||
: \
|
||||
: "r1" \
|
||||
);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __asm volatile ("msr primask, %0 \n\t" \
|
||||
: \
|
||||
: "r" (LockState) \
|
||||
: \
|
||||
); \
|
||||
}
|
||||
#elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_8M_MAIN__))
|
||||
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
|
||||
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
|
||||
#endif
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
__asm volatile ("mrs %0, basepri \n\t" \
|
||||
"mov r1, %1 \n\t" \
|
||||
"msr basepri, r1 \n\t" \
|
||||
: "=r" (LockState) \
|
||||
: "i"(SEGGER_RTT_MAX_INTERRUPT_PRIORITY) \
|
||||
: "r1" \
|
||||
);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __asm volatile ("msr basepri, %0 \n\t" \
|
||||
: \
|
||||
: "r" (LockState) \
|
||||
: \
|
||||
); \
|
||||
}
|
||||
|
||||
#elif defined(__ARM_ARCH_7A__)
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
__asm volatile ("mrs r1, CPSR \n\t" \
|
||||
"mov %0, r1 \n\t" \
|
||||
"orr r1, r1, #0xC0 \n\t" \
|
||||
"msr CPSR_c, r1 \n\t" \
|
||||
: "=r" (LockState) \
|
||||
: \
|
||||
: "r1" \
|
||||
);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \
|
||||
"mrs r1, CPSR \n\t" \
|
||||
"bic r1, r1, #0xC0 \n\t" \
|
||||
"and r0, r0, #0xC0 \n\t" \
|
||||
"orr r1, r1, r0 \n\t" \
|
||||
"msr CPSR_c, r1 \n\t" \
|
||||
: \
|
||||
: "r" (LockState) \
|
||||
: "r0", "r1" \
|
||||
); \
|
||||
}
|
||||
#elif defined(__riscv) || defined(__riscv_xlen)
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
__asm volatile ("csrr %0, mstatus \n\t" \
|
||||
"csrci mstatus, 8 \n\t" \
|
||||
"andi %0, %0, 8 \n\t" \
|
||||
: "=r" (LockState) \
|
||||
: \
|
||||
: \
|
||||
);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __asm volatile ("csrr a1, mstatus \n\t" \
|
||||
"or %0, %0, a1 \n\t" \
|
||||
"csrs mstatus, %0 \n\t" \
|
||||
: \
|
||||
: "r" (LockState) \
|
||||
: "a1" \
|
||||
); \
|
||||
}
|
||||
#else
|
||||
#define SEGGER_RTT_LOCK()
|
||||
#define SEGGER_RTT_UNLOCK()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for IAR EWARM
|
||||
*/
|
||||
#ifdef __ICCARM__
|
||||
#if (defined (__ARM6M__) && (__CORE__ == __ARM6M__)) || \
|
||||
(defined (__ARM8M_BASELINE__) && (__CORE__ == __ARM8M_BASELINE__))
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
LockState = __get_PRIMASK(); \
|
||||
__set_PRIMASK(1);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \
|
||||
}
|
||||
#elif (defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || \
|
||||
(defined (__ARM7M__) && (__CORE__ == __ARM7M__)) || \
|
||||
(defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__)) || \
|
||||
(defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__))
|
||||
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
|
||||
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
|
||||
#endif
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
LockState = __get_BASEPRI(); \
|
||||
__set_BASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __set_BASEPRI(LockState); \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for IAR RX
|
||||
*/
|
||||
#ifdef __ICCRX__
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned long LockState; \
|
||||
LockState = __get_interrupt_state(); \
|
||||
__disable_interrupt();
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __set_interrupt_state(LockState); \
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for IAR RL78
|
||||
*/
|
||||
#ifdef __ICCRL78__
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
__istate_t LockState; \
|
||||
LockState = __get_interrupt_state(); \
|
||||
__disable_interrupt();
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __set_interrupt_state(LockState); \
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for KEIL ARM
|
||||
*/
|
||||
#ifdef __CC_ARM
|
||||
#if (defined __TARGET_ARCH_6S_M)
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
register unsigned char PRIMASK __asm( "primask"); \
|
||||
LockState = PRIMASK; \
|
||||
PRIMASK = 1u; \
|
||||
__schedule_barrier();
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() PRIMASK = LockState; \
|
||||
__schedule_barrier(); \
|
||||
}
|
||||
#elif (defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M))
|
||||
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
|
||||
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
|
||||
#endif
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
register unsigned char BASEPRI __asm( "basepri"); \
|
||||
LockState = BASEPRI; \
|
||||
BASEPRI = SEGGER_RTT_MAX_INTERRUPT_PRIORITY; \
|
||||
__schedule_barrier();
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() BASEPRI = LockState; \
|
||||
__schedule_barrier(); \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for TI ARM
|
||||
*/
|
||||
#ifdef __TI_ARM__
|
||||
#if defined (__TI_ARM_V6M0__)
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
LockState = __get_PRIMASK(); \
|
||||
__set_PRIMASK(1);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \
|
||||
}
|
||||
#elif (defined (__TI_ARM_V7M3__) || defined (__TI_ARM_V7M4__))
|
||||
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
|
||||
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
|
||||
#endif
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
LockState = _set_interrupt_priority(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() _set_interrupt_priority(LockState); \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for CCRX
|
||||
*/
|
||||
#ifdef __RX
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned long LockState; \
|
||||
LockState = get_psw() & 0x010000; \
|
||||
clrpsw_i();
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() set_psw(get_psw() | LockState); \
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for embOS Simulation on Windows
|
||||
* (Can also be used for generic RTT locking with embOS)
|
||||
*/
|
||||
#if defined(WIN32) || defined(SEGGER_RTT_LOCK_EMBOS)
|
||||
|
||||
void OS_SIM_EnterCriticalSection(void);
|
||||
void OS_SIM_LeaveCriticalSection(void);
|
||||
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
OS_SIM_EnterCriticalSection();
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() OS_SIM_LeaveCriticalSection(); \
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration fallback
|
||||
*/
|
||||
#ifndef SEGGER_RTT_LOCK
|
||||
#define SEGGER_RTT_LOCK() // Lock RTT (nestable) (i.e. disable interrupts)
|
||||
#endif
|
||||
|
||||
#ifndef SEGGER_RTT_UNLOCK
|
||||
#define SEGGER_RTT_UNLOCK() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*************************** End of file ****************************/
|
||||
@@ -0,0 +1,500 @@
|
||||
/*********************************************************************
|
||||
* SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
**********************************************************************
|
||||
* *
|
||||
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
|
||||
* *
|
||||
* www.segger.com Support: support@segger.com *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* SEGGER RTT * Real Time Transfer for embedded targets *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* SEGGER strongly recommends to not make any changes *
|
||||
* to or modify the source code of this software in order to stay *
|
||||
* compatible with the RTT protocol and J-Link. *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or *
|
||||
* without modification, are permitted provided that the following *
|
||||
* condition is met: *
|
||||
* *
|
||||
* o Redistributions of source code must retain the above copyright *
|
||||
* notice, this condition and the following disclaimer. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
|
||||
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
|
||||
* DAMAGE. *
|
||||
* *
|
||||
**********************************************************************
|
||||
---------------------------END-OF-HEADER------------------------------
|
||||
File : SEGGER_RTT_printf.c
|
||||
Purpose : Replacement for printf to write formatted data via RTT
|
||||
Revision: $Rev: 17697 $
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
#include "SEGGER_RTT.h"
|
||||
#include "SEGGER_RTT_Conf.h"
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines, configurable
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE
|
||||
#define SEGGER_RTT_PRINTF_BUFFER_SIZE (64)
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
#define FORMAT_FLAG_LEFT_JUSTIFY (1u << 0)
|
||||
#define FORMAT_FLAG_PAD_ZERO (1u << 1)
|
||||
#define FORMAT_FLAG_PRINT_SIGN (1u << 2)
|
||||
#define FORMAT_FLAG_ALTERNATE (1u << 3)
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Types
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
char* pBuffer;
|
||||
unsigned BufferSize;
|
||||
unsigned Cnt;
|
||||
|
||||
int ReturnValue;
|
||||
|
||||
unsigned RTTBufferIndex;
|
||||
} SEGGER_RTT_PRINTF_DESC;
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function prototypes
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Static code
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
/*********************************************************************
|
||||
*
|
||||
* _StoreChar
|
||||
*/
|
||||
static void _StoreChar(SEGGER_RTT_PRINTF_DESC * p, char c) {
|
||||
unsigned Cnt;
|
||||
|
||||
Cnt = p->Cnt;
|
||||
if ((Cnt + 1u) <= p->BufferSize) {
|
||||
*(p->pBuffer + Cnt) = c;
|
||||
p->Cnt = Cnt + 1u;
|
||||
p->ReturnValue++;
|
||||
}
|
||||
//
|
||||
// Write part of string, when the buffer is full
|
||||
//
|
||||
if (p->Cnt == p->BufferSize) {
|
||||
if (SEGGER_RTT_Write(p->RTTBufferIndex, p->pBuffer, p->Cnt) != p->Cnt) {
|
||||
p->ReturnValue = -1;
|
||||
} else {
|
||||
p->Cnt = 0u;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _PrintUnsigned
|
||||
*/
|
||||
static void _PrintUnsigned(SEGGER_RTT_PRINTF_DESC * pBufferDesc, unsigned v, unsigned Base, unsigned NumDigits, unsigned FieldWidth, unsigned FormatFlags) {
|
||||
static const char _aV2C[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||
unsigned Div;
|
||||
unsigned Digit;
|
||||
unsigned Number;
|
||||
unsigned Width;
|
||||
char c;
|
||||
|
||||
Number = v;
|
||||
Digit = 1u;
|
||||
//
|
||||
// Get actual field width
|
||||
//
|
||||
Width = 1u;
|
||||
while (Number >= Base) {
|
||||
Number = (Number / Base);
|
||||
Width++;
|
||||
}
|
||||
if (NumDigits > Width) {
|
||||
Width = NumDigits;
|
||||
}
|
||||
//
|
||||
// Print leading chars if necessary
|
||||
//
|
||||
if ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u) {
|
||||
if (FieldWidth != 0u) {
|
||||
if (((FormatFlags & FORMAT_FLAG_PAD_ZERO) == FORMAT_FLAG_PAD_ZERO) && (NumDigits == 0u)) {
|
||||
c = '0';
|
||||
} else {
|
||||
c = ' ';
|
||||
}
|
||||
while ((FieldWidth != 0u) && (Width < FieldWidth)) {
|
||||
FieldWidth--;
|
||||
_StoreChar(pBufferDesc, c);
|
||||
if (pBufferDesc->ReturnValue < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pBufferDesc->ReturnValue >= 0) {
|
||||
//
|
||||
// Compute Digit.
|
||||
// Loop until Digit has the value of the highest digit required.
|
||||
// Example: If the output is 345 (Base 10), loop 2 times until Digit is 100.
|
||||
//
|
||||
while (1) {
|
||||
if (NumDigits > 1u) { // User specified a min number of digits to print? => Make sure we loop at least that often, before checking anything else (> 1 check avoids problems with NumDigits being signed / unsigned)
|
||||
NumDigits--;
|
||||
} else {
|
||||
Div = v / Digit;
|
||||
if (Div < Base) { // Is our divider big enough to extract the highest digit from value? => Done
|
||||
break;
|
||||
}
|
||||
}
|
||||
Digit *= Base;
|
||||
}
|
||||
//
|
||||
// Output digits
|
||||
//
|
||||
do {
|
||||
Div = v / Digit;
|
||||
v -= Div * Digit;
|
||||
_StoreChar(pBufferDesc, _aV2C[Div]);
|
||||
if (pBufferDesc->ReturnValue < 0) {
|
||||
break;
|
||||
}
|
||||
Digit /= Base;
|
||||
} while (Digit);
|
||||
//
|
||||
// Print trailing spaces if necessary
|
||||
//
|
||||
if ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == FORMAT_FLAG_LEFT_JUSTIFY) {
|
||||
if (FieldWidth != 0u) {
|
||||
while ((FieldWidth != 0u) && (Width < FieldWidth)) {
|
||||
FieldWidth--;
|
||||
_StoreChar(pBufferDesc, ' ');
|
||||
if (pBufferDesc->ReturnValue < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _PrintInt
|
||||
*/
|
||||
static void _PrintInt(SEGGER_RTT_PRINTF_DESC * pBufferDesc, int v, unsigned Base, unsigned NumDigits, unsigned FieldWidth, unsigned FormatFlags) {
|
||||
unsigned Width;
|
||||
int Number;
|
||||
|
||||
Number = (v < 0) ? -v : v;
|
||||
|
||||
//
|
||||
// Get actual field width
|
||||
//
|
||||
Width = 1u;
|
||||
while (Number >= (int)Base) {
|
||||
Number = (Number / (int)Base);
|
||||
Width++;
|
||||
}
|
||||
if (NumDigits > Width) {
|
||||
Width = NumDigits;
|
||||
}
|
||||
if ((FieldWidth > 0u) && ((v < 0) || ((FormatFlags & FORMAT_FLAG_PRINT_SIGN) == FORMAT_FLAG_PRINT_SIGN))) {
|
||||
FieldWidth--;
|
||||
}
|
||||
|
||||
//
|
||||
// Print leading spaces if necessary
|
||||
//
|
||||
if ((((FormatFlags & FORMAT_FLAG_PAD_ZERO) == 0u) || (NumDigits != 0u)) && ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u)) {
|
||||
if (FieldWidth != 0u) {
|
||||
while ((FieldWidth != 0u) && (Width < FieldWidth)) {
|
||||
FieldWidth--;
|
||||
_StoreChar(pBufferDesc, ' ');
|
||||
if (pBufferDesc->ReturnValue < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// Print sign if necessary
|
||||
//
|
||||
if (pBufferDesc->ReturnValue >= 0) {
|
||||
if (v < 0) {
|
||||
v = -v;
|
||||
_StoreChar(pBufferDesc, '-');
|
||||
} else if ((FormatFlags & FORMAT_FLAG_PRINT_SIGN) == FORMAT_FLAG_PRINT_SIGN) {
|
||||
_StoreChar(pBufferDesc, '+');
|
||||
} else {
|
||||
|
||||
}
|
||||
if (pBufferDesc->ReturnValue >= 0) {
|
||||
//
|
||||
// Print leading zeros if necessary
|
||||
//
|
||||
if (((FormatFlags & FORMAT_FLAG_PAD_ZERO) == FORMAT_FLAG_PAD_ZERO) && ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u) && (NumDigits == 0u)) {
|
||||
if (FieldWidth != 0u) {
|
||||
while ((FieldWidth != 0u) && (Width < FieldWidth)) {
|
||||
FieldWidth--;
|
||||
_StoreChar(pBufferDesc, '0');
|
||||
if (pBufferDesc->ReturnValue < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pBufferDesc->ReturnValue >= 0) {
|
||||
//
|
||||
// Print number without sign
|
||||
//
|
||||
_PrintUnsigned(pBufferDesc, (unsigned)v, Base, NumDigits, FieldWidth, FormatFlags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Public code
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
/*********************************************************************
|
||||
*
|
||||
* SEGGER_RTT_vprintf
|
||||
*
|
||||
* Function description
|
||||
* Stores a formatted string in SEGGER RTT control block.
|
||||
* This data is read by the host.
|
||||
*
|
||||
* Parameters
|
||||
* BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal")
|
||||
* sFormat Pointer to format string
|
||||
* pParamList Pointer to the list of arguments for the format string
|
||||
*
|
||||
* Return values
|
||||
* >= 0: Number of bytes which have been stored in the "Up"-buffer.
|
||||
* < 0: Error
|
||||
*/
|
||||
int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList) {
|
||||
char c;
|
||||
SEGGER_RTT_PRINTF_DESC BufferDesc;
|
||||
int v;
|
||||
unsigned NumDigits;
|
||||
unsigned FormatFlags;
|
||||
unsigned FieldWidth;
|
||||
char acBuffer[SEGGER_RTT_PRINTF_BUFFER_SIZE];
|
||||
|
||||
BufferDesc.pBuffer = acBuffer;
|
||||
BufferDesc.BufferSize = SEGGER_RTT_PRINTF_BUFFER_SIZE;
|
||||
BufferDesc.Cnt = 0u;
|
||||
BufferDesc.RTTBufferIndex = BufferIndex;
|
||||
BufferDesc.ReturnValue = 0;
|
||||
|
||||
do {
|
||||
c = *sFormat;
|
||||
sFormat++;
|
||||
if (c == 0u) {
|
||||
break;
|
||||
}
|
||||
if (c == '%') {
|
||||
//
|
||||
// Filter out flags
|
||||
//
|
||||
FormatFlags = 0u;
|
||||
v = 1;
|
||||
do {
|
||||
c = *sFormat;
|
||||
switch (c) {
|
||||
case '-': FormatFlags |= FORMAT_FLAG_LEFT_JUSTIFY; sFormat++; break;
|
||||
case '0': FormatFlags |= FORMAT_FLAG_PAD_ZERO; sFormat++; break;
|
||||
case '+': FormatFlags |= FORMAT_FLAG_PRINT_SIGN; sFormat++; break;
|
||||
case '#': FormatFlags |= FORMAT_FLAG_ALTERNATE; sFormat++; break;
|
||||
default: v = 0; break;
|
||||
}
|
||||
} while (v);
|
||||
//
|
||||
// filter out field with
|
||||
//
|
||||
FieldWidth = 0u;
|
||||
do {
|
||||
c = *sFormat;
|
||||
if ((c < '0') || (c > '9')) {
|
||||
break;
|
||||
}
|
||||
sFormat++;
|
||||
FieldWidth = (FieldWidth * 10u) + ((unsigned)c - '0');
|
||||
} while (1);
|
||||
|
||||
//
|
||||
// Filter out precision (number of digits to display)
|
||||
//
|
||||
NumDigits = 0u;
|
||||
c = *sFormat;
|
||||
if (c == '.') {
|
||||
sFormat++;
|
||||
do {
|
||||
c = *sFormat;
|
||||
if ((c < '0') || (c > '9')) {
|
||||
break;
|
||||
}
|
||||
sFormat++;
|
||||
NumDigits = NumDigits * 10u + ((unsigned)c - '0');
|
||||
} while (1);
|
||||
}
|
||||
//
|
||||
// Filter out length modifier
|
||||
//
|
||||
c = *sFormat;
|
||||
do {
|
||||
if ((c == 'l') || (c == 'h')) {
|
||||
sFormat++;
|
||||
c = *sFormat;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while (1);
|
||||
//
|
||||
// Handle specifiers
|
||||
//
|
||||
switch (c) {
|
||||
case 'c': {
|
||||
char c0;
|
||||
v = va_arg(*pParamList, int);
|
||||
c0 = (char)v;
|
||||
_StoreChar(&BufferDesc, c0);
|
||||
break;
|
||||
}
|
||||
case 'd':
|
||||
v = va_arg(*pParamList, int);
|
||||
_PrintInt(&BufferDesc, v, 10u, NumDigits, FieldWidth, FormatFlags);
|
||||
break;
|
||||
case 'u':
|
||||
v = va_arg(*pParamList, int);
|
||||
_PrintUnsigned(&BufferDesc, (unsigned)v, 10u, NumDigits, FieldWidth, FormatFlags);
|
||||
break;
|
||||
case 'x':
|
||||
case 'X':
|
||||
v = va_arg(*pParamList, int);
|
||||
_PrintUnsigned(&BufferDesc, (unsigned)v, 16u, NumDigits, FieldWidth, FormatFlags);
|
||||
break;
|
||||
case 's':
|
||||
{
|
||||
const char * s = va_arg(*pParamList, const char *);
|
||||
do {
|
||||
c = *s;
|
||||
s++;
|
||||
if (c == '\0') {
|
||||
break;
|
||||
}
|
||||
_StoreChar(&BufferDesc, c);
|
||||
} while (BufferDesc.ReturnValue >= 0);
|
||||
}
|
||||
break;
|
||||
case 'p':
|
||||
v = va_arg(*pParamList, int);
|
||||
_PrintUnsigned(&BufferDesc, (unsigned)v, 16u, 8u, 8u, 0u);
|
||||
break;
|
||||
case '%':
|
||||
_StoreChar(&BufferDesc, '%');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
sFormat++;
|
||||
} else {
|
||||
_StoreChar(&BufferDesc, c);
|
||||
}
|
||||
} while (BufferDesc.ReturnValue >= 0);
|
||||
|
||||
if (BufferDesc.ReturnValue > 0) {
|
||||
//
|
||||
// Write remaining data, if any
|
||||
//
|
||||
if (BufferDesc.Cnt != 0u) {
|
||||
SEGGER_RTT_Write(BufferIndex, acBuffer, BufferDesc.Cnt);
|
||||
}
|
||||
BufferDesc.ReturnValue += (int)BufferDesc.Cnt;
|
||||
}
|
||||
return BufferDesc.ReturnValue;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* SEGGER_RTT_printf
|
||||
*
|
||||
* Function description
|
||||
* Stores a formatted string in SEGGER RTT control block.
|
||||
* This data is read by the host.
|
||||
*
|
||||
* Parameters
|
||||
* BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal")
|
||||
* sFormat Pointer to format string, followed by the arguments for conversion
|
||||
*
|
||||
* Return values
|
||||
* >= 0: Number of bytes which have been stored in the "Up"-buffer.
|
||||
* < 0: Error
|
||||
*
|
||||
* Notes
|
||||
* (1) Conversion specifications have following syntax:
|
||||
* %[flags][FieldWidth][.Precision]ConversionSpecifier
|
||||
* (2) Supported flags:
|
||||
* -: Left justify within the field width
|
||||
* +: Always print sign extension for signed conversions
|
||||
* 0: Pad with 0 instead of spaces. Ignored when using '-'-flag or precision
|
||||
* Supported conversion specifiers:
|
||||
* c: Print the argument as one char
|
||||
* d: Print the argument as a signed integer
|
||||
* u: Print the argument as an unsigned integer
|
||||
* x: Print the argument as an hexadecimal integer
|
||||
* s: Print the string pointed to by the argument
|
||||
* p: Print the argument as an 8-digit hexadecimal integer. (Argument shall be a pointer to void.)
|
||||
*/
|
||||
int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...) {
|
||||
int r;
|
||||
va_list ParamList;
|
||||
|
||||
va_start(ParamList, sFormat);
|
||||
r = SEGGER_RTT_vprintf(BufferIndex, sFormat, &ParamList);
|
||||
va_end(ParamList);
|
||||
return r;
|
||||
}
|
||||
/*************************** End of file ****************************/
|
||||
@@ -0,0 +1,120 @@
|
||||
/*********************************************************************
|
||||
* SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
**********************************************************************
|
||||
* *
|
||||
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
|
||||
* *
|
||||
* www.segger.com Support: support@segger.com *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* SEGGER RTT * Real Time Transfer for embedded targets *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* SEGGER strongly recommends to not make any changes *
|
||||
* to or modify the source code of this software in order to stay *
|
||||
* compatible with the RTT protocol and J-Link. *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or *
|
||||
* without modification, are permitted provided that the following *
|
||||
* condition is met: *
|
||||
* *
|
||||
* o Redistributions of source code must retain the above copyright *
|
||||
* notice, this condition and the following disclaimer. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
|
||||
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
|
||||
* DAMAGE. *
|
||||
* *
|
||||
**********************************************************************
|
||||
---------------------------END-OF-HEADER------------------------------
|
||||
File : SEGGER_RTT_Syscalls_GCC.c
|
||||
Purpose : Low-level functions for using printf() via RTT in GCC.
|
||||
To use RTT for printf output, include this file in your
|
||||
application.
|
||||
Revision: $Rev: 17697 $
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
#if (defined __GNUC__) && !(defined __SES_ARM) && !(defined __CROSSWORKS_ARM)
|
||||
|
||||
#include <reent.h> // required for _write_r
|
||||
#include "SEGGER_RTT.h"
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Types
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//
|
||||
// If necessary define the _reent struct
|
||||
// to match the one passed by the used standard library.
|
||||
//
|
||||
struct _reent;
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function prototypes
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
int _write(int file, char *ptr, int len);
|
||||
int _write_r(struct _reent *r, int file, const void *ptr, int len);
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Global functions
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _write()
|
||||
*
|
||||
* Function description
|
||||
* Low-level write function.
|
||||
* libc subroutines will use this system routine for output to all files,
|
||||
* including stdout.
|
||||
* Write data via RTT.
|
||||
*/
|
||||
int _write(int file, char *ptr, int len) {
|
||||
(void) file; /* Not used, avoid warning */
|
||||
SEGGER_RTT_Write(0, ptr, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _write_r()
|
||||
*
|
||||
* Function description
|
||||
* Low-level reentrant write function.
|
||||
* libc subroutines will use this system routine for output to all files,
|
||||
* including stdout.
|
||||
* Write data via RTT.
|
||||
*/
|
||||
int _write_r(struct _reent *r, int file, const void *ptr, int len) {
|
||||
(void) file; /* Not used, avoid warning */
|
||||
(void) r; /* Not used, avoid warning */
|
||||
SEGGER_RTT_Write(0, ptr, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
#endif
|
||||
/****** End Of File *************************************************/
|
||||
@@ -0,0 +1,115 @@
|
||||
/*********************************************************************
|
||||
* SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
**********************************************************************
|
||||
* *
|
||||
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
|
||||
* *
|
||||
* www.segger.com Support: support@segger.com *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* SEGGER RTT * Real Time Transfer for embedded targets *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* SEGGER strongly recommends to not make any changes *
|
||||
* to or modify the source code of this software in order to stay *
|
||||
* compatible with the RTT protocol and J-Link. *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or *
|
||||
* without modification, are permitted provided that the following *
|
||||
* condition is met: *
|
||||
* *
|
||||
* o Redistributions of source code must retain the above copyright *
|
||||
* notice, this condition and the following disclaimer. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
|
||||
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
|
||||
* DAMAGE. *
|
||||
* *
|
||||
**********************************************************************
|
||||
---------------------------END-OF-HEADER------------------------------
|
||||
File : SEGGER_RTT_Syscalls_IAR.c
|
||||
Purpose : Low-level functions for using printf() via RTT in IAR.
|
||||
To use RTT for printf output, include this file in your
|
||||
application and set the Library Configuration to Normal.
|
||||
Revision: $Rev: 17697 $
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
#ifdef __IAR_SYSTEMS_ICC__
|
||||
|
||||
//
|
||||
// Since IAR EWARM V8 and EWRX V4, yfuns.h is considered as deprecated and LowLevelIOInterface.h
|
||||
// shall be used instead. To not break any compatibility with older compiler versions, we have a
|
||||
// version check in here.
|
||||
//
|
||||
#if ((defined __ICCARM__) && (__VER__ >= 8000000)) || ((defined __ICCRX__) && (__VER__ >= 400))
|
||||
#include <LowLevelIOInterface.h>
|
||||
#else
|
||||
#include <yfuns.h>
|
||||
#endif
|
||||
|
||||
#include "SEGGER_RTT.h"
|
||||
#pragma module_name = "?__write"
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function prototypes
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
size_t __write(int handle, const unsigned char * buffer, size_t size);
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Global functions
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
/*********************************************************************
|
||||
*
|
||||
* __write()
|
||||
*
|
||||
* Function description
|
||||
* Low-level write function.
|
||||
* Standard library subroutines will use this system routine
|
||||
* for output to all files, including stdout.
|
||||
* Write data via RTT.
|
||||
*/
|
||||
size_t __write(int handle, const unsigned char * buffer, size_t size) {
|
||||
(void) handle; /* Not used, avoid warning */
|
||||
SEGGER_RTT_Write(0, (const char*)buffer, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* __write_buffered()
|
||||
*
|
||||
* Function description
|
||||
* Low-level write function.
|
||||
* Standard library subroutines will use this system routine
|
||||
* for output to all files, including stdout.
|
||||
* Write data via RTT.
|
||||
*/
|
||||
size_t __write_buffered(int handle, const unsigned char * buffer, size_t size) {
|
||||
(void) handle; /* Not used, avoid warning */
|
||||
SEGGER_RTT_Write(0, (const char*)buffer, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
#endif
|
||||
/****** End Of File *************************************************/
|
||||
@@ -0,0 +1,386 @@
|
||||
/*********************************************************************
|
||||
* SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
**********************************************************************
|
||||
* *
|
||||
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
|
||||
* *
|
||||
* www.segger.com Support: support@segger.com *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* SEGGER RTT * Real Time Transfer for embedded targets *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* SEGGER strongly recommends to not make any changes *
|
||||
* to or modify the source code of this software in order to stay *
|
||||
* compatible with the RTT protocol and J-Link. *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or *
|
||||
* without modification, are permitted provided that the following *
|
||||
* condition is met: *
|
||||
* *
|
||||
* o Redistributions of source code must retain the above copyright *
|
||||
* notice, this condition and the following disclaimer. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
|
||||
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
|
||||
* DAMAGE. *
|
||||
* *
|
||||
**********************************************************************
|
||||
---------------------------END-OF-HEADER------------------------------
|
||||
File : RTT_Syscalls_KEIL.c
|
||||
Purpose : Retargeting module for KEIL MDK-CM3.
|
||||
Low-level functions for using printf() via RTT
|
||||
Revision: $Rev: 17697 $
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
#ifdef __CC_ARM
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <rt_sys.h>
|
||||
#include <rt_misc.h>
|
||||
|
||||
#include "SEGGER_RTT.h"
|
||||
/*********************************************************************
|
||||
*
|
||||
* #pragmas
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
#pragma import(__use_no_semihosting)
|
||||
|
||||
#ifdef _MICROLIB
|
||||
#pragma import(__use_full_stdio)
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines non-configurable
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
/* Standard IO device handles - arbitrary, but any real file system handles must be
|
||||
less than 0x8000. */
|
||||
#define STDIN 0x8001 // Standard Input Stream
|
||||
#define STDOUT 0x8002 // Standard Output Stream
|
||||
#define STDERR 0x8003 // Standard Error Stream
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Public const
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
#if __ARMCC_VERSION < 5000000
|
||||
//const char __stdin_name[] = "STDIN";
|
||||
const char __stdout_name[] = "STDOUT";
|
||||
const char __stderr_name[] = "STDERR";
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Public code
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _ttywrch
|
||||
*
|
||||
* Function description:
|
||||
* Outputs a character to the console
|
||||
*
|
||||
* Parameters:
|
||||
* c - character to output
|
||||
*
|
||||
*/
|
||||
void _ttywrch(int c) {
|
||||
fputc(c, stdout); // stdout
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_open
|
||||
*
|
||||
* Function description:
|
||||
* Opens the device/file in order to do read/write operations
|
||||
*
|
||||
* Parameters:
|
||||
* sName - sName of the device/file to open
|
||||
* OpenMode - This parameter is currently ignored
|
||||
*
|
||||
* Return value:
|
||||
* != 0 - Handle to the object to open, otherwise
|
||||
* == 0 -"device" is not handled by this module
|
||||
*
|
||||
*/
|
||||
FILEHANDLE _sys_open(const char * sName, int OpenMode) {
|
||||
(void)OpenMode;
|
||||
// Register standard Input Output devices.
|
||||
if (strcmp(sName, __stdout_name) == 0) {
|
||||
return (STDOUT);
|
||||
} else if (strcmp(sName, __stderr_name) == 0) {
|
||||
return (STDERR);
|
||||
} else
|
||||
return (0); // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_close
|
||||
*
|
||||
* Function description:
|
||||
* Closes the handle to the open device/file
|
||||
*
|
||||
* Parameters:
|
||||
* hFile - Handle to a file opened via _sys_open
|
||||
*
|
||||
* Return value:
|
||||
* 0 - device/file closed
|
||||
*
|
||||
*/
|
||||
int _sys_close(FILEHANDLE hFile) {
|
||||
(void)hFile;
|
||||
return 0; // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_write
|
||||
*
|
||||
* Function description:
|
||||
* Writes the data to an open handle.
|
||||
* Currently this function only outputs data to the console
|
||||
*
|
||||
* Parameters:
|
||||
* hFile - Handle to a file opened via _sys_open
|
||||
* pBuffer - Pointer to the data that shall be written
|
||||
* NumBytes - Number of bytes to write
|
||||
* Mode - The Mode that shall be used
|
||||
*
|
||||
* Return value:
|
||||
* Number of bytes *not* written to the file/device
|
||||
*
|
||||
*/
|
||||
int _sys_write(FILEHANDLE hFile, const unsigned char * pBuffer, unsigned NumBytes, int Mode) {
|
||||
int r = 0;
|
||||
|
||||
(void)Mode;
|
||||
if (hFile == STDOUT) {
|
||||
SEGGER_RTT_Write(0, (const char*)pBuffer, NumBytes);
|
||||
return 0;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_read
|
||||
*
|
||||
* Function description:
|
||||
* Reads data from an open handle.
|
||||
* Currently this modules does nothing.
|
||||
*
|
||||
* Parameters:
|
||||
* hFile - Handle to a file opened via _sys_open
|
||||
* pBuffer - Pointer to buffer to store the read data
|
||||
* NumBytes - Number of bytes to read
|
||||
* Mode - The Mode that shall be used
|
||||
*
|
||||
* Return value:
|
||||
* Number of bytes read from the file/device
|
||||
*
|
||||
*/
|
||||
int _sys_read(FILEHANDLE hFile, unsigned char * pBuffer, unsigned NumBytes, int Mode) {
|
||||
(void)hFile;
|
||||
(void)pBuffer;
|
||||
(void)NumBytes;
|
||||
(void)Mode;
|
||||
return (0); // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_istty
|
||||
*
|
||||
* Function description:
|
||||
* This function shall return whether the opened file
|
||||
* is a console device or not.
|
||||
*
|
||||
* Parameters:
|
||||
* hFile - Handle to a file opened via _sys_open
|
||||
*
|
||||
* Return value:
|
||||
* 1 - Device is a console
|
||||
* 0 - Device is not a console
|
||||
*
|
||||
*/
|
||||
int _sys_istty(FILEHANDLE hFile) {
|
||||
if (hFile > 0x8000) {
|
||||
return (1);
|
||||
}
|
||||
return (0); // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_seek
|
||||
*
|
||||
* Function description:
|
||||
* Seeks via the file to a specific position
|
||||
*
|
||||
* Parameters:
|
||||
* hFile - Handle to a file opened via _sys_open
|
||||
* Pos -
|
||||
*
|
||||
* Return value:
|
||||
* int -
|
||||
*
|
||||
*/
|
||||
int _sys_seek(FILEHANDLE hFile, long Pos) {
|
||||
(void)hFile;
|
||||
(void)Pos;
|
||||
return (0); // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_ensure
|
||||
*
|
||||
* Function description:
|
||||
*
|
||||
*
|
||||
* Parameters:
|
||||
* hFile - Handle to a file opened via _sys_open
|
||||
*
|
||||
* Return value:
|
||||
* int -
|
||||
*
|
||||
*/
|
||||
int _sys_ensure(FILEHANDLE hFile) {
|
||||
(void)hFile;
|
||||
return (-1); // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_flen
|
||||
*
|
||||
* Function description:
|
||||
* Returns the length of the opened file handle
|
||||
*
|
||||
* Parameters:
|
||||
* hFile - Handle to a file opened via _sys_open
|
||||
*
|
||||
* Return value:
|
||||
* Length of the file
|
||||
*
|
||||
*/
|
||||
long _sys_flen(FILEHANDLE hFile) {
|
||||
(void)hFile;
|
||||
return (0); // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_tmpnam
|
||||
*
|
||||
* Function description:
|
||||
* This function converts the file number fileno for a temporary
|
||||
* file to a unique filename, for example, tmp0001.
|
||||
*
|
||||
* Parameters:
|
||||
* pBuffer - Pointer to a buffer to store the name
|
||||
* FileNum - file number to convert
|
||||
* MaxLen - Size of the buffer
|
||||
*
|
||||
* Return value:
|
||||
* 1 - Error
|
||||
* 0 - Success
|
||||
*
|
||||
*/
|
||||
int _sys_tmpnam(char * pBuffer, int FileNum, unsigned MaxLen) {
|
||||
(void)pBuffer;
|
||||
(void)FileNum;
|
||||
(void)MaxLen;
|
||||
return (1); // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_command_string
|
||||
*
|
||||
* Function description:
|
||||
* This function shall execute a system command.
|
||||
*
|
||||
* Parameters:
|
||||
* cmd - Pointer to the command string
|
||||
* len - Length of the string
|
||||
*
|
||||
* Return value:
|
||||
* == NULL - Command was not successfully executed
|
||||
* == sCmd - Command was passed successfully
|
||||
*
|
||||
*/
|
||||
char * _sys_command_string(char * cmd, int len) {
|
||||
(void)len;
|
||||
return cmd; // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_exit
|
||||
*
|
||||
* Function description:
|
||||
* This function is called when the application returns from main
|
||||
*
|
||||
* Parameters:
|
||||
* ReturnCode - Return code from the main function
|
||||
*
|
||||
*
|
||||
*/
|
||||
void _sys_exit(int ReturnCode) {
|
||||
(void)ReturnCode;
|
||||
while (1); // Not implemented
|
||||
}
|
||||
|
||||
#if __ARMCC_VERSION >= 5000000
|
||||
/*********************************************************************
|
||||
*
|
||||
* stdout_putchar
|
||||
*
|
||||
* Function description:
|
||||
* Put a character to the stdout
|
||||
*
|
||||
* Parameters:
|
||||
* ch - Character to output
|
||||
*
|
||||
*
|
||||
*/
|
||||
int stdout_putchar(int ch) {
|
||||
(void)ch;
|
||||
return ch; // Not implemented
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*************************** End of file ****************************/
|
||||
@@ -0,0 +1,247 @@
|
||||
/*********************************************************************
|
||||
* SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
**********************************************************************
|
||||
* *
|
||||
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
|
||||
* *
|
||||
* www.segger.com Support: support@segger.com *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* SEGGER RTT * Real Time Transfer for embedded targets *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* SEGGER strongly recommends to not make any changes *
|
||||
* to or modify the source code of this software in order to stay *
|
||||
* compatible with the RTT protocol and J-Link. *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or *
|
||||
* without modification, are permitted provided that the following *
|
||||
* condition is met: *
|
||||
* *
|
||||
* o Redistributions of source code must retain the above copyright *
|
||||
* notice, this condition and the following disclaimer. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
|
||||
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
|
||||
* DAMAGE. *
|
||||
* *
|
||||
**********************************************************************
|
||||
---------------------------END-OF-HEADER------------------------------
|
||||
File : SEGGER_RTT_Syscalls_SES.c
|
||||
Purpose : Reimplementation of printf, puts and __getchar using RTT
|
||||
in SEGGER Embedded Studio.
|
||||
To use RTT for printf output, include this file in your
|
||||
application.
|
||||
Revision: $Rev: 18539 $
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
#if (defined __SES_ARM) || (defined __SES_RISCV) || (defined __CROSSWORKS_ARM)
|
||||
|
||||
#include "SEGGER_RTT.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include "limits.h"
|
||||
#include "__libc.h"
|
||||
#include "__vfprintf.h"
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines, configurable
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//
|
||||
// Select string formatting implementation.
|
||||
//
|
||||
// RTT printf formatting
|
||||
// - Configurable stack usage. (SEGGER_RTT_PRINTF_BUFFER_SIZE in SEGGER_RTT_Conf.h)
|
||||
// - No maximum string length.
|
||||
// - Limited conversion specifiers and flags. (See SEGGER_RTT_printf.c)
|
||||
// Standard library printf formatting
|
||||
// - Configurable formatting capabilities.
|
||||
// - Full conversion specifier and flag support.
|
||||
// - Maximum string length has to be known or (slightly) slower character-wise output.
|
||||
//
|
||||
// #define PRINTF_USE_SEGGER_RTT_FORMATTING 0 // Use standard library formatting
|
||||
// #define PRINTF_USE_SEGGER_RTT_FORMATTING 1 // Use RTT formatting
|
||||
//
|
||||
#ifndef PRINTF_USE_SEGGER_RTT_FORMATTING
|
||||
#define PRINTF_USE_SEGGER_RTT_FORMATTING 0
|
||||
#endif
|
||||
//
|
||||
// If using standard library formatting,
|
||||
// select maximum output string buffer size or character-wise output.
|
||||
//
|
||||
// #define PRINTF_BUFFER_SIZE 0 // Use character-wise output
|
||||
// #define PRINTF_BUFFER_SIZE 128 // Default maximum string length
|
||||
//
|
||||
#ifndef PRINTF_BUFFER_SIZE
|
||||
#define PRINTF_BUFFER_SIZE 128
|
||||
#endif
|
||||
|
||||
#if PRINTF_USE_SEGGER_RTT_FORMATTING // Use SEGGER RTT formatting implementation
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function prototypes
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList);
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Global functions, printf
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
/*********************************************************************
|
||||
*
|
||||
* printf()
|
||||
*
|
||||
* Function description
|
||||
* print a formatted string using RTT and SEGGER RTT formatting.
|
||||
*/
|
||||
int printf(const char *fmt,...) {
|
||||
int n;
|
||||
va_list args;
|
||||
|
||||
va_start (args, fmt);
|
||||
n = SEGGER_RTT_vprintf(0, fmt, &args);
|
||||
va_end(args);
|
||||
return n;
|
||||
}
|
||||
|
||||
#elif PRINTF_BUFFER_SIZE == 0 // Use standard library formatting with character-wise output
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Static functions
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
static int _putchar(int x, __printf_tag_ptr ctx) {
|
||||
(void)ctx;
|
||||
SEGGER_RTT_Write(0, (char *)&x, 1);
|
||||
return x;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Global functions, printf
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
/*********************************************************************
|
||||
*
|
||||
* printf()
|
||||
*
|
||||
* Function description
|
||||
* print a formatted string character-wise, using RTT and standard
|
||||
* library formatting.
|
||||
*/
|
||||
int printf(const char *fmt, ...) {
|
||||
int n;
|
||||
va_list args;
|
||||
__printf_t iod;
|
||||
|
||||
va_start(args, fmt);
|
||||
iod.string = 0;
|
||||
iod.maxchars = INT_MAX;
|
||||
iod.output_fn = _putchar;
|
||||
SEGGER_RTT_LOCK();
|
||||
n = __vfprintf(&iod, fmt, args);
|
||||
SEGGER_RTT_UNLOCK();
|
||||
va_end(args);
|
||||
return n;
|
||||
}
|
||||
|
||||
#else // Use standard library formatting with static buffer
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Global functions, printf
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
/*********************************************************************
|
||||
*
|
||||
* printf()
|
||||
*
|
||||
* Function description
|
||||
* print a formatted string using RTT and standard library formatting.
|
||||
*/
|
||||
int printf(const char *fmt,...) {
|
||||
int n;
|
||||
char aBuffer[PRINTF_BUFFER_SIZE];
|
||||
va_list args;
|
||||
|
||||
va_start (args, fmt);
|
||||
n = vsnprintf(aBuffer, sizeof(aBuffer), fmt, args);
|
||||
if (n > (int)sizeof(aBuffer)) {
|
||||
SEGGER_RTT_Write(0, aBuffer, sizeof(aBuffer));
|
||||
} else if (n > 0) {
|
||||
SEGGER_RTT_Write(0, aBuffer, n);
|
||||
}
|
||||
va_end(args);
|
||||
return n;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Global functions
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
/*********************************************************************
|
||||
*
|
||||
* puts()
|
||||
*
|
||||
* Function description
|
||||
* print a string using RTT.
|
||||
*/
|
||||
int puts(const char *s) {
|
||||
return SEGGER_RTT_WriteString(0, s);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* __putchar()
|
||||
*
|
||||
* Function description
|
||||
* Write one character via RTT.
|
||||
*/
|
||||
int __putchar(int x, __printf_tag_ptr ctx) {
|
||||
(void)ctx;
|
||||
SEGGER_RTT_Write(0, (char *)&x, 1);
|
||||
return x;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* __getchar()
|
||||
*
|
||||
* Function description
|
||||
* Wait for and get a character via RTT.
|
||||
*/
|
||||
int __getchar() {
|
||||
return SEGGER_RTT_WaitKey();
|
||||
}
|
||||
|
||||
#endif
|
||||
/****** End Of File *************************************************/
|
||||
@@ -39,10 +39,8 @@
|
||||
*/
|
||||
#include "app_util_platform.h"
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
/* Global nvic state instance, required by nrf_nvic.h */
|
||||
nrf_nvic_state_t nrf_nvic_state;
|
||||
#endif
|
||||
|
||||
static uint32_t m_in_critical_region = 0;
|
||||
|
||||
|
||||
@@ -52,10 +52,8 @@
|
||||
#include <stdint.h>
|
||||
#include "compiler_abstraction.h"
|
||||
#include "nrf.h"
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
#include "nrf_soc.h"
|
||||
#include "nrf_nvic.h"
|
||||
#endif
|
||||
#include "nrf_assert.h"
|
||||
#include "app_error.h"
|
||||
|
||||
|
||||
@@ -32,15 +32,18 @@
|
||||
static uint16_t service_handle;
|
||||
static ble_gatts_char_handles_t manufact_name_handles;
|
||||
static ble_gatts_char_handles_t model_num_handles;
|
||||
static ble_gatts_char_handles_t fw_rev_handles;
|
||||
static ble_gatts_char_handles_t pnp_id_handles;
|
||||
|
||||
#if 0
|
||||
static ble_gatts_char_handles_t serial_num_handles;
|
||||
static ble_gatts_char_handles_t hw_rev_handles;
|
||||
static ble_gatts_char_handles_t fw_rev_handles;
|
||||
static ble_gatts_char_handles_t sw_rev_handles;
|
||||
static ble_gatts_char_handles_t sys_id_handles;
|
||||
static ble_gatts_char_handles_t reg_cert_data_list_handles;
|
||||
static ble_gatts_char_handles_t pnp_id_handles;
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/**@brief Function for encoding a System ID.
|
||||
*
|
||||
* @param[out] p_encoded_buffer Buffer where the encoded data will be written.
|
||||
@@ -61,6 +64,7 @@ static void sys_id_encode(uint8_t * p_encoded_buffer, const ble_dis_sys_id_t * p
|
||||
p_encoded_buffer[6] = (p_sys_id->organizationally_unique_id & 0x00FF00) >> 8;
|
||||
p_encoded_buffer[7] = (p_sys_id->organizationally_unique_id & 0xFF0000) >> 16;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**@brief Function for encoding a PnP ID.
|
||||
@@ -182,6 +186,8 @@ uint32_t ble_dis_init(const ble_dis_init_t * p_dis_init)
|
||||
return err_code;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (p_dis_init->serial_num_str.length > 0)
|
||||
{
|
||||
err_code = char_add(BLE_UUID_SERIAL_NUMBER_STRING_CHAR,
|
||||
@@ -206,6 +212,8 @@ uint32_t ble_dis_init(const ble_dis_init_t * p_dis_init)
|
||||
return err_code;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (p_dis_init->fw_rev_str.length > 0)
|
||||
{
|
||||
err_code = char_add(BLE_UUID_FIRMWARE_REVISION_STRING_CHAR,
|
||||
@@ -218,6 +226,8 @@ uint32_t ble_dis_init(const ble_dis_init_t * p_dis_init)
|
||||
return err_code;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (p_dis_init->sw_rev_str.length > 0)
|
||||
{
|
||||
err_code = char_add(BLE_UUID_SOFTWARE_REVISION_STRING_CHAR,
|
||||
@@ -230,6 +240,7 @@ uint32_t ble_dis_init(const ble_dis_init_t * p_dis_init)
|
||||
return err_code;
|
||||
}
|
||||
}
|
||||
|
||||
if (p_dis_init->p_sys_id != NULL)
|
||||
{
|
||||
uint8_t encoded_sys_id[BLE_DIS_SYS_ID_LEN];
|
||||
@@ -257,6 +268,8 @@ uint32_t ble_dis_init(const ble_dis_init_t * p_dis_init)
|
||||
return err_code;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (p_dis_init->p_pnp_id != NULL)
|
||||
{
|
||||
uint8_t encoded_pnp_id[BLE_DIS_PNP_ID_LEN];
|
||||
|
||||
@@ -36,17 +36,6 @@
|
||||
#include "tusb.h"
|
||||
#endif
|
||||
|
||||
#define APP_TIMER_PRESCALER 0
|
||||
|
||||
#define IRQ_ENABLED 0x01 /**< Field identifying if an interrupt is enabled. */
|
||||
|
||||
/**< Maximum number of interrupts available. (from IRQn_Type) */
|
||||
#if defined(NRF52832_XXAA)
|
||||
#define MAX_NUMBER_INTERRUPTS 39
|
||||
#elif defined(NRF52840_XXAA) || defined(NRF52833_XXAA)
|
||||
#define MAX_NUMBER_INTERRUPTS 48
|
||||
#endif
|
||||
|
||||
/**@brief Enumeration for specifying current bootloader status.
|
||||
*/
|
||||
typedef enum
|
||||
@@ -60,6 +49,7 @@ typedef enum
|
||||
|
||||
static pstorage_handle_t m_bootsettings_handle; /**< Pstorage handle to use for registration and identifying the bootloader module on subsequent calls to the pstorage module for load and store of bootloader setting in flash. */
|
||||
static bootloader_status_t m_update_status; /**< Current update status for the bootloader module to ensure correct behaviour when updating settings and when update completes. */
|
||||
static bool m_cancel_timeout_on_usb; /**< If set the timeout is cancelled when USB is enumerated. Otherwise, the timeout is only cancelled when DFU update is started. */
|
||||
|
||||
APP_TIMER_DEF( _dfu_startup_timer );
|
||||
volatile bool dfu_startup_packet_received = false;
|
||||
@@ -90,7 +80,15 @@ static void pstorage_callback_handler(pstorage_handle_t * p_handle,
|
||||
*/
|
||||
static void dfu_startup_timer_handler(void * p_context)
|
||||
{
|
||||
// No packets are received within timeout, terminal and DFU mode
|
||||
#ifdef NRF_USBD
|
||||
if (m_cancel_timeout_on_usb && tud_mounted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// nRF52832 forced DFU on startup
|
||||
// No packets are received within timeout, exit DFU mode
|
||||
// dfu_startup_packet_received is set by process_dfu_packet() in dfu_transport_serial.c
|
||||
if (!dfu_startup_packet_received)
|
||||
{
|
||||
@@ -118,7 +116,7 @@ static void wait_for_events(void)
|
||||
// APP_ERROR_CHECK(err_code);
|
||||
|
||||
// Feed all Watchdog just in case application enable it
|
||||
// WDT cannot be disabled once started. It even last through soft reset (NVIC Reset)
|
||||
// WDT cannot be disabled once started. It even last through NVIC soft reset
|
||||
if ( nrf_wdt_started(NRF_WDT) )
|
||||
{
|
||||
for (uint8_t i=0; i<8; i++) nrf_wdt_reload_request_set(NRF_WDT, i);
|
||||
@@ -147,37 +145,40 @@ static void wait_for_events(void)
|
||||
}
|
||||
|
||||
|
||||
bool bootloader_app_is_valid(uint32_t app_addr)
|
||||
bool bootloader_app_is_valid(void)
|
||||
{
|
||||
bootloader_settings_t const * p_bootloader_settings;
|
||||
bool success = false;
|
||||
uint32_t const app_addr = DFU_BANK_0_REGION_START;
|
||||
|
||||
// There exists an application in CODE region 1.
|
||||
if (*((uint32_t *)app_addr) == EMPTY_FLASH_MASK)
|
||||
bootloader_settings_t const *p_bootloader_settings;
|
||||
bootloader_util_settings_get(&p_bootloader_settings);
|
||||
|
||||
enum { EMPTY_FLASH = 0xFFFFFFFFUL };
|
||||
|
||||
// Application is invalid if first 2 words are all 0xFFFFFFF
|
||||
if ( *((uint32_t *)app_addr ) == EMPTY_FLASH &&
|
||||
*((uint32_t *)(app_addr+4)) == EMPTY_FLASH )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// The application in CODE region 1 is flagged as valid during update.
|
||||
if ( p_bootloader_settings->bank_0 == BANK_VALID_APP )
|
||||
{
|
||||
uint16_t image_crc = 0;
|
||||
|
||||
// A stored crc value of 0 indicates that CRC checking is not used.
|
||||
if ( p_bootloader_settings->bank_0_crc != 0 )
|
||||
{
|
||||
return false;
|
||||
image_crc = crc16_compute((uint8_t*) app_addr,
|
||||
p_bootloader_settings->bank_0_size,
|
||||
NULL);
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
success = (image_crc == p_bootloader_settings->bank_0_crc);
|
||||
}
|
||||
|
||||
bootloader_util_settings_get(&p_bootloader_settings);
|
||||
|
||||
// The application in CODE region 1 is flagged as valid during update.
|
||||
if (p_bootloader_settings->bank_0 == BANK_VALID_APP)
|
||||
{
|
||||
uint16_t image_crc = 0;
|
||||
|
||||
// A stored crc value of 0 indicates that CRC checking is not used.
|
||||
if (p_bootloader_settings->bank_0_crc != 0)
|
||||
{
|
||||
image_crc = crc16_compute((uint8_t *)DFU_BANK_0_REGION_START,
|
||||
p_bootloader_settings->bank_0_size,
|
||||
NULL);
|
||||
}
|
||||
|
||||
success = (image_crc == p_bootloader_settings->bank_0_crc);
|
||||
}
|
||||
|
||||
return success;
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@@ -321,10 +322,12 @@ uint32_t bootloader_init(void)
|
||||
}
|
||||
|
||||
|
||||
uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms)
|
||||
uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms, bool cancel_timeout_on_usb)
|
||||
{
|
||||
uint32_t err_code;
|
||||
|
||||
m_cancel_timeout_on_usb = cancel_timeout_on_usb && !ota;
|
||||
|
||||
// Clear swap if banked update is used.
|
||||
err_code = dfu_init();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
@@ -334,7 +337,9 @@ uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms)
|
||||
err_code = dfu_transport_ble_update_start();
|
||||
}else
|
||||
{
|
||||
// timeout_ms > 0 is forced startup DFU
|
||||
// DFU mode with timeout can be
|
||||
// - Forced startup DFU for nRF52832 or
|
||||
// - Makecode single tap reset but no enumerated (battery power)
|
||||
if ( timeout_ms )
|
||||
{
|
||||
dfu_startup_packet_received = false;
|
||||
@@ -351,49 +356,51 @@ uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms)
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for disabling all interrupts before jumping from bootloader to application.
|
||||
*/
|
||||
static void interrupts_disable(void)
|
||||
void bootloader_app_start(void)
|
||||
{
|
||||
uint32_t interrupt_setting_mask;
|
||||
uint32_t irq = 0; // We start from first interrupt, i.e. interrupt 0.
|
||||
|
||||
// Fetch the current interrupt settings.
|
||||
interrupt_setting_mask = NVIC->ISER[0];
|
||||
|
||||
for (; irq < MAX_NUMBER_INTERRUPTS; irq++)
|
||||
{
|
||||
if (interrupt_setting_mask & (IRQ_ENABLED << irq))
|
||||
{
|
||||
// The interrupt was enabled, and hence disable it.
|
||||
NVIC_DisableIRQ((IRQn_Type)irq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void bootloader_app_start(uint32_t app_addr)
|
||||
{
|
||||
// If the applications CRC has been checked and passed, the magic number will be written and we
|
||||
// can start the application safely.
|
||||
APP_ERROR_CHECK ( sd_softdevice_disable() );
|
||||
|
||||
interrupts_disable();
|
||||
|
||||
#if 0 // may need set forward irq
|
||||
sd_mbr_command_t command =
|
||||
{
|
||||
.command = SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET,
|
||||
.params.irq_forward_address_set.address = MBR_SIZE,
|
||||
};
|
||||
|
||||
sd_mbr_command(&command);
|
||||
// Disable all interrupts
|
||||
NVIC->ICER[0]=0xFFFFFFFF;
|
||||
NVIC->ICPR[0]=0xFFFFFFFF;
|
||||
#if defined(__NRF_NVIC_ISER_COUNT) && __NRF_NVIC_ISER_COUNT == 2
|
||||
NVIC->ICER[1]=0xFFFFFFFF;
|
||||
NVIC->ICPR[1]=0xFFFFFFFF;
|
||||
#endif
|
||||
|
||||
APP_ERROR_CHECK( sd_softdevice_vector_table_base_set(CODE_REGION_1_START) );
|
||||
uint32_t fwd_ret;
|
||||
uint32_t app_addr;
|
||||
|
||||
bootloader_util_app_start(CODE_REGION_1_START);
|
||||
if ( is_sd_existed() )
|
||||
{
|
||||
PRINTF("SoftDevice exist\r\n");
|
||||
// App starts after SoftDevice
|
||||
app_addr = SD_SIZE_GET(MBR_SIZE);
|
||||
fwd_ret = sd_softdevice_vector_table_base_set(app_addr);
|
||||
}else
|
||||
{
|
||||
PRINTF("SoftDevice not exist\r\n");
|
||||
|
||||
// App starts right after MBR
|
||||
app_addr = MBR_SIZE;
|
||||
sd_mbr_command_t command =
|
||||
{
|
||||
.command = SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET,
|
||||
.params.irq_forward_address_set.address = app_addr,
|
||||
};
|
||||
|
||||
fwd_ret = sd_mbr_command(&command);
|
||||
}
|
||||
|
||||
// unlikely failed to forward vector table, manually set forward address
|
||||
if ( fwd_ret != NRF_SUCCESS )
|
||||
{
|
||||
PRINT_HEX(fwd_ret);
|
||||
|
||||
// MBR use first 4-bytes of SRAM to store foward address
|
||||
*(uint32_t *)(0x20000000) = app_addr;
|
||||
}
|
||||
|
||||
// jump to app
|
||||
bootloader_util_app_start(app_addr);
|
||||
}
|
||||
|
||||
|
||||
@@ -442,7 +449,8 @@ uint32_t bootloader_dfu_sd_update_continue(void)
|
||||
|
||||
uint32_t bootloader_dfu_sd_update_finalize(void)
|
||||
{
|
||||
dfu_update_status_t update_status = {DFU_UPDATE_SD_SWAPPED, };
|
||||
dfu_update_status_t update_status = { 0 };
|
||||
update_status.status_code = DFU_UPDATE_SD_SWAPPED;
|
||||
|
||||
bootloader_dfu_update_process(update_status);
|
||||
|
||||
|
||||
@@ -33,19 +33,16 @@
|
||||
uint32_t bootloader_init(void);
|
||||
|
||||
/**@brief Function for validating application region in flash.
|
||||
*
|
||||
* @param[in] app_addr Address to the region in flash where the application is stored.
|
||||
*
|
||||
* @retval true If Application region is valid.
|
||||
* @retval false If Application region is not valid.
|
||||
*/
|
||||
bool bootloader_app_is_valid(uint32_t app_addr);
|
||||
bool bootloader_app_is_valid(void);
|
||||
|
||||
/**@brief Function for starting the Device Firmware Update.
|
||||
*
|
||||
* @retval NRF_SUCCESS If new application image was successfully transferred.
|
||||
*/
|
||||
uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms);
|
||||
uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms, bool cancel_timeout_on_usb);
|
||||
|
||||
/**@brief Function for exiting bootloader and booting into application.
|
||||
*
|
||||
@@ -55,7 +52,7 @@ uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms);
|
||||
*
|
||||
* @param[in] app_addr Address to the region where the application is stored.
|
||||
*/
|
||||
void bootloader_app_start(uint32_t app_addr);
|
||||
void bootloader_app_start(void);
|
||||
|
||||
/**@brief Function for retrieving the bootloader settings.
|
||||
*
|
||||
@@ -92,6 +89,9 @@ uint32_t bootloader_dfu_sd_update_continue(void);
|
||||
*/
|
||||
uint32_t bootloader_dfu_sd_update_finalize(void);
|
||||
|
||||
|
||||
void bootloader_mbr_addrs_populate(void);
|
||||
|
||||
#endif // BOOTLOADER_H__
|
||||
|
||||
/**@} */
|
||||
@@ -13,45 +13,23 @@
|
||||
#include "bootloader_settings.h"
|
||||
#include <stdint.h>
|
||||
#include <dfu_types.h>
|
||||
#include "nrfx_nvmc.h"
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
/**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
|
||||
__attribute__ ((section(".bootloaderSettings")))
|
||||
uint8_t m_boot_settings[CODE_PAGE_SIZE];
|
||||
|
||||
uint8_t m_boot_settings[CODE_PAGE_SIZE] __attribute__((at(BOOTLOADER_SETTINGS_ADDRESS))) __attribute__((used)); /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
|
||||
uint32_t m_uicr_bootloader_start_address __attribute__((at(NRF_UICR_BOOT_START_ADDRESS))) = BOOTLOADER_REGION_START; /**< This variable makes the linker script write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
|
||||
/**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
|
||||
__attribute__ ((section(".uicrBootStartAddress")))
|
||||
volatile uint32_t m_uicr_bootloader_start_address = BOOTLOADER_REGION_START;
|
||||
|
||||
#elif defined ( __GNUC__ )
|
||||
|
||||
uint8_t m_boot_settings[CODE_PAGE_SIZE] __attribute__ ((section(".bootloaderSettings"))); /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
|
||||
volatile uint32_t m_uicr_bootloader_start_address __attribute__ ((section(".uicrBootStartAddress"))) = BOOTLOADER_REGION_START; /**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
|
||||
|
||||
#elif defined ( __ICCARM__ )
|
||||
|
||||
__no_init uint8_t m_boot_settings[CODE_PAGE_SIZE] @ BOOTLOADER_SETTINGS_ADDRESS; /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
|
||||
__root const uint32_t m_uicr_bootloader_start_address @ NRF_UICR_BOOT_START_ADDRESS = BOOTLOADER_REGION_START; /**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(NRF52_SERIES)
|
||||
#if defined ( __CC_ARM )
|
||||
|
||||
uint8_t m_mbr_params_page[CODE_PAGE_SIZE] __attribute__((at(BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS))) __attribute__((used)); /**< This variable reserves a codepage for mbr parameters, to ensure the compiler doesn't locate any code or variables at his location. */
|
||||
uint32_t m_uicr_mbr_params_page_address __attribute__((at(NRF_UICR_MBR_PARAMS_PAGE_ADDRESS)))
|
||||
= BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS; /**< This variable makes the linker script write the mbr parameters page address to the UICR register. This value will be written in the HEX file and thus written to the UICR when the bootloader is flashed into the chip */
|
||||
|
||||
#elif defined (__GNUC__ )
|
||||
|
||||
uint8_t m_mbr_params_page[CODE_PAGE_SIZE] __attribute__ ((section(".mbrParamsPage"))); /**< This variable reserves a codepage for mbr parameters, to ensure the compiler doesn't locate any code or variables at his location. */
|
||||
volatile uint32_t m_uicr_mbr_params_page_address __attribute__ ((section(".uicrMbrParamsPageAddress")))
|
||||
= BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS; /**< This variable makes the linker script write the mbr parameters page address to the UICR register. This value will be written in the HEX file and thus written to the UICR when the bootloader is flashed into the chip */
|
||||
|
||||
#elif defined (__ICCARM__ )
|
||||
|
||||
__no_init uint8_t m_mbr_params_page[CODE_PAGE_SIZE] @ BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS; /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
|
||||
__root const uint32_t m_uicr_mbr_params_page_address @ NRF_UICR_MBR_PARAMS_PAGE_ADDRESS = BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS; /**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
|
||||
|
||||
#endif
|
||||
#endif // NRF52_SERIES
|
||||
/**< This variable reserves a codepage for mbr parameters, to ensure the compiler doesn't locate any code or variables at his location. */
|
||||
__attribute__ ((section(".mbrParamsPage")))
|
||||
uint8_t m_mbr_params_page[CODE_PAGE_SIZE];
|
||||
|
||||
/**< This variable makes the linker script write the mbr parameters page address to the UICR register. This value will be written in the HEX file and thus written to the UICR when the bootloader is flashed into the chip */
|
||||
__attribute__ ((section(".uicrMbrParamsPageAddress")))
|
||||
volatile uint32_t m_uicr_mbr_params_page_address = BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS;
|
||||
|
||||
void bootloader_util_settings_get(const bootloader_settings_t ** pp_bootloader_settings)
|
||||
{
|
||||
@@ -61,3 +39,16 @@ void bootloader_util_settings_get(const bootloader_settings_t ** pp_bootloader_s
|
||||
|
||||
*pp_bootloader_settings = p_bootloader_settings;
|
||||
}
|
||||
|
||||
void bootloader_mbr_addrs_populate(void)
|
||||
{
|
||||
if (*(const uint32_t *)MBR_BOOTLOADER_ADDR == 0xFFFFFFFF)
|
||||
{
|
||||
nrfx_nvmc_word_write(MBR_BOOTLOADER_ADDR, BOOTLOADER_REGION_START);
|
||||
}
|
||||
|
||||
if (*(const uint32_t *)MBR_PARAM_PAGE_ADDR == 0xFFFFFFFF)
|
||||
{
|
||||
nrfx_nvmc_word_write(MBR_PARAM_PAGE_ADDR, BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS);
|
||||
}
|
||||
}
|
||||
@@ -40,9 +40,6 @@ typedef enum
|
||||
DFU_STATE_WAIT_4_ACTIVATE /**< State for: waiting for dfu_image_activate(). */
|
||||
} dfu_state_t;
|
||||
|
||||
#define APP_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. */
|
||||
#define DFU_TIMEOUT_INTERVAL APP_TIMER_TICKS(300000) /**< DFU timeout interval in units of timer ticks. */
|
||||
|
||||
#define IS_UPDATING_SD(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_SD) /**< Macro for determining if a SoftDevice update is ongoing. */
|
||||
#define IS_UPDATING_BL(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_BL) /**< Macro for determining if a Bootloader update is ongoing. */
|
||||
#define IS_UPDATING_APP(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_APP) /**< Macro for determining if a Application update is ongoing. */
|
||||
|
||||
@@ -1,843 +0,0 @@
|
||||
/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is property of Nordic Semiconductor ASA.
|
||||
* Terms and conditions of usage are described in detail in NORDIC
|
||||
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* Licensees are granted free, non-transferable use of the information. NO
|
||||
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
|
||||
* the file.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include "dfu.h"
|
||||
#include <dfu_types.h>
|
||||
#include "dfu_bank_internal.h"
|
||||
#include "nrf.h"
|
||||
#include "nrf_sdm.h"
|
||||
#include "app_error.h"
|
||||
#include "app_timer.h"
|
||||
#include "bootloader.h"
|
||||
#include "bootloader_types.h"
|
||||
#include "pstorage.h"
|
||||
#include "nrf_mbr.h"
|
||||
#include "dfu_init.h"
|
||||
#include "sdk_common.h"
|
||||
|
||||
static dfu_state_t m_dfu_state; /**< Current DFU state. */
|
||||
static uint32_t m_image_size; /**< Size of the image that will be transmitted. */
|
||||
|
||||
static dfu_start_packet_t m_start_packet; /**< Start packet received for this update procedure. Contains update mode and image sizes information to be used for image transfer. */
|
||||
static uint8_t m_init_packet[128]; /**< Init packet, can hold CRC, Hash, Signed Hash and similar, for image validation, integrety check and authorization checking. */
|
||||
static uint8_t m_init_packet_length; /**< Length of init packet received. */
|
||||
static uint16_t m_image_crc; /**< Calculated CRC of the image received. */
|
||||
|
||||
APP_TIMER_DEF(m_dfu_timer_id); /**< Application timer id. */
|
||||
static bool m_dfu_timed_out = false; /**< Boolean flag value for tracking DFU timer timeout state. */
|
||||
|
||||
static pstorage_handle_t m_storage_handle_swap; /**< Pstorage handle for the swap area (bank 1). Bank used when updating an application or bootloader without SoftDevice. */
|
||||
static pstorage_handle_t m_storage_handle_app; /**< Pstorage handle for the application area (bank 0). Bank used when updating a SoftDevice w/wo bootloader. Handle also used when swapping received application from bank 1 to bank 0. */
|
||||
static pstorage_handle_t * mp_storage_handle_active; /**< Pointer to the pstorage handle for the active bank for receiving of data packets. */
|
||||
|
||||
static dfu_callback_t m_data_pkt_cb; /**< Callback from DFU Bank module for notification of asynchronous operation such as flash prepare. */
|
||||
static dfu_bank_func_t m_functions; /**< Structure holding operations for the selected update process. */
|
||||
|
||||
|
||||
/**@brief Function for handling callbacks from pstorage module.
|
||||
*
|
||||
* @details Handles pstorage results for clear and storage operation. For detailed description of
|
||||
* the parameters provided with the callback, please refer to \ref pstorage_ntf_cb_t.
|
||||
*/
|
||||
static void pstorage_callback_handler(pstorage_handle_t * p_handle,
|
||||
uint8_t op_code,
|
||||
uint32_t result,
|
||||
uint8_t * p_data,
|
||||
uint32_t data_len)
|
||||
{
|
||||
switch (op_code)
|
||||
{
|
||||
case PSTORAGE_STORE_OP_CODE:
|
||||
if ((m_dfu_state == DFU_STATE_RX_DATA_PKT) && (m_data_pkt_cb != NULL))
|
||||
{
|
||||
m_data_pkt_cb(DATA_PACKET, result, p_data);
|
||||
}
|
||||
break;
|
||||
|
||||
case PSTORAGE_CLEAR_OP_CODE:
|
||||
if (m_dfu_state == DFU_STATE_PREPARING)
|
||||
{
|
||||
m_functions.cleared();
|
||||
m_dfu_state = DFU_STATE_RDY;
|
||||
if (m_data_pkt_cb != NULL)
|
||||
{
|
||||
m_data_pkt_cb(START_PACKET, result, p_data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
APP_ERROR_CHECK(result);
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for handling the DFU timeout.
|
||||
*
|
||||
* @param[in] p_context The timeout context.
|
||||
*/
|
||||
static void dfu_timeout_handler(void * p_context)
|
||||
{
|
||||
UNUSED_PARAMETER(p_context);
|
||||
dfu_update_status_t update_status;
|
||||
|
||||
m_dfu_timed_out = true;
|
||||
update_status.status_code = DFU_TIMEOUT;
|
||||
|
||||
bootloader_dfu_update_process(update_status);
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for restarting the DFU Timer.
|
||||
*
|
||||
* @details This function will stop and restart the DFU timer. This function will be called by the
|
||||
* functions handling any DFU packet received from the peer that is transferring a firmware
|
||||
* image.
|
||||
*/
|
||||
static uint32_t dfu_timer_restart(void)
|
||||
{
|
||||
if (m_dfu_timed_out)
|
||||
{
|
||||
// The DFU timer had already timed out.
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
uint32_t err_code = app_timer_stop(m_dfu_timer_id);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
err_code = app_timer_start(m_dfu_timer_id, DFU_TIMEOUT_INTERVAL, NULL);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for preparing of flash before receiving SoftDevice image.
|
||||
*
|
||||
* @details This function will erase current application area to ensure sufficient amount of
|
||||
* storage for the SoftDevice image. Upon erase complete a callback will be done.
|
||||
* See \ref dfu_bank_prepare_t for further details.
|
||||
*/
|
||||
static void dfu_prepare_func_app_erase(uint32_t image_size)
|
||||
{
|
||||
uint32_t err_code;
|
||||
|
||||
mp_storage_handle_active = &m_storage_handle_app;
|
||||
|
||||
// Doing a SoftDevice update thus current application must be cleared to ensure enough space
|
||||
// for new SoftDevice.
|
||||
m_dfu_state = DFU_STATE_PREPARING;
|
||||
err_code = pstorage_clear(&m_storage_handle_app, m_image_size);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for preparing swap before receiving application or bootloader image.
|
||||
*
|
||||
* @details This function will erase current swap area to ensure flash is ready for storage of the
|
||||
* Application or Bootloader image. Upon erase complete a callback will be done.
|
||||
* See \ref dfu_bank_prepare_t for further details.
|
||||
*/
|
||||
static void dfu_prepare_func_swap_erase(uint32_t image_size)
|
||||
{
|
||||
uint32_t err_code;
|
||||
|
||||
mp_storage_handle_active = &m_storage_handle_swap;
|
||||
|
||||
m_dfu_state = DFU_STATE_PREPARING;
|
||||
// err_code = pstorage_clear(&m_storage_handle_swap, DFU_IMAGE_MAX_SIZE_BANKED);
|
||||
err_code = pstorage_clear(&m_storage_handle_swap, image_size);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for handling behaviour when clear operation has completed.
|
||||
*/
|
||||
static void dfu_cleared_func_swap(void)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for handling behaviour when clear operation has completed.
|
||||
*/
|
||||
static void dfu_cleared_func_app(void)
|
||||
{
|
||||
dfu_update_status_t update_status = {DFU_BANK_0_ERASED, };
|
||||
bootloader_dfu_update_process(update_status);
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for calculating storage offset for receiving SoftDevice image.
|
||||
*
|
||||
* @details When a new SoftDevice is received it will be temporary stored in flash before moved to
|
||||
* address 0x0. In order to succesfully validate transfer and relocation it is important
|
||||
* that temporary image and final installed image does not ovwerlap hence an offset must
|
||||
* be calculated in case new image is larger than currently installed SoftDevice.
|
||||
*/
|
||||
uint32_t offset_calculate(uint32_t sd_image_size)
|
||||
{
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (m_start_packet.sd_image_size > DFU_BANK_0_REGION_START)
|
||||
{
|
||||
uint32_t page_mask = (CODE_PAGE_SIZE - 1);
|
||||
uint32_t diff = m_start_packet.sd_image_size - DFU_BANK_0_REGION_START;
|
||||
|
||||
offset = diff & ~page_mask;
|
||||
|
||||
// Align offset to next page if image size is not page sized.
|
||||
if ((diff & page_mask) > 0)
|
||||
{
|
||||
offset += CODE_PAGE_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for activating received SoftDevice image.
|
||||
*
|
||||
* @note This function will not move the SoftDevice image.
|
||||
* The bootloader settings will be marked as SoftDevice update complete and the swapping of
|
||||
* current SoftDevice will occur after system reset.
|
||||
*
|
||||
* @return NRF_SUCCESS on success.
|
||||
*/
|
||||
static uint32_t dfu_activate_sd(void)
|
||||
{
|
||||
dfu_update_status_t update_status;
|
||||
|
||||
update_status.status_code = DFU_UPDATE_SD_COMPLETE;
|
||||
update_status.app_crc = m_image_crc;
|
||||
update_status.sd_image_start = DFU_BANK_0_REGION_START;
|
||||
update_status.sd_size = m_start_packet.sd_image_size;
|
||||
update_status.bl_size = m_start_packet.bl_image_size;
|
||||
update_status.app_size = m_start_packet.app_image_size;
|
||||
|
||||
bootloader_dfu_update_process(update_status);
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for activating received Application image.
|
||||
*
|
||||
* @details This function will move the received application image fram swap (bank 1) to
|
||||
* application area (bank 0).
|
||||
*
|
||||
* @return NRF_SUCCESS on success. Error code otherwise.
|
||||
*/
|
||||
static uint32_t dfu_activate_app(void)
|
||||
{
|
||||
uint32_t err_code;
|
||||
|
||||
// Erase BANK 0.
|
||||
err_code = pstorage_clear(&m_storage_handle_app, m_start_packet.app_image_size);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
err_code = pstorage_store(&m_storage_handle_app,
|
||||
(uint8_t *)m_storage_handle_swap.block_id,
|
||||
m_start_packet.app_image_size,
|
||||
0);
|
||||
|
||||
if (err_code == NRF_SUCCESS)
|
||||
{
|
||||
dfu_update_status_t update_status;
|
||||
|
||||
memset(&update_status, 0, sizeof(dfu_update_status_t ));
|
||||
update_status.status_code = DFU_UPDATE_APP_COMPLETE;
|
||||
update_status.app_crc = m_image_crc;
|
||||
update_status.app_size = m_start_packet.app_image_size;
|
||||
|
||||
bootloader_dfu_update_process(update_status);
|
||||
}
|
||||
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for activating received Bootloader image.
|
||||
*
|
||||
* @note This function will not move the bootloader image.
|
||||
* The bootloader settings will be marked as Bootloader update complete and the swapping of
|
||||
* current bootloader will occur after system reset.
|
||||
*
|
||||
* @return NRF_SUCCESS on success.
|
||||
*/
|
||||
static uint32_t dfu_activate_bl(void)
|
||||
{
|
||||
dfu_update_status_t update_status;
|
||||
|
||||
update_status.status_code = DFU_UPDATE_BOOT_COMPLETE;
|
||||
update_status.app_crc = m_image_crc;
|
||||
update_status.sd_size = m_start_packet.sd_image_size;
|
||||
update_status.bl_size = m_start_packet.bl_image_size;
|
||||
update_status.app_size = m_start_packet.app_image_size;
|
||||
|
||||
bootloader_dfu_update_process(update_status);
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
uint32_t dfu_init(void)
|
||||
{
|
||||
uint32_t err_code;
|
||||
pstorage_module_param_t storage_module_param = {.cb = pstorage_callback_handler};
|
||||
|
||||
m_init_packet_length = 0;
|
||||
m_image_crc = 0;
|
||||
|
||||
err_code = pstorage_register(&storage_module_param, &m_storage_handle_app);
|
||||
if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
m_dfu_state = DFU_STATE_INIT_ERROR;
|
||||
return err_code;
|
||||
}
|
||||
|
||||
m_storage_handle_app.block_id = DFU_BANK_0_REGION_START;
|
||||
m_storage_handle_swap = m_storage_handle_app;
|
||||
m_storage_handle_swap.block_id = DFU_BANK_1_REGION_START;
|
||||
|
||||
// Create the timer to monitor the activity by the peer doing the firmware update.
|
||||
err_code = app_timer_create(&m_dfu_timer_id,
|
||||
APP_TIMER_MODE_SINGLE_SHOT,
|
||||
dfu_timeout_handler);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
// Start the DFU timer.
|
||||
err_code = app_timer_start(m_dfu_timer_id, DFU_TIMEOUT_INTERVAL, NULL);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
m_data_received = 0;
|
||||
m_dfu_state = DFU_STATE_IDLE;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void dfu_register_callback(dfu_callback_t callback_handler)
|
||||
{
|
||||
m_data_pkt_cb = callback_handler;
|
||||
}
|
||||
|
||||
|
||||
uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
{
|
||||
uint32_t err_code;
|
||||
|
||||
m_start_packet = *(p_packet->params.start_packet);
|
||||
|
||||
// Check that the requested update procedure is supported.
|
||||
// Currently the following combinations are allowed:
|
||||
// - Application
|
||||
// - SoftDevice
|
||||
// - Bootloader
|
||||
// - SoftDevice with Bootloader
|
||||
if (IS_UPDATING_APP(m_start_packet) &&
|
||||
(IS_UPDATING_SD(m_start_packet) || IS_UPDATING_BL(m_start_packet)))
|
||||
{
|
||||
// App update is only supported independently.
|
||||
return NRF_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
if (!(IS_WORD_SIZED(m_start_packet.sd_image_size) &&
|
||||
IS_WORD_SIZED(m_start_packet.bl_image_size) &&
|
||||
IS_WORD_SIZED(m_start_packet.app_image_size)))
|
||||
{
|
||||
// Image_sizes are not a multiple of 4 (word size).
|
||||
return NRF_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
m_image_size = m_start_packet.sd_image_size + m_start_packet.bl_image_size +
|
||||
m_start_packet.app_image_size;
|
||||
|
||||
if (m_start_packet.bl_image_size > DFU_BL_IMAGE_MAX_SIZE)
|
||||
{
|
||||
return NRF_ERROR_DATA_SIZE;
|
||||
}
|
||||
|
||||
if (IS_UPDATING_SD(m_start_packet))
|
||||
{
|
||||
if (m_image_size > (DFU_IMAGE_MAX_SIZE_FULL))
|
||||
{
|
||||
return NRF_ERROR_DATA_SIZE;
|
||||
}
|
||||
m_functions.prepare = dfu_prepare_func_app_erase;
|
||||
m_functions.cleared = dfu_cleared_func_app;
|
||||
m_functions.activate = dfu_activate_sd;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_image_size > DFU_IMAGE_MAX_SIZE_BANKED)
|
||||
{
|
||||
return NRF_ERROR_DATA_SIZE;
|
||||
}
|
||||
|
||||
m_functions.prepare = dfu_prepare_func_swap_erase;
|
||||
m_functions.cleared = dfu_cleared_func_swap;
|
||||
if (IS_UPDATING_BL(m_start_packet))
|
||||
{
|
||||
m_functions.activate = dfu_activate_bl;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_functions.activate = dfu_activate_app;
|
||||
}
|
||||
}
|
||||
|
||||
switch (m_dfu_state)
|
||||
{
|
||||
case DFU_STATE_IDLE:
|
||||
// Valid peer activity detected. Hence restart the DFU timer.
|
||||
err_code = dfu_timer_restart();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
m_functions.prepare(m_image_size);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
err_code = NRF_ERROR_INVALID_STATE;
|
||||
break;
|
||||
}
|
||||
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
{
|
||||
uint32_t data_length;
|
||||
uint32_t err_code;
|
||||
uint32_t * p_data;
|
||||
|
||||
VERIFY_PARAM_NOT_NULL(p_packet);
|
||||
|
||||
// Check pointer alignment.
|
||||
if (!is_word_aligned(p_packet->params.data_packet.p_data_packet))
|
||||
{
|
||||
// The p_data_packet is not word aligned address.
|
||||
return NRF_ERROR_INVALID_ADDR;
|
||||
}
|
||||
|
||||
switch (m_dfu_state)
|
||||
{
|
||||
case DFU_STATE_RDY:
|
||||
case DFU_STATE_RX_INIT_PKT:
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
|
||||
case DFU_STATE_RX_DATA_PKT:
|
||||
data_length = p_packet->params.data_packet.packet_length * sizeof(uint32_t);
|
||||
|
||||
if ((m_data_received + data_length) > m_image_size)
|
||||
{
|
||||
// The caller is trying to write more bytes into the flash than the size provided to
|
||||
// the dfu_image_size_set function. This is treated as a serious error condition and
|
||||
// an unrecoverable one. Hence point the variable mp_app_write_address to the top of
|
||||
// the flash area. This will ensure that all future application data packet writes
|
||||
// will be blocked because of the above check.
|
||||
m_data_received = 0xFFFFFFFF;
|
||||
|
||||
return NRF_ERROR_DATA_SIZE;
|
||||
}
|
||||
|
||||
// Valid peer activity detected. Hence restart the DFU timer.
|
||||
err_code = dfu_timer_restart();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
p_data = (uint32_t *)p_packet->params.data_packet.p_data_packet;
|
||||
|
||||
err_code = pstorage_store(mp_storage_handle_active,
|
||||
(uint8_t *)p_data,
|
||||
data_length,
|
||||
m_data_received);
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
m_data_received += data_length;
|
||||
|
||||
if (m_data_received != m_image_size)
|
||||
{
|
||||
// The entire image is not received yet. More data is expected.
|
||||
err_code = NRF_ERROR_INVALID_LENGTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The entire image has been received. Return NRF_SUCCESS.
|
||||
err_code = NRF_SUCCESS;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
err_code = NRF_ERROR_INVALID_STATE;
|
||||
break;
|
||||
}
|
||||
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
uint32_t dfu_init_pkt_complete(void)
|
||||
{
|
||||
uint32_t err_code = NRF_ERROR_INVALID_STATE;
|
||||
|
||||
// DFU initialization has been done and a start packet has been received.
|
||||
if (IMAGE_WRITE_IN_PROGRESS())
|
||||
{
|
||||
// Image write is already in progress. Cannot handle an init packet now.
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (m_dfu_state == DFU_STATE_RX_INIT_PKT)
|
||||
{
|
||||
err_code = dfu_init_prevalidate(m_init_packet, m_init_packet_length, m_start_packet.dfu_update_mode);
|
||||
if (err_code == NRF_SUCCESS)
|
||||
{
|
||||
m_dfu_state = DFU_STATE_RX_DATA_PKT;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_init_packet_length = 0;
|
||||
}
|
||||
}
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
{
|
||||
uint32_t err_code = NRF_SUCCESS;
|
||||
uint32_t length;
|
||||
|
||||
switch (m_dfu_state)
|
||||
{
|
||||
case DFU_STATE_RDY:
|
||||
m_dfu_state = DFU_STATE_RX_INIT_PKT;
|
||||
// When receiving init packet in state ready just update and fall through this case.
|
||||
|
||||
case DFU_STATE_RX_INIT_PKT:
|
||||
// DFU initialization has been done and a start packet has been received.
|
||||
if (IMAGE_WRITE_IN_PROGRESS())
|
||||
{
|
||||
// Image write is already in progress. Cannot handle an init packet now.
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
// Valid peer activity detected. Hence restart the DFU timer.
|
||||
err_code = dfu_timer_restart();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
length = p_packet->params.data_packet.packet_length * sizeof(uint32_t);
|
||||
if ((m_init_packet_length + length) > sizeof(m_init_packet))
|
||||
{
|
||||
return NRF_ERROR_INVALID_LENGTH;
|
||||
}
|
||||
|
||||
memcpy(&m_init_packet[m_init_packet_length],
|
||||
&p_packet->params.data_packet.p_data_packet[0],
|
||||
length);
|
||||
m_init_packet_length += length;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Either the start packet was not received or dfu_init function was not called before.
|
||||
err_code = NRF_ERROR_INVALID_STATE;
|
||||
break;
|
||||
}
|
||||
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
uint32_t dfu_image_validate()
|
||||
{
|
||||
uint32_t err_code;
|
||||
|
||||
switch (m_dfu_state)
|
||||
{
|
||||
case DFU_STATE_RX_DATA_PKT:
|
||||
// Check if the application image write has finished.
|
||||
if (m_data_received != m_image_size)
|
||||
{
|
||||
// Image not yet fully transfered by the peer or the peer has attempted to write
|
||||
// too much data. Hence the validation should fail.
|
||||
err_code = NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dfu_state = DFU_STATE_VALIDATE;
|
||||
|
||||
// Valid peer activity detected. Hence restart the DFU timer.
|
||||
err_code = dfu_timer_restart();
|
||||
if (err_code == NRF_SUCCESS)
|
||||
{
|
||||
err_code = dfu_init_postvalidate((uint8_t *)mp_storage_handle_active->block_id,
|
||||
m_image_size);
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
m_dfu_state = DFU_STATE_WAIT_4_ACTIVATE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
err_code = NRF_ERROR_INVALID_STATE;
|
||||
break;
|
||||
}
|
||||
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
uint32_t dfu_image_activate()
|
||||
{
|
||||
uint32_t err_code;
|
||||
|
||||
switch (m_dfu_state)
|
||||
{
|
||||
case DFU_STATE_WAIT_4_ACTIVATE:
|
||||
|
||||
// Stop the DFU Timer because the peer activity need not be monitored any longer.
|
||||
err_code = app_timer_stop(m_dfu_timer_id);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
err_code = m_functions.activate();
|
||||
break;
|
||||
|
||||
default:
|
||||
err_code = NRF_ERROR_INVALID_STATE;
|
||||
break;
|
||||
}
|
||||
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
void dfu_reset(void)
|
||||
{
|
||||
dfu_update_status_t update_status;
|
||||
|
||||
update_status.status_code = DFU_RESET;
|
||||
|
||||
bootloader_dfu_update_process(update_status);
|
||||
}
|
||||
|
||||
|
||||
static uint32_t dfu_compare_block(uint32_t * ptr1, uint32_t * ptr2, uint32_t len)
|
||||
{
|
||||
sd_mbr_command_t sd_mbr_cmd;
|
||||
|
||||
sd_mbr_cmd.command = SD_MBR_COMMAND_COMPARE;
|
||||
sd_mbr_cmd.params.compare.ptr1 = ptr1;
|
||||
sd_mbr_cmd.params.compare.ptr2 = ptr2;
|
||||
sd_mbr_cmd.params.compare.len = len / sizeof(uint32_t);
|
||||
|
||||
return sd_mbr_command(&sd_mbr_cmd);
|
||||
}
|
||||
|
||||
|
||||
static uint32_t dfu_copy_sd(uint32_t * src, uint32_t * dst, uint32_t len)
|
||||
{
|
||||
sd_mbr_command_t sd_mbr_cmd;
|
||||
|
||||
sd_mbr_cmd.command = SD_MBR_COMMAND_COPY_SD;
|
||||
sd_mbr_cmd.params.copy_sd.src = src;
|
||||
sd_mbr_cmd.params.copy_sd.dst = dst;
|
||||
sd_mbr_cmd.params.copy_sd.len = len / sizeof(uint32_t);
|
||||
|
||||
return sd_mbr_command(&sd_mbr_cmd);
|
||||
}
|
||||
|
||||
|
||||
static uint32_t dfu_sd_img_block_swap(uint32_t * src,
|
||||
uint32_t * dst,
|
||||
uint32_t len,
|
||||
uint32_t block_size)
|
||||
{
|
||||
// It is neccesarry to swap the new SoftDevice in 3 rounds to ensure correct copy of data
|
||||
// and verifucation of data in case power reset occurs during write to flash.
|
||||
// To ensure the robustness of swapping the images are compared backwards till start of
|
||||
// image swap. If the back is identical everything is swapped.
|
||||
uint32_t err_code = dfu_compare_block(src, dst, len);
|
||||
if (err_code == NRF_SUCCESS)
|
||||
{
|
||||
return err_code;
|
||||
}
|
||||
|
||||
if ((uint32_t)dst > SOFTDEVICE_REGION_START)
|
||||
{
|
||||
err_code = dfu_sd_img_block_swap((uint32_t *)((uint32_t)src - block_size),
|
||||
(uint32_t *)((uint32_t)dst - block_size),
|
||||
block_size,
|
||||
block_size);
|
||||
VERIFY_SUCCESS(err_code);
|
||||
}
|
||||
|
||||
err_code = dfu_copy_sd(src, dst, len);
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
return dfu_compare_block(src, dst, len);
|
||||
}
|
||||
|
||||
|
||||
uint32_t dfu_sd_image_swap(void)
|
||||
{
|
||||
bootloader_settings_t boot_settings;
|
||||
|
||||
bootloader_settings_get(&boot_settings);
|
||||
|
||||
if (boot_settings.sd_image_size == 0)
|
||||
{
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
if ((SOFTDEVICE_REGION_START + boot_settings.sd_image_size) > boot_settings.sd_image_start)
|
||||
{
|
||||
uint32_t err_code;
|
||||
uint32_t sd_start = SOFTDEVICE_REGION_START;
|
||||
uint32_t block_size = (boot_settings.sd_image_start - sd_start) / 2;
|
||||
|
||||
/* ##### FIX START ##### */
|
||||
block_size &= ~(uint32_t)(CODE_PAGE_SIZE - 1);
|
||||
/* ##### FIX END ##### */
|
||||
|
||||
uint32_t image_end = boot_settings.sd_image_start + boot_settings.sd_image_size;
|
||||
|
||||
uint32_t img_block_start = boot_settings.sd_image_start + 2 * block_size;
|
||||
uint32_t sd_block_start = sd_start + 2 * block_size;
|
||||
|
||||
if (SD_SIZE_GET(MBR_SIZE) < boot_settings.sd_image_size)
|
||||
{
|
||||
// This will clear a page thus ensuring the old image is invalidated before swapping.
|
||||
err_code = dfu_copy_sd((uint32_t *)(sd_start + block_size),
|
||||
(uint32_t *)(sd_start + block_size),
|
||||
sizeof(uint32_t));
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
err_code = dfu_copy_sd((uint32_t *)sd_start, (uint32_t *)sd_start, sizeof(uint32_t));
|
||||
VERIFY_SUCCESS(err_code);
|
||||
}
|
||||
|
||||
return dfu_sd_img_block_swap((uint32_t *)img_block_start,
|
||||
(uint32_t *)sd_block_start,
|
||||
image_end - img_block_start,
|
||||
block_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (boot_settings.sd_image_size != 0)
|
||||
{
|
||||
return dfu_copy_sd((uint32_t *)boot_settings.sd_image_start,
|
||||
(uint32_t *)SOFTDEVICE_REGION_START,
|
||||
boot_settings.sd_image_size);
|
||||
}
|
||||
}
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
uint32_t dfu_bl_image_swap(void)
|
||||
{
|
||||
bootloader_settings_t bootloader_settings;
|
||||
sd_mbr_command_t sd_mbr_cmd;
|
||||
|
||||
bootloader_settings_get(&bootloader_settings);
|
||||
|
||||
if (bootloader_settings.bl_image_size != 0)
|
||||
{
|
||||
uint32_t bl_image_start = (bootloader_settings.sd_image_size == 0) ?
|
||||
DFU_BANK_1_REGION_START :
|
||||
bootloader_settings.sd_image_start +
|
||||
bootloader_settings.sd_image_size;
|
||||
|
||||
sd_mbr_cmd.command = SD_MBR_COMMAND_COPY_BL;
|
||||
sd_mbr_cmd.params.copy_bl.bl_src = (uint32_t *)(bl_image_start);
|
||||
sd_mbr_cmd.params.copy_bl.bl_len = bootloader_settings.bl_image_size / sizeof(uint32_t);
|
||||
|
||||
return sd_mbr_command(&sd_mbr_cmd);
|
||||
}
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
uint32_t dfu_bl_image_validate(void)
|
||||
{
|
||||
bootloader_settings_t bootloader_settings;
|
||||
sd_mbr_command_t sd_mbr_cmd;
|
||||
|
||||
bootloader_settings_get(&bootloader_settings);
|
||||
|
||||
if (bootloader_settings.bl_image_size != 0)
|
||||
{
|
||||
uint32_t bl_image_start = (bootloader_settings.sd_image_size == 0) ?
|
||||
DFU_BANK_1_REGION_START :
|
||||
bootloader_settings.sd_image_start +
|
||||
bootloader_settings.sd_image_size;
|
||||
|
||||
sd_mbr_cmd.command = SD_MBR_COMMAND_COMPARE;
|
||||
sd_mbr_cmd.params.compare.ptr1 = (uint32_t *)BOOTLOADER_REGION_START;
|
||||
sd_mbr_cmd.params.compare.ptr2 = (uint32_t *)(bl_image_start);
|
||||
sd_mbr_cmd.params.compare.len = bootloader_settings.bl_image_size / sizeof(uint32_t);
|
||||
|
||||
return sd_mbr_command(&sd_mbr_cmd);
|
||||
}
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
uint32_t dfu_sd_image_validate(void)
|
||||
{
|
||||
bootloader_settings_t bootloader_settings;
|
||||
sd_mbr_command_t sd_mbr_cmd;
|
||||
|
||||
bootloader_settings_get(&bootloader_settings);
|
||||
|
||||
if (bootloader_settings.sd_image_size == 0)
|
||||
{
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
if ((SOFTDEVICE_REGION_START + bootloader_settings.sd_image_size) > bootloader_settings.sd_image_start)
|
||||
{
|
||||
uint32_t sd_start = SOFTDEVICE_REGION_START;
|
||||
uint32_t block_size = (bootloader_settings.sd_image_start - sd_start) / 2;
|
||||
uint32_t image_end = bootloader_settings.sd_image_start +
|
||||
bootloader_settings.sd_image_size;
|
||||
|
||||
/* ##### FIX START ##### */
|
||||
block_size &= ~(uint32_t)(CODE_PAGE_SIZE - 1);
|
||||
/* ##### FIX END ##### */
|
||||
uint32_t img_block_start = bootloader_settings.sd_image_start + 2 * block_size;
|
||||
uint32_t sd_block_start = sd_start + 2 * block_size;
|
||||
|
||||
if (SD_SIZE_GET(MBR_SIZE) < bootloader_settings.sd_image_size)
|
||||
{
|
||||
return NRF_ERROR_NULL;
|
||||
}
|
||||
|
||||
return dfu_sd_img_block_swap((uint32_t *)img_block_start,
|
||||
(uint32_t *)sd_block_start,
|
||||
image_end - img_block_start,
|
||||
block_size);
|
||||
}
|
||||
|
||||
sd_mbr_cmd.command = SD_MBR_COMMAND_COMPARE;
|
||||
sd_mbr_cmd.params.compare.ptr1 = (uint32_t *)SOFTDEVICE_REGION_START;
|
||||
sd_mbr_cmd.params.compare.ptr2 = (uint32_t *)bootloader_settings.sd_image_start;
|
||||
sd_mbr_cmd.params.compare.len = bootloader_settings.sd_image_size / sizeof(uint32_t);
|
||||
|
||||
return sd_mbr_command(&sd_mbr_cmd);
|
||||
}
|
||||
@@ -35,9 +35,6 @@ static uint8_t m_init_packet[64]; /**< Init packet
|
||||
static uint8_t m_init_packet_length; /**< Length of init packet received. */
|
||||
static uint16_t m_image_crc; /**< Calculated CRC of the image received. */
|
||||
|
||||
APP_TIMER_DEF(m_dfu_timer_id); /**< Application timer id. */
|
||||
static bool m_dfu_timed_out = false; /**< Boolean flag value for tracking DFU timer timeout state. */
|
||||
|
||||
static pstorage_handle_t m_storage_handle_app; /**< Pstorage handle for the application area (bank 0). Bank used when updating a SoftDevice w/wo bootloader. Handle also used when swapping received application from bank 1 to bank 0. */
|
||||
static pstorage_handle_t * mp_storage_handle_active; /**< Pointer to the pstorage handle for the active bank for receiving of data packets. */
|
||||
|
||||
@@ -83,47 +80,6 @@ static void pstorage_callback_handler(pstorage_handle_t * p_handle,
|
||||
APP_ERROR_CHECK(result);
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for handling the DFU timeout.
|
||||
*
|
||||
* @param[in] p_context The timeout context.
|
||||
*/
|
||||
static void dfu_timeout_handler(void * p_context)
|
||||
{
|
||||
UNUSED_PARAMETER(p_context);
|
||||
dfu_update_status_t update_status;
|
||||
|
||||
m_dfu_timed_out = true;
|
||||
update_status.status_code = DFU_TIMEOUT;
|
||||
|
||||
bootloader_dfu_update_process(update_status);
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for restarting the DFU Timer.
|
||||
*
|
||||
* @details This function will stop and restart the DFU timer. This function will be called by the
|
||||
* functions handling any DFU packet received from the peer that is transferring a firmware
|
||||
* image.
|
||||
*/
|
||||
static uint32_t dfu_timer_restart(void)
|
||||
{
|
||||
if (m_dfu_timed_out)
|
||||
{
|
||||
// The DFU timer had already timed out.
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
uint32_t err_code = app_timer_stop(m_dfu_timer_id);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
err_code = app_timer_start(m_dfu_timer_id, DFU_TIMEOUT_INTERVAL, NULL);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for preparing of flash before receiving SoftDevice image.
|
||||
*
|
||||
* @details This function will erase current application area to ensure sufficient amount of
|
||||
@@ -140,8 +96,7 @@ static void dfu_prepare_func_app_erase(uint32_t image_size)
|
||||
|
||||
if ( is_ota() )
|
||||
{
|
||||
uint32_t err_code;
|
||||
err_code = pstorage_clear(&m_storage_handle_app, m_image_size);
|
||||
uint32_t err_code = pstorage_clear(&m_storage_handle_app, m_image_size);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
}
|
||||
else
|
||||
@@ -151,7 +106,9 @@ static void dfu_prepare_func_app_erase(uint32_t image_size)
|
||||
|
||||
for ( uint32_t i = 0; i < page_count; i++ )
|
||||
{
|
||||
nrfx_nvmc_page_erase(DFU_BANK_0_REGION_START + i * CODE_PAGE_SIZE);
|
||||
uint32_t const addr = DFU_BANK_0_REGION_START + i * CODE_PAGE_SIZE;
|
||||
PRINTF("Erase 0x%08lX\r\n", addr);
|
||||
nrfx_nvmc_page_erase(addr);
|
||||
}
|
||||
|
||||
// invoke complete callback
|
||||
@@ -164,7 +121,8 @@ static void dfu_prepare_func_app_erase(uint32_t image_size)
|
||||
*/
|
||||
static void dfu_cleared_func_app(void)
|
||||
{
|
||||
dfu_update_status_t update_status = {DFU_BANK_0_ERASED, };
|
||||
dfu_update_status_t update_status = { 0 };
|
||||
update_status.status_code = DFU_BANK_0_ERASED;
|
||||
bootloader_dfu_update_process(update_status);
|
||||
}
|
||||
|
||||
@@ -287,16 +245,6 @@ uint32_t dfu_init(void)
|
||||
|
||||
m_storage_handle_app.block_id = DFU_BANK_0_REGION_START;
|
||||
|
||||
// Create the timer to monitor the activity by the peer doing the firmware update.
|
||||
err_code = app_timer_create(&m_dfu_timer_id,
|
||||
APP_TIMER_MODE_SINGLE_SHOT,
|
||||
dfu_timeout_handler);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
// Start the DFU timer.
|
||||
err_code = app_timer_start(m_dfu_timer_id, DFU_TIMEOUT_INTERVAL, NULL);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
m_data_received = 0;
|
||||
m_dfu_state = DFU_STATE_IDLE;
|
||||
|
||||
@@ -312,8 +260,6 @@ void dfu_register_callback(dfu_callback_t callback_handler)
|
||||
|
||||
uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
{
|
||||
uint32_t err_code;
|
||||
|
||||
m_start_packet = *(p_packet->params.start_packet);
|
||||
|
||||
// Check that the requested update procedure is supported.
|
||||
@@ -365,22 +311,11 @@ uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
m_functions.activate = dfu_activate_app;
|
||||
}
|
||||
|
||||
switch (m_dfu_state)
|
||||
{
|
||||
case DFU_STATE_IDLE:
|
||||
// Valid peer activity detected. Hence restart the DFU timer.
|
||||
err_code = dfu_timer_restart();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
m_functions.prepare(m_image_size);
|
||||
if ( DFU_STATE_IDLE != m_dfu_state ) return NRF_ERROR_INVALID_STATE;
|
||||
|
||||
break;
|
||||
m_functions.prepare(m_image_size);
|
||||
|
||||
default:
|
||||
err_code = NRF_ERROR_INVALID_STATE;
|
||||
break;
|
||||
}
|
||||
|
||||
return err_code;
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -420,10 +355,6 @@ uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
return NRF_ERROR_DATA_SIZE;
|
||||
}
|
||||
|
||||
// Valid peer activity detected. Hence restart the DFU timer.
|
||||
err_code = dfu_timer_restart();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
p_data = (uint32_t *)p_packet->params.data_packet.p_data_packet;
|
||||
|
||||
if ( is_ota() )
|
||||
@@ -491,14 +422,14 @@ uint32_t dfu_init_pkt_complete(void)
|
||||
|
||||
uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
{
|
||||
uint32_t err_code = NRF_SUCCESS;
|
||||
uint32_t length;
|
||||
|
||||
switch (m_dfu_state)
|
||||
{
|
||||
case DFU_STATE_RDY:
|
||||
m_dfu_state = DFU_STATE_RX_INIT_PKT;
|
||||
// When receiving init packet in state ready just update and fall through this case.
|
||||
// When receiving init packet in state ready just update and fall through this case.
|
||||
/* FALLTHRU */
|
||||
|
||||
case DFU_STATE_RX_INIT_PKT:
|
||||
// DFU initialization has been done and a start packet has been received.
|
||||
@@ -508,10 +439,6 @@ uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
// Valid peer activity detected. Hence restart the DFU timer.
|
||||
err_code = dfu_timer_restart();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
length = p_packet->params.data_packet.packet_length * sizeof(uint32_t);
|
||||
if ((m_init_packet_length + length) > sizeof(m_init_packet))
|
||||
{
|
||||
@@ -526,11 +453,10 @@ uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
|
||||
default:
|
||||
// Either the start packet was not received or dfu_init function was not called before.
|
||||
err_code = NRF_ERROR_INVALID_STATE;
|
||||
break;
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
return err_code;
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -552,16 +478,9 @@ uint32_t dfu_image_validate()
|
||||
{
|
||||
m_dfu_state = DFU_STATE_VALIDATE;
|
||||
|
||||
// Valid peer activity detected. Hence restart the DFU timer.
|
||||
err_code = dfu_timer_restart();
|
||||
if (err_code == NRF_SUCCESS)
|
||||
{
|
||||
err_code = dfu_init_postvalidate((uint8_t *)mp_storage_handle_active->block_id,
|
||||
m_image_size);
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
m_dfu_state = DFU_STATE_WAIT_4_ACTIVATE;
|
||||
}
|
||||
err_code = dfu_init_postvalidate((uint8_t *)mp_storage_handle_active->block_id, m_image_size);
|
||||
VERIFY_SUCCESS(err_code);
|
||||
m_dfu_state = DFU_STATE_WAIT_4_ACTIVATE;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -581,11 +500,6 @@ uint32_t dfu_image_activate()
|
||||
switch (m_dfu_state)
|
||||
{
|
||||
case DFU_STATE_WAIT_4_ACTIVATE:
|
||||
|
||||
// Stop the DFU Timer because the peer activity need not be monitored any longer.
|
||||
err_code = app_timer_stop(m_dfu_timer_id);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
err_code = m_functions.activate();
|
||||
break;
|
||||
|
||||
|
||||
@@ -54,8 +54,6 @@ enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 };
|
||||
#define SLAVE_LATENCY 0 /**< Slave latency. */
|
||||
#define CONN_SUP_TIMEOUT (4 * 100) /**< Connection supervisory timeout (4 seconds). */
|
||||
|
||||
#define APP_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. */
|
||||
|
||||
#define APP_ADV_INTERVAL MSEC_TO_UNITS(25, UNIT_0_625_MS) /**< The advertising interval (25 ms.). */
|
||||
#define APP_ADV_TIMEOUT BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED /**< The advertising timeout in units of seconds. This is set to @ref BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED so that the advertisement is done as long as there there is a call to @ref dfu_transport_close function.*/
|
||||
#define APP_DIRECTED_ADV_TIMEOUT 50 /**< number of direct advertisement (each lasting 1.28seconds). */
|
||||
@@ -738,7 +736,7 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
|
||||
|
||||
#ifdef CFG_DEBUG
|
||||
extern const char* dbg_ble_event_str(uint16_t evt_id);
|
||||
ADALOG("BLE", dbg_ble_event_str(p_ble_evt->header.evt_id));
|
||||
PRINTF("BLE %s\r\n", dbg_ble_event_str(p_ble_evt->header.evt_id));
|
||||
#endif
|
||||
|
||||
switch (p_ble_evt->header.evt_id)
|
||||
@@ -901,7 +899,7 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
|
||||
case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST:
|
||||
{
|
||||
uint16_t att_mtu = MIN(p_ble_evt->evt.gatts_evt.params.exchange_mtu_request.client_rx_mtu, BLEGATT_ATT_MTU_MAX);
|
||||
ADALOG("GAP", "ATT MTU is changed to %d", att_mtu);
|
||||
PRINTF("GAP ATT MTU is changed to %d\r\n", att_mtu);
|
||||
APP_ERROR_CHECK( sd_ble_gatts_exchange_mtu_reply(m_conn_handle, att_mtu) );
|
||||
}
|
||||
break;
|
||||
@@ -967,7 +965,7 @@ static void service_error_handler(uint32_t nrf_error)
|
||||
}
|
||||
|
||||
|
||||
static void ascii_to_utf8(ble_srv_utf8_str_t * p_utf8, char * p_ascii)
|
||||
static void ascii_to_utf8(ble_srv_utf8_str_t * p_utf8, const char * p_ascii)
|
||||
{
|
||||
p_utf8->length = (uint16_t)strlen(p_ascii);
|
||||
p_utf8->p_str = (uint8_t *)p_ascii;
|
||||
|
||||
@@ -201,55 +201,55 @@ static void process_dfu_packet(void * p_event_data, uint16_t event_size)
|
||||
extern bool dfu_startup_packet_received;
|
||||
dfu_startup_packet_received = true;
|
||||
|
||||
while (false == DATA_QUEUE_EMPTY())
|
||||
while (false == DATA_QUEUE_EMPTY())
|
||||
{
|
||||
// Fetch the element to be processed.
|
||||
for (index = 0; index < MAX_BUFFERS ; index++)
|
||||
{
|
||||
// Fetch the element to be processed.
|
||||
for (index = 0; index < MAX_BUFFERS ; index++)
|
||||
packet = &m_data_queue.data_packet[index];
|
||||
if (INVALID_PACKET != packet->packet_type)
|
||||
{
|
||||
packet = &m_data_queue.data_packet[index];
|
||||
if (INVALID_PACKET != packet->packet_type)
|
||||
switch (DATA_QUEUE_ELEMENT_GET_PTYPE(index))
|
||||
{
|
||||
switch (DATA_QUEUE_ELEMENT_GET_PTYPE(index))
|
||||
{
|
||||
case DATA_PACKET:
|
||||
(void)dfu_data_pkt_handle(packet);
|
||||
break;
|
||||
case DATA_PACKET:
|
||||
(void)dfu_data_pkt_handle(packet);
|
||||
break;
|
||||
|
||||
case START_PACKET:
|
||||
packet->params.start_packet =
|
||||
(dfu_start_packet_t*)packet->params.data_packet.p_data_packet;
|
||||
retval = dfu_start_pkt_handle(packet);
|
||||
APP_ERROR_CHECK(retval);
|
||||
break;
|
||||
case START_PACKET:
|
||||
packet->params.start_packet =
|
||||
(dfu_start_packet_t*)packet->params.data_packet.p_data_packet;
|
||||
retval = dfu_start_pkt_handle(packet);
|
||||
APP_ERROR_CHECK(retval);
|
||||
break;
|
||||
|
||||
case INIT_PACKET:
|
||||
(void)dfu_init_pkt_handle(packet);
|
||||
retval = dfu_init_pkt_complete();
|
||||
APP_ERROR_CHECK(retval);
|
||||
case INIT_PACKET:
|
||||
(void)dfu_init_pkt_handle(packet);
|
||||
retval = dfu_init_pkt_complete();
|
||||
APP_ERROR_CHECK(retval);
|
||||
|
||||
led_state(STATE_WRITING_STARTED);
|
||||
break;
|
||||
led_state(STATE_WRITING_STARTED);
|
||||
break;
|
||||
|
||||
case STOP_DATA_PACKET:
|
||||
(void)dfu_image_validate();
|
||||
(void)dfu_image_activate();
|
||||
case STOP_DATA_PACKET:
|
||||
(void)dfu_image_validate();
|
||||
(void)dfu_image_activate();
|
||||
|
||||
led_state(STATE_WRITING_FINISHED);
|
||||
led_state(STATE_WRITING_FINISHED);
|
||||
|
||||
// Break the loop by returning.
|
||||
return;
|
||||
// Break the loop by returning.
|
||||
return;
|
||||
|
||||
default:
|
||||
// No implementation needed.
|
||||
break;
|
||||
}
|
||||
|
||||
// Free the processed element.
|
||||
retval = data_queue_element_free(index);
|
||||
APP_ERROR_CHECK(retval);
|
||||
default:
|
||||
// No implementation needed.
|
||||
break;
|
||||
}
|
||||
|
||||
// Free the processed element.
|
||||
retval = data_queue_element_free(index);
|
||||
APP_ERROR_CHECK(retval);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,31 +29,38 @@
|
||||
#include "nrf.h"
|
||||
#include "app_util.h"
|
||||
|
||||
#ifndef SD_MAGIC_NUMBER
|
||||
#define SD_MAGIC_NUMBER 0x51B1E5DB
|
||||
#endif
|
||||
|
||||
static inline bool is_sd_existed(void)
|
||||
{
|
||||
return *((uint32_t*)(SOFTDEVICE_INFO_STRUCT_ADDRESS+4)) == SD_MAGIC_NUMBER;
|
||||
}
|
||||
|
||||
#define NRF_UICR_BOOT_START_ADDRESS (NRF_UICR_BASE + 0x14) /**< Register where the bootloader start address is stored in the UICR register. */
|
||||
#define NRF_UICR_MBR_PARAMS_PAGE_ADDRESS (NRF_UICR_BASE + 0x18) /**< Register where the mbr params page is stored in the UICR register. (Only in use in nRF52 MBR).*/
|
||||
|
||||
#define CODE_REGION_1_START SD_SIZE_GET(MBR_SIZE) /**< This field should correspond to the size of Code Region 0, (which is identical to Start of Code Region 1), found in UICR.CLEN0 register. This value is used for compile safety, as the linker will fail if application expands into bootloader. Runtime, the bootloader will use the value found in UICR.CLEN0. */
|
||||
// Application address is either after MBR or SD (if existed)
|
||||
#define CODE_REGION_1_START (is_sd_existed() ? SD_SIZE_GET(MBR_SIZE) : MBR_SIZE) /**< This field should correspond to the size of Code Region 0, (which is identical to Start of Code Region 1), found in UICR.CLEN0 register. This value is used for compile safety, as the linker will fail if application expands into bootloader. Runtime, the bootloader will use the value found in UICR.CLEN0. */
|
||||
|
||||
#define SOFTDEVICE_REGION_START MBR_SIZE /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
|
||||
#define CODE_PAGE_SIZE 0x1000 /**< Size of a flash codepage. Used for size of the reserved flash space in the bootloader region. Will be runtime checked against NRF_UICR->CODEPAGESIZE to ensure the region is correct. */
|
||||
|
||||
// Flash = 512 KB
|
||||
#if defined(NRF52832_XXAA) || defined(NRF52833_XXAA)
|
||||
|
||||
#define BOOTLOADER_REGION_START 0x00074000 /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
|
||||
#define BOOTLOADER_SETTINGS_ADDRESS 0x0007F000 /**< The field specifies the page location of the bootloader settings address. */
|
||||
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x0007E000 /**< The field specifies the page location of the mbr params page address. */
|
||||
#define BOOTLOADER_REGION_START 0x00074000 /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
|
||||
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x0007E000 /**< The field specifies the page location of the mbr params page address. */
|
||||
#define BOOTLOADER_SETTINGS_ADDRESS 0x0007F000 /**< The field specifies the page location of the bootloader settings address. */
|
||||
|
||||
// Flash = 1024 KB
|
||||
#elif defined(NRF52840_XXAA)
|
||||
|
||||
#define BOOTLOADER_REGION_START 0x000F4000 /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
|
||||
#define BOOTLOADER_SETTINGS_ADDRESS 0x000FF000 /**< The field specifies the page location of the bootloader settings address. */
|
||||
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x000FE000 /**< The field specifies the page location of the mbr params page address. */
|
||||
#define BOOTLOADER_REGION_START 0x000F4000 /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
|
||||
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x000FE000 /**< The field specifies the page location of the mbr params page address. */
|
||||
#define BOOTLOADER_SETTINGS_ADDRESS 0x000FF000 /**< The field specifies the page location of the bootloader settings address. */
|
||||
|
||||
#else
|
||||
|
||||
#error No target defined
|
||||
|
||||
#error No target defined
|
||||
#endif
|
||||
|
||||
#define DFU_REGION_TOTAL_SIZE (BOOTLOADER_REGION_START - CODE_REGION_1_START) /**< Total size of the region between SD and Bootloader. */
|
||||
@@ -67,7 +74,7 @@
|
||||
#define DFU_IMAGE_MAX_SIZE_BANKED (((DFU_IMAGE_MAX_SIZE_FULL) - \
|
||||
(DFU_IMAGE_MAX_SIZE_FULL % (2 * CODE_PAGE_SIZE)))/2) /**< Maximum size of an application, excluding save data from the application. */
|
||||
|
||||
#define DFU_BL_IMAGE_MAX_SIZE (BOOTLOADER_SETTINGS_ADDRESS - BOOTLOADER_REGION_START) /**< Maximum size of a bootloader, excluding save data from the current bootloader. */
|
||||
#define DFU_BL_IMAGE_MAX_SIZE (BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS - BOOTLOADER_REGION_START) /**< Maximum size of a bootloader, excluding save data from the current bootloader. */
|
||||
|
||||
#define DFU_BANK_0_REGION_START CODE_REGION_1_START /**< Bank 0 region start. */
|
||||
#define DFU_BANK_1_REGION_START (DFU_BANK_0_REGION_START + DFU_IMAGE_MAX_SIZE_BANKED) /**< Bank 1 region start. */
|
||||
@@ -131,7 +138,8 @@ typedef enum
|
||||
DFU_UPDATE_BOOT_COMPLETE, /**< Status update complete.*/
|
||||
DFU_BANK_0_ERASED, /**< Status bank 0 erased.*/
|
||||
DFU_TIMEOUT, /**< Status timeout.*/
|
||||
DFU_RESET /**< Status Reset to indicate current update procedure has been aborted and system should reset. */
|
||||
DFU_RESET, /**< Status Reset to indicate current update procedure has been aborted and system should reset. */
|
||||
DFU_UF2_BOOTLOADER_COMPLETE
|
||||
} dfu_update_status_code_t;
|
||||
|
||||
/**@brief Structure holding DFU complete event.
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
* Copyright (c) 2014 - 2017, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Nordic
|
||||
* Semiconductor ASA integrated circuit in a product or a software update for
|
||||
* such product, must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup nrf_mbr_api Master Boot Record API
|
||||
@{
|
||||
|
||||
@brief APIs for updating SoftDevice and BootLoader
|
||||
|
||||
*/
|
||||
|
||||
#ifndef NRF_MBR_H__
|
||||
#define NRF_MBR_H__
|
||||
|
||||
#include "nrf_svc.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup NRF_MBR_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@brief MBR SVC Base number. */
|
||||
#define MBR_SVC_BASE (0x18)
|
||||
|
||||
/**@brief Page size in words. */
|
||||
#define MBR_PAGE_SIZE_IN_WORDS (1024)
|
||||
|
||||
/** @brief The size that must be reserved for the MBR when a SoftDevice is written to flash.
|
||||
This is the offset where the first byte of the SoftDevice hex file is written. */
|
||||
#define MBR_SIZE (0x1000)
|
||||
|
||||
/** @brief Location (in the flash memory) of the bootloader address. */
|
||||
#define MBR_BOOTLOADER_ADDR (0xFF8)
|
||||
|
||||
/** @brief Location (in UICR) of the bootloader address. */
|
||||
#define MBR_UICR_BOOTLOADER_ADDR (&(NRF_UICR->NRFFW[0]))
|
||||
|
||||
/** @brief Location (in the flash memory) of the address of the MBR parameter page. */
|
||||
#define MBR_PARAM_PAGE_ADDR (0xFFC)
|
||||
|
||||
/** @brief Location (in UICR) of the address of the MBR parameter page. */
|
||||
#define MBR_UICR_PARAM_PAGE_ADDR (&(NRF_UICR->NRFFW[1]))
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_ENUMS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief nRF Master Boot Record API SVC numbers. */
|
||||
enum NRF_MBR_SVCS
|
||||
{
|
||||
SD_MBR_COMMAND = MBR_SVC_BASE, /**< ::sd_mbr_command */
|
||||
};
|
||||
|
||||
/**@brief Possible values for ::sd_mbr_command_t.command */
|
||||
enum NRF_MBR_COMMANDS
|
||||
{
|
||||
SD_MBR_COMMAND_COPY_BL, /**< Copy a new BootLoader. @see ::sd_mbr_command_copy_bl_t*/
|
||||
SD_MBR_COMMAND_COPY_SD, /**< Copy a new SoftDevice. @see ::sd_mbr_command_copy_sd_t*/
|
||||
SD_MBR_COMMAND_INIT_SD, /**< Initialize forwarding interrupts to SD, and run reset function in SD. Does not require any parameters in ::sd_mbr_command_t params.*/
|
||||
SD_MBR_COMMAND_COMPARE, /**< This command works like memcmp. @see ::sd_mbr_command_compare_t*/
|
||||
SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, /**< Change the address the MBR starts after a reset. @see ::sd_mbr_command_vector_table_base_set_t*/
|
||||
SD_MBR_COMMAND_RESERVED,
|
||||
SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET, /**< Start forwarding all interrupts to this address. @see ::sd_mbr_command_irq_forward_address_set_t*/
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_TYPES Types
|
||||
* @{ */
|
||||
|
||||
/**@brief This command copies part of a new SoftDevice
|
||||
*
|
||||
* The destination area is erased before copying.
|
||||
* If dst is in the middle of a flash page, that whole flash page will be erased.
|
||||
* If (dst+len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* The user of this function is responsible for setting the BPROT registers.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS indicates that the contents of the memory blocks where copied correctly.
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates that the contents of the memory blocks where not verified correctly after copying.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *src; /**< Pointer to the source of data to be copied.*/
|
||||
uint32_t *dst; /**< Pointer to the destination where the content is to be copied.*/
|
||||
uint32_t len; /**< Number of 32 bit words to copy. Must be a multiple of @ref MBR_PAGE_SIZE_IN_WORDS words.*/
|
||||
} sd_mbr_command_copy_sd_t;
|
||||
|
||||
|
||||
/**@brief This command works like memcmp, but takes the length in words.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS indicates that the contents of both memory blocks are equal.
|
||||
* @retval ::NRF_ERROR_NULL indicates that the contents of the memory blocks are not equal.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *ptr1; /**< Pointer to block of memory. */
|
||||
uint32_t *ptr2; /**< Pointer to block of memory. */
|
||||
uint32_t len; /**< Number of 32 bit words to compare.*/
|
||||
} sd_mbr_command_compare_t;
|
||||
|
||||
|
||||
/**@brief This command copies a new BootLoader.
|
||||
*
|
||||
* The MBR assumes that either @ref MBR_BOOTLOADER_ADDR or @ref MBR_UICR_BOOTLOADER_ADDR is set to
|
||||
* the address where the bootloader will be copied. If both addresses are set, the MBR will prioritize
|
||||
* @ref MBR_BOOTLOADER_ADDR.
|
||||
*
|
||||
* The bootloader destination is erased by this function.
|
||||
* If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* This command requires that @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR is set,
|
||||
* see @ref sd_mbr_command.
|
||||
*
|
||||
* This command will use the flash protect peripheral (BPROT or ACL) to protect the flash that is
|
||||
* not intended to be written.
|
||||
*
|
||||
* On success, this function will not return. It will start the new bootloader from reset-vector as normal.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN if the bootloader address is not set.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH if parameters attempts to read or write outside flash area.
|
||||
* @retval ::NRF_ERROR_NO_MEM No MBR parameter page is provided. See @ref sd_mbr_command.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *bl_src; /**< Pointer to the source of the bootloader to be be copied.*/
|
||||
uint32_t bl_len; /**< Number of 32 bit words to copy for BootLoader. */
|
||||
} sd_mbr_command_copy_bl_t;
|
||||
|
||||
/**@brief Change the address the MBR starts after a reset
|
||||
*
|
||||
* Once this function has been called, this address is where the MBR will start to forward
|
||||
* interrupts to after a reset.
|
||||
*
|
||||
* To restore default forwarding, this function should be called with @ref address set to 0. If a
|
||||
* bootloader is present, interrupts will be forwarded to the bootloader. If not, interrupts will
|
||||
* be forwarded to the SoftDevice.
|
||||
*
|
||||
* The location of a bootloader can be specified in @ref MBR_BOOTLOADER_ADDR or
|
||||
* @ref MBR_UICR_BOOTLOADER_ADDR. If both addresses are set, the MBR will prioritize
|
||||
* @ref MBR_BOOTLOADER_ADDR.
|
||||
*
|
||||
* This command requires that @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR is set,
|
||||
* see @ref sd_mbr_command.
|
||||
*
|
||||
* On success, this function will not return. It will reset the device.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR if parameter address is outside of the flash size.
|
||||
* @retval ::NRF_ERROR_NO_MEM No MBR parameter page is provided. See @ref sd_mbr_command.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/
|
||||
} sd_mbr_command_vector_table_base_set_t;
|
||||
|
||||
/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the MBR
|
||||
*
|
||||
* Unlike sd_mbr_command_vector_table_base_set_t, this function does not reset, and it does not
|
||||
* change where the MBR starts after reset.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/
|
||||
} sd_mbr_command_irq_forward_address_set_t;
|
||||
|
||||
/**@brief Input structure containing data used when calling ::sd_mbr_command
|
||||
*
|
||||
* Depending on what command value that is set, the corresponding params value type must also be
|
||||
* set. See @ref NRF_MBR_COMMANDS for command types and corresponding params value type. If command
|
||||
* @ref SD_MBR_COMMAND_INIT_SD is set, it is not necessary to set any values under params.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t command; /**< Type of command to be issued. See @ref NRF_MBR_COMMANDS. */
|
||||
union
|
||||
{
|
||||
sd_mbr_command_copy_sd_t copy_sd; /**< Parameters for copy SoftDevice.*/
|
||||
sd_mbr_command_compare_t compare; /**< Parameters for verify.*/
|
||||
sd_mbr_command_copy_bl_t copy_bl; /**< Parameters for copy BootLoader. Requires parameter page. */
|
||||
sd_mbr_command_vector_table_base_set_t base_set; /**< Parameters for vector table base set. Requires parameter page.*/
|
||||
sd_mbr_command_irq_forward_address_set_t irq_forward_address_set; /**< Parameters for irq forward address set*/
|
||||
} params; /**< Command parameters. */
|
||||
} sd_mbr_command_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Issue Master Boot Record commands
|
||||
*
|
||||
* Commands used when updating a SoftDevice and bootloader.
|
||||
*
|
||||
* The @ref SD_MBR_COMMAND_COPY_BL and @ref SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET requires
|
||||
* parameters to be retained by the MBR when resetting the IC. This is done in a separate flash
|
||||
* page. The location of the flash page should be provided by the application in either
|
||||
* @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR. If both addresses are set, the MBR
|
||||
* will prioritize @ref MBR_PARAM_PAGE_ADDR. This page will be cleared by the MBR and is used to
|
||||
* store the command before reset. When an address is specified, the page it refers to must not be
|
||||
* used by the application. If no address is provided by the application, i.e. both
|
||||
* @ref MBR_PARAM_PAGE_ADDR and @ref MBR_UICR_PARAM_PAGE_ADDR is 0xFFFFFFFF, MBR commands which use
|
||||
* flash will be unavailable and return @ref NRF_ERROR_NO_MEM.
|
||||
*
|
||||
* @param[in] param Pointer to a struct describing the command.
|
||||
*
|
||||
* @note For a complete set of return values, see ::sd_mbr_command_copy_sd_t,
|
||||
* ::sd_mbr_command_copy_bl_t, ::sd_mbr_command_compare_t,
|
||||
* ::sd_mbr_command_vector_table_base_set_t, ::sd_mbr_command_irq_forward_address_set_t
|
||||
*
|
||||
* @retval ::NRF_ERROR_NO_MEM No MBR parameter page provided
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM if an invalid command is given.
|
||||
*/
|
||||
SVCALL(SD_MBR_COMMAND, uint32_t, sd_mbr_command(sd_mbr_command_t* param));
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_MBR_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2012 - 2019, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Nordic
|
||||
* Semiconductor ASA integrated circuit in a product or a software update for
|
||||
* such product, must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRF_SVC__
|
||||
#define NRF_SVC__
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @brief Supervisor call declaration.
|
||||
*
|
||||
* A call to a function marked with @ref SVCALL, will trigger a Supervisor Call (SVC) Exception.
|
||||
* The SVCs with SVC numbers 0x00-0x0F are forwared to the application. All other SVCs are handled by the SoftDevice.
|
||||
*
|
||||
* @param[in] number The SVC number to be used.
|
||||
* @param[in] return_type The return type of the SVC function.
|
||||
* @param[in] signature Function signature. The function can have at most four arguments.
|
||||
*/
|
||||
|
||||
#ifdef SVCALL_AS_NORMAL_FUNCTION
|
||||
#define SVCALL(number, return_type, signature) return_type signature
|
||||
#else
|
||||
|
||||
#ifndef SVCALL
|
||||
#if defined (__CC_ARM)
|
||||
#define SVCALL(number, return_type, signature) return_type __svc(number) signature
|
||||
#elif defined (__GNUC__)
|
||||
#ifdef __cplusplus
|
||||
#define GCC_CAST_CPP (uint16_t)
|
||||
#else
|
||||
#define GCC_CAST_CPP
|
||||
#endif
|
||||
#define SVCALL(number, return_type, signature) \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \
|
||||
__attribute__((naked)) \
|
||||
__attribute__((unused)) \
|
||||
static return_type signature \
|
||||
{ \
|
||||
__asm( \
|
||||
"svc %0\n" \
|
||||
"bx r14" : : "I" (GCC_CAST_CPP number) : "r0" \
|
||||
); \
|
||||
} \
|
||||
_Pragma("GCC diagnostic pop")
|
||||
|
||||
#elif defined (__ICCARM__)
|
||||
#define PRAGMA(x) _Pragma(#x)
|
||||
#define SVCALL(number, return_type, signature) \
|
||||
PRAGMA(swi_number = (number)) \
|
||||
__swi return_type signature;
|
||||
#else
|
||||
#define SVCALL(number, return_type, signature) return_type signature
|
||||
#endif
|
||||
#endif // SVCALL
|
||||
|
||||
#endif // SVCALL_AS_NORMAL_FUNCTION
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_SVC__
|
||||
@@ -0,0 +1,35 @@
|
||||
Copyright (c) 2007 - 2019, Nordic Semiconductor ASA
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form, except as embedded into a Nordic
|
||||
Semiconductor ASA integrated circuit in a product or a software update for
|
||||
such product, must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
3. Neither the name of Nordic Semiconductor ASA nor the names of its
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
4. This software, with or without modification, must only be used with a
|
||||
Nordic Semiconductor ASA integrated circuit.
|
||||
|
||||
5. Any software provided in binary form under this license must not be reverse
|
||||
engineered, decompiled, modified and/or disassembled.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,179 @@
|
||||
:020000040000FA
|
||||
:1000000000040020810A000015070000610A0000BA
|
||||
:100010001F07000029070000330700000000000050
|
||||
:10002000000000000000000000000000A50A000021
|
||||
:100030003D070000000000004707000051070000D6
|
||||
:100040005B070000650700006F07000079070000EC
|
||||
:10005000830700008D07000097070000A10700003C
|
||||
:10006000AB070000B5070000BF070000C90700008C
|
||||
:10007000D3070000DD070000E7070000F1070000DC
|
||||
:10008000FB070000050800000F0800001908000029
|
||||
:10009000230800002D080000370800004108000078
|
||||
:1000A0004B080000550800005F08000069080000C8
|
||||
:1000B000730800007D080000870800009108000018
|
||||
:1000C0009B080000A5080000AF080000B908000068
|
||||
:1000D000C3080000CD080000D7080000E1080000B8
|
||||
:1000E000EB080000F5080000FF0800000909000007
|
||||
:1000F000130900001D090000270900003109000054
|
||||
:100100003B0900001FB500F003F88DE80F001FBD8C
|
||||
:1001100000F0ACBC40F6FC7108684FF01022401CA7
|
||||
:1001200008D00868401C09D00868401C04D0086842
|
||||
:1001300000F037BA9069F5E79069F9E7704770B554
|
||||
:100140000B46010B184400F6FF70040B4FF0805073
|
||||
:100150000022090303692403406943431D1B104621
|
||||
:1001600000F048FA29462046BDE8704000F042BA47
|
||||
:10017000F0B54FF6FF734FF4B4751A466E1E11E0DA
|
||||
:10018000A94201D3344600E00C46091B30F8027B3B
|
||||
:10019000641E3B441A44F9D19CB204EB134394B25D
|
||||
:1001A00004EB12420029EBD198B200EB134002EBB2
|
||||
:1001B000124140EA0140F0BDF34992B00446D1E952
|
||||
:1001C0000001CDE91001FF224021684600F0F4FB58
|
||||
:1001D00094E80F008DE80F00684610A902E004C8FB
|
||||
:1001E00041F8042D8842FAD110216846FFF7C0FF7C
|
||||
:1001F0001090AA208DF8440000F099F9FFF78AFFCB
|
||||
:1002000040F6FC7420684FF01025401C0FD0206889
|
||||
:1002100010226946803000F078F92068401C08D030
|
||||
:100220002068082210A900F070F900F061F9A869AF
|
||||
:10023000EEE7A869F5E74FF080500369406940F6A2
|
||||
:10024000FC71434308684FF01022401C06D0086838
|
||||
:1002500000F58050834203D2092070479069F7E788
|
||||
:100260000868401C04D00868401C03D00020704778
|
||||
:100270009069F9E70420704770B504460068C34DE3
|
||||
:10028000072876D2DFE800F033041929631E250021
|
||||
:10029000D4E9026564682946304600F062F92A46CE
|
||||
:1002A0002146304600F031F9AA002146304600F0E0
|
||||
:1002B00057FB002800D0032070BD00F009FC4FF46C
|
||||
:1002C000805007E0201D00F040F90028F4D100F034
|
||||
:1002D000FFFB60682860002070BD241D94E80700C3
|
||||
:1002E000920000F03DFB0028F6D00E2070BDFFF715
|
||||
:1002F000A2FF0028FAD1D4E901034FF0805100EBAE
|
||||
:10030000830208694D69684382420ED840F6F8704E
|
||||
:1003100005684FF010226D1C09D0056805EB8305B8
|
||||
:100320000B6949694B439D4203D9092070BD55694A
|
||||
:10033000F4E70168491C03D00068401C02D003E0C8
|
||||
:100340005069FAE70F2070BD2046FFF735FFFFF731
|
||||
:1003500072FF0028F7D1201D00F0F7F80028F2D135
|
||||
:1003600060680028F0D100F0E2F8FFF7D3FE00F05B
|
||||
:10037000BFF8072070BD10B50C46182802D0012028
|
||||
:10038000086010BD2068FFF777FF206010BD41684E
|
||||
:10039000054609B1012700E0002740F6F8742068FF
|
||||
:1003A0004FF01026401C2BD02068AA68920000F065
|
||||
:1003B000D7FA38B3A86881002068401C27D020688D
|
||||
:1003C000FFF7BDFED7B12068401C22D026684FF051
|
||||
:1003D0008050AC686D68016942695143A9420DD9EA
|
||||
:1003E000016940694143A14208D92146304600F0E5
|
||||
:1003F000B8F822462946304600F087F800F078F831
|
||||
:100400007069D2E700F093F8FFF784FEF6E77069B1
|
||||
:10041000D6E77669DBE740F6FC7420684FF01026DB
|
||||
:10042000401C23D02068401C0CD02068401C1FD0EA
|
||||
:100430002568206805F18005401C1BD027683879A5
|
||||
:10044000AA2819D040F6F8700168491C42D001680A
|
||||
:10045000491C45D00168491C3ED001680968491C07
|
||||
:100460003ED00168491C39D000683EE0B069DAE747
|
||||
:10047000B569DEE7B769E2E710212846FFF778FEA5
|
||||
:100480003968814222D12068401C05D0D4F8001080
|
||||
:1004900001F18002C03107E0B169F9E730B108CA63
|
||||
:1004A00051F8040D984201D1012000E000208A4259
|
||||
:1004B000F4D158B1286810B1042803D0FEE72846CB
|
||||
:1004C000FFF765FF3149686808600EE0FFF722FE1C
|
||||
:1004D00000F00EF87169BBE77169BFE7706904E06D
|
||||
:1004E0004FF480500168491C01D000F0CBFAFEE7C0
|
||||
:1004F000BFF34F8F26480168264A01F4E06111439B
|
||||
:100500000160BFF34F8F00BFFDE72DE9F0411746B3
|
||||
:100510000D460646002406E03046296800F054F8EF
|
||||
:10052000641C2D1D361DBC42F6D3BDE8F08140F69B
|
||||
:10053000FC700168491C04D0D0F800004FF48051D1
|
||||
:10054000FDE54FF010208069F8E74FF080510A690F
|
||||
:10055000496900684A43824201D810207047002050
|
||||
:10056000704770B50C4605464FF4806608E0284693
|
||||
:1005700000F017F8B44205D3A4F5806405F5805562
|
||||
:10058000002CF4D170BD0000F40A0000000000202F
|
||||
:100590000CED00E00400FA05144801680029FCD0C5
|
||||
:1005A0007047134A0221116010490B68002BFCD0E0
|
||||
:1005B0000F4B1B1D186008680028FCD0002010603D
|
||||
:1005C00008680028FCD07047094B10B501221A605A
|
||||
:1005D000064A1468002CFCD0016010680028FCD08A
|
||||
:1005E0000020186010680028FCD010BD00E4014015
|
||||
:1005F00004E5014070B50C46054600F073F810B9EB
|
||||
:1006000000F07EF828B121462846BDE8704000F091
|
||||
:1006100007B821462846BDE8704000F037B8000012
|
||||
:100620007FB5002200920192029203920A0B000B06
|
||||
:100630006946012302440AE0440900F01F0651F80C
|
||||
:10064000245003FA06F6354341F82450401C8242F8
|
||||
:10065000F2D80D490868009A10430860081D016827
|
||||
:10066000019A1143016000F03DF800280AD00649C4
|
||||
:1006700010310868029A10430860091D0868039A3F
|
||||
:10068000104308607FBD00000006004030B50F4CED
|
||||
:10069000002200BF04EB0213D3F800582DB9D3F8A1
|
||||
:1006A000045815B9D3F808581DB1521C082AF1D3C3
|
||||
:1006B00030BD082AFCD204EB0212C2F80008C3F8CD
|
||||
:1006C00004180220C3F8080830BD000000E0014013
|
||||
:1006D0004FF08050D0F83001082801D0002070473A
|
||||
:1006E000012070474FF08050D0F83011062905D016
|
||||
:1006F000D0F83001401C01D0002070470120704725
|
||||
:100700004FF08050D0F830010A2801D00020704707
|
||||
:100710000120704708208F490968095808471020B0
|
||||
:100720008C4909680958084714208A4909680958FA
|
||||
:100730000847182087490968095808473020854923
|
||||
:100740000968095808473820824909680958084744
|
||||
:100750003C20804909680958084740207D490968BC
|
||||
:100760000958084744207B49096809580847482028
|
||||
:1007700078490968095808474C207649096809589A
|
||||
:10078000084750207349096809580847542071499F
|
||||
:1007900009680958084758206E49096809580847E8
|
||||
:1007A0005C206C4909680958084760206949096854
|
||||
:1007B00009580847642067490968095808476820AC
|
||||
:1007C00064490968095808476C2062490968095852
|
||||
:1007D000084770205F4909680958084774205D4937
|
||||
:1007E00009680958084778205A490968095808478C
|
||||
:1007F0007C205849096809580847802055490968EC
|
||||
:10080000095808478420534909680958084788202F
|
||||
:1008100050490968095808478C204E490968095809
|
||||
:10082000084790204B4909680958084794204949CE
|
||||
:10083000096809580847982046490968095808472F
|
||||
:100840009C204449096809580847A0204149096883
|
||||
:1008500009580847A4203F49096809580847A820B3
|
||||
:100860003C49096809580847AC203A4909680958C1
|
||||
:100870000847B0203749096809580847B420354966
|
||||
:10088000096809580847B8203249096809580847D3
|
||||
:10089000BC203049096809580847C0202D4909681B
|
||||
:1008A00009580847C4202B49096809580847C82037
|
||||
:1008B0002849096809580847CC2026490968095879
|
||||
:1008C0000847D0202349096809580847D4202149FE
|
||||
:1008D000096809580847D8201E4909680958084777
|
||||
:1008E000DC201C49096809580847E02019490968B3
|
||||
:1008F00009580847E4201749096809580847E820BB
|
||||
:100900001449096809580847EC2012490968095830
|
||||
:100910000847F0200F49096809580847F4200D4995
|
||||
:10092000096809580847F8200A490968095808471A
|
||||
:10093000FC2008490968095808475FF48070054998
|
||||
:10094000096809580847000003480449024A034B54
|
||||
:100950007047000000000020000B0000000B0000AA
|
||||
:1009600040EA010310B59B070FD1042A0DD310C82C
|
||||
:1009700008C9121F9C42F8D020BA19BA884201D97E
|
||||
:10098000012010BD4FF0FF3010BD1AB1D30703D0C6
|
||||
:10099000521C07E0002010BD10F8013B11F8014B7C
|
||||
:1009A0001B1B07D110F8013B11F8014B1B1B01D198
|
||||
:1009B000921EF1D1184610BD02F0FF0343EA032254
|
||||
:1009C00042EA024200F005B87047704770474FF0A6
|
||||
:1009D00000020429C0F0128010F0030C00F01B800C
|
||||
:1009E000CCF1040CBCF1020F18BF00F8012BA8BF1A
|
||||
:1009F00020F8022BA1EB0C0100F00DB85FEAC17CDE
|
||||
:100A000024BF00F8012B00F8012B48BF00F8012B90
|
||||
:100A100070474FF0000200B51346944696462039C1
|
||||
:100A200022BFA0E80C50A0E80C50B1F12001BFF4A7
|
||||
:100A3000F7AF090728BFA0E80C5048BF0CC05DF80D
|
||||
:100A400004EB890028BF40F8042B08BF704748BF5B
|
||||
:100A500020F8022B11F0804F18BF00F8012B7047CF
|
||||
:100A6000014B1B68DB6818470000002009480A4951
|
||||
:100A70007047FFF7FBFFFFF745FB00BD20BFFDE719
|
||||
:100A8000064B1847064A1060016881F308884068E1
|
||||
:100A900000470000000B0000000B000017040000DE
|
||||
:100AA000000000201EF0040F0CBFEFF30881EFF3ED
|
||||
:100AB0000981886902380078182803D100E0000015
|
||||
:100AC000074A1047074A12682C3212681047000084
|
||||
:100AD00000B5054B1B68054A9B58984700BD0000B0
|
||||
:100AE0007703000000000020F00A0000040000006E
|
||||
:100AF000001000000000000000FFFFFF0090D00386
|
||||
:0400000500000A816C
|
||||
:00000001FF
|
||||
+1
-1
Submodule lib/tinyusb updated: 23df777b30...4e6aa0d81d.
Submodule
+1
Submodule lib/uf2 added at adbb8c7260.
@@ -28,7 +28,7 @@ MEMORY
|
||||
DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04
|
||||
|
||||
/** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information
|
||||
* from application to bootloader when using buttonluss DFU OTA. */
|
||||
* from application to bootloader when using buttonless DFU OTA. */
|
||||
NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ MEMORY
|
||||
DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04
|
||||
|
||||
/** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information
|
||||
* from application to bootloader when using buttonluss DFU OTA. */
|
||||
* from application to bootloader when using buttonless DFU OTA. */
|
||||
NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ MEMORY
|
||||
DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04
|
||||
|
||||
/** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information
|
||||
* from application to bootloader when using buttonluss DFU OTA. */
|
||||
* from application to bootloader when using buttonless DFU OTA. */
|
||||
NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80
|
||||
|
||||
|
||||
File renamed without changes.
@@ -0,0 +1,363 @@
|
||||
<!DOCTYPE CrossStudio_Project_File>
|
||||
<solution Name="Adafruit_nRF52_Bootloader" target="8" version="2">
|
||||
<project Name="Adafruit_nRF52_Bootloader">
|
||||
<configuration
|
||||
Name="Common"
|
||||
Placement="Flash"
|
||||
Target="nRF52840_xxAA"
|
||||
arm_architecture="v7EM"
|
||||
arm_core_type="Cortex-M4"
|
||||
arm_endian="Little"
|
||||
arm_fp_abi="Hard"
|
||||
arm_fpu_type="FPv4-SP-D16"
|
||||
arm_interwork="No"
|
||||
arm_linker_heap_size="1024"
|
||||
arm_linker_process_stack_size="0"
|
||||
arm_linker_stack_size="1024"
|
||||
arm_simulator_memory_simulation_parameter="ROM;0x00000000;0x00100000;RAM;0x20000000;0x00040000"
|
||||
arm_target_debug_interface_type="ADIv5"
|
||||
arm_target_device_name="nRF52840_xxAA"
|
||||
arm_target_interface_type="SWD"
|
||||
build_treat_warnings_as_errors="Yes"
|
||||
c_preprocessor_definitions="__nRF_FAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;NO_VTOR_CONFIG;MK_BOOTLOADER_VERSION=0x00020A;CONFIG_GPIO_AS_PINRESET;CONFIG_NFCT_PINS_AS_GPIOS;SOFTDEVICE_PRESENT;UF2_VERSION="Segger";BLEDIS_FW_VERSION="Segger";DFU_APP_DATA_RESERVED=7*4096;CFG_DEBUG"
|
||||
c_user_include_directories=".;../src/;../src/usb;../src/boards;../src/cmsis/include;$(tusbDir);$(nrfxDir);$(nrfxDir)/mdk;$(nrfxDir)/hal;$(nrfxDir)/drivers/include;$(nrfxDir)/drivers/src;$(sdDir)/include;$(sdDir)/include/nrf52;$(sdk11Dir)/drivers_nrf/pstorage;$(sdk11Dir)/ble/common/;$(sdk11Dir)/ble/ble_services/ble_dfu;$(sdk11Dir)/ble/ble_services/ble_dis;$(sdk11Dir)/libraries/bootloader_dfu;$(sdk11Dir)/libraries/bootloader_dfu/hci_transport;$(sdk11Dir)/libraries/util;$(sdkDir)/toolchain/cmsis/include;$(sdkDir)/device;$(sdkDir)/toolchain;$(sdkDir)/drivers_nrf/hal;$(sdkDir)/drivers_nrf/systick;$(sdkDir)/drivers_nrf/uart;$(sdkDir)/drivers_nrf/usbd;$(sdkDir)/drivers_nrf/common;$(sdkDir)/drivers_nrf/delay;$(sdkDir)/drivers_nrf/power;$(sdkDir)/drivers_nrf/clock;$(sdkDir)/libraries/util;$(sdkDir)/libraries/timer;$(sdkDir)/libraries/scheduler;$(sdkDir)/libraries/crc16;$(sdkDir)/libraries/util;$(sdkDir)/libraries/hci/config;$(sdkDir)/libraries/uart;$(sdkDir)/libraries/hci;$(sdkDir)/external/fprintf;$(sdkDir)/libraries/strerror;$(sdkDir)/libraries/atomic;$(sdkDir)/libraries/balloc;$(sdkDir)/libraries/experimental_log/src;$(sdkDir)/libraries/experimental_log;$(sdkDir)/libraries/experimental_section_vars;$(sdkDir)/libraries/experimental_memobj"
|
||||
debug_initial_breakpoint_set_option="Never"
|
||||
debug_register_definition_file="$(ProjectDir)/nrf52840_Registers.xml"
|
||||
debug_target_connection="J-Link"
|
||||
gcc_enable_all_warnings="No"
|
||||
gcc_entry_point="Reset_Handler"
|
||||
gcc_optimization_level="Debug"
|
||||
linker_memory_map_file="$(ProjectDir)/nRF52840_xxAA_MemoryMap.xml"
|
||||
linker_printf_width_precision_supported="Yes"
|
||||
linker_section_placement_file="$(ProjectDir)/flash_placement.xml"
|
||||
macros="DeviceHeaderFile=$(PackagesDir)/nRF/CMSIS/Device/Include/nrf.h;DeviceLibraryIdentifier=M4lf;DeviceSystemFile=$(PackagesDir)/nRF/CMSIS/Device/Source/system_nrf52840.c;DeviceVectorsFile=$(PackagesDir)/nRF/Source/ses_nrf52840_Vectors.s;DeviceFamily=nRF;Target=nRF52840_xxAA;Placement=Flash;sdkDir=../lib/sdk/components;sdk11Dir=../lib/sdk11/components;sdDir=../lib/softdevice/s140_nrf52_6.1.1/s140_nrf52_6.1.1_API;tusbDir=../lib/tinyusb/src;nrfxDir=../lib/nrfx"
|
||||
project_directory=""
|
||||
project_type="Executable"
|
||||
target_reset_script="Reset();"
|
||||
target_script_file="$(ProjectDir)/nRF_Target.js"
|
||||
target_trace_initialize_script="EnableTrace("$(TraceInterfaceType)")" />
|
||||
<folder Name="RTT Files">
|
||||
<file file_name="SEGGER_RTT.c" />
|
||||
<file file_name="SEGGER_RTT.h" />
|
||||
<file file_name="SEGGER_RTT_Conf.h" />
|
||||
<file file_name="SEGGER_RTT_SES.c" />
|
||||
</folder>
|
||||
<folder Name="Script Files">
|
||||
<file file_name="nRF_Target.js">
|
||||
<configuration Name="Common" file_type="Reset Script" />
|
||||
</file>
|
||||
</folder>
|
||||
<folder Name="System Files">
|
||||
<file file_name="thumb_crt0.s" />
|
||||
<file file_name="flash_placement.xml" />
|
||||
<file file_name="nRF52840_xxAA_MemoryMap.xml" />
|
||||
<file file_name="nRF52832_xxAA_MemoryMap.xml" />
|
||||
</folder>
|
||||
<configuration Name="Debug Single" gcc_optimization_level="Debug" />
|
||||
<configuration
|
||||
Name="Release Single"
|
||||
gcc_optimization_level="Optimize For Size" />
|
||||
<folder Name="lib">
|
||||
<folder
|
||||
Name="sdk"
|
||||
exclude=""
|
||||
filter="*.h;*.c"
|
||||
path="../lib/sdk"
|
||||
recurse="Yes" />
|
||||
<folder Name="sdk11">
|
||||
<folder Name="components">
|
||||
<folder Name="ble">
|
||||
<folder Name="ble_services">
|
||||
<folder Name="ble_dfu">
|
||||
<file file_name="../lib/sdk11/components/ble/ble_services/ble_dfu/ble_dfu.c" />
|
||||
<file file_name="../lib/sdk11/components/ble/ble_services/ble_dfu/ble_dfu.h" />
|
||||
</folder>
|
||||
<folder Name="ble_dis">
|
||||
<file file_name="../lib/sdk11/components/ble/ble_services/ble_dis/ble_dis.c" />
|
||||
<file file_name="../lib/sdk11/components/ble/ble_services/ble_dis/ble_dis.h" />
|
||||
</folder>
|
||||
</folder>
|
||||
<folder Name="common">
|
||||
<file file_name="../lib/sdk11/components/ble/common/ble_srv_common.h" />
|
||||
</folder>
|
||||
</folder>
|
||||
<folder Name="drivers_nrf">
|
||||
<folder Name="pstorage">
|
||||
<file file_name="../lib/sdk11/components/drivers_nrf/pstorage/pstorage.h" />
|
||||
<file file_name="../lib/sdk11/components/drivers_nrf/pstorage/pstorage_raw.c" />
|
||||
</folder>
|
||||
</folder>
|
||||
<folder Name="libraries">
|
||||
<folder Name="bootloader_dfu">
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/bootloader.c" />
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/bootloader.h" />
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/bootloader_settings.c" />
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/bootloader_settings.h" />
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/bootloader_types.h" />
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/bootloader_util.c" />
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/bootloader_util.h" />
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu.h" />
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_bank_internal.h" />
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_ble_svc.h" />
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_ble_svc_internal.h" />
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_init.h" />
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_transport.h" />
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_transport_ble.c" />
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_transport_serial.c" />
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_types.h" />
|
||||
<folder Name="ble_transport">
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/ble_transport/hci_mem_pool_internal.h" />
|
||||
</folder>
|
||||
<folder Name="hci_transport">
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/hci_transport/hci_mem_pool_internal.h" />
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/hci_transport/hci_transport_config.h" />
|
||||
</folder>
|
||||
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_single_bank.c" />
|
||||
</folder>
|
||||
<folder Name="util">
|
||||
<file file_name="../lib/sdk11/components/libraries/util/nrf_log.h" />
|
||||
</folder>
|
||||
</folder>
|
||||
</folder>
|
||||
</folder>
|
||||
<folder Name="tinyusb">
|
||||
<folder Name="src">
|
||||
<file file_name="../lib/tinyusb/src/tusb.c" />
|
||||
<file file_name="../lib/tinyusb/src/tusb.h" />
|
||||
<file file_name="../lib/tinyusb/src/tusb_hal.h" />
|
||||
<file file_name="../lib/tinyusb/src/tusb_option.h" />
|
||||
<folder Name="class">
|
||||
<folder Name="cdc">
|
||||
<file file_name="../lib/tinyusb/src/class/cdc/cdc.h" />
|
||||
<file file_name="../lib/tinyusb/src/class/cdc/cdc_device.c" />
|
||||
<file file_name="../lib/tinyusb/src/class/cdc/cdc_device.h" />
|
||||
</folder>
|
||||
<folder Name="hid">
|
||||
<file file_name="../lib/tinyusb/src/class/hid/hid.h" />
|
||||
<file file_name="../lib/tinyusb/src/class/hid/hid_device.c" />
|
||||
<file file_name="../lib/tinyusb/src/class/hid/hid_device.h" />
|
||||
</folder>
|
||||
<folder Name="msc">
|
||||
<file file_name="../lib/tinyusb/src/class/msc/msc.h" />
|
||||
<file file_name="../lib/tinyusb/src/class/msc/msc_device.c" />
|
||||
<file file_name="../lib/tinyusb/src/class/msc/msc_device.h" />
|
||||
</folder>
|
||||
</folder>
|
||||
<folder Name="common">
|
||||
<file file_name="../lib/tinyusb/src/common/binary.h" />
|
||||
<file file_name="../lib/tinyusb/src/common/timeout_timer.h" />
|
||||
<file file_name="../lib/tinyusb/src/common/tusb_common.h" />
|
||||
<file file_name="../lib/tinyusb/src/common/tusb_compiler.h" />
|
||||
<file file_name="../lib/tinyusb/src/common/tusb_error.h" />
|
||||
<file file_name="../lib/tinyusb/src/common/tusb_fifo.c" />
|
||||
<file file_name="../lib/tinyusb/src/common/tusb_fifo.h" />
|
||||
<file file_name="../lib/tinyusb/src/common/tusb_types.h" />
|
||||
<file file_name="../lib/tinyusb/src/common/tusb_verify.h" />
|
||||
<folder Name="compiler">
|
||||
<file file_name="../lib/tinyusb/src/common/compiler/tusb_compiler_gcc.h" />
|
||||
<file file_name="../lib/tinyusb/src/common/compiler/tusb_compiler_iar.h" />
|
||||
</folder>
|
||||
</folder>
|
||||
<folder Name="device">
|
||||
<file file_name="../lib/tinyusb/src/device/dcd.h" />
|
||||
<file file_name="../lib/tinyusb/src/device/usbd.c" />
|
||||
<file file_name="../lib/tinyusb/src/device/usbd.h" />
|
||||
<file file_name="../lib/tinyusb/src/device/usbd_pvt.h" />
|
||||
<file file_name="../lib/tinyusb/src/device/usbd_control.c" />
|
||||
</folder>
|
||||
<folder Name="osal">
|
||||
<file file_name="../lib/tinyusb/src/osal/osal.h" />
|
||||
<file file_name="../lib/tinyusb/src/osal/osal_none.h" />
|
||||
</folder>
|
||||
<folder Name="portable">
|
||||
<folder Name="nordic">
|
||||
<folder Name="nrf5x">
|
||||
<file file_name="../lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c" />
|
||||
</folder>
|
||||
</folder>
|
||||
</folder>
|
||||
</folder>
|
||||
<configuration Name="Feather52832" build_exclude_from_build="Yes" />
|
||||
</folder>
|
||||
<folder Name="nrfx">
|
||||
<file file_name="../lib/nrfx/nrfx.h" />
|
||||
<folder Name="drivers">
|
||||
<file file_name="../lib/nrfx/drivers/nrfx_common.h" />
|
||||
<file file_name="../lib/nrfx/drivers/nrfx_errors.h" />
|
||||
<folder Name="include">
|
||||
<file file_name="../lib/nrfx/drivers/include/nrf_bitmask.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_adc.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_clock.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_comp.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_gpiote.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_i2s.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_lpcomp.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_pdm.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_power.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_power_clock.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_ppi.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_pwm.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_qdec.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_qspi.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_rng.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_rtc.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_saadc.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_spi.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_spim.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_spis.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_swi.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_systick.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_timer.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_twi.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_twim.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_twis.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_uart.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_uarte.h" />
|
||||
<file file_name="../lib/nrfx/drivers/include/nrfx_wdt.h" />
|
||||
</folder>
|
||||
<folder Name="src">
|
||||
<file file_name="../lib/nrfx/drivers/src/nrfx_power.c" />
|
||||
<file file_name="../lib/nrfx/drivers/src/nrfx_nvmc.c" />
|
||||
</folder>
|
||||
</folder>
|
||||
<folder Name="hal">
|
||||
<file file_name="../lib/nrfx/hal/nrf_adc.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_ccm.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_clock.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_comp.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_ecb.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_egu.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_gpio.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_gpiote.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_i2s.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_lpcomp.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_nvmc.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_pdm.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_power.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_ppi.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_pwm.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_qdec.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_qspi.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_radio.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_rng.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_rtc.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_saadc.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_spi.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_spim.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_spis.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_systick.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_temp.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_timer.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_twi.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_twim.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_twis.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_uart.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_uarte.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_usbd.h" />
|
||||
<file file_name="../lib/nrfx/hal/nrf_wdt.h" />
|
||||
</folder>
|
||||
<folder Name="mdk">
|
||||
<file file_name="../lib/nrfx/mdk/compiler_abstraction.h" />
|
||||
<file file_name="../lib/nrfx/mdk/nrf.h" />
|
||||
<file file_name="../lib/nrfx/mdk/nrf52.h" />
|
||||
<file file_name="../lib/nrfx/mdk/nrf52832_peripherals.h" />
|
||||
<file file_name="../lib/nrfx/mdk/nrf52840.h" />
|
||||
<file file_name="../lib/nrfx/mdk/nrf52840_bitfields.h" />
|
||||
<file file_name="../lib/nrfx/mdk/nrf52840_peripherals.h" />
|
||||
<file file_name="../lib/nrfx/mdk/nrf52_bitfields.h" />
|
||||
<file file_name="../lib/nrfx/mdk/nrf_peripherals.h" />
|
||||
<file file_name="../lib/nrfx/mdk/ses_startup_nrf52.s">
|
||||
<configuration
|
||||
Name="Feather52840 Size++"
|
||||
build_exclude_from_build="Yes" />
|
||||
<configuration
|
||||
Name="Feather52840"
|
||||
build_exclude_from_build="Yes" />
|
||||
</file>
|
||||
<file file_name="../lib/nrfx/mdk/ses_startup_nrf52840.s">
|
||||
<configuration
|
||||
Name="Feather52840 Size++"
|
||||
build_exclude_from_build="No" />
|
||||
<configuration
|
||||
Name="Feather52832"
|
||||
build_exclude_from_build="Yes" />
|
||||
</file>
|
||||
<file file_name="../lib/nrfx/mdk/ses_startup_nrf_common.s">
|
||||
<configuration
|
||||
Name="Feather52840 Size++"
|
||||
build_exclude_from_build="No" />
|
||||
</file>
|
||||
<file file_name="../lib/nrfx/mdk/startup_config.h" />
|
||||
<file file_name="../lib/nrfx/mdk/system_nrf52.c">
|
||||
<configuration
|
||||
Name="Feather52840 Size++"
|
||||
build_exclude_from_build="Yes" />
|
||||
<configuration
|
||||
Name="Feather52840"
|
||||
build_exclude_from_build="Yes" />
|
||||
</file>
|
||||
<file file_name="../lib/nrfx/mdk/system_nrf52.h" />
|
||||
<file file_name="../lib/nrfx/mdk/system_nrf52840.c">
|
||||
<configuration
|
||||
Name="Feather52832"
|
||||
build_exclude_from_build="Yes" />
|
||||
</file>
|
||||
<file file_name="../lib/nrfx/mdk/system_nrf52840.h" />
|
||||
</folder>
|
||||
<folder Name="soc">
|
||||
<file file_name="../lib/nrfx/soc/nrfx_coredep.h" />
|
||||
<file file_name="../lib/nrfx/soc/nrfx_irqs.h" />
|
||||
<file file_name="../lib/nrfx/soc/nrfx_irqs_nrf51.h" />
|
||||
<file file_name="../lib/nrfx/soc/nrfx_irqs_nrf52810.h" />
|
||||
<file file_name="../lib/nrfx/soc/nrfx_irqs_nrf52832.h" />
|
||||
<file file_name="../lib/nrfx/soc/nrfx_irqs_nrf52840.h" />
|
||||
</folder>
|
||||
</folder>
|
||||
</folder>
|
||||
<configuration
|
||||
Name="Feather52840"
|
||||
c_preprocessor_definitions="NRF52840_XXAA;S140"
|
||||
c_user_include_directories="../src/boards/feather_nrf52840_express"
|
||||
gcc_optimization_level="Debug"
|
||||
linker_memory_map_file="nRF52840_xxAA_MemoryMap.xml" />
|
||||
<configuration
|
||||
Name="Feather52832"
|
||||
c_preprocessor_definitions="NRF52832_XXAA;S132"
|
||||
c_user_include_directories="../src/boards/feather_nrf52832"
|
||||
gcc_optimization_level="Debug"
|
||||
linker_memory_map_file="nRF52832_xxAA_MemoryMap.xml" />
|
||||
<folder Name="src">
|
||||
<folder Name="boards">
|
||||
<folder Name="feather_nrf52840_express">
|
||||
<file file_name="../src/boards/feather_nrf52840_express/board.h" />
|
||||
<file file_name="../src/boards/feather_nrf52840_express/pinconfig.c" />
|
||||
</folder>
|
||||
<file file_name="../src/boards/boards.c" />
|
||||
<file file_name="../src/boards/boards.h" />
|
||||
</folder>
|
||||
<folder
|
||||
Name="cmsis"
|
||||
exclude=""
|
||||
filter="*.c;*.h"
|
||||
path="../src/cmsis"
|
||||
recurse="Yes" />
|
||||
<file file_name="../src/dfu_ble_svc.c" />
|
||||
<file file_name="../src/dfu_init.c" />
|
||||
<file file_name="../src/flash_nrf5x.c" />
|
||||
<file file_name="../src/flash_nrf5x.h" />
|
||||
<file file_name="../src/main.c" />
|
||||
<file file_name="../src/nrfx_config.h" />
|
||||
<file file_name="../src/nrfx_glue.h" />
|
||||
<file file_name="../src/pstorage_platform.h" />
|
||||
<file file_name="../src/sdk_config.h" />
|
||||
<folder
|
||||
Name="usb"
|
||||
exclude=""
|
||||
filter="*.c;*.h"
|
||||
path="../src/usb"
|
||||
recurse="Yes" />
|
||||
</folder>
|
||||
</project>
|
||||
<configuration Name="Feather52840" />
|
||||
<configuration Name="Feather52832" />
|
||||
</solution>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Ha Thach for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef ADM_B_NRF52840_1_H
|
||||
#define ADM_B_NRF52840_1_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 19) // Red
|
||||
//#define LED_SECONDARY_PIN 12 // Blue
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
|
||||
#define BUTTON_1 _PINNUM(0, 11)
|
||||
#define BUTTON_2 _PINNUM(0, 12)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Atelier-Du-Maker"
|
||||
#define BLEDIS_MODEL "ADM_B_NRF52840_1"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x009F
|
||||
#define USB_DESC_CDC_ONLY_PID 0x009F
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "AtelierDuMaker NRF52840 Breakout"
|
||||
#define UF2_VOLUME_LABEL "ADM840BOOT"
|
||||
#define UF2_BOARD_ID "ADM_B_NRF52840_1"
|
||||
#define UF2_INDEX_URL "https://github.com/Atelier-Du-Maker/HolyIoT_NRF52840"
|
||||
|
||||
#endif // ADM_B_NRF52840_1_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Ha Thach for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _AE_BL652_BO_H
|
||||
#define _AE_BL652_BO_H
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 2
|
||||
#define LED_PRIMARY_PIN 17 // LED1
|
||||
#define LED_SECONDARY_PIN 19 // LED2
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 11 // BTN1
|
||||
#define BUTTON_2 15 // BTN2
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 8
|
||||
#define TX_PIN_NUMBER 6
|
||||
#define CTS_PIN_NUMBER 0
|
||||
#define RTS_PIN_NUMBER 0
|
||||
#define HWFC false
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Akizuki Denshi Tsusho"
|
||||
#define BLEDIS_MODEL "AE-BL652-BO"
|
||||
|
||||
#endif // _AE_BL652_BO_H
|
||||
@@ -0,0 +1,2 @@
|
||||
# nrf52 is nrf52832
|
||||
MCU_SUB_VARIANT = nrf52
|
||||
@@ -46,16 +46,9 @@
|
||||
#define BUTTON_2 _PINNUM(0, 29) // middle button
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER _PINNUM(0, 28) // SDA
|
||||
#define TX_PIN_NUMBER _PINNUM(0, 3) // SCL
|
||||
#define CTS_PIN_NUMBER 0
|
||||
#define RTS_PIN_NUMBER 0
|
||||
#define HWFC false
|
||||
|
||||
// Used as model string in OTA mode
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "ARAMCON Badge Team"
|
||||
#define BLEDIS_MODEL "ARAMCON Badge 2019"
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -47,15 +47,6 @@
|
||||
#define BUTTON_2 _PINNUM(0, 10)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 8
|
||||
#define TX_PIN_NUMBER 6
|
||||
#define CTS_PIN_NUMBER 0
|
||||
#define RTS_PIN_NUMBER 0
|
||||
#define HWFC false
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@@ -42,16 +42,9 @@
|
||||
#define BUTTON_2 _PINNUM(1, 12) // D3 switch
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER _PINNUM(1, 10)
|
||||
#define TX_PIN_NUMBER _PINNUM(1, 3)
|
||||
#define CTS_PIN_NUMBER 0
|
||||
#define RTS_PIN_NUMBER 0
|
||||
#define HWFC false
|
||||
|
||||
// Used as model string in OTA mode
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Arduino"
|
||||
#define BLEDIS_MODEL "Nano 33 BLE"
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Ha Thach for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _BASTBLE_NRF52840_H
|
||||
#define _BASTBLE_NRF52840_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1 // red LED
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 24)
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(0, 05)
|
||||
#define BUTTON_2 _PINNUM(0, 10)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "ElectronicCats"
|
||||
#define BLEDIS_MODEL "BastBLE"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Shared VID/PID with Feather nRF52840, will be disabled for building in the future
|
||||
#define USB_DESC_VID 0x1209
|
||||
#define USB_DESC_UF2_PID 0x805A
|
||||
#define USB_DESC_CDC_ONLY_PID 0x805A
|
||||
|
||||
#define UF2_PRODUCT_NAME "Bast BLE"
|
||||
#define UF2_VOLUME_LABEL "BASTBLE"
|
||||
#define UF2_BOARD_ID "Bast-ble-v1"
|
||||
#define UF2_INDEX_URL "https://www.electroniccats.com"
|
||||
|
||||
#endif // _BASTBLE_NRF52840_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Pierre Constantineau
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _BLUEMICRO_NRF52840_H
|
||||
#define _BLUEMICRO_NRF52840_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 2
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 4)
|
||||
#define LED_SECONDARY_PIN _PINNUM(1, 10)
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2 // none connected at all
|
||||
#define BUTTON_1 _PINNUM(0, 18) // unusable: RESET
|
||||
#define BUTTON_2 _PINNUM(1, 1) // no connection on E73-2G4M08S1C Module
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "BlueMicro"
|
||||
#define BLEDIS_MODEL "BlueMicro 840"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB PID from openmoko:
|
||||
// Approved PR https://github.com/openmoko/openmoko-usb-oui/pull/20
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x1d50
|
||||
#define USB_DESC_UF2_PID 0x6160
|
||||
#define USB_DESC_CDC_ONLY_PID 0x6160
|
||||
|
||||
#define UF2_PRODUCT_NAME "BlueMicro"
|
||||
#define UF2_VOLUME_LABEL "BLUEMICRO"
|
||||
#define UF2_BOARD_ID "nRF52840-BlueMicro-v1"
|
||||
#define UF2_INDEX_URL "http://bluemicro.jpconstantineau.com/"
|
||||
|
||||
#endif // _BLUEMICRO_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -82,6 +82,31 @@ void board_init(void)
|
||||
neopixel_init();
|
||||
#endif
|
||||
|
||||
#if ENABLE_DCDC_0 == 1
|
||||
NRF_POWER->DCDCEN0 = 1;
|
||||
#endif
|
||||
#if ENABLE_DCDC_1 == 1
|
||||
NRF_POWER->DCDCEN = 1;
|
||||
#endif
|
||||
|
||||
// When board is supplied on VDDH (and not VDD), this specifies what voltage the GPIO should run at
|
||||
// and what voltage is output at VDD. The default (0xffffffff) is 1.8V; typically you'll want
|
||||
// #define UICR_REGOUT0_VALUE UICR_REGOUT0_VOUT_3V3
|
||||
// in board.h when using that power configuration.
|
||||
#ifdef UICR_REGOUT0_VALUE
|
||||
if (NRF_UICR->REGOUT0 != UICR_REGOUT0_VALUE)
|
||||
{
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_UICR->REGOUT0 = UICR_REGOUT0_VALUE;
|
||||
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Init scheduler
|
||||
APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
|
||||
|
||||
@@ -132,11 +157,6 @@ void SysTick_Handler(void)
|
||||
}
|
||||
|
||||
|
||||
uint32_t tusb_hal_millis(void)
|
||||
{
|
||||
return ( ( ((uint64_t)app_timer_cnt_get())*1000*(APP_TIMER_CONFIG_RTC_FREQUENCY+1)) / APP_TIMER_CLOCK_FREQ );
|
||||
}
|
||||
|
||||
void pwm_teardown(NRF_PWM_Type* pwm )
|
||||
{
|
||||
pwm->TASKS_SEQSTART[0] = 0;
|
||||
@@ -295,7 +315,7 @@ void led_state(uint32_t state)
|
||||
} else if (temp_color_active) {
|
||||
final_color = (uint8_t*)&rgb_color;
|
||||
}
|
||||
#if LED_NEOPIXEL || defined(LED_RGB_RED_PIN)
|
||||
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN)
|
||||
if (final_color != NULL) {
|
||||
neopixel_write(final_color);
|
||||
}
|
||||
@@ -33,6 +33,10 @@
|
||||
|
||||
#include "board.h"
|
||||
|
||||
#ifndef UF2_VOLUME_LABEL
|
||||
#define UF2_VOLUME_LABEL "NRF52BOOT "
|
||||
#endif
|
||||
|
||||
#ifndef BUTTON_DFU
|
||||
#define BUTTON_DFU BUTTON_1
|
||||
#endif
|
||||
@@ -57,6 +61,14 @@
|
||||
#define BOARD_RGB_BRIGHTNESS 0x101010
|
||||
#endif
|
||||
|
||||
// Power configuration - should we enable DC/DC converters? (requires inductors on board)
|
||||
#ifndef ENABLE_DCDC_0
|
||||
#define ENABLE_DCDC_0 0
|
||||
#endif
|
||||
#ifndef ENABLE_DCDC_1
|
||||
#define ENABLE_DCDC_1 0
|
||||
#endif
|
||||
|
||||
// Helper function
|
||||
#define memclr(buffer, size) memset(buffer, 0, size)
|
||||
#define varclr(_var) memclr(_var, sizeof(*(_var)))
|
||||
@@ -105,18 +117,17 @@ bool is_ota(void);
|
||||
//--------------------------------------------------------------------+
|
||||
// DEBUG
|
||||
//--------------------------------------------------------------------+
|
||||
//#define CFG_DEBUG
|
||||
|
||||
#ifdef CFG_DEBUG
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define PRINTF printf
|
||||
#define PRINT_LOCATION() printf("%s: %d:\n", __PRETTY_FUNCTION__, __LINE__)
|
||||
#define PRINT_MESS(x) printf("%s: %d: %s \n" , __FUNCTION__, __LINE__, (char*)(x))
|
||||
#define PRTNT_HEAP() if (CFG_DEBUG == 3) printf("\n%s: %d: Heap free: %d\n", __FUNCTION__, __LINE__, util_heap_get_free_size())
|
||||
#define PRINT_STR(x) printf("%s: %d: " #x " = %s\n" , __FUNCTION__, __LINE__, (char*)(x) )
|
||||
#define PRINT_INT(x) printf("%s: %d: " #x " = %ld\n" , __FUNCTION__, __LINE__, (uint32_t) (x) )
|
||||
#define PRINT_HEX(x) printf("%s: %d: " #x " = 0x%X\n" , __FUNCTION__, __LINE__, (uint32_t) (x) )
|
||||
#define PRINT_HEX(x) printf("%s: %d: " #x " = 0x%lX\n" , __FUNCTION__, __LINE__, (uint32_t) (x) )
|
||||
|
||||
#define PRINT_BUFFER(buf, n) \
|
||||
do {\
|
||||
@@ -126,25 +137,16 @@ bool is_ota(void);
|
||||
printf("\n");\
|
||||
}while(0)
|
||||
|
||||
#define ADALOG(tag, ...) \
|
||||
do { \
|
||||
if ( tag ) printf("[%s] ", tag);\
|
||||
printf(__VA_ARGS__);\
|
||||
printf("\n");\
|
||||
}while(0)
|
||||
|
||||
#else
|
||||
|
||||
#define PRINTF(...)
|
||||
#define PRINT_LOCATION()
|
||||
#define PRINT_MESS(x)
|
||||
#define PRTNT_HEAP()
|
||||
#define PRINT_STR(x)
|
||||
#define PRINT_INT(x)
|
||||
#define PRINT_HEX(x)
|
||||
#define PRINT_BUFFER(buf, n)
|
||||
|
||||
#define ADALOG(...)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -46,16 +46,9 @@
|
||||
#define BUTTON_2 _PINNUM(1, 15) // right button
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLDOWN
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER _PINNUM(0, 30)
|
||||
#define TX_PIN_NUMBER _PINNUM(0, 14)
|
||||
#define CTS_PIN_NUMBER 0
|
||||
#define RTS_PIN_NUMBER 0
|
||||
#define HWFC false
|
||||
|
||||
// Used as model string in OTA mode
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Adafruit Industries"
|
||||
#define BLEDIS_MODEL "Circuit Playground nRF52840"
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -46,16 +46,9 @@
|
||||
#define BUTTON_2 _PINNUM(1, 10) // right button
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER _PINNUM(0, 09)
|
||||
#define TX_PIN_NUMBER _PINNUM(0, 10)
|
||||
#define CTS_PIN_NUMBER 0
|
||||
#define RTS_PIN_NUMBER 0
|
||||
#define HWFC false
|
||||
|
||||
// Used as model string in OTA mode
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Adafruit Industries"
|
||||
#define BLEDIS_MODEL "CLUE nRF52840"
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -47,19 +47,15 @@
|
||||
#define BUTTON_2 1 // P0.1 not exposed anywhere, FRST n/a
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 7
|
||||
#define TX_PIN_NUMBER 8
|
||||
#define CTS_PIN_NUMBER 0
|
||||
#define RTS_PIN_NUMBER 0
|
||||
#define HWFC false
|
||||
|
||||
// Used as model string in OTA mode
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Electronut Labs"
|
||||
#define BLEDIS_MODEL "Papyr"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define UF2_PRODUCT_NAME "Electronut Labs Papyr"
|
||||
#define UF2_BOARD_ID "nRF52840-Papyr-v1"
|
||||
#define UF2_INDEX_URL "https://docs.electronut.in/papyr"
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -50,7 +50,9 @@
|
||||
#define RTS_PIN_NUMBER 0
|
||||
#define HWFC false
|
||||
|
||||
// Used as model string in OTA mode
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Adafruit Industries"
|
||||
#define BLEDIS_MODEL "Feather nRF52832"
|
||||
|
||||
|
||||
@@ -47,15 +47,6 @@
|
||||
#define BUTTON_2 _PINNUM(0, 10)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 8
|
||||
#define TX_PIN_NUMBER 6
|
||||
#define CTS_PIN_NUMBER 0
|
||||
#define RTS_PIN_NUMBER 0
|
||||
#define HWFC false
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -47,15 +47,6 @@
|
||||
#define BUTTON_2 _PINNUM(0, 10)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 8
|
||||
#define TX_PIN_NUMBER 6
|
||||
#define CTS_PIN_NUMBER 0
|
||||
#define RTS_PIN_NUMBER 0
|
||||
#define HWFC false
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Ha Thach for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _IKIGAISENSE_VITA_NRF52840_H
|
||||
#define _IKIGAISENSE_VITA_NRF52840_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 2
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 15)
|
||||
#define LED_SECONDARY_PIN _PINNUM(1, 10)
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
#define LED_NEOPIXEL _PINNUM(0, 16)
|
||||
#define NEOPIXELS_NUMBER 1
|
||||
#define BOARD_RGB_BRIGHTNESS 0x040404
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(1, 02)
|
||||
#define BUTTON_2 _PINNUM(0, 10)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "IkigaiSense Technologies"
|
||||
#define BLEDIS_MODEL "Vita nRF52840"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0093
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0093
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "IkigaiSense Vita nRF52840"
|
||||
#define UF2_VOLUME_LABEL "ISVITABoot"
|
||||
#define UF2_BOARD_ID "nRF52840-isVITA-revA"
|
||||
#define UF2_INDEX_URL "https://github.com/ikigaisense/vita"
|
||||
|
||||
#endif // _IKIGAISENSE_VITA_NRF52840_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -46,16 +46,9 @@
|
||||
#define BUTTON_2 _PINNUM(1, 02) // D2 breakout
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER _PINNUM(0, 25)
|
||||
#define TX_PIN_NUMBER _PINNUM(0, 24)
|
||||
#define CTS_PIN_NUMBER 0
|
||||
#define RTS_PIN_NUMBER 0
|
||||
#define HWFC false
|
||||
|
||||
// Used as model string in OTA mode
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Adafruit Industries"
|
||||
#define BLEDIS_MODEL "ItsyBitsy nRF52840 Express"
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
31, 100, // used entries, total entries
|
||||
4, 0x1d, // PIN_BTN_A = PA29
|
||||
7, 0x29, // PIN_DOTSTAR_CLOCK = PB09
|
||||
8, 0x8, // PIN_DOTSTAR_DATA = PA08
|
||||
13, 0x6, // PIN_LED = PA06
|
||||
18, 0x14, // PIN_MISO = PA20
|
||||
19, 0xf, // PIN_MOSI = PA15
|
||||
21, 0x19, // PIN_RX = PA25
|
||||
23, 0xd, // PIN_SCK = PA13
|
||||
24, 0xe, // PIN_SCL = PA14
|
||||
25, 0x10, // PIN_SDA = PA16
|
||||
28, 0x18, // PIN_TX = PA24
|
||||
100, 0x4, // PIN_A0 = PA04
|
||||
101, 0x1e, // PIN_A1 = PA30
|
||||
102, 0x1c, // PIN_A2 = PA28
|
||||
103, 0x1f, // PIN_A3 = PA31
|
||||
104, 0x2, // PIN_A4 = PA02
|
||||
105, 0x3, // PIN_A5 = PA03
|
||||
152, 0x22, // PIN_D2 = PB02
|
||||
155, 0x1b, // PIN_D5 = PA27
|
||||
157, 0x28, // PIN_D7 = PB08
|
||||
159, 0x7, // PIN_D9 = PA07
|
||||
160, 0x5, // PIN_D10 = PA05
|
||||
161, 0x1a, // PIN_D11 = PA26
|
||||
162, 0xb, // PIN_D12 = PA11
|
||||
163, 0xc, // PIN_D13 = PA12
|
||||
201, 0x1, // NUM_DOTSTARS = 1
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -39,6 +39,7 @@
|
||||
//#define LED_RGB_GREEN_PIN _PINNUM(0, 22)
|
||||
//#define LED_RGB_BLUE_PIN _PINNUM(0, 24)
|
||||
#define BOARD_RGB_BRIGHTNESS 0x404040
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
@@ -48,10 +49,21 @@
|
||||
#define BUTTON_2 _PINNUM(0, 19) // no connection
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
// Used as model string in OTA mode
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "MakerDiary"
|
||||
#define BLEDIS_MODEL "nRF52840 Micro Dev Kit USB Dongle"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Shared VID/PID with Feather nRF52840, will be disabled for building in the future
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0029
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0029
|
||||
|
||||
#define UF2_PRODUCT_NAME "MDK nRF52840 USB Dongle"
|
||||
#define UF2_VOLUME_LABEL "MDK840DONGL"
|
||||
#define UF2_BOARD_ID "nRF52840-Dongle-v1"
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -47,16 +47,9 @@
|
||||
#define BUTTON_2 _PINNUM(2, 2)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 8
|
||||
#define TX_PIN_NUMBER 6
|
||||
#define CTS_PIN_NUMBER 0
|
||||
#define RTS_PIN_NUMBER 0
|
||||
#define HWFC false
|
||||
|
||||
// Used as model string in OTA mode
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Adafruit Industries"
|
||||
#define BLEDIS_MODEL "Metro nRF52840 Express"
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Nick Winans
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _NICENANO_H
|
||||
#define _NICENANO_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 15) // Blue
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2 // none connected at all
|
||||
#define BUTTON_1 _PINNUM(0, 18) // unusable: RESET
|
||||
#define BUTTON_2 _PINNUM(0, 19) // no connection
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Nice Keyboards"
|
||||
#define BLEDIS_MODEL "nice!nano"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x00B3
|
||||
#define USB_DESC_CDC_ONLY_PID 0x00B3
|
||||
|
||||
#define UF2_PRODUCT_NAME "nice!nano"
|
||||
#define UF2_VOLUME_LABEL "NICENANO"
|
||||
#define UF2_BOARD_ID "nRF52840-nicenano-v1"
|
||||
#define UF2_INDEX_URL "https://docs.nicekeyboards.com/#/nice!nano/"
|
||||
|
||||
#endif // _NICENANO_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Yihui Xiong for Makerdiary
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MAKERDIARY_NRF52840_M2_H_
|
||||
#define _MAKERDIARY_NRF52840_M2_H_
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 30) // Red
|
||||
#define LED_DOCK_GREEN_PIN _PINNUM(1, 7) // Only available on the M.2 Dock
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
#define LED_RGB_RED_PIN _PINNUM(0, 30)
|
||||
#define LED_RGB_GREEN_PIN _PINNUM(0, 29)
|
||||
#define LED_RGB_BLUE_PIN _PINNUM(0, 31)
|
||||
#define BOARD_RGB_BRIGHTNESS 0x404040
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(0, 19)
|
||||
#define BUTTON_2 _PINNUM(1, 7)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Makerdiary"
|
||||
#define BLEDIS_MODEL "nRF52840 M.2"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x2886
|
||||
#define USB_DESC_UF2_PID 0xF00F
|
||||
#define USB_DESC_CDC_ONLY_PID 0xF00F
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// UF2
|
||||
//--------------------------------------------------------------------+
|
||||
#define UF2_PRODUCT_NAME "MakerDiary nRF52840 M.2 Module"
|
||||
#define UF2_VOLUME_LABEL "nRF52840M2"
|
||||
#define UF2_BOARD_ID "nRF52840M2"
|
||||
#define UF2_INDEX_URL "https://wiki.makerdiary.com/nrf52840-m2"
|
||||
|
||||
|
||||
#endif /* _MAKERDIARY_NRF52840_M2_H_ */
|
||||
@@ -0,0 +1,2 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
USE_NFCT = yes
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -43,16 +43,9 @@
|
||||
#define BUTTON_2 _PINNUM(0, 03) // SW1
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER _PINNUM(0, 09)
|
||||
#define TX_PIN_NUMBER _PINNUM(0, 10)
|
||||
#define CTS_PIN_NUMBER 0
|
||||
#define RTS_PIN_NUMBER 0
|
||||
#define HWFC false
|
||||
|
||||
// Used as model string in OTA mode
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "OSHWA"
|
||||
#define BLEDIS_MODEL "OHS2020 Badge"
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -47,19 +47,21 @@
|
||||
#define BUTTON_FRESET _PINNUM(0, 03) // A0
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 8
|
||||
#define TX_PIN_NUMBER 6
|
||||
#define CTS_PIN_NUMBER 0
|
||||
#define RTS_PIN_NUMBER 0
|
||||
#define HWFC false
|
||||
|
||||
// Used as model string in OTA mode
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Particle Industries"
|
||||
#define BLEDIS_MODEL "Argon"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Shared VID/PID with Feather nRF52840, will be disabled for building in the future
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0029
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0029
|
||||
|
||||
#define UF2_PRODUCT_NAME "Particle Argon"
|
||||
#define UF2_VOLUME_LABEL "ARGONBOOT "
|
||||
#define UF2_BOARD_ID "nRF52840-Argon-v1"
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -47,19 +47,21 @@
|
||||
#define BUTTON_FRESET _PINNUM(0, 03) // A0
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 8
|
||||
#define TX_PIN_NUMBER 6
|
||||
#define CTS_PIN_NUMBER 0
|
||||
#define RTS_PIN_NUMBER 0
|
||||
#define HWFC false
|
||||
|
||||
// Used as model string in OTA mode
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Particle Industries"
|
||||
#define BLEDIS_MODEL "Boron"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Shared VID/PID with Feather nRF52840, will be disabled for building in the future
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0029
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0029
|
||||
|
||||
#define UF2_PRODUCT_NAME "Particle Boron"
|
||||
#define UF2_VOLUME_LABEL "BORONBOOT "
|
||||
#define UF2_BOARD_ID "nRF52840-Boron-v1"
|
||||
|
||||
Loaded 100 of 134 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user