boards: adafruit feather nrf52840 update UF2

Add support for flashing the Adafruit Feather nrf52840 Express
using UF2 over USB.

Also standardise on using the UF2 variant, so add a non UF2 variant
of the Sense board, so it can be flashed using the SWD headers.

Created flash dtsi files for both SWD and UF2. These are actually identical
for many other boards and should probably be moved to common in future.

Signed-off-by: Jacob Winther <jacob@9.nz>
This commit is contained in:
Jacob Winther 2024-09-02 21:39:58 +12:00 committed by Fabio Baltieri
commit 67fbbaedc5
17 changed files with 324 additions and 104 deletions

View file

@ -6,8 +6,8 @@
*/
/dts-v1/;
#include "adafruit_feather_nrf52840_common.dtsi"
#include "adafruit_feather_nrf52840_flash.dtsi"
/ {
model = "Adafruit Feather nRF52840 Express";
@ -19,7 +19,6 @@
zephyr,uart-mcumgr = &uart0;
zephyr,bt-mon-uart = &uart0;
zephyr,bt-c2h-uart = &uart0;
zephyr,code-partition = &slot0_partition;
};
leds {
@ -28,39 +27,3 @@
};
};
};
&flash0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 0x0000C000>;
};
slot0_partition: partition@c000 {
label = "image-0";
reg = <0x0000C000 0x00067000>;
};
slot1_partition: partition@73000 {
label = "image-1";
reg = <0x00073000 0x00067000>;
};
scratch_partition: partition@da000 {
label = "image-scratch";
reg = <0x000da000 0x0001e000>;
};
/*
* The flash starting at 0x000f8000 and ending at
* 0x000fffff is reserved for use by the application.
*/
/* Storage partition will be used by FCB/NFFS/NVS if enabled. */
storage_partition: partition@f8000 {
label = "storage";
reg = <0x000f8000 0x00008000>;
};
};
};

View file

@ -15,7 +15,6 @@
chosen {
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,ieee802154 = &ieee802154;
};

View file

@ -0,0 +1,47 @@
/*
* Copyright (c) 2024 Jacob Winther
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
chosen {
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_partition;
};
};
&flash0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 0x0000C000>;
};
slot0_partition: partition@c000 {
label = "image-0";
reg = <0x0000C000 0x00077000>;
};
slot1_partition: partition@83000 {
label = "image-1";
reg = <0x00083000 0x00075000>;
};
/*
* The flash starting at 0x000f8000 and ending at
* 0x000fffff is reserved for use by the application.
*/
/*
* Storage partition will be used by FCB/LittleFS/NVS
* if enabled.
*/
storage_partition: partition@f8000 {
label = "storage";
reg = <0x000f8000 0x00008000>;
};
};
};

View file

@ -0,0 +1,52 @@
/*
* Copyright (c) 2024 Jacob Winther
*
* SPDX-License-Identifier: Apache-2.0
*
* Default flash layout for nrf52840 using UF2
*/
/ {
chosen {
zephyr,flash = &flash0;
zephyr,code-partition = &code_partition;
};
};
&flash0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
/* To enable flashing with UF2 bootloader, we
* must reserve a partition for SoftDevice.
* See https://learn.adafruit.com/
* introducing-the-adafruit-nrf52840-feather?view=all#hathach-memory-map
*/
reserved_partition_0: partition@0 {
label = "SoftDevice";
read-only;
reg = <0x000000000 DT_SIZE_K(152)>;
};
code_partition: partition@26000 {
label = "Application";
reg = <0x00026000 DT_SIZE_K(796)>;
};
/*
* The flash starting at 0x000ed000 and ending at
* 0x000f4000 is reserved for use by the application.
*/
storage_partition: partition@ed000 {
label = "storage";
reg = <0x0000ed000 DT_SIZE_K(28)>;
};
boot_partition: partition@f4000 {
label = "UF2";
read-only;
reg = <0x000f4000 DT_SIZE_K(48)>;
};
};
};

View file

