Modifying the device tree for a custom board

Hi

I was developing an application on an nRF52840 DK, using nRF Connect SDK v2.4.1.
I now want to modify this project to run on a custom nRF52840 board.

To learn how to do this, I started with a new Nordic sample: peripheral uart, and I built this (successfully) for the nRF52840 DK.

Now, to create a build for a custom nRF52840 board, instead of the nRF52840 DK, I performed the following steps (adapting the steps described here).

Step 1

I created an 'arm' folder the local board directory under the working project

Fullscreen
1
peripheral_uart\boards\arm
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


Step 2

I copied the nRF52840 DK board folder from:

Fullscreen
1
ncs\v2.4.1\zephyr\boards\arm\nrf52840dk_nrf52840
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

to:

Fullscreen
1
peripheral_uart\boards\arm\
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

and renamed the folder:

Fullscreen
1
peripheral_uart\boards\arm\ customer1_nrf52840
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


Step 3

I renamed filenames in this new folder, from:

Fullscreen
1
2
3
4
nrf52840dk_nrf52840.dts
nrf52840dk_nrf52840.yaml
nrf52840dk_nrf52840_defconfig
nrf52840dk_nrf52840-pinctrl.dtsi
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


to:
Fullscreen
1
2
3
4
customer1_nrf52840.dts
customer1_nrf52840.yaml
customer1_nrf52840_defconfig
customer1_nrf52840-pinctrl.dtsi
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Step 4

I renamed all the BOARD_NRF52840DK_NRF52840 to BOARD_CUSTOMER1_NRF52840
in files:

Fullscreen
1
2
3
Kconfig
Kconfig.defconfig
Kconfig.board
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

And in Kconfig.defconfig, renamed Boolean:

Fullscreen
1
2
default "nrf52840dk_nrf52840"
default "customer1_nrf52840"
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

And in Kconfig.board, renamed Boolean:

Fullscreen
1
2
bool "nRF52840 DK NRF52840"
bool "customer1 NRF52840"
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Step 5

In customer1_nrf52840.dts, I modified the dtsi include from:

Fullscreen
1
#include "nrf52840dk_nrf52840-pinctrl.dtsi"
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

To:

Fullscreen
1
#include "customer1_nrf52840-pinctrl.dtsi"
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


And the model/compatible, from:

Fullscreen
1
2
model = "Nordic nRF52840 DK NRF52840";
compatible = "nordic,nrf52840-dk-nrf52840";
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

To:
Fullscreen
1
2
model = "Nordic customer1 NRF52840";
compatible = "nordic,customer1-nrf52840";
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Step 6

In customer1_nrf52840_defconfig, I modified the board config include from:

Fullscreen
1
CONFIG_BOARD_NRF52840DK_NRF52840=y
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

To:
Fullscreen
1
CONFIG_BOARD_CUSTOMER1_NRF52840=y
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Step 7

In customer1_nrf52840.yaml, modified the identifier and name, from:

Fullscreen
1
2
identifier: nrf52840dk_nrf52840
name: nRF52840-DK-NRF52840
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

to:
Fullscreen
1
2
identifier: customer1_nrf52840
name: customer1-DK-NRF52840
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Step 8

I added the following line in CMakeLists.txt, to add the local board information:

Fullscreen
1
list(APPEND BOARD_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Step 9

I closed VSCode and re-opened it, then defined a new custom build configuration:

Result:

The application builds, using the customer dts and dtsi files.

Question:

Is this the correct way to modify an application to use a custom device?
Did I miss anything?

Regards

Garrett