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 | |
|---|---|---|---|
|
|
c01b7f9285 | ||
|
|
3718aaeeaf | ||
|
|
0526a2b120 | ||
|
|
ab4ecd141f | ||
|
|
8ccb638a84 | ||
|
|
fc63d5096a | ||
|
|
7d59a758da | ||
|
|
e2e220a505 | ||
|
|
9df8b8b870 | ||
|
|
802437220c | ||
|
|
80e0c1501e | ||
|
|
7bd3c5489f | ||
|
|
2446d02e59 | ||
|
|
c55783d9b5 | ||
|
|
c7cb5f971e | ||
|
|
be2ba81b4b | ||
|
|
7ddab6435f | ||
|
|
fe5cbd8183 | ||
|
|
563f15158d | ||
|
|
c5c2039bfd | ||
|
|
dd43e2ac87 | ||
|
|
27cd385c58 | ||
|
|
995b977b8a | ||
|
|
ddae34c381 | ||
|
|
6c2867bc00 | ||
|
|
9c6c0d3031 | ||
|
|
db63651473 | ||
|
|
32bfb2adae | ||
|
|
3114f92afb | ||
|
|
467bd2bf1c | ||
|
|
a83f5d8e11 | ||
|
|
9ff2378a25 | ||
|
|
5d04a6c26a | ||
|
|
2fe17d9996 | ||
|
|
54ca93d499 | ||
|
|
0e6936de76 | ||
|
|
454b281201 | ||
|
|
5b2b688d03 | ||
|
|
e25b63a43a | ||
|
|
6df0bfdc4c | ||
|
|
3adfba32c8 | ||
|
|
a78d555f79 | ||
|
|
16e7af43a3 | ||
|
|
1597434ed7 | ||
|
|
e3449cd771 | ||
|
|
c4cf262b95 | ||
|
|
cf6aca19b0 | ||
|
|
d0389fe8f4 | ||
|
|
7cd90551c9 | ||
|
|
254ed6253e | ||
|
|
8a979d33bc | ||
|
|
c6d02901b3 | ||
|
|
126115a2cb | ||
|
|
3d99a55940 | ||
|
|
f8fdf47823 | ||
|
|
85a1556864 | ||
|
|
9c474844be | ||
|
|
5f5371b9b3 | ||
|
|
1d7ca6a1dc | ||
|
|
7691f08ff0 | ||
|
|
5b6488ca70 | ||
|
|
9556f2ace8 | ||
|
|
ef4d0e7564 | ||
|
|
fc00e2b202 | ||
|
|
8906b2a8bd | ||
|
|
c751975f1d | ||
|
|
c3fc0dba91 | ||
|
|
a921f27ee8 | ||
|
|
04290e7bea | ||
|
|
d78322519a | ||
|
|
09daa09a5e | ||
|
|
661827c166 | ||
|
|
2c13fd53f4 | ||
|
|
b1029c6ae5 | ||
|
|
95325465cc | ||
|
|
580ae2e7fc | ||
|
|
4ce961f25b | ||
|
|
90e3149050 | ||
|
|
fb847b942e | ||
|
|
dfc3db25c3 | ||
|
|
bc40cd7c46 |
No files matched your search
@@ -0,0 +1,32 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: "[Bug]"
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**Set up (please complete the following information)**
|
||||
- Your Board and BSP version
|
||||
- Your OS (mac/windows/linux) and its version
|
||||
- Serial debug log (enable IDE's Debug Mode Level to 1 or 2)
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -0,0 +1,44 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v1
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v1.1.0
|
||||
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- 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"
|
||||
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`"
|
||||
|
||||
- name: Build
|
||||
run: python3 tools/build_all.py
|
||||
|
||||
- name: Upload Release Asset
|
||||
if: github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested')
|
||||
working-directory: tools
|
||||
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"
|
||||
|
||||
@@ -56,3 +56,5 @@ _build-*/
|
||||
bin/
|
||||
*.emSession
|
||||
*.jlink
|
||||
|
||||
TAGS
|
||||
File renamed without changes.
@@ -21,7 +21,7 @@ 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/$(SD_NAME)_v$(word 1, $(subst ., ,$(SD_VERSION))).ld
|
||||
LD_FILE = $(SRC_PATH)/linker/$(MCU_SUB_VARIANT)_$(SD_NAME)_v$(word 1, $(subst ., ,$(SD_VERSION))).ld
|
||||
|
||||
MERGED_FNAME = $(OUTPUT_FILENAME)_$(SD_NAME)_$(SD_VERSION)
|
||||
|
||||
@@ -41,6 +41,9 @@ else
|
||||
NRFJPROG = nrfjprog
|
||||
endif
|
||||
|
||||
# auto-detect BMP on macOS, otherwise have to specify
|
||||
BMP_PORT ?= $(shell ls -1 /dev/cu.usbmodem????????1 | head -1)
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
PROGFILES = C:/Program Files (x86)
|
||||
GNU_INSTALL_ROOT = $(PROGFILES)/GNU Tools ARM Embedded/7 2018-q2-update/bin/
|
||||
@@ -67,6 +70,9 @@ 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))))
|
||||
@@ -76,23 +82,33 @@ remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-ou
|
||||
#*********************************
|
||||
BOARD_LIST = $(sort $(subst .h,,$(subst src/boards/,,$(wildcard src/boards/*))))
|
||||
|
||||
NRF52832_BOARDLIST = feather_nrf52832
|
||||
IS_52832 = $(filter $(BOARD),$(NRF52832_BOARDLIST))
|
||||
|
||||
ifeq ($(filter $(BOARD),$(BOARD_LIST)),)
|
||||
$(info You must provide a BOARD parameter with 'BOARD='. Supported boards are:)
|
||||
$(info $(BOARD_LIST))
|
||||
$(error Invalid BOARD specified)
|
||||
endif
|
||||
|
||||
# Build directory
|
||||
BUILD = _build-$(BOARD)
|
||||
|
||||
ifneq ($(IS_52832),)
|
||||
SD_NAME = s132
|
||||
DFU_DEV_REV = 0xADAF
|
||||
# Board specific
|
||||
-include src/boards/$(BOARD)/board.mk
|
||||
|
||||
# MCU_SUB_VARIANT can be nrf52 (nrf52832), nrf52833, nrf52840
|
||||
ifeq ($(MCU_SUB_VARIANT),nrf52)
|
||||
SD_NAME = s132
|
||||
DFU_DEV_REV = 0xADAF
|
||||
MCU_FLAGS = -DNRF52 -DNRF52832_XXAA -DS132
|
||||
else ifeq ($(MCU_SUB_VARIANT),nrf52833)
|
||||
SD_NAME = s140
|
||||
DFU_DEV_REV = 52840
|
||||
MCU_FLAGS = -DNRF52833_XXAA -DS140
|
||||
else ifeq ($(MCU_SUB_VARIANT),nrf52840)
|
||||
SD_NAME = s140
|
||||
DFU_DEV_REV = 52840
|
||||
MCU_FLAGS = -DNRF52840_XXAA -DS140
|
||||
else
|
||||
SD_NAME = s140
|
||||
DFU_DEV_REV = 52840
|
||||
$(error Sub Variant $(MCU_SUB_VARIANT) is unknown)
|
||||
endif
|
||||
|
||||
#******************************************************************************
|
||||
@@ -106,9 +122,13 @@ 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 sources files in specific board
|
||||
C_SOURCE_FILES += $(wildcard $(SRC_PATH)/boards/$(BOARD)/*.c)
|
||||
|
||||
# nrfx
|
||||
C_SOURCE_FILES += $(NRFX_PATH)/drivers/src/nrfx_power.c
|
||||
C_SOURCE_FILES += $(NRFX_PATH)/hal/nrf_nvmc.c
|
||||
C_SOURCE_FILES += $(NRFX_PATH)/drivers/src/nrfx_nvmc.c
|
||||
C_SOURCE_FILES += $(NRFX_PATH)/mdk/system_$(MCU_SUB_VARIANT).c
|
||||
|
||||
# SDK 11 files
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader.c
|
||||
@@ -134,10 +154,8 @@ 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
|
||||
|
||||
ifneq ($(IS_52832),)
|
||||
|
||||
C_SOURCE_FILES += $(NRFX_PATH)/mdk/system_nrf52.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
|
||||
@@ -147,25 +165,19 @@ 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
|
||||
|
||||
# nrfx
|
||||
C_SOURCE_FILES += $(NRFX_PATH)/mdk/system_nrf52840.c
|
||||
|
||||
# Tinyusb stack
|
||||
# TinyUSB stack
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/portable/nordic/nrf5x/dcd_nrf5x.c
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/portable/nordic/nrf5x/hal_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)/class/custom/custom_device.c
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/tusb.c
|
||||
|
||||
endif
|
||||
@@ -174,11 +186,7 @@ endif
|
||||
#******************************************************************************
|
||||
# Assembly Files
|
||||
#******************************************************************************
|
||||
ifneq ($(IS_52832),)
|
||||
ASM_SOURCE_FILES = $(NRFX_PATH)/mdk/gcc_startup_nrf52.S
|
||||
else
|
||||
ASM_SOURCE_FILES = $(NRFX_PATH)/mdk/gcc_startup_nrf52840.S
|
||||
endif
|
||||
ASM_SOURCE_FILES = $(NRFX_PATH)/mdk/gcc_startup_$(MCU_SUB_VARIANT).S
|
||||
|
||||
#******************************************************************************
|
||||
# INCLUDE PATH
|
||||
@@ -198,6 +206,7 @@ IPATH += $(NRFX_PATH)
|
||||
IPATH += $(NRFX_PATH)/mdk
|
||||
IPATH += $(NRFX_PATH)/hal
|
||||
IPATH += $(NRFX_PATH)/drivers/include
|
||||
IPATH += $(NRFX_PATH)/drivers/src
|
||||
|
||||
IPATH += $(SDK11_PATH)/libraries/bootloader_dfu/hci_transport
|
||||
IPATH += $(SDK11_PATH)/libraries/bootloader_dfu
|
||||
@@ -245,6 +254,7 @@ 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)"'
|
||||
CFLAGS += -DBLEDIS_FW_VERSION='"$(GIT_VERSION) $(SD_NAME) $(SD_VERSION)"'
|
||||
@@ -252,15 +262,6 @@ 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))'
|
||||
|
||||
ifneq ($(IS_52832),)
|
||||
CFLAGS += -DNRF52
|
||||
CFLAGS += -DNRF52832_XXAA
|
||||
CFLAGS += -DS132
|
||||
else
|
||||
CFLAGS += -DNRF52840_XXAA
|
||||
CFLAGS += -DS140
|
||||
endif
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
# Linker Flags
|
||||
@@ -289,14 +290,7 @@ ASMFLAGS += -DBLE_STACK_SUPPORT_REQD
|
||||
ASMFLAGS += -DSWI_DISABLE0
|
||||
ASMFLAGS += -DSOFTDEVICE_PRESENT
|
||||
ASMFLAGS += -DFLOAT_ABI_HARD
|
||||
|
||||
ifneq ($(IS_52832),)
|
||||
ASMFLAGS += -DNRF52
|
||||
ASMFLAGS += -DS132
|
||||
else
|
||||
ASMFLAGS += -DNRF52840_XXAA
|
||||
ASMFLAGS += -DS140
|
||||
endif
|
||||
ASMFLAGS += $(MCU_FLAGS)
|
||||
|
||||
C_SOURCE_FILE_NAMES = $(notdir $(C_SOURCE_FILES))
|
||||
C_PATHS = $(call remduplicates, $(dir $(C_SOURCE_FILES) ) )
|
||||
@@ -355,6 +349,13 @@ erase:
|
||||
@echo Erasing chip
|
||||
$(NRFJPROG) --eraseall -f nrf52
|
||||
|
||||
gdbflash: $(BUILD)/$(MERGED_FNAME).hex
|
||||
@echo Flashing: $<
|
||||
@$(GDB_BMP) -nx --batch -ex 'load $<' -ex 'compare-sections' -ex 'kill'
|
||||
|
||||
gdb: $(BUILD)/$(OUTPUT_FILENAME)-nosd.out
|
||||
$(GDB_BMP) $<
|
||||
|
||||
#******************* Compile rules *******************
|
||||
|
||||
## Create build directories
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
# Adafruit nRF52 Bootloader
|
||||
|
||||
[](https://travis-ci.com/adafruit/Adafruit_nRF52_Bootloader)
|
||||
[](https://github.com/adafruit/Adafruit_nRF52_Bootloader/actions)
|
||||
|
||||
This is a CDC/DFU/UF2 bootloader for nRF52 boards.
|
||||
|
||||
- [Adafruit CLUE](https://www.adafruit.com/product/4500)
|
||||
- [Adafruit Circuit Playground Bluefruit](https://www.adafruit.com/product/4333)
|
||||
- [Adafruit Feather nRF52832](https://www.adafruit.com/product/3406)
|
||||
- [Adafruit Feather nRF52840 Express](https://www.adafruit.com/product/4062)
|
||||
- [Adafruit Feather nRF52840 Sense](https://www.adafruit.com/product/4516)
|
||||
- [Adafruit ItsyBitsy nRF52840 Express](https://www.adafruit.com/product/4481)
|
||||
- Adafruit Metro nRF52840 Express
|
||||
- [Electronut Labs Papyr](https://docs.electronut.in/papyr/)
|
||||
- MakerDiary MDK nRF52840 USB Dongle
|
||||
@@ -59,8 +63,8 @@ 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
|
||||
- `DFU = HIGH and `FRST = HIGH`: Go to application code if it is present, otherwise enter DFU with UF2
|
||||
- `DFU = HIGH` and `FRST = LOW`: Factory Reset mode: erase firmware application and its data
|
||||
- `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.
|
||||
|
||||
@@ -76,7 +80,7 @@ For other boards, please check the board definition for details.
|
||||
|
||||
### Making your own UF2
|
||||
|
||||
To create your own UF2 DFU update image, simply use the [Python conversion script](https://github.com/Microsoft/uf2/blob/master/utils/uf2conv.py) on a .bin file or .hex file, specifying the family as **0xADA52840**. Be sure to compile your application to start at 0x26000 (152k). If using a .bin file with the conversion script you must specify this with the -b switch.
|
||||
To create your own UF2 DFU update image, simply use the [Python conversion script](https://github.com/Microsoft/uf2/blob/master/utils/uf2conv.py) on a .bin file or .hex file, specifying the family as **0xADA52840**. If using a .bin file with the conversion script you must specify application address with the -b switch, this address depend on the SoftDevice size/version e.g S140 v6 is 0x26000
|
||||
|
||||
To create a UF2 image from a .bin file:
|
||||
```
|
||||
@@ -96,7 +100,7 @@ This is preferred if you are not developing/customizing the bootloader.
|
||||
Pre-builtin binaries are available on GitHub [releases](https://github.com/adafruit/Adafruit_nRF52_Bootloader/releases)
|
||||
|
||||
Note: The bootloader can be downgraded. Since the binary release is a merged version of
|
||||
of both bootloader and the Nordic SoftDevice, you can freely upgrade/downgrade to any version you like.
|
||||
both bootloader and the Nordic SoftDevice, you can freely upgrade/downgrade to any version you like.
|
||||
|
||||
## How to compile and build
|
||||
|
||||
@@ -108,7 +112,7 @@ You must have have a J-Link available to "unbrick" your device.
|
||||
Prerequisites
|
||||
|
||||
- ARM GCC
|
||||
- Nordic's [nRF5x Command Line Tools](http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.tools%2Fdita%2Ftools%2Fnrf5x_command_line_tools%2Fnrf5x_installation.html)
|
||||
- Nordic's [nRF5x Command Line Tools](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools)
|
||||
|
||||
To build:
|
||||
|
||||
@@ -162,7 +166,13 @@ Compiling file: main.c
|
||||
make: *** [_build/main.o] Error 127
|
||||
```
|
||||
|
||||
... you may need to edit the `Makefile` and update `GNU_INSTALL_ROOT` to point to the root path of your GCC ARM toolchain.
|
||||
... you may need to pass the location of the GCC ARM toolchain binaries to `make` using
|
||||
the variable `GNU_INSTALL_ROOT` as below:
|
||||
```
|
||||
$ make GNU_INSTALL_ROOT=/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/ BOARD=feather_nrf52832 all
|
||||
```
|
||||
|
||||
_Please note that the path needs a trailing path separator (a `/`)_
|
||||
|
||||
#### 2. `mergehex: No such file or directory`
|
||||
|
||||
|
||||
+30
-3
@@ -1,5 +1,33 @@
|
||||
# Adafruit nRF52 Bootloader Changelog
|
||||
|
||||
## 0.3.2 - 2020.03.12
|
||||
|
||||
- Make sure all pins are in reset state when jumping to app mode.
|
||||
|
||||
## 0.3.1 - 2020.03.05
|
||||
- Correct LED1 for Feather Sense and change volume name to FTHRSNSBOOT.
|
||||
|
||||
## 0.3.0 - 2020.01.13
|
||||
|
||||
- Upgrade nrfx to v2 for supporting future nrf mcu such as nrf52833, nrf5340
|
||||
- Upgrade TinyUSB
|
||||
- New boards support
|
||||
- Arduino ble nano 33
|
||||
- Adafruit CLUE
|
||||
- Raytac MDBT50Q-RX dongle
|
||||
- Migrate CI to github Action
|
||||
|
||||
## 0.2.13 - 2019.09.25
|
||||
|
||||
- Fixed button pulldown with Adafruit Circuit Playground Bluefruit, PR #77 thanks to @khanning
|
||||
|
||||
## 0.2.12 - 2019.08.22
|
||||
|
||||
- Fixed block alignment bug also in dfu_sd_image_validate (single & dual banks), PR #71 thanks to @fanoush
|
||||
- Added new board: Adafruit Circuit Playground Bluefruit
|
||||
- Added new board: Adafruit ItsyBitsy nRF52840 Express (WIP)
|
||||
- Fixed bug in __DOSTIME__ macro, PR #75 thanks to @henrygab
|
||||
|
||||
## 0.2.11
|
||||
|
||||
- Fixed various FAT issues, thanks to @henrygab
|
||||
@@ -8,7 +36,7 @@
|
||||
- NFC pins are forced to GPIO mode by bootloader
|
||||
- Added Metro nRF52840 Express VID/PID
|
||||
- Enhance board management
|
||||
- Added electronut/papyr_support
|
||||
- Added electronut/papyr_support
|
||||
|
||||
## 0.2.9
|
||||
|
||||
@@ -24,7 +52,7 @@
|
||||
- Fixed PWM psel[1] is not reset
|
||||
- Fixed #41 move RXD, TXD into board header
|
||||
- Added Metro nRF52840 Rev A
|
||||
- Fixed #40 OTA issue with BLE_GAP_EVT_PHY_UPDATE_REQUEST e.g connecting with iPhone X
|
||||
- Fixed #40 OTA issue with BLE_GAP_EVT_PHY_UPDATE_REQUEST e.g connecting with iPhone X
|
||||
|
||||
## 0.2.6
|
||||
|
||||
@@ -42,4 +70,3 @@
|
||||
- Fully support Feather nRF52840
|
||||
- Update bootloader with new led pattern
|
||||
- Fix #203: return software timer handle
|
||||
|
||||
+1
-1
Submodule lib/nrfx updated: 096e770ee4...7a4c9d946c.
@@ -119,11 +119,23 @@ __STATIC_INLINE void apply_config(nrf_drv_uart_t const * p_instance, nrf_drv_uar
|
||||
nrf_gpio_cfg_input(p_config->pselrxd, NRF_GPIO_PIN_NOPULL);
|
||||
}
|
||||
|
||||
nrf_uarte_config_t uarte_cfg =
|
||||
{
|
||||
.hwfc = (nrf_uarte_hwfc_t) p_config->hwfc,
|
||||
.parity = (nrf_uarte_parity_t) p_config->parity
|
||||
};
|
||||
|
||||
nrf_uart_config_t uart_cfg =
|
||||
{
|
||||
.hwfc = (nrf_uart_hwfc_t) p_config->hwfc,
|
||||
.parity = (nrf_uart_parity_t) p_config->parity
|
||||
};
|
||||
|
||||
CODE_FOR_UARTE
|
||||
(
|
||||
nrf_uarte_baudrate_set(p_instance->reg.p_uarte, (nrf_uarte_baudrate_t)p_config->baudrate);
|
||||
nrf_uarte_configure(p_instance->reg.p_uarte, (nrf_uarte_parity_t)p_config->parity,
|
||||
(nrf_uarte_hwfc_t)p_config->hwfc);
|
||||
// nrf_uarte_configure(p_instance->reg.p_uarte, (nrf_uarte_parity_t)p_config->parity, (nrf_uarte_hwfc_t)p_config->hwfc);
|
||||
nrf_uarte_configure(p_instance->reg.p_uarte, &uarte_cfg);
|
||||
nrf_uarte_txrx_pins_set(p_instance->reg.p_uarte, p_config->pseltxd, p_config->pselrxd);
|
||||
if (p_config->hwfc == NRF_UART_HWFC_ENABLED)
|
||||
{
|
||||
@@ -142,7 +154,8 @@ __STATIC_INLINE void apply_config(nrf_drv_uart_t const * p_instance, nrf_drv_uar
|
||||
CODE_FOR_UART
|
||||
(
|
||||
nrf_uart_baudrate_set(p_instance->reg.p_uart, p_config->baudrate);
|
||||
nrf_uart_configure(p_instance->reg.p_uart, p_config->parity, p_config->hwfc);
|
||||
// nrf_uart_configure(p_instance->reg.p_uart, p_config->parity, p_config->hwfc);
|
||||
nrf_uart_configure(p_instance->reg.p_uart, &uart_cfg);
|
||||
nrf_uart_txrx_pins_set(p_instance->reg.p_uart, p_config->pseltxd, p_config->pselrxd);
|
||||
if (p_config->hwfc == NRF_UART_HWFC_ENABLED)
|
||||
{
|
||||
|
||||
@@ -44,7 +44,8 @@
|
||||
#include "app_uart.h"
|
||||
#include "nrf_error.h"
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
// nRF has native usb peripheral
|
||||
#ifdef NRF_USBD
|
||||
#include "tusb.h"
|
||||
#endif
|
||||
|
||||
@@ -121,13 +122,17 @@ static uint32_t send_tx_byte_end(void);
|
||||
*/
|
||||
uint32_t (*send_tx_byte) (void) = send_tx_byte_default;
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
static uint32_t serial_put(char ch)
|
||||
{
|
||||
return tud_cdc_write_char(ch) ? NRF_SUCCESS : NRF_ERROR_NO_MEM;
|
||||
}
|
||||
#ifdef NRF_USBD
|
||||
|
||||
static uint32_t serial_put(char ch)
|
||||
{
|
||||
return tud_cdc_write_char(ch) ? NRF_SUCCESS : NRF_ERROR_NO_MEM;
|
||||
}
|
||||
|
||||
#else
|
||||
#define serial_put app_uart_put
|
||||
|
||||
#define serial_put app_uart_put
|
||||
|
||||
#endif
|
||||
|
||||
static uint32_t send_tx_byte_end(void)
|
||||
@@ -345,7 +350,7 @@ static bool rx_buffer_overflowed(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef NRF_USBD
|
||||
|
||||
static uint32_t slip_uart_open(void)
|
||||
{
|
||||
@@ -441,7 +446,8 @@ uint32_t hci_slip_open()
|
||||
uint32_t hci_slip_close()
|
||||
{
|
||||
m_current_state = SLIP_OFF;
|
||||
#ifdef NRF52840_XXAA
|
||||
|
||||
#ifdef NRF_USBD
|
||||
return NRF_SUCCESS;
|
||||
#else
|
||||
uint32_t err_code = app_uart_close();
|
||||
|
||||
@@ -40,11 +40,11 @@
|
||||
#define INVALID_OPCODE 0x00 /**< Invalid op code identifier. */
|
||||
|
||||
#ifdef NRF51
|
||||
#define SOC_MAX_WRITE_SIZE 1024 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API on the nRF51. */
|
||||
#elif defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
|
||||
#define SOC_MAX_WRITE_SIZE 4096 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API on the nRF52. */
|
||||
#define SOC_MAX_WRITE_SIZE 1024 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API on the nRF51. */
|
||||
#elif defined(NRF52_SERIES)
|
||||
#define SOC_MAX_WRITE_SIZE 4096 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API on the nRF52. */
|
||||
#else
|
||||
#error No target defined
|
||||
#error No target defined
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include "boards.h"
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef NRF_USBD
|
||||
#include "tusb.h"
|
||||
#endif
|
||||
|
||||
@@ -40,11 +40,11 @@
|
||||
|
||||
#define IRQ_ENABLED 0x01 /**< Field identifying if an interrupt is enabled. */
|
||||
|
||||
/**< Maximum number of interrupts available. */
|
||||
/**< Maximum number of interrupts available. (from IRQn_Type) */
|
||||
#if defined(NRF52832_XXAA)
|
||||
#define MAX_NUMBER_INTERRUPTS 39
|
||||
#elif defined(NRF52840_XXAA)
|
||||
#define MAX_NUMBER_INTERRUPTS 48
|
||||
#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.
|
||||
@@ -119,17 +119,16 @@ static void wait_for_events(void)
|
||||
|
||||
// Feed all Watchdog just in case application enable it
|
||||
// WDT cannot be disabled once started. It even last through soft reset (NVIC Reset)
|
||||
if ( nrf_wdt_started() )
|
||||
if ( nrf_wdt_started(NRF_WDT) )
|
||||
{
|
||||
for (uint8_t i=0; i<8; i++) nrf_wdt_reload_request_set(i);
|
||||
for (uint8_t i=0; i<8; i++) nrf_wdt_reload_request_set(NRF_WDT, i);
|
||||
}
|
||||
|
||||
// Event received. Process it from the scheduler.
|
||||
app_sched_execute();
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef NRF_USBD
|
||||
// skip if usb is not inited ( e.g OTA / finializing sd/bootloader )
|
||||
extern bool usb_inited(void);
|
||||
if ( tusb_inited() )
|
||||
{
|
||||
tud_task();
|
||||
@@ -194,8 +193,8 @@ static void bootloader_settings_save(bootloader_settings_t * p_settings)
|
||||
}
|
||||
else
|
||||
{
|
||||
nrf_nvmc_page_erase(BOOTLOADER_SETTINGS_ADDRESS);
|
||||
nrf_nvmc_write_words(BOOTLOADER_SETTINGS_ADDRESS, (uint32_t *) p_settings, sizeof(bootloader_settings_t) / 4);
|
||||
nrfx_nvmc_page_erase(BOOTLOADER_SETTINGS_ADDRESS);
|
||||
nrfx_nvmc_words_write(BOOTLOADER_SETTINGS_ADDRESS, (uint32_t *) p_settings, sizeof(bootloader_settings_t) / 4);
|
||||
|
||||
pstorage_callback_handler(&m_bootsettings_handle, PSTORAGE_STORE_OP_CODE, NRF_SUCCESS, (uint8_t *) p_settings, sizeof(bootloader_settings_t));
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ __root const uint32_t m_uicr_bootloader_start_address @ NRF_UICR_BOOT_START_A
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
|
||||
#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. */
|
||||
@@ -50,7 +50,7 @@ __no_init uint8_t m_mbr_params_page[CODE_PAGE_SIZE] @ BOOTLOADER_MBR_PARAMS_
|
||||
__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 // defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
|
||||
#endif // NRF52_SERIES
|
||||
|
||||
|
||||
void bootloader_util_settings_get(const bootloader_settings_t ** pp_bootloader_settings)
|
||||
|
||||
@@ -817,6 +817,9 @@ uint32_t dfu_sd_image_validate(void)
|
||||
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;
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ static void dfu_prepare_func_app_erase(uint32_t image_size)
|
||||
|
||||
for ( uint32_t i = 0; i < page_count; i++ )
|
||||
{
|
||||
nrf_nvmc_page_erase(DFU_BANK_0_REGION_START + i * CODE_PAGE_SIZE);
|
||||
nrfx_nvmc_page_erase(DFU_BANK_0_REGION_START + i * CODE_PAGE_SIZE);
|
||||
}
|
||||
|
||||
// invoke complete callback
|
||||
@@ -790,6 +790,9 @@ uint32_t dfu_sd_image_validate(void)
|
||||
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;
|
||||
|
||||
|
||||
@@ -30,22 +30,20 @@
|
||||
#include "app_util.h"
|
||||
|
||||
#define NRF_UICR_BOOT_START_ADDRESS (NRF_UICR_BASE + 0x14) /**< Register where the bootloader start address is stored in the UICR register. */
|
||||
|
||||
#if defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
|
||||
#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).*/
|
||||
#endif
|
||||
|
||||
#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. */
|
||||
#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. */
|
||||
|
||||
|
||||
#if defined(NRF52832_XXAA)
|
||||
// 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. */
|
||||
|
||||
// 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. */
|
||||
|
||||
+1
-1
Submodule lib/tinyusb updated: 55874813f8...23df777b30.
+40
-20
@@ -34,18 +34,28 @@
|
||||
#define SCHED_QUEUE_SIZE 30 /**< Maximum number of events in the scheduler queue. */
|
||||
|
||||
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN)
|
||||
void neopixel_init(void);
|
||||
void neopixel_write(uint8_t *pixels);
|
||||
void neopixel_teardown(void);
|
||||
#endif
|
||||
|
||||
//------------- IMPLEMENTATION -------------//
|
||||
void button_init(uint32_t pin)
|
||||
{
|
||||
nrf_gpio_cfg_sense_input(pin, BUTTON_PULL, NRF_GPIO_PIN_SENSE_LOW);
|
||||
if ( BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN )
|
||||
{
|
||||
nrf_gpio_cfg_sense_input(pin, BUTTON_PULL, NRF_GPIO_PIN_SENSE_HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
nrf_gpio_cfg_sense_input(pin, BUTTON_PULL, NRF_GPIO_PIN_SENSE_LOW);
|
||||
}
|
||||
}
|
||||
|
||||
bool button_pressed(uint32_t pin)
|
||||
{
|
||||
return (nrf_gpio_pin_read(pin) == 0) ? true : false;
|
||||
uint32_t const active_state = (BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN ? 1 : 0);
|
||||
return nrf_gpio_pin_read(pin) == active_state;
|
||||
}
|
||||
|
||||
void board_init(void)
|
||||
@@ -67,9 +77,8 @@ void board_init(void)
|
||||
led_pwm_init(LED_SECONDARY, LED_SECONDARY_PIN);
|
||||
#endif
|
||||
|
||||
// use neopixel for use enumeration
|
||||
// use neopixel for use enumeration
|
||||
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN)
|
||||
extern void neopixel_init(void);
|
||||
neopixel_init();
|
||||
#endif
|
||||
|
||||
@@ -93,10 +102,8 @@ void board_teardown(void)
|
||||
led_pwm_teardown();
|
||||
|
||||
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN)
|
||||
extern void neopixel_teardown(void);
|
||||
neopixel_teardown();
|
||||
#endif
|
||||
// Button
|
||||
|
||||
// Stop RTC1 used by app_timer
|
||||
NVIC_DisableIRQ(RTC1_IRQn);
|
||||
@@ -107,6 +114,13 @@ void board_teardown(void)
|
||||
|
||||
// Stop LF clock
|
||||
NRF_CLOCK->TASKS_LFCLKSTOP = 1UL;
|
||||
|
||||
// make sure all pins are back in reset state
|
||||
// NUMBER_OF_PINS is defined in nrf_gpio.h
|
||||
for (int i = 0; i < NUMBER_OF_PINS; ++i)
|
||||
{
|
||||
nrf_gpio_cfg_default(i);
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t _systick_count = 0;
|
||||
@@ -297,9 +311,9 @@ void led_state(uint32_t state)
|
||||
#define MAGIC_T1H 13UL | (0x8000) // 0.8125us
|
||||
#define CTOPVAL 20UL // 1.25us
|
||||
|
||||
#define NEO_NUMBYTE 3
|
||||
#define BYTE_PER_PIXEL 3
|
||||
|
||||
static uint16_t pixels_pattern[NEO_NUMBYTE * 8 + 2];
|
||||
static uint16_t pixels_pattern[NEOPIXELS_NUMBER*BYTE_PER_PIXEL * 8 + 2];
|
||||
|
||||
// use PWM1 for neopixel
|
||||
void neopixel_init(void)
|
||||
@@ -347,29 +361,35 @@ void neopixel_init(void)
|
||||
|
||||
void neopixel_teardown(void)
|
||||
{
|
||||
uint8_t grb[3] = { 0, 0, 0 };
|
||||
uint8_t rgb[3] = { 0, 0, 0 };
|
||||
|
||||
NRFX_DELAY_US(50); // wait for previous write is complete
|
||||
|
||||
neopixel_write(grb);
|
||||
neopixel_write(rgb);
|
||||
NRFX_DELAY_US(50); // wait for this write
|
||||
|
||||
pwm_teardown(NRF_PWM1);
|
||||
}
|
||||
|
||||
// write 3 bytes color to a built-in neopixel
|
||||
// write 3 bytes color RGB to built-in neopixel
|
||||
void neopixel_write (uint8_t *pixels)
|
||||
{
|
||||
uint8_t grb[NEO_NUMBYTE] = {pixels[1], pixels[2], pixels[0]};
|
||||
// convert RGB to GRB
|
||||
uint8_t grb[BYTE_PER_PIXEL] = {pixels[1], pixels[2], pixels[0]};
|
||||
uint16_t pos = 0; // bit position
|
||||
for ( uint16_t n = 0; n < NEO_NUMBYTE; n++ )
|
||||
{
|
||||
uint8_t pix = grb[n];
|
||||
|
||||
for ( uint8_t mask = 0x80; mask > 0; mask >>= 1 )
|
||||
// Set all neopixel to same value
|
||||
for (uint16_t n = 0; n < NEOPIXELS_NUMBER; n++ )
|
||||
{
|
||||
for(uint8_t c = 0; c < BYTE_PER_PIXEL; c++)
|
||||
{
|
||||
pixels_pattern[pos] = (pix & mask) ? MAGIC_T1H : MAGIC_T0H;
|
||||
pos++;
|
||||
uint8_t const pix = grb[c];
|
||||
|
||||
for ( uint8_t mask = 0x80; mask > 0; mask >>= 1 )
|
||||
{
|
||||
pixels_pattern[pos] = (pix & mask) ? MAGIC_T1H : MAGIC_T0H;
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,8 +429,8 @@ void neopixel_init(void)
|
||||
|
||||
void neopixel_teardown(void)
|
||||
{
|
||||
uint8_t grb[3] = { 0, 0, 0 };
|
||||
neopixel_write(grb);
|
||||
uint8_t rgb[3] = { 0, 0, 0 };
|
||||
neopixel_write(rgb);
|
||||
nrf_gpio_cfg_default(LED_RGB_RED_PIN);
|
||||
nrf_gpio_cfg_default(LED_RGB_GREEN_PIN);
|
||||
nrf_gpio_cfg_default(LED_RGB_BLUE_PIN);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "nrf.h"
|
||||
#include "nrf_gpio.h"
|
||||
|
||||
#include "board.h"
|
||||
@@ -35,6 +36,7 @@
|
||||
#ifndef BUTTON_DFU
|
||||
#define BUTTON_DFU BUTTON_1
|
||||
#endif
|
||||
|
||||
#ifndef BUTTON_FRESET
|
||||
#define BUTTON_FRESET BUTTON_2
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Uri Shaked
|
||||
* Copyright (c) 2019 Benjamin Meisels
|
||||
*
|
||||
* 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 _ARAMCON_BADGE_2019_H
|
||||
#define _ARAMCON_BADGE_2019_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 11) // Red
|
||||
|
||||
#define LED_NEOPIXEL _PINNUM(0, 8)
|
||||
#define NEOPIXELS_NUMBER 4
|
||||
#define BOARD_RGB_BRIGHTNESS 0x040404
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(0, 2) // left Button
|
||||
#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
|
||||
#define BLEDIS_MANUFACTURER "ARAMCON Badge Team"
|
||||
#define BLEDIS_MODEL "ARAMCON Badge 2019"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0079
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0079
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "ARAMCON Badge 2019"
|
||||
#define UF2_VOLUME_LABEL "ARAMBOOT"
|
||||
#define UF2_BOARD_ID "nrf52840-ARAMCON-Badge-2019"
|
||||
#define UF2_INDEX_URL "https://github.com/aramcon-badge"
|
||||
|
||||
#endif // _ARAMCON_BADGE_2019_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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 _ARCARDE_FEATHER_NRF52840_H
|
||||
#define _ARCARDE_FEATHER_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
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* 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 "Adafruit Industries"
|
||||
#define BLEDIS_MODEL "Feather nRF52840 Express"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0029
|
||||
#define USB_DESC_CDC_ONLY_PID 0x002A
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52840 Express"
|
||||
#define UF2_VOLUME_LABEL "ARCADE-N4"
|
||||
#define UF2_BOARD_ID "nRF52840-Feather-revD"
|
||||
#define UF2_INDEX_URL "https://www.adafruit.com/product/4062"
|
||||
|
||||
#endif // _ARCARDE_FEATHER_NRF52840_H
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -0,0 +1,62 @@
|
||||
#include "boards.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] = {
|
||||
/* CF2 START */
|
||||
513675505, 539130489, // magic
|
||||
49, 100, // used entries, total entries
|
||||
4, 0x18, // PIN_BTN_A = PIN_RX
|
||||
5, 0xa, // PIN_BTN_B = PIN_D2
|
||||
13, 0x29, // PIN_LED = PIN_D13
|
||||
18, 0xf, // PIN_MISO = PA15
|
||||
19, 0xd, // PIN_MOSI = PA13
|
||||
20, 0x23, // PIN_NEOPIXEL = PB03
|
||||
21, 0x18, // PIN_RX = PA24
|
||||
23, 0xe, // PIN_SCK = PA14
|
||||
24, 0xb, // PIN_SCL = PA11
|
||||
25, 0xc, // PIN_SDA = PA12
|
||||
28, 0x19, // PIN_TX = PA25
|
||||
32, 0xe, // PIN_DISPLAY_SCK = PIN_SCK
|
||||
34, 0xd, // PIN_DISPLAY_MOSI = PIN_MOSI
|
||||
35, 0x1e, // PIN_DISPLAY_CS = PIN_A2
|
||||
36, 0x1c, // PIN_DISPLAY_DC = PIN_A3
|
||||
37, 0xa0, // DISPLAY_WIDTH = 160
|
||||
38, 0x80, // DISPLAY_HEIGHT = 128
|
||||
39, 0x80, // DISPLAY_CFG0 = 0x80
|
||||
40, 0x603, // DISPLAY_CFG1 = 0x603
|
||||
41, 0x20, // DISPLAY_CFG2 = 0x20
|
||||
43, 0x2, // PIN_DISPLAY_RST = PIN_A4
|
||||
44, 0x3, // PIN_DISPLAY_BL = PIN_A5
|
||||
47, 0x6, // PIN_BTN_LEFT = PIN_D11
|
||||
48, 0x1a, // PIN_BTN_RIGHT = PIN_D9
|
||||
49, 0x1b, // PIN_BTN_UP = PIN_D10
|
||||
50, 0x7, // PIN_BTN_DOWN = PIN_D6
|
||||
51, 0x8, // PIN_BTN_MENU = PIN_D12
|
||||
56, 0x2a, // PIN_LED2 = PB10
|
||||
60, 0x19, // PIN_JACK_TX = PIN_TX
|
||||
100, 0x4, // PIN_A0 = PA04
|
||||
101, 0x5, // PIN_A1 = PA05
|
||||
102, 0x1e, // PIN_A2 = PA30
|
||||
103, 0x1c, // PIN_A3 = PA28
|
||||
104, 0x2, // PIN_A4 = PA02
|
||||
105, 0x3, // PIN_A5 = PA03
|
||||
152, 0xa, // PIN_D2 = PA10
|
||||
155, 0x28, // PIN_D5 = PB08
|
||||
156, 0x7, // PIN_D6 = PA07
|
||||
159, 0x1a, // PIN_D9 = PA26
|
||||
160, 0x1b, // PIN_D10 = PA27
|
||||
161, 0x6, // PIN_D11 = PA06
|
||||
162, 0x8, // PIN_D12 = PA08
|
||||
163, 0x29, // PIN_D13 = PB09
|
||||
200, 0x1, // NUM_NEOPIXELS = 1
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, 0xd7688ea1, // BOOTLOADER_BOARD_ID = 0xd7688ea1
|
||||
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,
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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 _ARDUINOBLE33_NRF52840_H
|
||||
#define _ARDUINOBLE33_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(1, 11) // D2 switch
|
||||
#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
|
||||
#define BLEDIS_MANUFACTURER "Arduino"
|
||||
#define BLEDIS_MODEL "Nano 33 BLE"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0063
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0064
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Arduino Nano 33 BLE"
|
||||
#define UF2_VOLUME_LABEL "NANO33BOOT"
|
||||
#define UF2_BOARD_ID "nRF52840-Nano-33"
|
||||
#define UF2_INDEX_URL "https://www.arduino.cc/"
|
||||
|
||||
#endif // _ITSY_NRF52840_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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 _CPLAY_NRF52840_H
|
||||
#define _CPLAY_NRF52840_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 14)
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
#define LED_NEOPIXEL _PINNUM(0, 13)
|
||||
#define NEOPIXELS_NUMBER 10
|
||||
#define BOARD_RGB_BRIGHTNESS 0x040404
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(1, 02) // left button
|
||||
#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
|
||||
#define BLEDIS_MANUFACTURER "Adafruit Industries"
|
||||
#define BLEDIS_MODEL "Circuit Playground nRF52840"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0045
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0045
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Adafruit Circuit Playground nRF52840"
|
||||
#define UF2_VOLUME_LABEL "CPLAYBTBOOT"
|
||||
#define UF2_BOARD_ID "nRF52840-CircuitPlayground-revD"
|
||||
#define UF2_INDEX_URL "https://www.adafruit.com/product/4333"
|
||||
|
||||
#endif // _CPLAY_NRF52840_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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 _CLUE_NRF52840_H
|
||||
#define _CLUE_NRF52840_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 01)
|
||||
#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) // left button
|
||||
#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
|
||||
#define BLEDIS_MANUFACTURER "Adafruit Industries"
|
||||
#define BLEDIS_MODEL "CLUE nRF52840"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0071
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0071
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Adafruit CLUE nRF52840"
|
||||
#define UF2_VOLUME_LABEL "CLUEBOOT"
|
||||
#define UF2_BOARD_ID "nRF52840-CLUE-revA"
|
||||
#define UF2_INDEX_URL "https://www.adafruit.com/product/4500"
|
||||
|
||||
#endif // _CLUE_NRF52840_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -48,7 +48,7 @@
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 7
|
||||
#define TX_PIN_NUMBER 8
|
||||
@@ -67,24 +67,4 @@
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x003B
|
||||
|
||||
#define USB_STRING_DESCRIPTORS { \
|
||||
/* 0: is supported language = English */ \
|
||||
TUD_DESC_STRCONV(0x0409), \
|
||||
\
|
||||
/* 1: Manufacturer */ \
|
||||
TUD_DESC_STRCONV('E','l','e','c','t','r','o','n','u','t',' ','L','a','b','s'), \
|
||||
\
|
||||
/* 2: Product */ \
|
||||
TUD_DESC_STRCONV('P','a','p','y','r', ' ', 'D','F','U'), \
|
||||
\
|
||||
/* 3: Serials TODO use chip ID */ \
|
||||
usb_desc_str_serial, \
|
||||
\
|
||||
/* 4: CDC Interface */ \
|
||||
TUD_DESC_STRCONV('P','a','p','y','r',' ','S','e','r','i','a','l'), \
|
||||
\
|
||||
/* 5: MSC Interface */ \
|
||||
TUD_DESC_STRCONV('P','a','p','y','r',' ','U','F','2'), \
|
||||
}
|
||||
|
||||
#endif // PPAPYR_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -42,7 +42,7 @@
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 8
|
||||
#define TX_PIN_NUMBER 6
|
||||
@@ -51,10 +51,10 @@
|
||||
#define HWFC false
|
||||
|
||||
// Used as model string in OTA mode
|
||||
#define BLEDIS_MANUFACTURER "Adafruit Industries"
|
||||
#define BLEDIS_MODEL "Feather nRF52832"
|
||||
#define BLEDIS_MANUFACTURER "Adafruit Industries"
|
||||
#define BLEDIS_MODEL "Feather nRF52832"
|
||||
|
||||
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52832"
|
||||
#define UF2_INDEX_URL "https://www.adafruit.com/product/3406"
|
||||
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52832"
|
||||
#define UF2_INDEX_URL "https://www.adafruit.com/product/3406"
|
||||
|
||||
#endif // _FEATHER_NRF52832_H
|
||||
@@ -0,0 +1,2 @@
|
||||
# nrf52 is nrf52832
|
||||
MCU_SUB_VARIANT = nrf52
|
||||
@@ -33,10 +33,12 @@
|
||||
#define LEDS_NUMBER 2
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 15)
|
||||
#define LED_SECONDARY_PIN _PINNUM(1, 10)
|
||||
#define LED_NEOPIXEL 16
|
||||
#define BOARD_RGB_BRIGHTNESS 0x040404
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
#define LED_NEOPIXEL _PINNUM(0, 16)
|
||||
#define NEOPIXELS_NUMBER 1
|
||||
#define BOARD_RGB_BRIGHTNESS 0x040404
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
@@ -46,7 +48,7 @@
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 8
|
||||
#define TX_PIN_NUMBER 6
|
||||
@@ -54,7 +56,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 nRF52840 Express"
|
||||
|
||||
@@ -66,9 +70,9 @@
|
||||
#define USB_DESC_CDC_ONLY_PID 0x002A
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52840 Express"
|
||||
#define UF2_VOLUME_LABEL "FTHR840BOOT"
|
||||
#define UF2_BOARD_ID "nRF52840-Feather-revD"
|
||||
#define UF2_INDEX_URL "https://www.adafruit.com/product/4062"
|
||||
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52840 Express"
|
||||
#define UF2_VOLUME_LABEL "FTHR840BOOT"
|
||||
#define UF2_BOARD_ID "nRF52840-Feather-revD"
|
||||
#define UF2_INDEX_URL "https://www.adafruit.com/product/4062"
|
||||
|
||||
#endif // _FEATHER_NRF52840_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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 _FEATHER_NRF52840_SENSE_H
|
||||
#define _FEATHER_NRF52840_SENSE_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 2
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 9)
|
||||
#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
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* 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 "Adafruit Industries"
|
||||
#define BLEDIS_MODEL "Feather nRF52840 Sense"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0087
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0088
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52840 Sense"
|
||||
#define UF2_VOLUME_LABEL "FTHRSNSBOOT"
|
||||
#define UF2_BOARD_ID "nRF52840-Feather-Sense"
|
||||
#define UF2_INDEX_URL "https://www.adafruit.com/product/4516"
|
||||
|
||||
#endif // _FEATHER_NRF52840_SENSE_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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 _ITSYBITSY_NRF52840_H
|
||||
#define _ITSYBITSY_NRF52840_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 6)
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
#define LED_NEOPIXEL _PINNUM(0, 8)
|
||||
#define NEOPIXELS_NUMBER 1
|
||||
#define BOARD_RGB_BRIGHTNESS 0x040404
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(0, 29) // user switch
|
||||
#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
|
||||
#define BLEDIS_MANUFACTURER "Adafruit Industries"
|
||||
#define BLEDIS_MODEL "ItsyBitsy nRF52840 Express"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0051
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0052
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Adafruit ItsyBitsy nRF52840 Express"
|
||||
#define UF2_VOLUME_LABEL "ITSY840BOOT"
|
||||
#define UF2_BOARD_ID "nRF52840-ItsyBitsy-revA"
|
||||
#define UF2_INDEX_URL "https://www.adafruit.com/"
|
||||
|
||||
#endif // _ITSY_NRF52840_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -33,10 +33,12 @@
|
||||
#define LEDS_NUMBER 2
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 13)
|
||||
#define LED_SECONDARY_PIN _PINNUM(1, 15)
|
||||
#define LED_NEOPIXEL _PINNUM(0, 13)
|
||||
#define BOARD_RGB_BRIGHTNESS 0x040404
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
#define LED_NEOPIXEL _PINNUM(0, 13)
|
||||
#define NEOPIXELS_NUMBER 1
|
||||
#define BOARD_RGB_BRIGHTNESS 0x040404
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
@@ -46,7 +48,7 @@
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 8
|
||||
#define TX_PIN_NUMBER 6
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Ha Thach for Adafruit Industries
|
||||
* Copyright (c) 2020 Michael Welling
|
||||
*
|
||||
* 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 _OHS2020_BADGE_H
|
||||
#define _OHS2020_BADGE_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 04) // fake LED since we have none
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(0, 29) // SW2
|
||||
#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
|
||||
#define BLEDIS_MANUFACTURER "OSHWA"
|
||||
#define BLEDIS_MODEL "OHS2020 Badge"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x007F
|
||||
#define USB_DESC_CDC_ONLY_PID 0x007F
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "OHS2020 Badge"
|
||||
#define UF2_VOLUME_LABEL "BADGEBOOT"
|
||||
#define UF2_BOARD_ID "OHS2020-Badge-revA"
|
||||
#define UF2_INDEX_URL "https://2020.oshwa.org/"
|
||||
|
||||
#endif // _OHS2020_BADGE_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -48,7 +48,7 @@
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 8
|
||||
#define TX_PIN_NUMBER 6
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -48,7 +48,7 @@
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 8
|
||||
#define TX_PIN_NUMBER 6
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -48,7 +48,7 @@
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 8
|
||||
#define TX_PIN_NUMBER 6
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -42,7 +42,7 @@
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 8
|
||||
#define TX_PIN_NUMBER 6
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -45,7 +45,7 @@
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART
|
||||
/* UART (only used by nRF52832)
|
||||
*------------------------------------------------------------------*/
|
||||
#define RX_PIN_NUMBER 20
|
||||
#define TX_PIN_NUMBER 17
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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 PCA10100_H
|
||||
#define PCA10100_H
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 2
|
||||
#define LED_PRIMARY_PIN 13
|
||||
#define LED_SECONDARY_PIN 14
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 11
|
||||
#define BUTTON_2 12
|
||||
#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
|
||||
#define BLEDIS_MANUFACTURER "Nordic"
|
||||
#define BLEDIS_MODEL "PCA10100"
|
||||
|
||||
#define UF2_PRODUCT_NAME "Nordic nRF52833 DK"
|
||||
#define UF2_BOARD_ID "nRF52833-pca10100-v1"
|
||||
#define UF2_INDEX_URL "https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52833-DK"
|
||||
|
||||
#endif // PCA10100_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52833
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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 RAYTAC_MDBT50Q_RX_H
|
||||
#define RAYTAC_MDBT50Q_RX_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 13)
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
|
||||
#define BUTTON_1 _PINNUM(0, 15)
|
||||
#define BUTTON_2 _PINNUM(0, 10)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* UART (only used by nRF52832) (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 "Raytac"
|
||||
#define BLEDIS_MODEL "MDBT50Q-RX"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0029
|
||||
#define USB_DESC_CDC_ONLY_PID 0x002A
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Raytac MDBT50Q-RX"
|
||||
#define UF2_VOLUME_LABEL "MDBT50QBOOT"
|
||||
#define UF2_BOARD_ID "nRF52840-MDBT50Q_RX-verD"
|
||||
#define UF2_INDEX_URL "https://www.raytac.com/product/ins.php?index_id=89"
|
||||
|
||||
#endif // RAYTAC_MDBT50Q_RX_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* 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 _WAVESHARE_NRF52840_H
|
||||
#define _WAVESHARE_NRF52840_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 2
|
||||
/* This is led marked LED1 on the board */
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 13)
|
||||
/* This is led marked LED2 on the board */
|
||||
#define LED_SECONDARY_PIN _PINNUM(0, 14)
|
||||
/* There are two more LEDs, but for the purposes of bootloader that
|
||||
* doesn't matter. */
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
/* This is the 'KEY1' in top left of the board under RESET key.
|
||||
* It is used to remain in bootloader mode after reset. */
|
||||
#define BUTTON_1 _PINNUM(0, 11)
|
||||
/* Pin below is in the bottom left of PCB, and can be shorted to GND
|
||||
* with a regular 2.54mm jumper or tweezers. This pin is used to
|
||||
* clear user firmware and remain in bootloader mode. */
|
||||
#define BUTTON_2 _PINNUM(0, 29)
|
||||
#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 "Waveshare"
|
||||
#define BLEDIS_MODEL "nRF52840 Eval"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0029
|
||||
#define USB_DESC_CDC_ONLY_PID 0x002A
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Waveshare nRF52840 Eval"
|
||||
#define UF2_VOLUME_LABEL "WS52840EVK"
|
||||
#define UF2_BOARD_ID "WS-nRF52840-EVK"
|
||||
#define UF2_INDEX_URL "https://www.waveshare.com/wiki/NRF52840_Eval_Kit"
|
||||
|
||||
#endif // _WAVESHARE_NRF52840_H
|
||||
@@ -0,0 +1 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
+1
-1
@@ -83,7 +83,7 @@
|
||||
*/
|
||||
#define ADAFRUIT_DEVICE_TYPE 0x0052
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA)
|
||||
#define ADAFRUIT_DEV_REV 52840
|
||||
#elif defined NRF52832_XXAA
|
||||
#define ADAFRUIT_DEV_REV 0xADAF
|
||||
|
||||
+2
-2
@@ -44,9 +44,9 @@ void flash_nrf5x_flush (bool need_erase)
|
||||
// - nRF52840 dfu serial/uf2 are USB-based which are DMA and should have no problems.
|
||||
//
|
||||
// Note: MSC uf2 does not erase page in advance like dfu serial
|
||||
if ( need_erase ) nrf_nvmc_page_erase(_fl_addr);
|
||||
if ( need_erase ) nrfx_nvmc_page_erase(_fl_addr);
|
||||
|
||||
nrf_nvmc_write_words(_fl_addr, (uint32_t *) _fl_buf, FLASH_PAGE_SIZE / 4);
|
||||
nrfx_nvmc_words_write(_fl_addr, (uint32_t *) _fl_buf, FLASH_PAGE_SIZE / 4);
|
||||
}
|
||||
|
||||
_fl_addr = FLASH_CACHE_INVALID_ADDR;
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "nrf_nvmc.h"
|
||||
#include "nrfx_nvmc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -11,30 +11,32 @@ MEMORY
|
||||
* those values do not match. The check is performed in main.c, see
|
||||
* APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
|
||||
*/
|
||||
FLASH (rx) : ORIGIN = 0xF4000, LENGTH = 0xA000 /* 40 KB */
|
||||
FLASH (rx) : ORIGIN = 0x74000, LENGTH = 0x7E000-0x74000 /* 40 KB */
|
||||
|
||||
/** Location of mbr params page in flash. */
|
||||
MBR_PARAMS_PAGE (rw) : ORIGIN = 0x0007E000, LENGTH = 0x1000
|
||||
|
||||
/** Location of bootloader setting in flash. */
|
||||
BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0007F000, LENGTH = 0x1000
|
||||
|
||||
|
||||
|
||||
/** RAM Region for bootloader. */
|
||||
/* Avoid conflict with NOINIT for OTA bond sharing */
|
||||
RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20040000-0x20008000
|
||||
RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20020000-0x20008000
|
||||
|
||||
/* Location for double reset detection, no init */
|
||||
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.
|
||||
*/
|
||||
NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80
|
||||
|
||||
* from application to bootloader when using buttonluss DFU OTA. */
|
||||
NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80
|
||||
|
||||
|
||||
/** Location of bootloader setting in flash. */
|
||||
BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x000FF000, LENGTH = 0x1000
|
||||
|
||||
/** Location in UICR where bootloader start address is stored. */
|
||||
UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04
|
||||
|
||||
/** Location of mbr params page in flash. */
|
||||
MBR_PARAMS_PAGE (rw) : ORIGIN = 0x000FE000, LENGTH = 0x1000
|
||||
|
||||
|
||||
/** Location in UICR where mbr params page address is stored. */
|
||||
UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/* Linker script to configure memory regions. */
|
||||
|
||||
SEARCH_DIR(.)
|
||||
GROUP(-lgcc -lc -lnosys)
|
||||
|
||||
MEMORY
|
||||
{
|
||||
/** Flash start address for the bootloader. This setting will also be stored in UICR to allow the
|
||||
* MBR to init the bootloader when starting the system. This value must correspond to
|
||||
* BOOTLOADER_REGION_START found in dfu_types.h. The system is prevented from starting up if
|
||||
* those values do not match. The check is performed in main.c, see
|
||||
* APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
|
||||
*/
|
||||
FLASH (rx) : ORIGIN = 0xF4000, LENGTH = 0xFE000-0xF4000-2048 /* 38 KB */
|
||||
|
||||
BOOTLOADER_CONFIG (r): ORIGIN = 0xFE000 - 2048, LENGTH = 2048
|
||||
|
||||
/** Location of mbr params page in flash. */
|
||||
MBR_PARAMS_PAGE (rw) : ORIGIN = 0xFE000, LENGTH = 0x1000
|
||||
|
||||
/** Location of bootloader setting in flash. */
|
||||
BOOTLOADER_SETTINGS (rw) : ORIGIN = 0xFF000, LENGTH = 0x1000
|
||||
|
||||
|
||||
|
||||
/** RAM Region for bootloader. */
|
||||
/* Avoid conflict with NOINIT for OTA bond sharing */
|
||||
RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20040000-0x20008000
|
||||
|
||||
/* Location for double reset detection, no init */
|
||||
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. */
|
||||
NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80
|
||||
|
||||
|
||||
|
||||
/** Location in UICR where bootloader start address is stored. */
|
||||
UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04
|
||||
|
||||
/** Location in UICR where mbr params page address is stored. */
|
||||
UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.fs_data_out ALIGN(4):
|
||||
{
|
||||
PROVIDE( __start_fs_data = .);
|
||||
KEEP(*(fs_data))
|
||||
PROVIDE( __stop_fs_data = .);
|
||||
} = 0
|
||||
|
||||
.bootloaderConfig :
|
||||
{
|
||||
KEEP(*(.bootloaderConfig))
|
||||
} > BOOTLOADER_CONFIG
|
||||
|
||||
/* Place the bootloader settings page in flash. */
|
||||
.bootloaderSettings(NOLOAD) :
|
||||
{
|
||||
|
||||
} > BOOTLOADER_SETTINGS
|
||||
|
||||
/* Write the bootloader address in UICR. */
|
||||
.uicrBootStartAddress :
|
||||
{
|
||||
KEEP(*(.uicrBootStartAddress))
|
||||
} > UICR_BOOTLOADER
|
||||
|
||||
/* Place the mbr params page in flash. */
|
||||
.mbrParamsPage(NOLOAD) :
|
||||
{
|
||||
|
||||
} > MBR_PARAMS_PAGE
|
||||
|
||||
/* Write the bootloader address in UICR. */
|
||||
.uicrMbrParamsPageAddress :
|
||||
{
|
||||
KEEP(*(.uicrMbrParamsPageAddress))
|
||||
} > UICR_MBR_PARAM_PAGE
|
||||
|
||||
.dbl_reset(NOLOAD) :
|
||||
{
|
||||
|
||||
} > DBL_RESET
|
||||
|
||||
/* No init RAM section in bootloader. Used for bond information exchange. */
|
||||
.noinit(NOLOAD) :
|
||||
{
|
||||
|
||||
} > NOINIT
|
||||
|
||||
/* other placements follow here... */
|
||||
}
|
||||
|
||||
INCLUDE "nrf_common.ld"
|
||||
@@ -11,28 +11,31 @@ MEMORY
|
||||
* those values do not match. The check is performed in main.c, see
|
||||
* APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
|
||||
*/
|
||||
FLASH (rx) : ORIGIN = 0x74000, LENGTH = 0xA000 /* 40 KB */
|
||||
FLASH (rx) : ORIGIN = 0x74000, LENGTH = 0x7E000-0x74000 /* 40 KB */
|
||||
|
||||
/** Location of mbr params page in flash. */
|
||||
MBR_PARAMS_PAGE (rw) : ORIGIN = 0x7E000, LENGTH = 0x1000
|
||||
|
||||
/** Location of bootloader setting in flash. */
|
||||
BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x7F000, LENGTH = 0x1000
|
||||
|
||||
|
||||
|
||||
/** RAM Region for bootloader. */
|
||||
RAM (rwx) : ORIGIN = 0x20003000, LENGTH = 0x20007F7C-0x20003000
|
||||
RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20010000-0x20008000
|
||||
|
||||
/* Location for double reset detection, no init */
|
||||
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 buttonluss DFU OTA. */
|
||||
NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80
|
||||
|
||||
/** Location of bootloader setting in flash. */
|
||||
BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0007F000, LENGTH = 0x1000
|
||||
|
||||
|
||||
/** Location in UICR where bootloader start address is stored. */
|
||||
UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04
|
||||
|
||||
/** Location of mbr params page in flash. */
|
||||
MBR_PARAMS_PAGE (rw) : ORIGIN = 0x0007E000, LENGTH = 0x1000
|
||||
|
||||
/** Location in UICR where mbr params page address is stored. */
|
||||
UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04
|
||||
}
|
||||
+28
-9
@@ -61,14 +61,15 @@
|
||||
#include "nrf_error.h"
|
||||
|
||||
#include "boards.h"
|
||||
#include "uf2/uf2.h"
|
||||
|
||||
#include "pstorage_platform.h"
|
||||
#include "nrf_mbr.h"
|
||||
#include "pstorage.h"
|
||||
#include "nrfx_nvmc.h"
|
||||
|
||||
#include "nrf_nvmc.h"
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef NRF_USBD
|
||||
#include "nrf_usbd.h"
|
||||
#include "tusb.h"
|
||||
|
||||
@@ -105,12 +106,17 @@ void usb_teardown(void);
|
||||
#define DFU_MAGIC_UF2_RESET 0x57
|
||||
|
||||
#define DFU_DBL_RESET_MAGIC 0x5A1AD5 // SALADS
|
||||
#define DFU_DBL_RESET_APP 0x4ee5677e
|
||||
#define DFU_DBL_RESET_DELAY 500
|
||||
#define DFU_DBL_RESET_MEM 0x20007F7C
|
||||
|
||||
#define BOOTLOADER_VERSION_REGISTER NRF_TIMER2->CC[0]
|
||||
#define DFU_SERIAL_STARTUP_INTERVAL 1000
|
||||
|
||||
// Allow for using reset button essentially to swap between application and bootloader.
|
||||
// This is controlled by a flag in the app and is the behavior of CPX and all Arcade boards when using MakeCode.
|
||||
#define APP_ASKS_FOR_SINGLE_TAP_RESET() (*((uint32_t*)(USER_FLASH_START + 0x200)) == 0x87eeb07c)
|
||||
|
||||
// These value must be the same with one in dfu_transport_ble.c
|
||||
#define BLEGAP_EVENT_LENGTH 6
|
||||
#define BLEGATT_ATT_MTU_MAX 247
|
||||
@@ -120,9 +126,12 @@ enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 };
|
||||
#define APPDATA_ADDR_START (BOOTLOADER_REGION_START-DFU_APP_DATA_RESERVED)
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
STATIC_ASSERT( APPDATA_ADDR_START == 0xED000);
|
||||
// Flash 1024 KB
|
||||
STATIC_ASSERT( APPDATA_ADDR_START == 0xED000);
|
||||
|
||||
#else
|
||||
STATIC_ASSERT( APPDATA_ADDR_START == 0x6D000);
|
||||
// Flash 512 KB
|
||||
STATIC_ASSERT( APPDATA_ADDR_START == 0x6D000);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -194,9 +203,13 @@ int main(void)
|
||||
_ota_dfu = _ota_dfu || ( button_pressed(BUTTON_DFU) && button_pressed(BUTTON_FRESET) ) ;
|
||||
|
||||
bool const valid_app = bootloader_app_is_valid(DFU_BANK_0_REGION_START);
|
||||
bool const just_start_app = valid_app && !dfu_start && (*dbl_reset_mem) == DFU_DBL_RESET_APP;
|
||||
|
||||
if (!just_start_app && APP_ASKS_FOR_SINGLE_TAP_RESET())
|
||||
dfu_start = 1;
|
||||
|
||||
// App mode: register 1st reset and DFU startup (nrf52832)
|
||||
if ( ! (dfu_start || !valid_app) )
|
||||
if ( ! (just_start_app || dfu_start || !valid_app) )
|
||||
{
|
||||
// Register our first reset for double reset detection
|
||||
(*dbl_reset_mem) = DFU_DBL_RESET_MAGIC;
|
||||
@@ -215,7 +228,10 @@ int main(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
(*dbl_reset_mem) = 0;
|
||||
if (APP_ASKS_FOR_SINGLE_TAP_RESET())
|
||||
(*dbl_reset_mem) = DFU_DBL_RESET_APP;
|
||||
else
|
||||
(*dbl_reset_mem) = 0;
|
||||
|
||||
if ( dfu_start || !valid_app )
|
||||
{
|
||||
@@ -258,6 +274,9 @@ int main(void)
|
||||
// MBR must be init before start application
|
||||
if ( !sd_inited ) softdev_mbr_init();
|
||||
|
||||
// clear in case we kept DFU_DBL_RESET_APP there
|
||||
(*dbl_reset_mem) = 0;
|
||||
|
||||
// Select a bank region to use as application region.
|
||||
// @note: Only applications running from DFU_BANK_0_REGION_START is supported.
|
||||
bootloader_app_start(DFU_BANK_0_REGION_START);
|
||||
@@ -275,11 +294,11 @@ void adafruit_factory_reset(void)
|
||||
// clear all App Data if any
|
||||
if ( DFU_APP_DATA_RESERVED )
|
||||
{
|
||||
nrf_nvmc_page_erase(APPDATA_ADDR_START);
|
||||
nrfx_nvmc_page_erase(APPDATA_ADDR_START);
|
||||
}
|
||||
|
||||
// Only need to erase the 1st page of Application code to make it invalid
|
||||
nrf_nvmc_page_erase(DFU_BANK_0_REGION_START);
|
||||
nrfx_nvmc_page_erase(DFU_BANK_0_REGION_START);
|
||||
|
||||
// back to normal
|
||||
led_state(STATE_FACTORY_RESET_FINISHED);
|
||||
@@ -423,7 +442,7 @@ uint32_t proc_soc(void)
|
||||
{
|
||||
pstorage_sys_event_handler(soc_evt);
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef NRF_USBD
|
||||
extern void tusb_hal_nrf_power_event(uint32_t event);
|
||||
/*------------- usb power event handler -------------*/
|
||||
int32_t usbevt = (soc_evt == NRF_EVT_POWER_USB_DETECTED ) ? NRFX_POWER_USB_EVT_DETECTED:
|
||||
|
||||
+8
-4
@@ -2,13 +2,17 @@
|
||||
#define NRFX_CONFIG_H__
|
||||
|
||||
// Power
|
||||
#define NRFX_POWER_ENABLED 1
|
||||
#define NRFX_POWER_CONFIG_IRQ_PRIORITY 7
|
||||
#define NRFX_POWER_ENABLED 1
|
||||
#define NRFX_POWER_DEFAULT_CONFIG_IRQ_PRIORITY 7
|
||||
|
||||
#define NRFX_CLOCK_ENABLED 0
|
||||
|
||||
#define NRFX_NVMC_ENABLED 1
|
||||
|
||||
// UART
|
||||
#ifdef NRF52832_XXAA
|
||||
#define NRFX_UART_ENABLED 1
|
||||
#define NRFX_UART0_ENABLED 1
|
||||
#define NRFX_UART_ENABLED 1
|
||||
#define NRFX_UART0_ENABLED 1
|
||||
|
||||
#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 7
|
||||
#define NRFX_UART_DEFAULT_CONFIG_HWFC NRF_UART_HWFC_DISABLED
|
||||
|
||||
+62
-24
@@ -45,38 +45,47 @@ int write_block(uint32_t block_no, uint8_t *data, bool quiet, WriteState *state)
|
||||
// tinyusb callbacks
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Invoked when received SCSI_CMD_INQUIRY
|
||||
// Application fill vendor id, product id and revision with string up to 8, 16, 4 characters respectively
|
||||
void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4])
|
||||
{
|
||||
(void) lun;
|
||||
|
||||
const char vid[] = "Adafruit";
|
||||
const char pid[] = "nRF UF2";
|
||||
const char rev[] = "1.0";
|
||||
|
||||
memcpy(vendor_id , vid, strlen(vid));
|
||||
memcpy(product_id , pid, strlen(pid));
|
||||
memcpy(product_rev, rev, strlen(rev));
|
||||
}
|
||||
|
||||
// Invoked when received Test Unit Ready command.
|
||||
// return true allowing host to read/write this LUN e.g SD card inserted
|
||||
bool tud_msc_test_unit_ready_cb(uint8_t lun)
|
||||
{
|
||||
(void) lun;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Callback invoked when received an SCSI command not in built-in list below
|
||||
// - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, MODE_SENSE6, REQUEST_SENSE
|
||||
// - READ10 and WRITE10 has their own callbacks
|
||||
int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize)
|
||||
{
|
||||
void const* response = NULL;
|
||||
int32_t resplen = 0;
|
||||
memset(buffer, 0, bufsize);
|
||||
uint16_t resplen = 0;
|
||||
|
||||
switch ( scsi_cmd[0] )
|
||||
// most scsi handled is input
|
||||
bool in_xfer = true;
|
||||
|
||||
switch (scsi_cmd[0])
|
||||
{
|
||||
case SCSI_CMD_TEST_UNIT_READY:
|
||||
// Command that host uses to check our readiness before sending other commands
|
||||
resplen = 0;
|
||||
break;
|
||||
|
||||
case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
|
||||
// Host is about to read/write etc ... better not to disconnect disk
|
||||
resplen = 0;
|
||||
break;
|
||||
|
||||
case SCSI_CMD_START_STOP_UNIT:
|
||||
// Host try to eject/safe remove/poweroff us. We could safely disconnect with disk storage, or go into lower power
|
||||
/* scsi_start_stop_unit_t const * start_stop = (scsi_start_stop_unit_t const *) scsi_cmd;
|
||||
// Start bit = 0 : low power mode, if load_eject = 1 : unmount disk storage as well
|
||||
// Start bit = 1 : Ready mode, if load_eject = 1 : mount disk storage
|
||||
start_stop->start;
|
||||
start_stop->load_eject;
|
||||
*/
|
||||
resplen = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Set Sense = Invalid Command Operation
|
||||
tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
|
||||
@@ -86,13 +95,18 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
|
||||
break;
|
||||
}
|
||||
|
||||
// return len must not larger than bufsize
|
||||
if ( resplen > (int32_t)bufsize ) resplen = bufsize;
|
||||
// return resplen must not larger than bufsize
|
||||
if ( resplen > bufsize ) resplen = bufsize;
|
||||
|
||||
// copy response to stack's buffer if any
|
||||
if ( response && resplen )
|
||||
if ( response && (resplen > 0) )
|
||||
{
|
||||
memcpy(buffer, response, resplen);
|
||||
if(in_xfer)
|
||||
{
|
||||
memcpy(buffer, response, resplen);
|
||||
}else
|
||||
{
|
||||
// SCSI output
|
||||
}
|
||||
}
|
||||
|
||||
return resplen;
|
||||
@@ -161,6 +175,8 @@ void tud_msc_write10_complete_cb(uint8_t lun)
|
||||
}
|
||||
}
|
||||
|
||||
// Invoked when received SCSI_CMD_READ_CAPACITY_10 and SCSI_CMD_READ_FORMAT_CAPACITY to determine the disk size
|
||||
// Application update block count and block size
|
||||
void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size)
|
||||
{
|
||||
(void) lun;
|
||||
@@ -169,4 +185,26 @@ void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_siz
|
||||
*block_size = 512;
|
||||
}
|
||||
|
||||
// Invoked when received Start Stop Unit command
|
||||
// - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage
|
||||
// - Start = 1 : active mode, if load_eject = 1 : load disk storage
|
||||
bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject)
|
||||
{
|
||||
(void) lun;
|
||||
(void) power_condition;
|
||||
|
||||
if ( load_eject )
|
||||
{
|
||||
if (start)
|
||||
{
|
||||
// load disk storage
|
||||
}else
|
||||
{
|
||||
// unload disk storage
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
+1
-25
@@ -58,11 +58,6 @@
|
||||
//------------- Class enabled -------------//
|
||||
#define CFG_TUD_CDC 1
|
||||
#define CFG_TUD_MSC 1
|
||||
#define CFG_TUD_HID_KEYBOARD 0
|
||||
#define CFG_TUD_HID_MOUSE 0
|
||||
#define CFG_TUD_HID_GENERIC 0 // not supported yet
|
||||
#define CFG_TUD_CUSTOM_CLASS 0
|
||||
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* CLASS DRIVER
|
||||
@@ -72,34 +67,15 @@
|
||||
#define CFG_TUD_CDC_RX_BUFSIZE 1024
|
||||
#define CFG_TUD_CDC_TX_BUFSIZE 1024
|
||||
|
||||
/* TX is sent automatically on every Start of Frame event ~ 1ms.
|
||||
* If not enabled, application must call tud_cdc_flush() periodically
|
||||
* Note: Enabled this could overflow device task, if it does, define
|
||||
* CFG_TUD_TASK_QUEUE_SZ with large value
|
||||
*/
|
||||
#define CFG_TUD_CDC_FLUSH_ON_SOF 0
|
||||
|
||||
// Number of supported Logical Unit Number
|
||||
#define CFG_TUD_MSC_MAXLUN 1
|
||||
|
||||
// Buffer size for each read/write transfer, the more the better
|
||||
#define CFG_TUD_MSC_BUFSIZE (4*1024)
|
||||
|
||||
// Vendor name included in Inquiry response, max 8 bytes
|
||||
#define CFG_TUD_MSC_VENDOR "Adafruit"
|
||||
|
||||
// Product name included in Inquiry response, max 16 bytes
|
||||
#define CFG_TUD_MSC_PRODUCT "Feather nRF52840"
|
||||
|
||||
// Product revision string included in Inquiry response, max 4 bytes
|
||||
#define CFG_TUD_MSC_PRODUCT_REV "1.0"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB RAM PLACEMENT
|
||||
//--------------------------------------------------------------------+
|
||||
#define CFG_TUSB_ATTR_USBRAM
|
||||
#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4)
|
||||
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
||||
|
||||
|
||||
#define BREAKPOINT_IGNORE_COUNT(n) \
|
||||
|
||||
@@ -43,10 +43,10 @@ SOFTWARE.
|
||||
: (__DATE__ [2u] == 'y' ) ? 5u /*May*/ \
|
||||
: (__DATE__ [2u] == 'n' ) ? 6u /*Jun*/ \
|
||||
: (__DATE__ [2u] == 'l' ) ? 7u /*Jul*/ \
|
||||
: (__DATE__ [2u] == 'g' ) ? 8u /*Jul*/ \
|
||||
: (__DATE__ [2u] == 'p' ) ? 9u /*Jul*/ \
|
||||
: (__DATE__ [2u] == 't' ) ? 10u /*Jul*/ \
|
||||
: (__DATE__ [2u] == 'v' ) ? 11u /*Jul*/ \
|
||||
: (__DATE__ [2u] == 'g' ) ? 8u /*Aug*/ \
|
||||
: (__DATE__ [2u] == 'p' ) ? 9u /*Sep*/ \
|
||||
: (__DATE__ [2u] == 't' ) ? 10u /*Oct*/ \
|
||||
: (__DATE__ [2u] == 'v' ) ? 11u /*Nov*/ \
|
||||
: 12u /*Dec*/ )
|
||||
|
||||
#define __DAY_INT__ ( \
|
||||
@@ -71,12 +71,12 @@ SOFTWARE.
|
||||
#define __DOSDATE__ ( \
|
||||
((__YEAR_INT__ - 1980u) << 9u) | \
|
||||
( __MONTH_INT__ << 5u) | \
|
||||
( __DAY_INT__ << 0u) )
|
||||
( __DAY_INT__ << 0u) )
|
||||
|
||||
#define __DOSTIME__ ( \
|
||||
( __HOUR_INT__ << 11u) | \
|
||||
( __MONTH_INT__ << 5u) | \
|
||||
( __DAY_INT__ << 0u) )
|
||||
( __HOUR_INT__ << 11u) | \
|
||||
( __MINUTE_INT__ << 5u) | \
|
||||
( __SECONDS_INT__ << 0u) )
|
||||
|
||||
#endif // COMPILE_DATE_H
|
||||
|
||||
+4
-28
@@ -40,13 +40,6 @@
|
||||
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// from usb_desc.c for dynamic descriptor
|
||||
extern tusb_desc_device_t usb_desc_dev;
|
||||
extern usb_desc_cfg_t usb_desc_cfg;
|
||||
|
||||
// Serial string using unique Device ID
|
||||
extern uint16_t usb_desc_str_serial[1+16];
|
||||
|
||||
/* tinyusb function that handles power event (detected, ready, removed)
|
||||
* We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled. */
|
||||
extern void tusb_hal_nrf_power_event(uint32_t event);
|
||||
@@ -94,26 +87,9 @@ void usb_init(bool cdc_only)
|
||||
tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_READY);
|
||||
}
|
||||
|
||||
if ( cdc_only )
|
||||
{
|
||||
// Change PID to CDC only
|
||||
usb_desc_dev.idProduct = USB_DESC_CDC_ONLY_PID;
|
||||
usb_desc_init(cdc_only);
|
||||
|
||||
// Remove MSC interface = reduce total interface + adjust config desc length
|
||||
usb_desc_cfg.config.bNumInterfaces--;
|
||||
usb_desc_cfg.config.wTotalLength -= sizeof(usb_desc_cfg.msc);
|
||||
}
|
||||
|
||||
// Create Serial string descriptor
|
||||
char tmp_serial[17];
|
||||
sprintf(tmp_serial, "%08lX%08lX", NRF_FICR->DEVICEID[1], NRF_FICR->DEVICEID[0]);
|
||||
|
||||
for(uint8_t i=0; i<16; i++)
|
||||
{
|
||||
usb_desc_str_serial[1+i] = tmp_serial[i];
|
||||
}
|
||||
|
||||
// Init tusb stack
|
||||
// Init TinyUSB stack
|
||||
tusb_init();
|
||||
}
|
||||
|
||||
@@ -124,7 +100,7 @@ void usb_teardown(void)
|
||||
// Abort all transfers
|
||||
|
||||
// Disable pull up
|
||||
nrf_usbd_pullup_disable();
|
||||
nrf_usbd_pullup_disable(NRF_USBD);
|
||||
|
||||
// Disable Interrupt
|
||||
NVIC_DisableIRQ(USBD_IRQn);
|
||||
@@ -132,7 +108,7 @@ void usb_teardown(void)
|
||||
// disable all interrupt
|
||||
NRF_USBD->INTENCLR = NRF_USBD->INTEN;
|
||||
|
||||
nrf_usbd_disable();
|
||||
nrf_usbd_disable(NRF_USBD);
|
||||
sd_clock_hfclk_release();
|
||||
|
||||
sd_power_usbdetected_enable(false);
|
||||
|
||||
+104
-226
@@ -24,15 +24,6 @@
|
||||
|
||||
#include "usb_desc.h"
|
||||
|
||||
|
||||
/*------------- Interface Numbering -------------*/
|
||||
enum {
|
||||
ITF_NUM_CDC = 0 ,
|
||||
ITF_NUM_CDC_DATA ,
|
||||
ITF_NUM_MSC ,
|
||||
ITF_NUM_TOTAL
|
||||
};
|
||||
|
||||
enum {
|
||||
ITF_STR_LANGUAGE = 0 ,
|
||||
ITF_STR_MANUFACTURER ,
|
||||
@@ -42,59 +33,16 @@ enum {
|
||||
ITF_STR_MSC
|
||||
};
|
||||
|
||||
/*------------- Endpoint Numbering & Size -------------*/
|
||||
#define _EP_IN(x) (0x80 | (x))
|
||||
#define _EP_OUT(x) (x)
|
||||
|
||||
// CDC
|
||||
#define EP_CDC_NOTIF _EP_IN ( ITF_NUM_CDC+1 )
|
||||
#define EP_CDC_NOTIF_SIZE 8
|
||||
|
||||
#define EP_CDC_OUT _EP_OUT( ITF_NUM_CDC+2 )
|
||||
#define EP_CDC_IN _EP_IN ( ITF_NUM_CDC+2 )
|
||||
|
||||
// Mass Storage
|
||||
#define EP_MSC_OUT _EP_OUT( ITF_NUM_MSC+1 )
|
||||
#define EP_MSC_IN _EP_IN ( ITF_NUM_MSC+1 )
|
||||
|
||||
#define EP_MSC_SIZE 64
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// STRING DESCRIPTORS
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
#ifndef USB_STRING_DESCRIPTORS
|
||||
#define USB_STRING_DESCRIPTORS { \
|
||||
/* 0: is supported language = English */ \
|
||||
TUD_DESC_STRCONV(0x0409), \
|
||||
\
|
||||
/* 1: Manufacturer */ \
|
||||
TUD_DESC_STRCONV('A','d','a','f','r','u','i','t',' ','I','n','d','u','s','t','r','i','e','s'), \
|
||||
\
|
||||
/* 2: Product */ \
|
||||
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','n','R','F','5','2','8','4','0', ' ', 'D','F','U'), \
|
||||
\
|
||||
/* 3: Serials TODO use chip ID */ \
|
||||
usb_desc_str_serial, \
|
||||
\
|
||||
/* 4: CDC Interface */ \
|
||||
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','S','e','r','i','a','l'), \
|
||||
\
|
||||
/* 5: MSC Interface */ \
|
||||
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','U','F','2'), \
|
||||
}
|
||||
#endif
|
||||
// CDC + MSC or CDC only mode
|
||||
static bool _cdc_only = false;
|
||||
|
||||
// Serial is 64-bit DeviceID -> 16 chars len
|
||||
uint16_t usb_desc_str_serial[1+16] = { TUD_DESC_STR_HEADER(16) };
|
||||
|
||||
// array of pointer to string descriptors
|
||||
uint16_t const * const string_desc_arr [] = USB_STRING_DESCRIPTORS;
|
||||
static char desc_str_serial[1+16];
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Device Descriptor
|
||||
//--------------------------------------------------------------------+
|
||||
tusb_desc_device_t usb_desc_dev =
|
||||
tusb_desc_device_t desc_device =
|
||||
{
|
||||
.bLength = sizeof(tusb_desc_device_t),
|
||||
.bDescriptorType = TUSB_DESC_DEVICE,
|
||||
@@ -118,187 +66,117 @@ tusb_desc_device_t usb_desc_dev =
|
||||
.bNumConfigurations = 0x01
|
||||
};
|
||||
|
||||
// Invoked when received GET DEVICE DESCRIPTOR
|
||||
// Application return pointer to descriptor
|
||||
uint8_t const * tud_descriptor_device_cb(void)
|
||||
{
|
||||
return (uint8_t const *) &desc_device;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Configuration Descriptor
|
||||
//--------------------------------------------------------------------+
|
||||
usb_desc_cfg_t usb_desc_cfg =
|
||||
|
||||
enum {
|
||||
ITF_NUM_CDC = 0 ,
|
||||
ITF_NUM_CDC_DATA ,
|
||||
ITF_NUM_MSC ,
|
||||
ITF_NUM_TOTAL
|
||||
};
|
||||
|
||||
uint8_t const desc_configuration_cdc_msc[] =
|
||||
{
|
||||
.config =
|
||||
{
|
||||
.bLength = sizeof(tusb_desc_configuration_t),
|
||||
.bDescriptorType = TUSB_DESC_CONFIGURATION,
|
||||
.wTotalLength = sizeof(usb_desc_cfg_t),
|
||||
.bNumInterfaces = ITF_NUM_TOTAL,
|
||||
.bConfigurationValue = 1,
|
||||
.iConfiguration = 0x00,
|
||||
.bmAttributes = TUSB_DESC_CONFIG_ATT_BUS_POWER,
|
||||
.bMaxPower = TUSB_DESC_CONFIG_POWER_MA(100)
|
||||
},
|
||||
// Interface count, string index, total length, attribute, power in mA
|
||||
TUD_CONFIG_DESCRIPTOR(ITF_NUM_TOTAL, 0, TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_MSC_DESC_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
||||
|
||||
// IAD points to CDC Interfaces
|
||||
.cdc =
|
||||
{
|
||||
.iad =
|
||||
{
|
||||
.bLength = sizeof(tusb_desc_interface_assoc_t),
|
||||
.bDescriptorType = TUSB_DESC_INTERFACE_ASSOCIATION,
|
||||
// Interface number, string index, EP notification address and size, EP data address (out, in) and size.
|
||||
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, ITF_STR_CDC, 0x81, 8, 0x02, 0x82, 64),
|
||||
|
||||
.bFirstInterface = ITF_NUM_CDC,
|
||||
.bInterfaceCount = 2,
|
||||
// Interface number, string index, EP Out & EP In address, EP size
|
||||
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, ITF_STR_MSC, 0x03, 0x83, 64),
|
||||
};
|
||||
|
||||
.bFunctionClass = TUSB_CLASS_CDC,
|
||||
.bFunctionSubClass = CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL,
|
||||
.bFunctionProtocol = CDC_COMM_PROTOCOL_ATCOMMAND,
|
||||
.iFunction = 0
|
||||
},
|
||||
uint8_t const desc_configuration_cdc_only[] =
|
||||
{
|
||||
// Interface count, string index, total length, attribute, power in mA
|
||||
TUD_CONFIG_DESCRIPTOR(ITF_NUM_TOTAL-1, 0, TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
||||
|
||||
//------------- CDC Communication Interface -------------//
|
||||
.comm_itf =
|
||||
{
|
||||
.bLength = sizeof(tusb_desc_interface_t),
|
||||
.bDescriptorType = TUSB_DESC_INTERFACE,
|
||||
.bInterfaceNumber = ITF_NUM_CDC,
|
||||
.bAlternateSetting = 0,
|
||||
.bNumEndpoints = 1,
|
||||
.bInterfaceClass = TUSB_CLASS_CDC,
|
||||
.bInterfaceSubClass = CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL,
|
||||
.bInterfaceProtocol = CDC_COMM_PROTOCOL_ATCOMMAND,
|
||||
.iInterface = ITF_STR_CDC
|
||||
},
|
||||
|
||||
.header =
|
||||
{
|
||||
.bLength = sizeof(cdc_desc_func_header_t),
|
||||
.bDescriptorType = TUSB_DESC_CLASS_SPECIFIC,
|
||||
.bDescriptorSubType = CDC_FUNC_DESC_HEADER,
|
||||
.bcdCDC = 0x0120
|
||||
},
|
||||
|
||||
.call =
|
||||
{
|
||||
.bLength = sizeof(cdc_desc_func_call_management_t),
|
||||
.bDescriptorType = TUSB_DESC_CLASS_SPECIFIC,
|
||||
.bDescriptorSubType = CDC_FUNC_DESC_CALL_MANAGEMENT,
|
||||
.bmCapabilities = { 0 },
|
||||
.bDataInterface = ITF_NUM_CDC+1,
|
||||
},
|
||||
|
||||
.acm =
|
||||
{
|
||||
.bLength = sizeof(cdc_desc_func_acm_t),
|
||||
.bDescriptorType = TUSB_DESC_CLASS_SPECIFIC,
|
||||
.bDescriptorSubType = CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT,
|
||||
.bmCapabilities = { // 0x02
|
||||
.support_line_request = 1,
|
||||
}
|
||||
},
|
||||
|
||||
.union_func =
|
||||
{
|
||||
.bLength = sizeof(cdc_desc_func_union_t), // plus number of
|
||||
.bDescriptorType = TUSB_DESC_CLASS_SPECIFIC,
|
||||
.bDescriptorSubType = CDC_FUNC_DESC_UNION,
|
||||
.bControlInterface = ITF_NUM_CDC,
|
||||
.bSubordinateInterface = ITF_NUM_CDC+1,
|
||||
},
|
||||
|
||||
.ep_notif =
|
||||
{
|
||||
.bLength = sizeof(tusb_desc_endpoint_t),
|
||||
.bDescriptorType = TUSB_DESC_ENDPOINT,
|
||||
.bEndpointAddress = EP_CDC_NOTIF,
|
||||
.bmAttributes = { .xfer = TUSB_XFER_INTERRUPT },
|
||||
.wMaxPacketSize = { .size = EP_CDC_NOTIF_SIZE },
|
||||
.bInterval = 0x10
|
||||
},
|
||||
|
||||
//------------- CDC Data Interface -------------//
|
||||
.data_itf =
|
||||
{
|
||||
.bLength = sizeof(tusb_desc_interface_t),
|
||||
.bDescriptorType = TUSB_DESC_INTERFACE,
|
||||
.bInterfaceNumber = ITF_NUM_CDC+1,
|
||||
.bAlternateSetting = 0x00,
|
||||
.bNumEndpoints = 2,
|
||||
.bInterfaceClass = TUSB_CLASS_CDC_DATA,
|
||||
.bInterfaceSubClass = 0,
|
||||
.bInterfaceProtocol = 0,
|
||||
.iInterface = 0x00
|
||||
},
|
||||
|
||||
.ep_out =
|
||||
{
|
||||
.bLength = sizeof(tusb_desc_endpoint_t),
|
||||
.bDescriptorType = TUSB_DESC_ENDPOINT,
|
||||
.bEndpointAddress = EP_CDC_OUT,
|
||||
.bmAttributes = { .xfer = TUSB_XFER_BULK },
|
||||
.wMaxPacketSize = { .size = CFG_TUD_CDC_EPSIZE },
|
||||
.bInterval = 0
|
||||
},
|
||||
|
||||
.ep_in =
|
||||
{
|
||||
.bLength = sizeof(tusb_desc_endpoint_t),
|
||||
.bDescriptorType = TUSB_DESC_ENDPOINT,
|
||||
.bEndpointAddress = EP_CDC_IN,
|
||||
.bmAttributes = { .xfer = TUSB_XFER_BULK },
|
||||
.wMaxPacketSize = { .size = CFG_TUD_CDC_EPSIZE },
|
||||
.bInterval = 0
|
||||
},
|
||||
},
|
||||
|
||||
//------------- Mass Storage-------------//
|
||||
.msc =
|
||||
{
|
||||
.itf =
|
||||
{
|
||||
.bLength = sizeof(tusb_desc_interface_t),
|
||||
.bDescriptorType = TUSB_DESC_INTERFACE,
|
||||
.bInterfaceNumber = ITF_NUM_MSC,
|
||||
.bAlternateSetting = 0x00,
|
||||
.bNumEndpoints = 2,
|
||||
.bInterfaceClass = TUSB_CLASS_MSC,
|
||||
.bInterfaceSubClass = MSC_SUBCLASS_SCSI,
|
||||
.bInterfaceProtocol = MSC_PROTOCOL_BOT,
|
||||
.iInterface = ITF_STR_MSC
|
||||
},
|
||||
|
||||
.ep_out =
|
||||
{
|
||||
.bLength = sizeof(tusb_desc_endpoint_t),
|
||||
.bDescriptorType = TUSB_DESC_ENDPOINT,
|
||||
.bEndpointAddress = EP_MSC_OUT,
|
||||
.bmAttributes = { .xfer = TUSB_XFER_BULK },
|
||||
.wMaxPacketSize = { .size = EP_MSC_SIZE},
|
||||
.bInterval = 1
|
||||
},
|
||||
|
||||
.ep_in =
|
||||
{
|
||||
.bLength = sizeof(tusb_desc_endpoint_t),
|
||||
.bDescriptorType = TUSB_DESC_ENDPOINT,
|
||||
.bEndpointAddress = EP_MSC_IN,
|
||||
.bmAttributes = { .xfer = TUSB_XFER_BULK },
|
||||
.wMaxPacketSize = { .size = EP_MSC_SIZE },
|
||||
.bInterval = 1
|
||||
}
|
||||
}
|
||||
// Interface number, string index, EP notification address and size, EP data address (out, in) and size.
|
||||
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, ITF_STR_CDC, 0x81, 8, 0x02, 0x82, 64),
|
||||
};
|
||||
|
||||
|
||||
// tud_desc_set is required by tinyusb stack
|
||||
// since CFG_TUD_DESC_AUTO is enabled, we only need to set string_arr
|
||||
tud_desc_set_t tud_desc_set =
|
||||
// Invoked when received GET CONFIGURATION DESCRIPTOR
|
||||
// Application return pointer to descriptor
|
||||
// Descriptor contents must exist long enough for transfer to complete
|
||||
uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
|
||||
{
|
||||
.device = &usb_desc_dev,
|
||||
.config = &usb_desc_cfg,
|
||||
.string_arr = (uint8_t const **) string_desc_arr,
|
||||
.string_count = sizeof(string_desc_arr)/sizeof(string_desc_arr[0]),
|
||||
(void) index; // for multiple configurations
|
||||
return _cdc_only ? desc_configuration_cdc_only : desc_configuration_cdc_msc;
|
||||
}
|
||||
|
||||
.hid_report =
|
||||
{
|
||||
.generic = NULL,
|
||||
.boot_keyboard = NULL,
|
||||
.boot_mouse = NULL
|
||||
}
|
||||
// Enumerate as CDC + MSC or CDC only
|
||||
void usb_desc_init(bool cdc_only)
|
||||
{
|
||||
_cdc_only = cdc_only;
|
||||
|
||||
if ( cdc_only )
|
||||
{
|
||||
// Change PID to CDC only
|
||||
desc_device.idProduct = USB_DESC_CDC_ONLY_PID;
|
||||
}
|
||||
|
||||
// Create Serial string descriptor
|
||||
sprintf(desc_str_serial, "%08lX%08lX", NRF_FICR->DEVICEID[1], NRF_FICR->DEVICEID[0]);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// STRING DESCRIPTORS
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// array of pointer to string descriptors
|
||||
char const* string_desc_arr [] =
|
||||
{
|
||||
(const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409)
|
||||
BLEDIS_MANUFACTURER, // 1: Manufacturer
|
||||
BLEDIS_MODEL, // 2: Product
|
||||
desc_str_serial, // 3: Serials, should use chip ID
|
||||
"nRF Serial", // 4: CDC Interface
|
||||
"nRF UF2", // 5: MSC Interface
|
||||
};
|
||||
|
||||
// up to 64 unicode characters
|
||||
static uint16_t _desc_str[64+1];
|
||||
|
||||
// Invoked when received GET STRING DESCRIPTOR request
|
||||
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
|
||||
uint16_t const* tud_descriptor_string_cb(uint8_t index)
|
||||
{
|
||||
uint8_t chr_count;
|
||||
|
||||
if ( index == 0)
|
||||
{
|
||||
memcpy(&_desc_str[1], string_desc_arr[0], 2);
|
||||
chr_count = 1;
|
||||
}else
|
||||
{
|
||||
if ( !(index < sizeof(string_desc_arr)/sizeof(string_desc_arr[0])) ) return NULL;
|
||||
|
||||
// Convert ASCII string into UTF-16
|
||||
const char* str = string_desc_arr[index];
|
||||
|
||||
// Cap at max char
|
||||
chr_count = strlen(str);
|
||||
if ( chr_count > 31 ) chr_count = 31;
|
||||
|
||||
for(uint8_t i=0; i<chr_count; i++)
|
||||
{
|
||||
_desc_str[1+i] = str[i];
|
||||
}
|
||||
}
|
||||
|
||||
// first byte is length (including header), second byte is string type
|
||||
_desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
|
||||
|
||||
return _desc_str;
|
||||
}
|
||||
+4
-45
@@ -28,59 +28,18 @@
|
||||
#include "tusb.h"
|
||||
#include "boards.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void usb_desc_init(bool cdc_only);
|
||||
|
||||
#ifndef USB_DESC_VID
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_VID 0x239A
|
||||
#endif
|
||||
|
||||
#ifndef USB_DESC_UF2_PID
|
||||
#define USB_DESC_UF2_PID 0x0029
|
||||
#define USB_DESC_UF2_PID 0x0029
|
||||
#endif
|
||||
|
||||
#ifndef USB_DESC_CDC_ONLY_PID
|
||||
#define USB_DESC_CDC_ONLY_PID 0x002A
|
||||
#endif
|
||||
|
||||
|
||||
/*------------- Configuration Descriptor -------------*/
|
||||
typedef struct ATTR_PACKED
|
||||
{
|
||||
tusb_desc_configuration_t config;
|
||||
|
||||
//------------- CDC -------------//
|
||||
struct ATTR_PACKED
|
||||
{
|
||||
tusb_desc_interface_assoc_t iad;
|
||||
|
||||
//CDC Control Interface
|
||||
tusb_desc_interface_t comm_itf;
|
||||
cdc_desc_func_header_t header;
|
||||
cdc_desc_func_call_management_t call;
|
||||
cdc_desc_func_acm_t acm;
|
||||
cdc_desc_func_union_t union_func;
|
||||
tusb_desc_endpoint_t ep_notif;
|
||||
|
||||
//CDC Data Interface
|
||||
tusb_desc_interface_t data_itf;
|
||||
tusb_desc_endpoint_t ep_out;
|
||||
tusb_desc_endpoint_t ep_in;
|
||||
}cdc;
|
||||
|
||||
//------------- Mass Storage -------------//
|
||||
struct ATTR_PACKED
|
||||
{
|
||||
tusb_desc_interface_t itf;
|
||||
tusb_desc_endpoint_t ep_out;
|
||||
tusb_desc_endpoint_t ep_in;
|
||||
} msc;
|
||||
} usb_desc_cfg_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#define USB_DESC_CDC_ONLY_PID 0x002A
|
||||
#endif
|
||||
|
||||
#endif /* USB_DESC_H_ */
|
||||
+23
-7
@@ -11,8 +11,13 @@ travis = False
|
||||
if "TRAVIS" in os.environ and os.environ["TRAVIS"] == "true":
|
||||
travis = True
|
||||
|
||||
success_count = 0
|
||||
fail_count = 0
|
||||
exit_status = 0
|
||||
|
||||
build_format = '| {:30} | {:9} '
|
||||
build_separator = '-' * 54
|
||||
|
||||
all_boards = []
|
||||
for entry in os.scandir("src/boards"):
|
||||
all_boards.append(entry.name)
|
||||
@@ -21,6 +26,10 @@ for entry in os.scandir("src/boards"):
|
||||
|
||||
total_time = time.monotonic()
|
||||
|
||||
print(build_separator)
|
||||
print((build_format + '| {:5} |').format('Board', 'Result', 'Time'))
|
||||
print(build_separator)
|
||||
|
||||
for board in all_boards:
|
||||
bin_directory = "bin/{}/".format(board)
|
||||
os.makedirs(bin_directory, exist_ok=True)
|
||||
@@ -28,10 +37,14 @@ for board in all_boards:
|
||||
start_time = time.monotonic()
|
||||
make_result = subprocess.run("make -j 4 BOARD={} combinehex genpkg".format(board), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
build_duration = time.monotonic() - start_time
|
||||
success = "\033[32msucceeded\033[0m"
|
||||
if make_result.returncode != 0:
|
||||
|
||||
if make_result.returncode == 0:
|
||||
success = "\033[32msucceeded\033[0m"
|
||||
success_count += 1
|
||||
else:
|
||||
exit_status = make_result.returncode
|
||||
success = "\033[31mfailed\033[0m"
|
||||
success = "\033[31mfailed\033[0m "
|
||||
fail_count += 1
|
||||
|
||||
for entry in os.scandir("_build-{}".format(board)):
|
||||
for extension in ["zip", "hex"]:
|
||||
@@ -40,15 +53,18 @@ for board in all_boards:
|
||||
|
||||
if travis:
|
||||
print('travis_fold:start:build-{}\\r'.format(board))
|
||||
print("Build {} took {:.2f}s and {}".format(board, build_duration, success))
|
||||
|
||||
print((build_format + '| {:.2f}s |').format(board, success, build_duration))
|
||||
|
||||
if make_result.returncode != 0:
|
||||
print(make_result.stdout.decode("utf-8"))
|
||||
if travis:
|
||||
print('travis_fold:end:build-{}\\r'.format(board))
|
||||
|
||||
print()
|
||||
|
||||
# Build Summary
|
||||
total_time = time.monotonic() - total_time
|
||||
print("Total build time took {:.2f}s".format(total_time))
|
||||
print(build_separator)
|
||||
print("Build Sumamary: {} \033[32msucceeded\033[0m, {} \033[31mfailed\033[0m and took {:.2f}s".format(success_count, fail_count, total_time))
|
||||
print(build_separator)
|
||||
|
||||
sys.exit(exit_status)
|
||||
@@ -0,0 +1,76 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2017 Scott Shawcroft 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.
|
||||
"""
|
||||
`adafruit_adabot`
|
||||
====================================================
|
||||
|
||||
TODO(description)
|
||||
|
||||
* Author(s): Scott Shawcroft
|
||||
"""
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def _fix_url(url):
|
||||
if url.startswith("/"):
|
||||
url = "https://api.github.com" + url
|
||||
return url
|
||||
|
||||
def _fix_kwargs(kwargs):
|
||||
api_version = "application/vnd.github.scarlet-witch-preview+json;application/vnd.github.hellcat-preview+json"
|
||||
if "headers" in kwargs:
|
||||
if "Accept" in kwargs["headers"]:
|
||||
kwargs["headers"]["Accept"] += ";" + api_version
|
||||
else:
|
||||
kwargs["headers"]["Accept"] = api_version
|
||||
else:
|
||||
kwargs["headers"] = {"Accept": "application/vnd.github.hellcat-preview+json"}
|
||||
if "ADABOT_GITHUB_ACCESS_TOKEN" in os.environ and "auth" not in kwargs:
|
||||
access_token = os.environ["ADABOT_GITHUB_ACCESS_TOKEN"]
|
||||
if "params" in kwargs:
|
||||
kwargs["params"]["access_token"] = access_token
|
||||
else:
|
||||
kwargs["params"] = {"access_token": access_token}
|
||||
if "timeout" not in kwargs:
|
||||
kwargs["timeout"] = 30
|
||||
return kwargs
|
||||
|
||||
def get(url, **kwargs):
|
||||
response = requests.get(_fix_url(url), **_fix_kwargs(kwargs))
|
||||
remaining = int(response.headers["X-RateLimit-Remaining"])
|
||||
if remaining % 100 == 0:
|
||||
print(remaining, "requests remaining this hour")
|
||||
return response
|
||||
|
||||
def post(url, **kwargs):
|
||||
return requests.post(_fix_url(url), **_fix_kwargs(kwargs))
|
||||
|
||||
def put(url, **kwargs):
|
||||
return requests.put(_fix_url(url), **_fix_kwargs(kwargs))
|
||||
|
||||
def patch(url, **kwargs):
|
||||
return requests.patch(_fix_url(url), **_fix_kwargs(kwargs))
|
||||
|
||||
def delete(url, **kwargs):
|
||||
return requests.delete(_fix_url(url), **_fix_kwargs(kwargs))
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#! /usr/bin/env python3
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import uritemplate
|
||||
|
||||
sys.path.append("adabot")
|
||||
import github_requests as github
|
||||
|
||||
exit_status = 0
|
||||
|
||||
for dirpath, dirnames, filenames in os.walk("../bin"):
|
||||
if not filenames:
|
||||
continue
|
||||
for filename in filenames:
|
||||
full_filename = os.path.join(dirpath, filename)
|
||||
label = filename.replace("adafruit-circuitpython-", "")
|
||||
url_vars = {}
|
||||
url_vars["name"] = filename
|
||||
url_vars["label"] = label
|
||||
url = uritemplate.expand(os.environ["UPLOAD_URL"], url_vars)
|
||||
headers = {"content-type": "application/octet-stream"}
|
||||
print(url)
|
||||
with open(full_filename, "rb") as f:
|
||||
response = github.post(url, data=f, headers=headers)
|
||||
if not response.ok:
|
||||
if response.status_code == 422 and response.json().get("errors", [{"code":""}])[0]["code"] == "already_exists":
|
||||
print("File already uploaded. Skipping.")
|
||||
continue
|
||||
print("Upload of {} failed with {}.".format(filename, response.status_code))
|
||||
print(response.text)
|
||||
sys.exit(response.status_code)
|
||||
|
||||
sys.exit(exit_status)
|
||||
Reference in new issue
Block a user