diff --git a/boards/nordic/nrf52840dongle/Kconfig b/boards/nordic/nrf52840dongle/Kconfig index c8698ad0701..7b725874fa0 100644 --- a/boards/nordic/nrf52840dongle/Kconfig +++ b/boards/nordic/nrf52840dongle/Kconfig @@ -6,8 +6,8 @@ if BOARD_NRF52840DONGLE config BOARD_HAS_NRF5_BOOTLOADER - bool "Board has nRF5 bootloader" - default y + bool + default y if !BOARD_NRF52840DONGLE_NRF52840_BARE help If selected, applications are linked so that they can be loaded by Nordic nRF5 bootloader. diff --git a/boards/nordic/nrf52840dongle/Kconfig.defconfig b/boards/nordic/nrf52840dongle/Kconfig.defconfig index 5bdbb6ce63b..22c5f176b5b 100644 --- a/boards/nordic/nrf52840dongle/Kconfig.defconfig +++ b/boards/nordic/nrf52840dongle/Kconfig.defconfig @@ -9,18 +9,12 @@ if BOARD_NRF52840DONGLE # To let the nRF5 bootloader load an application, the application # must be linked after Nordic MBR, that is factory-programmed on the board. -# Nordic nRF5 bootloader exists outside of the partitions specified in the -# DTS file, so we manually override FLASH_LOAD_OFFSET to link the application -# correctly, after Nordic MBR. - -# When building MCUBoot, MCUBoot itself will select USE_DT_CODE_PARTITION -# which will make it link into the correct partition specified in DTS file, -# the offset is applied here so that the full partition size can be used when -# the bootloader Kconfig option has been disabled. +# If the application wants to use the full partition size, a "bare" board +# variant should be used instead. config FLASH_LOAD_OFFSET default 0x1000 - depends on BOARD_HAS_NRF5_BOOTLOADER && (MCUBOOT || !USE_DT_CODE_PARTITION) + depends on BOARD_HAS_NRF5_BOOTLOADER && !USE_DT_CODE_PARTITION source "boards/common/usb/Kconfig.cdc_acm_serial.defconfig" diff --git a/boards/nordic/nrf52840dongle/board.yml b/boards/nordic/nrf52840dongle/board.yml index 59eae5b3429..b5f92096eea 100644 --- a/boards/nordic/nrf52840dongle/board.yml +++ b/boards/nordic/nrf52840dongle/board.yml @@ -4,3 +4,5 @@ board: vendor: nordic socs: - name: nrf52840 + variants: + - name: bare diff --git a/boards/nordic/nrf52840dongle/doc/index.rst b/boards/nordic/nrf52840dongle/doc/index.rst index 95ec7a34288..b5da6678d00 100644 --- a/boards/nordic/nrf52840dongle/doc/index.rst +++ b/boards/nordic/nrf52840dongle/doc/index.rst @@ -254,13 +254,9 @@ For Segger J-Link debug probes, follow the instructions in the :ref:`nordic_segger` page to install and configure all the necessary software. Further information can be found in :ref:`nordic_segger_flashing`. -Locate the DTS file: :zephyr_file:`boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts`. -This file requires a small modification to use a different partition table. -Edit the include directive to include "fstab-debugger" instead of "fstab-stock". - -In addition, the Kconfig file in the same directory must be modified by setting -``BOARD_HAS_NRF5_BOOTLOADER`` to be default ``n``, otherwise the code will be -flashed with an offset. +Use the ``nrf52840dongle/nrf52840/bare`` board variant to build your application. +This variant uses a modified partition table, which does not reserve space for +the onboard USB bootloader. Then build and flash applications as usual (see :ref:`build_an_application` and :ref:`application_run` for more details). @@ -269,7 +265,7 @@ Here is an example for the :zephyr:code-sample:`blinky` application. .. zephyr-app-commands:: :zephyr-app: samples/basic/blinky - :board: nrf52840dongle/nrf52840 + :board: nrf52840dongle/nrf52840/bare :goals: build flash Observe the LED on the board blinking. diff --git a/boards/nordic/nrf52840dongle/fstab-stock.dtsi b/boards/nordic/nrf52840dongle/fstab-stock.dtsi deleted file mode 100644 index b487f02c153..00000000000 --- a/boards/nordic/nrf52840dongle/fstab-stock.dtsi +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2019 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/* Flash partition table compatible with Nordic nRF5 bootloader */ - -&flash0 { - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - /* MCUboot placed after Nordic MBR (this is set with the FLASH_LOAD_OFFSET - * Kconfig value when BOARD_HAS_NRF5_BOOTLOADER is enabled), otherwise MCUboot - * will be placed at 0x0. The size of this partition ensures that MCUBoot can - * be built with CDC ACM support and w/o optimizations. - */ - boot_partition: partition@0 { - label = "mcuboot"; - reg = <0x00000000 0x00010000>; - }; - - slot0_partition: partition@10000 { - label = "image-0"; - reg = <0x00010000 0x00066000>; - }; - - slot1_partition: partition@76000 { - label = "image-1"; - reg = <0x00076000 0x00066000>; - }; - - storage_partition: partition@dc000 { - label = "storage"; - reg = <0x000dc000 0x00004000>; - }; - - /* Nordic nRF5 bootloader <0xe0000 0x1c000> - * - * In addition, the last and second last flash pages - * are used by the nRF5 bootloader and MBR to store settings. - */ - }; -}; diff --git a/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts index 890570b7eee..e446c5aaf54 100644 --- a/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts +++ b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts @@ -6,191 +6,45 @@ */ /dts-v1/; -#include -#include "nrf52840dongle_nrf52840-pinctrl.dtsi" -#include +#include "nrf52840dongle_nrf52840_common.dtsi" -/ { - model = "Nordic nRF52840 Dongle NRF52840"; - compatible = "nordic,nrf52840-dongle-nrf52840"; +/* Flash partition table compatible with the onboard USB bootloader */ - chosen { - zephyr,sram = &sram0; - zephyr,flash = &flash0; - zephyr,code-partition = &slot0_partition; - zephyr,ieee802154 = &ieee802154; - }; - - leds { - compatible = "gpio-leds"; +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; - led0_green: led_0 { - gpios = <&gpio0 6 GPIO_ACTIVE_LOW>; - label = "Green LED 0"; + /* MCUboot placed after Nordic MBR. + * The size of this partition ensures that MCUBoot can + * be built with CDC ACM support and w/o optimizations. + */ + boot_partition: partition@1000 { + label = "mcuboot"; + reg = <0x00001000 0x0000f000>; }; - led1_red: led_1 { - gpios = <&gpio0 8 GPIO_ACTIVE_LOW>; - label = "Red LED 1"; + slot0_partition: partition@10000 { + label = "image-0"; + reg = <0x00010000 0x00066000>; }; - led1_green: led_2 { - gpios = <&gpio1 9 GPIO_ACTIVE_LOW>; - label = "Green LED 1"; + slot1_partition: partition@76000 { + label = "image-1"; + reg = <0x00076000 0x00066000>; }; - led1_blue: led_3 { - gpios = <&gpio0 12 GPIO_ACTIVE_LOW>; - label = "Blue LED 1"; + storage_partition: partition@dc000 { + label = "storage"; + reg = <0x000dc000 0x00004000>; }; - }; - - pwmleds { - compatible = "pwm-leds"; - red_pwm_led: pwm_led_0 { - pwms = <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>; - }; - - green_pwm_led: pwm_led_1 { - pwms = <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>; - }; - - blue_pwm_led: pwm_led_2 { - pwms = <&pwm0 2 PWM_MSEC(20) PWM_POLARITY_INVERTED>; - }; - }; - - buttons { - compatible = "gpio-keys"; - - button0: button_0 { - gpios = <&gpio1 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; - label = "Push button switch 0"; - zephyr,code = ; - }; + /* Onboard USB bootloader <0xe0000 0x1c000> + * + * In addition, the last and second last flash pages + * are used by the onboard USB bootloader and MBR to store + * settings. + */ }; - - /* These aliases are provided for compatibility with samples */ - aliases { - sw0 = &button0; - led0 = &led0_green; - led1 = &led1_red; - led2 = &led1_green; - led3 = &led1_blue; - led0-green = &led0_green; - led1-red = &led1_red; - led1-green = &led1_green; - led1-blue = &led1_blue; - pwm-led0 = &red_pwm_led; - pwm-led1 = &green_pwm_led; - pwm-led2 = &blue_pwm_led; - red-pwm-led = &red_pwm_led; - green-pwm-led = &green_pwm_led; - blue-pwm-led = &blue_pwm_led; - mcuboot-button0 = &button0; - mcuboot-led0 = &led0_green; - watchdog0 = &wdt0; - }; -}; - -®0 { - status = "okay"; -}; - -®1 { - regulator-initial-mode = ; -}; - -&adc { - status = "okay"; -}; - -&gpiote { - status = "okay"; -}; - -&uicr { - nfct-pins-as-gpios; - gpio-as-nreset; }; - -&gpio0 { - status = "okay"; -}; - -&gpio1 { - status = "okay"; -}; - -&uart0 { - compatible = "nordic,nrf-uarte"; - status = "okay"; - current-speed = <115200>; - pinctrl-0 = <&uart0_default>; - pinctrl-1 = <&uart0_sleep>; - pinctrl-names = "default", "sleep"; -}; - -&i2c0 { - compatible = "nordic,nrf-twi"; - status = "okay"; - pinctrl-0 = <&i2c0_default>; - pinctrl-1 = <&i2c0_sleep>; - pinctrl-names = "default", "sleep"; -}; - -&i2c1 { - compatible = "nordic,nrf-twi"; - /* Cannot be used together with spi1. */ - /* status = "okay"; */ - pinctrl-0 = <&i2c1_default>; - pinctrl-1 = <&i2c1_sleep>; - pinctrl-names = "default", "sleep"; -}; - -&pwm0 { - status = "okay"; - pinctrl-0 = <&pwm0_default>; - pinctrl-1 = <&pwm0_sleep>; - pinctrl-names = "default", "sleep"; -}; - -/* - * By default, not adding all available SPI instances (spi2, spi3) due to - * limited GPIOs available on dongle board. - */ -&spi0 { - compatible = "nordic,nrf-spi"; - /* Cannot be used together with i2c0. */ - /* status = "okay"; */ - pinctrl-0 = <&spi0_default>; - pinctrl-1 = <&spi0_sleep>; - pinctrl-names = "default", "sleep"; -}; - -&spi1 { - compatible = "nordic,nrf-spi"; - status = "okay"; - pinctrl-0 = <&spi1_default>; - pinctrl-1 = <&spi1_sleep>; - pinctrl-names = "default", "sleep"; -}; - -&ieee802154 { - status = "okay"; -}; - -/* Include flash partition table. - * Two partition tables are available: - * fstab-stock -compatible with Nordic nRF5 bootloader, default - * fstab-debugger -to use an external debugger, w/o the nRF5 bootloader - */ -#include "fstab-stock.dtsi" - -zephyr_udc0: &usbd { - compatible = "nordic,nrf-usbd"; - status = "okay"; -}; - -#include <../boards/common/usb/cdc_acm_serial.dtsi> diff --git a/boards/nordic/nrf52840dongle/fstab-debugger.dtsi b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare.dts similarity index 75% rename from boards/nordic/nrf52840dongle/fstab-debugger.dtsi rename to boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare.dts index dd3d12403c6..b8b76a8e63b 100644 --- a/boards/nordic/nrf52840dongle/fstab-debugger.dtsi +++ b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare.dts @@ -1,10 +1,14 @@ /* - * Copyright (c) 2019 Nordic Semiconductor ASA + * Copyright (c) 2018-2023 Nordic Semiconductor ASA + * Copyright (c) 2017 Linaro Limited * * SPDX-License-Identifier: Apache-2.0 */ -/* Flash partition table without support for Nordic nRF5 bootloader */ +/dts-v1/; +#include "nrf52840dongle_nrf52840_common.dtsi" + +/* Flash partition table without support for the onboard USB bootloader */ &flash0 { partitions { diff --git a/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare.yaml b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare.yaml new file mode 100644 index 00000000000..516cd385264 --- /dev/null +++ b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare.yaml @@ -0,0 +1,20 @@ +identifier: nrf52840dongle/nrf52840/bare +name: nRF52840-Dongle-NRF52840-bare +type: mcu +arch: arm +ram: 256 +flash: 1024 +toolchain: + - zephyr + - gnuarmemb +supported: + - adc + - usb_device + - ble + - pwm + - spi + - watchdog + - counter + - netif:openthread + - gpio +vendor: nordic diff --git a/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare_defconfig b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare_defconfig new file mode 100644 index 00000000000..ffaccd75ea8 --- /dev/null +++ b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare_defconfig @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Enable MPU +CONFIG_ARM_MPU=y + +# Enable hardware stack protection +CONFIG_HW_STACK_PROTECTION=y + +# enable GPIO +CONFIG_GPIO=y + +# Board Kconfig.defconfig enables USB CDC ACM and should disable USB remote +# wakeup by default. It needs to be disabled here, because the USB nrfx +# driver always overwrites option from Kconfig mentioned above with the +# imply from CONFIG_USB_NRFX. +CONFIG_USB_DEVICE_REMOTE_WAKEUP=n diff --git a/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_common.dtsi b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_common.dtsi new file mode 100644 index 00000000000..4039b490861 --- /dev/null +++ b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_common.dtsi @@ -0,0 +1,189 @@ +/* + * Copyright (c) 2018-2023 Nordic Semiconductor ASA + * Copyright (c) 2017 Linaro Limited + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include "nrf52840dongle_nrf52840-pinctrl.dtsi" +#include + +/ { + model = "Nordic nRF52840 Dongle NRF52840"; + compatible = "nordic,nrf52840-dongle-nrf52840"; + + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,code-partition = &slot0_partition; + zephyr,ieee802154 = &ieee802154; + }; + + leds { + compatible = "gpio-leds"; + + led0_green: led_0 { + gpios = <&gpio0 6 GPIO_ACTIVE_LOW>; + label = "Green LED 0"; + }; + + led1_red: led_1 { + gpios = <&gpio0 8 GPIO_ACTIVE_LOW>; + label = "Red LED 1"; + }; + + led1_green: led_2 { + gpios = <&gpio1 9 GPIO_ACTIVE_LOW>; + label = "Green LED 1"; + }; + + led1_blue: led_3 { + gpios = <&gpio0 12 GPIO_ACTIVE_LOW>; + label = "Blue LED 1"; + }; + }; + + pwmleds { + compatible = "pwm-leds"; + + red_pwm_led: pwm_led_0 { + pwms = <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>; + }; + + green_pwm_led: pwm_led_1 { + pwms = <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>; + }; + + blue_pwm_led: pwm_led_2 { + pwms = <&pwm0 2 PWM_MSEC(20) PWM_POLARITY_INVERTED>; + }; + }; + + buttons { + compatible = "gpio-keys"; + + button0: button_0 { + gpios = <&gpio1 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "Push button switch 0"; + zephyr,code = ; + }; + }; + + /* These aliases are provided for compatibility with samples */ + aliases { + sw0 = &button0; + led0 = &led0_green; + led1 = &led1_red; + led2 = &led1_green; + led3 = &led1_blue; + led0-green = &led0_green; + led1-red = &led1_red; + led1-green = &led1_green; + led1-blue = &led1_blue; + pwm-led0 = &red_pwm_led; + pwm-led1 = &green_pwm_led; + pwm-led2 = &blue_pwm_led; + red-pwm-led = &red_pwm_led; + green-pwm-led = &green_pwm_led; + blue-pwm-led = &blue_pwm_led; + mcuboot-button0 = &button0; + mcuboot-led0 = &led0_green; + watchdog0 = &wdt0; + }; +}; + +®0 { + status = "okay"; +}; + +®1 { + regulator-initial-mode = ; +}; + +&adc { + status = "okay"; +}; + +&gpiote { + status = "okay"; +}; + +&uicr { + nfct-pins-as-gpios; + gpio-as-nreset; +}; + +&gpio0 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&uart0 { + compatible = "nordic,nrf-uarte"; + status = "okay"; + current-speed = <115200>; + pinctrl-0 = <&uart0_default>; + pinctrl-1 = <&uart0_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&i2c0 { + compatible = "nordic,nrf-twi"; + status = "okay"; + pinctrl-0 = <&i2c0_default>; + pinctrl-1 = <&i2c0_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&i2c1 { + compatible = "nordic,nrf-twi"; + /* Cannot be used together with spi1. */ + /* status = "okay"; */ + pinctrl-0 = <&i2c1_default>; + pinctrl-1 = <&i2c1_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&pwm0 { + status = "okay"; + pinctrl-0 = <&pwm0_default>; + pinctrl-1 = <&pwm0_sleep>; + pinctrl-names = "default", "sleep"; +}; + +/* + * By default, not adding all available SPI instances (spi2, spi3) due to + * limited GPIOs available on dongle board. + */ +&spi0 { + compatible = "nordic,nrf-spi"; + /* Cannot be used together with i2c0. */ + /* status = "okay"; */ + pinctrl-0 = <&spi0_default>; + pinctrl-1 = <&spi0_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&spi1 { + compatible = "nordic,nrf-spi"; + status = "okay"; + pinctrl-0 = <&spi1_default>; + pinctrl-1 = <&spi1_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&ieee802154 { + status = "okay"; +}; + +zephyr_udc0: &usbd { + compatible = "nordic,nrf-usbd"; + status = "okay"; +}; + +#include <../boards/common/usb/cdc_acm_serial.dtsi> diff --git a/tests/drivers/adc/adc_api/boards/nrf52840dongle_nrf52840_bare.overlay b/tests/drivers/adc/adc_api/boards/nrf52840dongle_nrf52840_bare.overlay new file mode 100644 index 00000000000..d791b6fd57e --- /dev/null +++ b/tests/drivers/adc/adc_api/boards/nrf52840dongle_nrf52840_bare.overlay @@ -0,0 +1,7 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2025 Tomasz Chyrowicz + */ + +#include "nordic,nrf-saadc-common.dtsi"