Skip to content

Commit be70dff

Browse files
committed
[nrf fromlist] boards: Add nRF52840 dongle bare variant
Add a variant for builds that use debugger to flash the dongle, effectively overwriting the stock nRF5 SDK bootloader. Upstream PR #: 92405 Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no>
1 parent 7830f6c commit be70dff

11 files changed

+278
-242
lines changed

boards/nordic/nrf52840dongle/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
if BOARD_NRF52840DONGLE
77

88
config BOARD_HAS_NRF5_BOOTLOADER
9-
bool "Board has nRF5 bootloader"
10-
default y
9+
bool
10+
default y if !BOARD_NRF52840DONGLE_NRF52840_BARE
1111
help
1212
If selected, applications are linked so that they can be loaded by Nordic
1313
nRF5 bootloader.

boards/nordic/nrf52840dongle/Kconfig.defconfig

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,12 @@ if BOARD_NRF52840DONGLE
99
# To let the nRF5 bootloader load an application, the application
1010
# must be linked after Nordic MBR, that is factory-programmed on the board.
1111

12-
# Nordic nRF5 bootloader exists outside of the partitions specified in the
13-
# DTS file, so we manually override FLASH_LOAD_OFFSET to link the application
14-
# correctly, after Nordic MBR.
15-
16-
# When building MCUBoot, MCUBoot itself will select USE_DT_CODE_PARTITION
17-
# which will make it link into the correct partition specified in DTS file,
18-
# the offset is applied here so that the full partition size can be used when
19-
# the bootloader Kconfig option has been disabled.
12+
# If the application wants to use the full partition size, a "bare" board
13+
# variant should be used instead.
2014

2115
config FLASH_LOAD_OFFSET
2216
default 0x1000
23-
depends on BOARD_HAS_NRF5_BOOTLOADER && (MCUBOOT || !USE_DT_CODE_PARTITION)
17+
depends on BOARD_HAS_NRF5_BOOTLOADER && !USE_DT_CODE_PARTITION
2418

2519
source "boards/common/usb/Kconfig.cdc_acm_serial.defconfig"
2620

boards/nordic/nrf52840dongle/board.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ board:
44
vendor: nordic
55
socs:
66
- name: nrf52840
7+
variants:
8+
- name: bare

boards/nordic/nrf52840dongle/doc/index.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,9 @@ For Segger J-Link debug probes, follow the instructions in the
254254
:ref:`nordic_segger` page to install and configure all the necessary
255255
software. Further information can be found in :ref:`nordic_segger_flashing`.
256256

257-
Locate the DTS file: :zephyr_file:`boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts`.
258-
This file requires a small modification to use a different partition table.
259-
Edit the include directive to include "fstab-debugger" instead of "fstab-stock".
260-
261-
In addition, the Kconfig file in the same directory must be modified by setting
262-
``BOARD_HAS_NRF5_BOOTLOADER`` to be default ``n``, otherwise the code will be
263-
flashed with an offset.
257+
Use the ``nrf52840dongle/nrf52840/bare`` board variant to build your application.
258+
This variant uses a modified partition table, which does not reserve space for
259+
the onboard USB bootloader.
264260

265261
Then build and flash applications as usual (see :ref:`build_an_application` and
266262
:ref:`application_run` for more details).
@@ -269,7 +265,7 @@ Here is an example for the :zephyr:code-sample:`blinky` application.
269265

270266
.. zephyr-app-commands::
271267
:zephyr-app: samples/basic/blinky
272-
:board: nrf52840dongle/nrf52840
268+
:board: nrf52840dongle/nrf52840/bare
273269
:goals: build flash
274270

275271
Observe the LED on the board blinking.

boards/nordic/nrf52840dongle/fstab-stock.dtsi

Lines changed: 0 additions & 46 deletions
This file was deleted.

boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts

Lines changed: 29 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -6,191 +6,45 @@
66
*/
77

88
/dts-v1/;
9-
#include <nordic/nrf52840_qiaa.dtsi>
10-
#include "nrf52840dongle_nrf52840-pinctrl.dtsi"
11-
#include <zephyr/dt-bindings/input/input-event-codes.h>
9+
#include "nrf52840dongle_nrf52840_common.dtsi"
1210

