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

peripheral_uart\boards\arm


Step 2

I copied the nRF52840 DK board folder from:

ncs\v2.4.1\zephyr\boards\arm\nrf52840dk_nrf52840

to:

peripheral_uart\boards\arm\

and renamed the folder:

peripheral_uart\boards\arm\ customer1_nrf52840


Step 3

I renamed filenames in this new folder, from:

nrf52840dk_nrf52840.dts
nrf52840dk_nrf52840.yaml
nrf52840dk_nrf52840_defconfig
nrf52840dk_nrf52840-pinctrl.dtsi


to:
customer1_nrf52840.dts
customer1_nrf52840.yaml
customer1_nrf52840_defconfig
customer1_nrf52840-pinctrl.dtsi

Step 4

I renamed all the BOARD_NRF52840DK_NRF52840 to BOARD_CUSTOMER1_NRF52840
in files:

Kconfig
Kconfig.defconfig
Kconfig.board

And in Kconfig.defconfig, renamed Boolean:

default "nrf52840dk_nrf52840"
default "customer1_nrf52840"

And in Kconfig.board, renamed Boolean:

bool "nRF52840 DK NRF52840"
bool "customer1 NRF52840"

Step 5

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

#include "nrf52840dk_nrf52840-pinctrl.dtsi"

To:

#include "customer1_nrf52840-pinctrl.dtsi"


And the model/compatible, from:

model = "Nordic nRF52840 DK NRF52840";
compatible = "nordic,nrf52840-dk-nrf52840";

To:
model = "Nordic customer1 NRF52840";
compatible = "nordic,customer1-nrf52840";

Step 6

In customer1_nrf52840_defconfig, I modified the board config include from:

CONFIG_BOARD_NRF52840DK_NRF52840=y

To:
CONFIG_BOARD_CUSTOMER1_NRF52840=y

Step 7

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

identifier: nrf52840dk_nrf52840
name: nRF52840-DK-NRF52840

to:
identifier: customer1_nrf52840
name: customer1-DK-NRF52840

Step 8

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

list(APPEND BOARD_ROOT ${CMAKE_CURRENT_SOURCE_DIR})

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

Related