Skip to content

Commit 190defd

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 80b3635 commit 190defd

12 files changed

+270
-211
lines changed

boards/nordic/nrf52840dongle/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ if BOARD_NRF52840DONGLE
88
config BOARD_HAS_NRF5_BOOTLOADER
99
bool "Board has nRF5 bootloader"
1010
default y
11+
depends on !BOARD_NRF52840DONGLE_NRF52840_BARE
1112
help
1213
If selected, applications are linked so that they can be loaded by Nordic
1314
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: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ name.
243243

244244
You can then sign and flash it using the steps above.
245245

246+
.. _zephyr_board_nrf52840dongle_flashing-option-3:
247+
246248
Option 3: Using an External Debug Probe
247249
---------------------------------------
248250

@@ -254,13 +256,9 @@ For Segger J-Link debug probes, follow the instructions in the
254256
:ref:`nordic_segger` page to install and configure all the necessary
255257
software. Further information can be found in :ref:`nordic_segger_flashing`.
256258

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.
259+
Use the ``nrf52840dongle/nrf52840/bare`` board variant to build your application.
260+
This variant uses a modified partition table, that does not reserve space for
261+
the onboard USB bootloader.
264262

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

270268
.. zephyr-app-commands::
271269
:zephyr-app: samples/basic/blinky
272-
:board: nrf52840dongle/nrf52840
270+
:board: nrf52840dongle/nrf52840/bare
273271
:goals: build flash
274272

275273
Observe the LED on the board blinking.

boards/nordic/nrf52840dongle/fstab-debugger.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
/* Flash partition table without support for Nordic nRF5 bootloader */
7+
/* Flash partition table without support for Nordic onboard USB bootloader */
88

99
&flash0 {
1010
partitions {

boards/nordic/nrf52840dongle/fstab-stock.dtsi

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,21 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
/* Flash partition table compatible with Nordic nRF5 bootloader */
7+
/* Flash partition table compatible with Nordic onboard USB bootloader */
88

99
&flash0 {
1010
partitions {
1111
compatible = "fixed-partitions";
1212
#address-cells = <1>;
1313
#size-cells = <1>;
1414

15-
/* MCUboot placed after Nordic MBR (this is set with the FLASH_LOAD_OFFSET
16-
* Kconfig value when BOARD_HAS_NRF5_BOOTLOADER is enabled), otherwise MCUboot
17-
* will be placed at 0x0. The size of this partition ensures that MCUBoot can
15+
/* MCUboot placed after Nordic MBR.
16+
* The size of this partition ensures that MCUBoot can
1817
* be built with CDC ACM support and w/o optimizations.
1918
*/
20-
boot_partition: partition@0 {
19+
boot_partition: partition@1000 {
2120
label = "mcuboot";
22-
reg = <0x00000000 0x00010000>;
21+
reg = <0x00001000 0x0000f000>;
2322
};
2423

2524
slot0_partition: partition@10000 {
@@ -37,10 +36,11 @@
3736
reg = <0x000dc000 0x00004000>;
3837
};
3938

40-
/* Nordic nRF5 bootloader <0xe0000 0x1c000>
39+
/* Nordic onboard USB bootloader <0xe0000 0x1c000>
4140
*
4241
* In addition, the last and second last flash pages
43-
* are used by the nRF5 bootloader and MBR to store settings.
42+
* are used by the onboard USB bootloader and MBR to store
43+
* settings.
4444
*/
4545
};
4646
};

boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts

Lines changed: 3 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -6,191 +6,9 @@
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";
16-
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";
26-
27-
led0_green: led_0 {
28-
gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
29-
label = "Green LED 0";
30-
};
31-
32-
led1_red: led_1 {
33-
gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
34-
label = "Red LED 1";
35-
};
36-
37-
led1_green: led_2 {
38-
gpios = <&gpio1 9 GPIO_ACTIVE_LOW>;
39-
label = "Green LED 1";
40-
};
41-
42-
led1_blue: led_3 {
43-
gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
44-
label = "Blue LED 1";
45-
};
46-
};
47-
48-
pwmleds {
49-
compatible = "pwm-leds";
50-
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-
};
72-
};
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;
116-
};
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
11+
/* Include flash partition table that is compatible with Nordic onboard USB
12+
* bootloader.
18813
*/
18914
#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>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2018-2023 Nordic Semiconductor ASA
3+
* Copyright (c) 2017 Linaro Limited
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
/dts-v1/;
9+
#include "nrf52840dongle_nrf52840_common.dtsi"
10+
11+
/* Include flash partition table that is not compatible with Nordic nRF5
12+
* bootloader. Use an external debugger to program the device.
13+
*/
14+
#include "fstab-debugger.dtsi"
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)