diff --git a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840.dts b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840.dts index 8786b9cd2e3b745..2c52fd4310ee25a 100644 --- a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840.dts +++ b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840.dts @@ -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>; - }; - }; -}; diff --git a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_common.dtsi b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_common.dtsi index 6eff846559d7d5b..647919b278b8835 100644 --- a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_common.dtsi +++ b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_common.dtsi @@ -15,7 +15,6 @@ chosen { zephyr,sram = &sram0; - zephyr,flash = &flash0; zephyr,ieee802154 = &ieee802154; }; diff --git a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_flash.dtsi b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_flash.dtsi new file mode 100644 index 000000000000000..60c0456913cada3 --- /dev/null +++ b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_flash.dtsi @@ -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>; + }; + }; +}; diff --git a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_flash_uf2.dtsi b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_flash_uf2.dtsi new file mode 100644 index 000000000000000..877d1f45c2335c5 --- /dev/null +++ b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_flash_uf2.dtsi @@ -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)>; + }; + }; +}; diff --git a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense.dts b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense.dts index 26dbe9ca8106b07..2a8f47269ad6880 100644 --- a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense.dts +++ b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense.dts @@ -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"; - }; -}; diff --git a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_defconfig b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_defconfig index 18c22c337d08d10..fb20a748810e433 100644 --- a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_defconfig +++ b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_defconfig @@ -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 diff --git a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_uf2.dts b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_uf2.dts new file mode 100644 index 000000000000000..0ad7ee1e960d0f3 --- /dev/null +++ b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_uf2.dts @@ -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"; + }; +}; diff --git a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_uf2.yaml b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_uf2.yaml new file mode 100644 index 000000000000000..08eb1eaa7f1db1e --- /dev/null +++ b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_uf2.yaml @@ -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 diff --git a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_uf2_defconfig b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_uf2_defconfig new file mode 100644 index 000000000000000..18c22c337d08d10 --- /dev/null +++ b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_sense_uf2_defconfig @@ -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 diff --git a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_uf2.dts b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_uf2.dts new file mode 100644 index 000000000000000..33f2d3e598c8fce --- /dev/null +++ b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_uf2.dts @@ -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"; + }; +}; diff --git a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_uf2.yaml b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_uf2.yaml new file mode 100644 index 000000000000000..ebb7a399f0ca46a --- /dev/null +++ b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_uf2.yaml @@ -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 diff --git a/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_uf2_defconfig b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_uf2_defconfig new file mode 100644 index 000000000000000..f6ec20976464845 --- /dev/null +++ b/boards/adafruit/feather_nrf52840/adafruit_feather_nrf52840_nrf52840_uf2_defconfig @@ -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 diff --git a/boards/adafruit/feather_nrf52840/board.yml b/boards/adafruit/feather_nrf52840/board.yml index fa1386fa0c3bc97..5841c2f4bf0ba6d 100644 --- a/boards/adafruit/feather_nrf52840/board.yml +++ b/boards/adafruit/feather_nrf52840/board.yml @@ -4,4 +4,7 @@ board: socs: - name: nrf52840 variants: + - name: uf2 - name: sense + variants: + - name: uf2 diff --git a/boards/adafruit/feather_nrf52840/doc/index.rst b/boards/adafruit/feather_nrf52840/doc/index.rst index d17872b2e1a9d6c..e4e62c0556efbda 100644 --- a/boards/adafruit/feather_nrf52840/doc/index.rst +++ b/boards/adafruit/feather_nrf52840/doc/index.rst @@ -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 diff --git a/tests/drivers/adc/adc_api/boards/adafruit_feather_nrf52840_nrf52840.overlay b/tests/drivers/adc/adc_api/boards/adafruit_feather_nrf52840.overlay similarity index 100% rename from tests/drivers/adc/adc_api/boards/adafruit_feather_nrf52840_nrf52840.overlay rename to tests/drivers/adc/adc_api/boards/adafruit_feather_nrf52840.overlay diff --git a/tests/drivers/adc/adc_api/boards/adafruit_feather_nrf52840_nrf52840_sense_uf2.overlay b/tests/drivers/adc/adc_api/boards/adafruit_feather_nrf52840_nrf52840_sense_uf2.overlay new file mode 100644 index 000000000000000..2af48efc4d1d47a --- /dev/null +++ b/tests/drivers/adc/adc_api/boards/adafruit_feather_nrf52840_nrf52840_sense_uf2.overlay @@ -0,0 +1,7 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2023 Benjamin Björnsson + */ + +#include "nordic,nrf-saadc-common.dtsi" diff --git a/tests/drivers/adc/adc_api/boards/adafruit_feather_nrf52840_nrf52840_uf2.overlay b/tests/drivers/adc/adc_api/boards/adafruit_feather_nrf52840_nrf52840_uf2.overlay new file mode 100644 index 000000000000000..2af48efc4d1d47a --- /dev/null +++ b/tests/drivers/adc/adc_api/boards/adafruit_feather_nrf52840_nrf52840_uf2.overlay @@ -0,0 +1,7 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2023 Benjamin Björnsson + */ + +#include "nordic,nrf-saadc-common.dtsi"