Skip to content

Commit

Permalink
Add a formal board definition for Ardunino Nano 33 BLE (#16)
Browse files Browse the repository at this point in the history
* Add a formal board definition for Ardunino Nano 33 BLE

* Update travis to point to new location

* Update travis to point to new location

* USe Docker image instead of rebuilding src each time

* Updating README
  • Loading branch information
charlesportwoodii authored Jul 5, 2020
1 parent f481a77 commit 99b6ca9
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 35 deletions.
36 changes: 8 additions & 28 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
dist: bionic
language: c
language: generic

cache:
directories:
- $HOME/gcc-arm-none-eabi-9-2020-q2-major
- $HOME/nrf_sdk/16.0.0

addons:
apt:
packages:
- dos2unix
- python
- python-pip
services:
- docker

env:
global:
- GNU_INSTALL_ROOT="$HOME/gcc-arm-none-eabi-9-2020-q2-major/bin/"
- NORDIC_SDK_PATH="$HOME/nrf_sdk/16.0.0"
- PATH="$PATH:$HOME/gcc-arm-none-eabi-9-2020-q2-major/bin:$HOME/mergehex"

matrix:
- BOARD=sparkfun-pro-mini
- BOARD=sparkfun-pro-mini DEBUG=1
Expand All @@ -38,23 +24,17 @@ env:
- BOARD=particle-argon DEBUG=1
- BOARD=feather-express
- BOARD=feather-express DEBUG=1
- BOARD=arduino-nano-33-ble
- BOARD=arduino-nano-33-ble DEBUG=1
- BOARD=generic DEBUG=1

before_install:
- chmod +x $TRAVIS_BUILD_DIR/.travis/before_install.sh
- ln -s default_private.pem private.pem
- ln -s default_dfu_public_key.c dfu_public_key.c

install:
- $TRAVIS_BUILD_DIR/.travis/before_install.sh
# Verify the arm-none-eabi-gcc binary is working correctly
- arm-none-eabi-gcc --version
# Verify mergehex is loaded into PATH
- mergehex --version
- pip install --user nrfutil
- docker pull kaidyth/nrf52_toolchain:latest

script:
- make clean_build
- docker run -v${PWD-.}:/app --env BOARD=$BOARD --env DEBUG=$DEBUG kaidyth/nrf52_toolchain:latest

deploy:
provider: releases
Expand All @@ -66,6 +46,6 @@ deploy:
skip_cleanup: true
draft: true
on:
repo: charlesportwoodii/kaidyth_nrf52_bootloader
repo: kaidyth/nrf52_bootloader
tags: true
condition: $DEBUG=0
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Kaidyth Bootloader

[![Travis Build Status](https://img.shields.io/travis/com/charlesportwoodii/kaidyth_nrf52_bootloader.svg?label=TravisCI&style=flat-square)](https://travis-ci.com/charlesportwoodii/kaidyth_nrf52_bootloader)
[![Travis Build Status](https://img.shields.io/travis/com/kaidyth/nrf52_bootloader.svg?label=TravisCI&style=flat-square)](https://travis-ci.com/kaidyth/nrf52_bootloader)

A secure bluetooth DFU bootloader for nRF52 with support for the following boards:

Expand All @@ -12,6 +12,7 @@ A secure bluetooth DFU bootloader for nRF52 with support for the following board
- [Adafruit nRF52840 Feather Express](https://www.adafruit.com/product/4062)
- [Particle Xenon](https://docs.particle.io/xenon/)
- [Pitaya Go](https://wiki.makerdiary.com/pitaya-go/)
- [Arduino Nano 33 BLE](https://store.arduino.cc/usa/nano-33-ble)

## Features

Expand All @@ -24,7 +25,7 @@ A secure bluetooth DFU bootloader for nRF52 with support for the following board
### Planned Features

- Application Wipe via 2 Pin Reset
- DFU using UF2
- Arduino BLE* (see below)

## Flashing

Expand All @@ -42,18 +43,19 @@ nrfjprog --memwr 0x10001304 --val 0xFFFFFFFD
nrfjprog -f nf52 --reset
```

> Note that the default bootloader is distributed with a public keypair for application signing. This will permit anyone who has access to the key to be able to flash and overwrite any application you have while in OTA DFU mode. If you're using this bootloader in a production setting, it is recommended to build your own binary with your own keypair.
### Unsupported Boards

While this bootloader has a variety of officially supported boards, your specific board, module, or chip may not yet have a formal definition. Published with the pre-built binaries is a generic board in DEBUG mode only that has no LEDS or buttons that you can flash to your solution and the bootloader will just "work".
While this bootloader has a variety of officially supported boards, your specific board, module, or chip may not yet have a formal definition.

Alternatively, you can build the variant yourself by running:
The generic variant can be built by running the following command.

```bash
make BOARD=generic clean_build
```


> Note that the default bootloader is distributed with a public keypair for application signing. This will permit anyone who has access to the key to be able to flash and overwrite any application you have while in OTA DFU mode. If you're using this bootloader in a production setting, it is recommended to build your own binary with your own keypair.
> The generic bootloader is distributed in `DEBUG` mode to aid in debugging and creating a formal definition. You are advised to create a formal production ready board definition for your variant before going into production.
### Building/Development

Expand All @@ -64,8 +66,16 @@ docker build . -t kaidyth_dfu/toolchain:latest
docker run -v${PWD-.}:/app --env BOARD=mdk-usb-dongle kaidyth_dfu/toolchain:latest
```

Hex and .zip archives for DFU flashes are outputted to the `_build_<board>` directory after compilation succeeds.z
Hex and .zip archives for DFU flashes are outputted to the `_build_<board>` directory after compilation succeeds.

> Note that patches the nRF52 SDK to to add some unoffocially supported functionality (such as `NRF_DFU_BL_ALLOW_DOWNGRADE` and `NRF_DFU_BL_ACCEPT_SAME_VERSION`). It's recommended to use the docker environment for building unless you plan on switching `NORDIC_SDK_PATH` between projects.
If you're interested in setting up your own development environment without docker, take a look at the [Getting Started](https://github.com/charlesportwoodii/kaidyth_nrf52_bootloader/wiki/Getting-Started) page for more information on the dependencies needed.

### Arduino Support

This bootloader should compatible with Arduino Libraries excluding ones that interface with the Soft Device. Things such as I2C, GPIO, and Neopixels should work using their respective libaries.

### Bluetooth / ArdinoBLE / Adarfruit NRF52 Bluefruit

The Nordic Secure Bootloader, and by proxy this bootloader do not officially support any operation that directly interfaces with the Soft Device, include Arduino BLE and Adafruit Bluefruit. If you want to use bluetooth functionality you are strongly encouraged to use the nRF5 SDK.
12 changes: 12 additions & 0 deletions boards/arduino-nano-33-ble/s140/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
include ../../Makefile.boards

CFLAGS += -DBOARD_CUSTOM

ASMFLAGS += -DBOARD_CUSTOM

ifeq ($(DEBUG), 1)
CFLAGS += -DNRF_LOG_BACKEND_UART_TX_PIN=3
CFLAGS += -DNRF_LOG_BACKEND_UART_RX_PIN=10
ASMFLAGS += -DNRF_LOG_BACKEND_UART_TX_PIN=3
ASMFLAGS += -DNRF_LOG_BACKEND_UART_RX_PIN=10
endif
81 changes: 81 additions & 0 deletions boards/arduino-nano-33-ble/s140/include/custom_board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* Copyright (c) 2019-Present Charles R. Portwood II <charlesportwoodii@erianna.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef CUSTOM_BOARD_H
#define CUSTOM_BOARD_H

#ifdef __cplusplus
extern "C" {
#endif

#include "nrf_gpio.h"

#define LEDS_NUMBER 5

#define LED_1 NRF_GPIO_PIN_MAP(0,24)
#define LED_2 NRF_GPIO_PIN_MAP(0,16)
#define LED_3 NRF_GPIO_PIN_MAP(0,6)
#define LED_4 NRF_GPIO_PIN_MAP(0,13)
#define LED_5 NRF_GPIO_PIN_MAP(1,9)

#define LED_RED LED_1
#define LED_GREEN LED_2
#define LED_BLUE LED_3

#define LED_BUILTIN LED_4
#define LED_PWR LED_5

#define LED_START LED_1
#define LED_STOP LED_3

#define LEDS_ACTIVE_STATE 0

#define LEDS_LIST { LED_1, LED_2, LED_3, LED_4, LED_5 }

#define LEDS_INV_MASK LEDS_MASK

#define BSP_LED_0 LED_1
#define BSP_LED_1 LED_2
#define BSP_LED_2 LED_3
#define BSP_LED_3 LED_4
#define BSP_LED_4 LED_5

#define BUTTONS_NUMBER 0
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTONS_ACTIVE_STATE 0

#define RX_PIN_NUMBER 10
#define TX_PIN_NUMBER 3
#define CTS_PIN_NUMBER 0xFFFFFFFF //NC
#define RTS_PIN_NUMBER 0xFFFFFFFF //NC
#define HWFC false

#ifdef __cplusplus
}
#endif

#endif // CUSTOM_BOARD_H

0 comments on commit 99b6ca9

Please sign in to comment.