@ -1,5 +1,4 @@
/*
* Copyright (c) 2020 Tobias Svehagen
* Copyright (c) 2024 Jacob Winther
*
* SPDX-License-Identifier: Apache-2.0
@ -7,18 +6,18 @@
/dts-v1/;
#include "adafruit_feather_nrf52840_common.dtsi"
#include "adafruit_feather_nrf52840_flash.dtsi"
/ {
model = "Adafruit Feather nRF52840 Sense";
compatible = "adafruit,feather-nrf52840-sense";
compatible = "adafruit,feather-nrf52840-sense-uf2";
chosen {
zephyr,console = &cdc_acm_uart0;
zephyr,shell-uart = &cdc_acm_uart0;
zephyr,uart-mcumgr = &cdc_acm_uart0;
zephyr,bt-mon-uart = &cdc_acm_uart0;
zephyr,bt-c2h-uart = &cdc_acm_uart0;
zephyr,code-partition = &code_partition;
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,uart-mcumgr = &uart0;
zephyr,bt-mon-uart = &uart0;
zephyr,bt-c2h-uart = &uart0;
};
leds {
@ -34,47 +33,3 @@
reg = <0x44>;
};
};
&flash0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
/* To enable flashing with UF2 bootloader, we
* must reserve a partition for SoftDevice.
* See https://learn.adafruit.com/
* introducing-the-adafruit-nrf52840-feather?view=all#hathach-memory-map
*/
reserved_partition_0: partition@0 {
label = "SoftDevice";
read-only;
reg = <0x000000000 DT_SIZE_K(152)>;
};
code_partition: partition@26000 {
label = "Application";
reg = <0x00026000 DT_SIZE_K(796)>;
};
/*
* The flash starting at 0x000ed000 and ending at
* 0x000f4000 is reserved for use by the application.
*/
storage_partition: partition@ed000 {
label = "storage";
reg = <0x0000ed000 DT_SIZE_K(28)>;
};
boot_partition: partition@f4000 {
label = "UF2";
read-only;
reg = <0x000f4000 DT_SIZE_K(48)>;
};
};
};
zephyr_udc0: &usbd {
cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
};
};

View file

@ -16,12 +16,3 @@ CONFIG_UART_CONSOLE=y
# 32kHz clock source
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y
# Logger cannot use itself to log
CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y
# Enable USB
CONFIG_USB_DEVICE_STACK=y
# Build UF2 by default, supported by the Adafruit nRF52 Bootloader
CONFIG_BUILD_OUTPUT_UF2=y

View file

@ -0,0 +1,42 @@
/*
* Copyright (c) 2020 Tobias Svehagen
* Copyright (c) 2024 Jacob Winther
*
* SPDX-License-Identifier: Apache-2.0
*/
/dts-v1/;
#include "adafruit_feather_nrf52840_common.dtsi"
#include "adafruit_feather_nrf52840_flash_uf2.dtsi"
/ {
model = "Adafruit Feather nRF52840 Sense";
compatible = "adafruit,feather-nrf52840-sense-uf2";
chosen {
zephyr,console = &cdc_acm_uart0;
zephyr,shell-uart = &cdc_acm_uart0;
zephyr,uart-mcumgr = &cdc_acm_uart0;
zephyr,bt-mon-uart = &cdc_acm_uart0;
zephyr,bt-c2h-uart = &cdc_acm_uart0;
};
leds {
led0: led_0 {
gpios = <&gpio1 9 0>;
};
};
};
&i2c0 {
SHT3XD: sht3xd@44 {
compatible = "sensirion,sht3xd";
reg = <0x44>;
};
};
zephyr_udc0: &usbd {
cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
};
};

View file

@ -0,0 +1,19 @@
identifier: adafruit_feather_nrf52840/nrf52840/sense/uf2
name: Adafruit Feather nRF52840 Sense UF2
type: mcu
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- adc
- usb_device
- usb_cdc
- ble
- watchdog
- counter
- feather_serial
- feather_i2c
- feather_spi
vendor: adafruit

View file

@ -0,0 +1,27 @@
# SPDX-License-Identifier: Apache-2.0
# Enable MPU
CONFIG_ARM_MPU=y
# Enable GPIO
CONFIG_GPIO=y
# Enable UART driver
CONFIG_SERIAL=y
# Enable console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
# 32kHz clock source
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y
# Logger cannot use itself to log
CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y
# Enable USB
CONFIG_USB_DEVICE_STACK=y
# Build UF2 by default, supported by the Adafruit nRF52 Bootloader
CONFIG_BUILD_OUTPUT_UF2=y

View file