13-
/ {
14-
model = "Nordic nRF52840 Dongle NRF52840";
15-
compatible = "nordic,nrf52840-dongle-nrf52840";
11+
/* Flash partition table compatible with the onboard USB bootloader */
1612

17-
chosen {
18-
zephyr,sram = &sram0;
19-
zephyr,flash = &flash0;
20-
zephyr,code-partition = &slot0_partition;
21-
zephyr,ieee802154 = &ieee802154;
22-
};
23-
24-
leds {
25-
compatible = "gpio-leds";
13+
&flash0 {
14+
partitions {
15+
compatible = "fixed-partitions";
16+
#address-cells = <1>;
17+
#size-cells = <1>;
2618

27-
led0_green: led_0 {
28-
gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
29-
label = "Green LED 0";
19+
/* MCUboot placed after Nordic MBR.
20+
* The size of this partition ensures that MCUBoot can
21+
* be built with CDC ACM support and w/o optimizations.
22+
*/
23+
boot_partition: partition@1000 {
24+
label = "mcuboot";
25+
reg = <0x00001000 0x0000f000>;
3026
};
3127

32-
led1_red: led_1 {
33-
gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
34-
label = "Red LED 1";
28+
slot0_partition: partition@10000 {
29+
label = "image-0";
30+
reg = <0x00010000 0x00066000>;
3531
};
3632

37-
led1_green: led_2 {
38-
gpios = <&gpio1 9 GPIO_ACTIVE_LOW>;
39-
label = "Green LED 1";
33+
slot1_partition: partition@76000 {
34+
label = "image-1";
35+
reg = <0x00076000 0x00066000>;
4036
};
4137

42-
led1_blue: led_3 {
43-
gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
44-
label = "Blue LED 1";
38+
storage_partition: partition@dc000 {
39+
label = "storage";
40+
reg = <0x000dc000 0x00004000>;
4541
};
46-
};
47-
48-
pwmleds {
49-
compatible = "pwm-leds";
5042

51-
red_pwm_led: pwm_led_0 {
52-
pwms = <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
53-
};
54-
55-
green_pwm_led: pwm_led_1 {
56-
pwms = <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
57-
};
58-
59-
blue_pwm_led: pwm_led_2 {
60-
pwms = <&pwm0 2 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
61-
};
62-
};
63-
64-
buttons {
65-
compatible = "gpio-keys";
66-
67-
button0: button_0 {
68-
gpios = <&gpio1 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
69-
label = "Push button switch 0";
70-
zephyr,code = <INPUT_KEY_0>;
71-
};
43+
/* Onboard USB bootloader <0xe0000 0x1c000>
44+
*
45+
* In addition, the last and second last flash pages
46+
* are used by the onboard USB bootloader and MBR to store
47+
* settings.
48+
*/
7249
};
73-
74-
/* These aliases are provided for compatibility with samples */
75-
aliases {
76-
sw0 = &button0;
77-
led0 = &led0_green;
78-
led1 = &led1_red;
79-
led2 = &led1_green;
80-
led3 = &led1_blue;
81-
led0-green = &led0_green;
82-
led1-red = &led1_red;
83-
led1-green = &led1_green;
84-
led1-blue = &led1_blue;
85-
pwm-led0 = &red_pwm_led;
86-
pwm-led1 = &green_pwm_led;
87-
pwm-led2 = &blue_pwm_led;
88-
red-pwm-led = &red_pwm_led;
89-
green-pwm-led = &green_pwm_led;
90-
blue-pwm-led = &blue_pwm_led;
91-
mcuboot-button0 = &button0;
92-
mcuboot-led0 = &led0_green;
93-
watchdog0 = &wdt0;
94-
};
95-
};
96-
97-
&reg0 {
98-
status = "okay";
99-
};
100-
101-
&reg1 {
102-
regulator-initial-mode = <NRF5X_REG_MODE_DCDC>;
103-
};
104-
105-
&adc {
106-
status = "okay";
107-
};
108-
109-
&gpiote {
110-
status = "okay";
111-
};
112-
113-
&uicr {
114-
nfct-pins-as-gpios;
115-
gpio-as-nreset;
11650
};
117-
118-
&gpio0 {
119-
status = "okay";
120-
};
121-
122-
&gpio1 {
123-
status = "okay";
124-
};
125-
126-
&uart0 {
127-
compatible = "nordic,nrf-uarte";
128-
status = "okay";
129-
current-speed = <115200>;
130-
pinctrl-0 = <&uart0_default>;
131-
pinctrl-1 = <&uart0_sleep>;
132-
pinctrl-names = "default", "sleep";
133-
};
134-
135-
&i2c0 {
136-
compatible = "nordic,nrf-twi";
137-
status = "okay";
138-
pinctrl-0 = <&i2c0_default>;
139-
pinctrl-1 = <&i2c0_sleep>;
140-
pinctrl-names = "default", "sleep";
141-
};
142-
143-
&i2c1 {
144-
compatible = "nordic,nrf-twi";
145-
/* Cannot be used together with spi1. */
146-
/* status = "okay"; */
147-
pinctrl-0 = <&i2c1_default>;
148-
pinctrl-1 = <&i2c1_sleep>;
149-
pinctrl-names = "default", "sleep";
150-
};
151-
152-
&pwm0 {
153-
status = "okay";
154-
pinctrl-0 = <&pwm0_default>;
155-
pinctrl-1 = <&pwm0_sleep>;
156-
pinctrl-names = "default", "sleep";
157-
};
158-
159-
/*
160-
* By default, not adding all available SPI instances (spi2, spi3) due to
161-
* limited GPIOs available on dongle board.
162-
*/
163-
&spi0 {
164-
compatible = "nordic,nrf-spi";
165-
/* Cannot be used together with i2c0. */
166-
/* status = "okay"; */
167-
pinctrl-0 = <&spi0_default>;
168-
pinctrl-1 = <&spi0_sleep>;
169-
pinctrl-names = "default", "sleep";
170-
};
171-
172-
&spi1 {
173-
compatible = "nordic,nrf-spi";
174-
status = "okay";
175-
pinctrl-0 = <&spi1_default>;
176-
pinctrl-1 = <&spi1_sleep>;
177-
pinctrl-names = "default", "sleep";
178-
};
179-
180-
&ieee802154 {
181-
status = "okay";
182-
};
183-
184-
/* Include flash partition table.
185-
* Two partition tables are available:
186-
* fstab-stock -compatible with Nordic nRF5 bootloader, default
187-
* fstab-debugger -to use an external debugger, w/o the nRF5 bootloader
188-
*/
189-
#include "fstab-stock.dtsi"
190-
191-
zephyr_udc0: &usbd {
192-
compatible = "nordic,nrf-usbd";
193-
status = "okay";
194-
};
195-
196-
#include <../boards/common/usb/cdc_acm_serial.dtsi>

boards/nordic/nrf52840dongle/fstab-debugger.dtsi renamed to boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare.dts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
/*
2-
* Copyright (c) 2019 Nordic Semiconductor ASA
2+
* Copyright (c) 2018-2023 Nordic Semiconductor ASA
3+
* Copyright (c) 2017 Linaro Limited
34
*
45
* SPDX-License-Identifier: Apache-2.0
56
*/
67

7-
/* Flash partition table without support for Nordic nRF5 bootloader */
8+
/dts-v1/;
9+
#include "nrf52840dongle_nrf52840_common.dtsi"
10+
11+
/* Flash partition table without support for the onboard USB bootloader */
812

913
&flash0 {
1014
partitions {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
identifier: nrf52840dongle/nrf52840/bare
2+
name: nRF52840-Dongle-NRF52840-bare
3+
type: mcu
4+
arch: arm
5+
ram: 256
6+
flash: 1024
7+
toolchain:
8+
- zephyr
9+
- gnuarmemb
10+
supported:
11+
- adc
12+
- usb_device
13+
- ble
14+
- pwm
15+
- spi
16+
- watchdog
17+
- counter
18+
- netif:openthread
19+
- gpio
20+
vendor: nordic
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
# Enable MPU
4+
CONFIG_ARM_MPU=y
5+
6+
# Enable hardware stack protection
7+
CONFIG_HW_STACK_PROTECTION=y
8+
9+
# enable GPIO
10+
CONFIG_GPIO=y
11+
12+
# Board Kconfig.defconfig enables USB CDC ACM and should disable USB remote
13+
# wakeup by default. It needs to be disabled here, because the USB nrfx
14+
# driver always overwrites option from Kconfig mentioned above with the
15+
# imply from CONFIG_USB_NRFX.
16+
CONFIG_USB_DEVICE_REMOTE_WAKEUP=n

0 commit comments

Comments
 (0)