Skip to content

Commit

Permalink
boards: adafruit feather nrf52840 update UF2
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jacobw committed Aug 30, 2024
1 parent 3e2e1a3 commit 0f38b73
Show file tree
Hide file tree
Showing 17 changed files with 325 additions and 104 deletions.
39 changes: 1 addition & 38 deletions boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840.dts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

/dts-v1/;

#include "adafruit_feather_nrf52840_common.dtsi"
#include "adafruit_feather_nrf52840_flash.dtsi"

/ {
model = "Adafruit Feather nRF52840 Express";
Expand All @@ -19,7 +19,6 @@
zephyr,uart-mcumgr = &uart0;
zephyr,bt-mon-uart = &uart0;
zephyr,bt-c2h-uart = &uart0;
zephyr,code-partition = &slot0_partition;
};

leds {
Expand All @@ -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>;
};
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

chosen {
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,ieee802154 = &ieee802154;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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 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>;
};
};
};
Original file line number Diff line number Diff line change
@@ -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)>;
};
};
};
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
/*
* 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.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 {
Expand All @@ -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";
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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";
};
};
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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";
};
};
Loading

0 comments on commit 0f38b73

Please sign in to comment.