@ -0,0 +1,34 @@
/*
* Copyright (c) 2024 Jacob Winther
*
* SPDX-License-Identifier: Apache-2.0
*/
/dts-v1/;
#include "adafruit_feather_nrf52840_common.dtsi"
#include "adafruit_feather_nrf52840_flash_uf2.dtsi"
/ {
model = "Adafruit Feather nRF52840 Express";
compatible = "adafruit,feather-nrf52840-uf2";
chosen {
zephyr,console = &cdc_acm_uart0;
zephyr,shell-uart = &cdc_acm_uart0;
zephyr,uart-mcumgr = &cdc_acm_uart0;
zephyr,bt-mon-uart = &cdc_acm_uart0;
zephyr,bt-c2h-uart = &cdc_acm_uart0;
};
leds {
led0: led_0 {
gpios = <&gpio1 15 0>;
};
};
};
zephyr_udc0: &usbd {
cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
};
};

View file

@ -0,0 +1,18 @@
identifier: adafruit_feather_nrf52840/nrf52840/uf2
name: Adafruit Feather nRF52840 Express UF2
type: mcu
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- adc
- usb_device
- ble
- watchdog
- counter
- feather_serial
- feather_i2c
- feather_spi
vendor: adafruit

View file

@ -0,0 +1,23 @@
# SPDX-License-Identifier: Apache-2.0
# Enable MPU
CONFIG_ARM_MPU=y
# Enable GPIO
CONFIG_GPIO=y
# Enable UART driver
CONFIG_SERIAL=y
# Enable console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
# Logger cannot use itself to log
CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y
# Enable USB
CONFIG_USB_DEVICE_STACK=y
# Build UF2 by default, supported by the Adafruit nRF52 Bootloader
CONFIG_BUILD_OUTPUT_UF2=y

View file

@ -4,4 +4,7 @@ board:
socs:
- name: nrf52840
variants:
- name: uf2
- name: sense
variants:
- name: uf2

View file

@ -135,8 +135,8 @@ Programming and Debugging
Flashing
========
Flashing Zephyr onto the ``adafruit_feather_nrf52480`` board is possible
using an external programmer. The programmer is attached to the SWD header.
Flashing Zephyr onto both the Feather nRF52840 Express and Sense is possible
using the SWD headers. Only the Express board has an SWD connector however.
Both the Feather nRF52840 Express and Sense ship with the `Adafruit nRF52 Bootloader`_
which supports flashing using `UF2`_. This allows easy flashing of new images,
@ -150,7 +150,15 @@ but does not support debugging the device.
.. zephyr-app-commands::
:zephyr-app: samples/basic/blinky
:board: adafruit_feather_nrf52840/nrf52840
:board: adafruit_feather_nrf52840
:goals: build
:compact:
.. group-tab:: Express UF2
.. zephyr-app-commands::
:zephyr-app: samples/basic/blinky
:board: adafruit_feather_nrf52840/nrf52840/uf2
:goals: build
:compact:
@ -162,6 +170,14 @@ but does not support debugging the device.
:goals: build
:compact:
.. group-tab:: Sense UF2
.. zephyr-app-commands::
:zephyr-app: samples/basic/blinky
:board: adafruit_feather_nrf52840/nrf52840/sense/uf2
:goals: build
:compact:
#. If using UF2, connect the board to your host computer using USB.
#. Tap the reset button twice quickly to enter bootloader mode.
@ -177,10 +193,19 @@ but does not support debugging the device.
.. zephyr-app-commands::
:zephyr-app: samples/basic/blinky
:board: adafruit_feather_nrf52840/nrf52840
:board: adafruit_feather_nrf52840
:goals: flash
:compact:
.. group-tab:: Express UF2
.. zephyr-app-commands::
:zephyr-app: samples/basic/blinky
:board: adafruit_feather_nrf52840/nrf52840/uf2
:goals: flash
:compact:
.. group-tab:: Sense
.. zephyr-app-commands::
@ -189,6 +214,14 @@ but does not support debugging the device.
:goals: flash
:compact:
.. group-tab:: Sense UF2
.. zephyr-app-commands::
:zephyr-app: samples/basic/blinky
:board: adafruit_feather_nrf52840/nrf52840/sense/uf2
:goals: flash
:compact:
#. You should see the red LED blink.
References

View file

@ -0,0 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Benjamin Björnsson <benjamin.bjornsson@gmail.com>
*/
#include "nordic,nrf-saadc-common.dtsi"

View file

@ -0,0 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Benjamin Björnsson <benjamin.bjornsson@gmail.com>
*/
#include "nordic,nrf-saadc-common.dtsi"