Skip to content

WIP: Nano 33 BLE #407

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,54 @@ pca10056.menu.debug.l2=Level 2 (Full Debug)
pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
pca10056.menu.debug.l3=Level 3 (Segger SystemView)
pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3



# ----------------------------------
# Arduino Nano 33 BLE
# ----------------------------------
arduinonano33ble.name=Arduino Nano 33 BLE (Unsupported)

# VID/PID for the Adafruit bootloader with/without UF2
arduinonano33ble.vid.0=0x239A
arduinonano33ble.pid.0=0x0063
arduinonano33ble.vid.1=0x239A
arduinonano33ble.pid.1=0x0064

# Upload
arduinonano33ble.bootloader.tool=bootburn
arduinonano33ble.upload.tool=nrfutil
arduinonano33ble.upload.protocol=nrfutil
arduinonano33ble.upload.use_1200bps_touch=true
arduinonano33ble.upload.wait_for_upload_port=true
arduinonano33ble.upload.maximum_size=815104
arduinonano33ble.upload.maximum_data_size=237568

# Build
arduinonano33ble.build.mcu=cortex-m4
arduinonano33ble.build.f_cpu=64000000
arduinonano33ble.build.board=NRF52840_NANO33BLE
arduinonano33ble.build.core=nRF5
arduinonano33ble.build.variant=arduino_nano_33_ble
arduinonano33ble.build.usb_manufacturer="Arduino"
arduinonano33ble.build.usb_product="Nano 33 BLE"
arduinonano33ble.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_NANO33BLE {build.flags.usb}
arduinonano33ble.build.ldscript=nrf52840_s140_v6.ld
arduinonano33ble.build.vid=0x239A
arduinonano33ble.build.pid=0x8063

# SoftDevice Menu
arduinonano33ble.menu.softdevice.s140v6=0.2.13-23~ga9e8804 SoftDevice s140 6.1.1
arduinonano33ble.menu.softdevice.s140v6.build.sd_name=s140
arduinonano33ble.menu.softdevice.s140v6.build.sd_version=6.1.1
arduinonano33ble.menu.softdevice.s140v6.build.sd_fwid=0x00B6

# Debug Menu
arduinonano33ble.menu.debug.l0=Level 0 (Release)
arduinonano33ble.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
arduinonano33ble.menu.debug.l1=Level 1 (Error Message)
arduinonano33ble.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
arduinonano33ble.menu.debug.l2=Level 2 (Full Debug)
arduinonano33ble.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
arduinonano33ble.menu.debug.l3=Level 3 (Segger SystemView)
arduinonano33ble.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
86 changes: 86 additions & 0 deletions bootloader/arduino_nano_33_ble/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Unsupported Arduino Nano 33 BLE

This directory contains an Adafruit bootloader for the Arduino Nano 33 BLE. This
isn't a supported Adafruit product: its inclusion is a community contribution,
and it's not for newbies.

To use the Bluefruit libraries and board definition on the Arduino Nano 33 BLE,
you need to first install the bootloader and SoftDevice, which currently
requires an SWD debugger such as a J-Link, Black Magic Probe, or ATMEL-ICE (in
the SAM port - operating as a CMSIS-DAP programmer).

## Installing the Adafruit (UF2) bootloader

There are pads (for pogo pins or soldering wires to) on the back of the Nano 33
BLE to access the SWD lines - see the second page of the
[Arduino pinout guide](https://content.arduino.cc/assets/Pinout-NANOble_v1.pdf).
They are spaced at 0.1 inch with each other and with the last row of pins on the
board, so you can use two pieces of perfboard to build a small pogo pin jig that
aligns itself using those last two pins. However you choose to connect, the pads
will need to be connected to the appropriate pins of your debug/programming
tool.

If you have a CMSIS-DAP compatible tool, you can use openocd as included with
the Arduino nRF528xx hardware support to flash the bootloader. Everywhere you
see "$ARDUINODIR" in the following command, replace it with something like
`/home/ryan/.arduino15` (for Linux).

```sh
$ARDUINODIR/packages/arduino/tools/openocd/0.10.0-arduino9/bin/openocd -d2 -s $ARDUINODIR/packages/arduino/tools/openocd/0.10.0-arduino9/share/openocd/scripts/ -f interface/cmsis-dap.cfg -f target/nrf52.cfg -c "telnet_port disabled; init; reset init; halt; adapter_khz 10000; nrf5 mass_erase; program {$ARDUINODIR/packages/adafruit/hardware/nrf52/0.15.1/bootloader/arduino_nano_33_ble/arduino_nano_33_ble_bootloader-0.2.13_s140_6.1.1.hex}; reset run; shutdown "
```

You may need to adjust the version numbers in the various paths there.

Once this is flashed, you'll need to use the Adafruit entry for the Nano 33 BLE
in the Boards menu, instead of the Arduino one, since the Arduino board config
uses a bootloader protocol that is uncommon on the nRF52 (SAM-BA/bossac) and not
the same as what is used by Adafruit (nrfutil/adafruit-nrfutil).

## Returning to Arduino (bossac) bootloader

Re-connect the Nano 33 BLE to your programmer, and load the
`packages/arduino/hardware/mbed/1.1.3/bootloaders/nano33ble/bootloader.hex` file
(from your `~/.arduino15` directory on Linux or equivalent on your platform)
again. If you have a CMSIS-DAP compatible programmer like an ATMEL-ICE, this is
pretty easy and can be done in the Arduino IDE:

- Under Tools, Programmer, choose ARM CMSIS-DAP compatible
- Under Tools, Board, choose the Arduino Nano 33 BLE in the "Arduino nRF528x
(MBed OS)" section.
- Choose Tools, Burn Bootloader.

This runs the same openocd command described above but with the Arduino
bootloader hex.

## Peripherals

The same basic pins as the Arduino-provided core for this board are provided.

The on-board LSM9DS1 is on the second (onboard-only) I2C bus, called `Wire1`.
The pullup to that bus is `PIN_ENABLE_I2C_PULLUP`, which is enabled (set to
`HIGH`) on startup by default. Power to that sensor is controlled by
`PIN_ENABLE_SENSORS_3V3`, also set `HIGH` on startup by default.

D13 has an LED (yellow, next to USB port) as usual. In addition, there is an
onboard RGB LED: just as in the Arduino-provided core, `LEDR`, `LEDG`, and
`LEDB` are the pins controlling the three color components with `analogWrite`:
Note that 0 is max and 255 is min for these LEDs.

The Power LED is actually software-controlled, so if you need another LED, you
can control `LED_PWR` (active-high).

## Development

This is still a work in progress:

- Bootloader:
- UF2 mass-storage flashing doesn't appear to work properly.
- current.uf2 shows up as only 512 bytes.
- Arduino core:
- Some things appear to result in an extra-long delay or hang, such as:
- using the onboard LSM9DS1 with `Adafruit_LSM9DS1` never gets past the
first serial printout, though it works fine with the Arduino-provided
board config after replacing the constructor line with
`Adafruit_LSM9DS1 lsm = Adafruit_LSM9DS1(&Wire1);`
- The bluefruit scan example works, but takes a long time before it gets to
the first scan result.
Loading