In this exercise, we will create a custom board definition from scratch for a board that is based on a single-core Nordic SoC that does not have TF-M support. We will use the nRF52833 SoC as an example, but the instructions will be very similar to other SoCs.
The hardware that we will be developing the custom board for is based on the nRF52833 DK. We will assume that the new board will have almost the exact schematics except that it doesn’t have an Arduino shield. So it’s more like a small-factor version of the Development Kit. Therefore, we will use the Hardware Schematics of the DK as our starting point.
If you are using a different development kit for this course. Use the hardware schematic of your board as a starting point. They can be found here: nRF52840 DK, nRF52 DK.
The schematic below was obtained from the nRF52833 DK schematics.
Exercise steps
Important
This exercise assumes you have installed the latest nRF Connect for the VS Code extension (>= Version 2024.2.214). If you are using an old nRF Connect for VS Code extension (< Version 2024.2.214), make sure to update it to the latest version.
1. Create a new directory on your root directory and name it my_boards.
In this directory (for example C:\my_boards), we will store our custom board definitions.
2. Open VS Code, and from the Welcome page, click on Create a new board.
You will be prompted with five steps:
Provide a human-readable name for your board. You need to follow the instructions provided in Creating board files when naming your board. We will name our board DevAcademy nRF52833
The board ID will be automatically generated from the human readable name. We can change it if we want to . However, we will leave it as is devacademy_nrf52833
Select the SoC used by your custom board. This is a very critical step, and we need to select the exact SoC number (nRF52840, nRF52832, etc.) and variant used (QIAA , CIAA, etc.) on the custom board. We will be using the nRF52833 QIAA.
Set the root directory where your board will be defined. We will pass the directory we defined in step 1: C:\my_boards
Provide your company name. In our case, we will pass “Nordic Semiconductor” for the exercise.
3. Point the build system to the custom board root directory.
By default, the build system in nRF Connect goes to specific folders to look for board definitions. Namely, <SDK Installation Path>/zephyr/boards/arm/ and <SDK Installation Path>/nrf/boards/arm/.
We need to tell the build system to look at the directory we created in Step 1. To do that, we have three different options (Option 3 is used for this exercise ):
Option 1: Inside the application CMake file, CMakeLists.txt.
This is done by defining the BOARD_ROOTbefore pulling in the Zephyr boilerplate with find_package(Zephyr ...). When specifying BOARD_ROOT in a CMakeLists.txt, then an absolute path must be provided, for example list(APPEND BOARD_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/<extra-board-root>). When using -DBOARD_ROOT=<board-root> both absolute and relative paths can be used. Relative paths are treated relatively to the application directory.
Option 2: At build time.
We can build an application targeting a custom board by specifying the location of the custom board information with the -DBOARD_ROOT parameter to the build system. This can be done both using CLI (west) or using the Add build configuration GUI. Ex: Using CLI
Copy
west build -b <board name> -- -DBOARD_ROOT=<path to boards>
When using -DBOARD_ROOT=<board-root> both absolute and relative paths can be used. Relative paths are treated relatively to the application directory.
Option 3: From within VS Code.
This is the method that we will use in this exercise. Navigate to the Settings of nRF Connect Extension. This can be done by navigating to File -> Preferences -> Settings -> Extensions -> nRF Connect -> Board Roots, then add the directory defined in Step 1.
4. Open the custom board definition folder in VS Code.
In VS Code, head to File->Open Folder, then navigate to the custom board definition folder we created in the previous steps then select the folder of the newly created board. This will open the board’s files in the Explorer of VS Code.
5. Open devacademy_nrf52833_defconfig.
This file is a Kconfig fragment that is merged as-is into the final build of any application built for the specified board. In addition to the default Kconfig symbols in this file, we need to add any Kconfig symbols we want to be enabled for any application built for our board. In the case of the DevAcademy nRF52833, since the schematic contains an interface MCU with RTT support and USB/Serial converter, we want to add UART, RTT. We will also enable GPIO support.
Therefore, append the following to the end of the file
We will enable the System on Chip Voltage DC/DC regulator since the schematic of the custom board contains the needed components to support this mode.
7. Create a new application based on the Hello World sample.
Create an application based on the Hello World sample, save it somewhere on your disk (do not save it in the boards directory). Then build the application for the new custom board, as shown in the screenshot below. The sample will not be runnable at the beginning. The purpose here is to build the sample so that the DeviceTree Visual Editor will be able to parse the project.
8. Go to the DeviceTree Visual Editor.
Once the build is complete, press on the DeviceTree in the ACTIONS Panel.
The DeviceTree Visual Editor provides an overview of the devicetree context and a visual representation of the devicetree structure of your project. We will use it along with the devicetree text editor to seamlessly populate the devicetree files.
Notice that it used the default devacademy_nrf52833.dts as a starting point. It also pulls in the SoC devicetree, since it’s included in the devacademy_nrf52833.dts. The SoC devicetree has some nodes enabled, but the majority are disabled (For example, the GPIOs are disabled). We will use the features provided both in the DeviceTree Visual Editor and the Devicetree text editor to help us populate the content of the devacademy_nrf52833.dts file.
8.1 Enable GPIOs and GPIOTE.
The first thing we need to enable in the devicetree is the GPIOs and GPIOTE. In the NODES View, Expand soc and scroll down to gpio0, gpio1, and gpiote. Then, tick the boxes next to it. Depending on the soc used, there could be more or less GPIO/GPIOTE ports.
Ticking the box next to their entries in the GUI (DeviceTree Visual Editor) will write the following into the devacademy_nrf52833.dts file.
Copy
&gpio0 { status = "okay";};&gpio1 { status = "okay";};&gpiote { status = "okay";};
You should also notice that the GPIOs and Pins are now visible on the SoC. This can be done by switching to the Pins view in the bottom right corner.
Switch to the text editing mode by pressing on the below symbol in the top right corner. Pressing on the Open Text Editor button on the upper right corner will display the devicetree file in text format.
You could also have the windows next to each other, by dragging the title of the opened file to the right of the screen, as shown below. Doing this will help understand what is happening on the deivcetree files when using the Devicetree Visual Editor.
Switch back to the Peripherals view by clicking on the icon below in the bottom right corner
8.2 Define LEDs and Buttons
The Buttons and LEDs on the schematics are connected to the DevAcademy nRF52833 custom board as shown below:
Let’s convert this into Devicetree syntax using the GUI (DeviceTree Visual Editor).
8.2.1 Adding LEDs
The GPIOs connected to the four LEDs are P0.13, P0.14 , P0.15, and P0.16, and the LEDs are connected to VDD on the other end. Therefore, we need to configure the GPIOs as active low. We will use both the visual editor and text editor to do that, as shown below:
8.2.1.1 Add an LED
Click on the + sign. This will prompt you with the add node windows.
Select I/O pins , LED, and name the new node as led_0. Select the pin to which the LED is connected to. The first LED is connected to P0.13 in the schematics. This is demonstrated in the video below:
This will create a parent node called leds of compatible gpio-leds and create a child node called led_0. In the next step, we will configure the led_0 node.
8.2.1.2 Configure the led_0 node
Make sure you are in the Peripherals View, and the led_0 node is selected. Add a label to the led_0 node . Name the node label led0 . Note that this is a node label and not a label property( As covered in the nRF Connect SDK Fundamentals course ). Then configure the node properties to match the hardware schematics ( In the case of the DevAcademy nRF52833, change it to active low ), and finally, change the label property to “Green LED 0”.
8.2.1.3 Add the remaining LED nodes
Add the remaining LED nodes and set the configurations of the nodes to match the schematics as shown in the video below. Since we have already set the configration for one LED and the rest are to some extent similar ( except they have different pin assignments and should have different human-readable labels), we will use the text editor to add them. Notice how the GUI has updated accordingly when changes are done directly to the devicetree files. This is demonstrated in the video below:
8.2.2 Adding buttons
The GPIOs connected to the four buttons are P0.11, P0.12, P0.24, and P0.25, and the buttons are connected to the ground on the other end. Therefore, we must pull up these GPIOs and make them active low. This is done as illustrated below:
8.2.2.1 Add a button and configure it.
Same as we did with the LED. Click on the + sign on nodes. This will prompt you with the add node window. Select Select I/O pins , Button, name the button node button_0 . Select the pin to which the Button is connected to. The first Button is connected to P0.11 in the schematics. This will create a parent node called buttons of compatible gpio-keys and create a child node called button_0 .
After that, Add a label to the button_0node . Name the label button0 . Then, configure the node properties to match the hardware schematic, and finally, change the label property to “Push button switch 0”.
8.2.2.2 Add the remaining Button nodes
Add the remaining nodes and set the configurations of the nodes to match the schematics as shown in the video below:
8.3 Adding the Pinctrl file
The pin mappings of the various nodes (except for LEDs and buttons) must be done in a separate file called the pinctrl file(<board_name>-pinctrl.dtsi). This file must be created manually and included in the board devicetree file (<board_name>.dts)
8.3.1 Create a pinctrl file
Name the pinctrl file: devacademy_nrf52833-pinctrl.dtsi .This file, of course, must reside in the custom board directory. Inside the pinctrl file, you always need to reference the pinctrl node as shown below:
The chosen node’s properties are used to configure system- or subsystem-wide values. So, these values are referenced by the different software modules you configured, usually through the DT_CHOSEN() macro. See the example of the UART Console and the UART MCUmanager and the shell UART backedend.
Note that there are other “chosen” preoperties related to Bluetooth LE boards. Namely: zephyr,bt-mon-uart and zephyr,bt-c2h-uart if you plan to use the Host monitor or HCI over UART (Expose the Bluetooth LE controller to external MCU), respectively.
8.5 Adding I2C, SPI, and PWM Peripherals
8.5.1 I2C
The P0.26 and P0.27 GPIOs are used for I2C peripheral. On the nRF52833, there are two I2C peripherals , we will enable i2c0 and connect it to these two pins.
8.5.1.1 Add the following in devacademy_nrf52833-pinctrl.dtsi
We will use the dedicated SPI peripheral (spi1) on the nRF52833 SoC. Note that spi0 is shared with i2c0 as a serial unit so we can use only one at a time.
8.5.2.1 Add the following in devacademy_nrf52833-pinctrl.dtsi
8.6 The samples in nRF Connect SDK and Zephyr OS uses fixed aliases for devicetree nodes. Therefore, to ensure that samples find these aliases, it’s crucial to add aliases in the board devicetree file . Add the following inside the / root node.
8.7 If you plan to use other peripherals on your device on all applications built for this board, for example, the USB device peripheral. You will also need to enable its node in the board devicetree.
Testing
9. Build and flash the application to your board.
In this part, we will build and flash different samples on the custom board devacademy_nrf52833 for testing purposes. You can see the custom board from the Add Build Configuration Window, as shown below.
9.1 Test Serial Console/UART.
Build the “Hello World” sample for the target devacademy_nrf52833 and flash it to your board. You should see the following output.
With this, we have validated that the serial Console / UART is working properly.
9.2 Test LEDs and buttons.
Build the “Button” Sample for the target devacademy_nrf52833 and flash it to your board . You should see that everytime you press Button 1 on the DK , LED 1 is turned on. Also you should see the following output on the terminal.
*** Booting nRF Connect SDK 2.6.1-3758bcbfa5cd ***Set up button at gpio@50000000 pin 11Set up LED at gpio@50000000 pin 13Press the buttonButton pressed at 219119Button pressed at 242602Button pressed at 269271Button pressed at 273719
Terminal
9.3 Test PWM.
Build the “PWM LED ” Sample for the target devacademy_nrf52833 and flash it to your board. You should see that LED 1 is turned on and off and then gradually start fading. Also, you should see the following output on the terminal.
The radio node for the Bluetooth LE is already enabled “status = "okay" in the SoC devicetree file. Therefore you don’t need to do any changes in the board devicetree file. However, if you plan to use the IEEE 802.15.4 radio (for Zigbee or Thread), you will need to enable the ieee802154 and set the chosen property zephyr,ieee802154 = &ieee802154 in the board devicetree file.
Build the “BLE UART service ” or the “BLE LED Button Service” sample for the target devacademy_nrf52833 and flash it to your board and test the sample as specified in the document for the selected sample.
9.5 Test I2C and SPI.
To test I2C or SPI you would need external components. You could follow the instructions in these lessons for I2C and SPI.
In this Privacy Policy you will find information on Nordic Semiconductor ASA (“Nordic Semiconductor”) processes your personal data when you use the Nordic Developer Academy.
References to “we” and “us” in this document refers to Nordic Semiconductor.
2. Our processing of personal data when you use the Nordic Developer Academy
2.1 Nordic Developer Academy
Nordic Semiconductor processes personal data in order to provide you with the features and functionality of the Nordic Developer Academy. Creating a user account is optional, but required if you want to track you progress and view your completed courses and obtained certificates. If you choose to create a user account, we will process the following categories of personal data:
Email
Name
Password (encrypted)
Course progression (e.g. which course you have completely or partly completed)
Certificate information, which consists of name of completed course and the validity of the certificate
Course results
During your use of the Nordic Developer Academy, you may also be asked if you want to provide feedback. If you choose to respond to any such surveys, we will also process the personal data in your responses in that survey.
The legal basis for this processing is GDPR article 6 (1) b. The processing is necessary for Nordic Semiconductor to provide the Nordic Developer Academy under the Terms of Service.
2.2 Analytics
If you consent to analytics, Nordic Semiconductor will use Google Analytics to obtain statistics about how the Nordic Developer Academy is used. This includes collecting information on for example what pages are viewed, the duration of the visit, the way in which the pages are maneuvered, what links are clicked, technical information about your equipment. The information is used to learn how Nordic Developer Academy is used and how the user experience can be further developed.
2.2 Newsletter
You can consent to receive newsletters from Nordic from within the Nordic Developer Academy. How your personal data is processed when you sign up for our newsletters is described in the Nordic Semiconductor Privacy Policy.
3. Retention period
We will store your personal data for as long you use the Nordic Developer Academy. If our systems register that you have not used your account for 36 months, your account will be deleted.
4. Additional information
Additional information on how we process personal data can be found in the Nordic Semiconductor Privacy Policy and Cookie Policy.
Nordic Developer Academy Terms of Service
1. Introduction
These terms and conditions (“Terms of Use”) apply to the use of the Nordic Developer Academy, provided by Nordic Semiconductor ASA, org. nr. 966 011 726, a public limited liability company registered in Norway (“Nordic Semiconductor”).
Nordic Developer Academy allows the user to take technical courses related to Nordic Semiconductor products, software and services, and obtain a certificate certifying completion of these courses. By completing the registration process for the Nordic Developer Academy, you are agreeing to be bound by these Terms of Use.
These Terms of Use are applicable as long as you have a user account giving you access to Nordic Developer Academy.
2. Access to and use of Nordic Developer Academy
Upon acceptance of these Terms of Use you are granted a non-exclusive right of access to, and use of Nordic Developer Academy, as it is provided to you at any time. Nordic Semiconductor provides Nordic Developer Academy to you free of charge, subject to the provisions of these Terms of Use and the Nordic Developer Academy Privacy Policy.
To access select features of Nordic Developer Academy, you need to create a user account. You are solely responsible for the security associated with your user account, including always keeping your login details safe.
You will able to receive an electronic certificate from Nordic Developer Academy upon completion of courses. By issuing you such a certificate, Nordic Semiconductor certifies that you have completed the applicable course, but does not provide any further warrants or endorsements for any particular skills or professional qualifications.
Nordic Semiconductor will continuously develop Nordic Developer Academy with new features and functionality, but reserves the right to remove or alter any existing functions without notice.
3. Acceptable use
You undertake that you will use Nordic Developer Academy in accordance with applicable law and regulations, and in accordance with these Terms of Use. You must not modify, adapt, or hack Nordic Developer Academy or modify another website so as to falsely imply that it is associated with Nordic Developer Academy, Nordic Semiconductor, or any other Nordic Semiconductor product, software or service.
You agree not to reproduce, duplicate, copy, sell, resell or in any other way exploit any portion of Nordic Developer Academy, use of Nordic Developer Academy, or access to Nordic Developer Academy without the express written permission by Nordic Semiconductor. You must not upload, post, host, or transmit unsolicited email, SMS, or \”spam\” messages.
You are responsible for ensuring that the information you post and the content you share does not;
contain false, misleading or otherwise erroneous information
infringe someone else’s copyrights or other intellectual property rights
contain sensitive personal data or
contain information that might be received as offensive or insulting.
Such information may be removed without prior notice.
Nordic Semiconductor reserves the right to at any time determine whether a use of Nordic Developer Academy is in violation of its requirements for acceptable use.
Violation of the at any time applicable requirements for acceptable use may result in termination of your account. We will take reasonable steps to notify you and state the reason for termination in such cases.
4. Routines for planned maintenance
Certain types of maintenance may imply a stop or reduction in availability of Nordic Developer Academy. Nordic Semiconductor does not warrant any level of service availability but will provide its best effort to limit the impact of any planned maintenance on the availability of Nordic Developer Academy.
5. Intellectual property rights
Nordic Semiconductor retains all rights to all elements of Nordic Developer Academy. This includes, but is not limited to, the concept, design, trademarks, know-how, trade secrets, copyrights and all other intellectual property rights.
Nordic Semiconductor receives all rights to all content uploaded or created in Nordic Developer Academy. You do not receive any license or usage rights to Nordic Developer Academy beyond what is explicitly stated in this Agreement.
6. Liability and damages
Nothing within these Terms of Use is intended to limit your statutory data privacy rights as a data subject, as described in the Nordic Developer Academy Privacy Policy. You acknowledge that errors might occur from time to time and waive any right to claim for compensation as a result of errors in Nordic Developer Academy. When an error occurs, you shall notify Nordic Semiconductor of the error and provide a description of the error situation.
You agree to indemnify Nordic Semiconductor for any loss, including indirect loss, arising out of or in connection with your use of Nordic Developer Academy or violations of these Terms of Use. Nordic Semiconductor shall not be held liable for, and does not warrant that (i) Nordic Developer Academy will meet your specific requirements, (ii) Nordic Developer Academy will be uninterrupted, timely, secure, or error-free, (iii) the results that may be obtained from the use of Nordic Developer Academy will be accurate or reliable, (iv) the quality of any products, services, information, or other material purchased or obtained by you through Nordic Developer Academy will meet your expectations, or that (v) any errors in Nordic Developer Academy will be corrected.
You accept that this is a service provided to you without any payment and hence you accept that Nordic Semiconductor will not be held responsible, or liable, for any breaches of these Terms of Use or any loss connected to your use of Nordic Developer Academy. Unless otherwise follows from mandatory law, Nordic Semiconductor will not accept any such responsibility or liability.
7. Change of terms
Nordic Semiconductor may update and change the Terms of Use from time to time. Nordic Semiconductor will seek to notify you about significant changes before such changes come into force and give you a possibility to evaluate the effects of proposed changes. Continued use of Nordic Developer Academy after any such changes shall constitute your acceptance of such changes. You can review the current version of the Terms of Use at any time at https://academy.nordicsemi.com/terms-of-service/
8. Transfer of rights
Nordic Semiconductor is entitled to transfer its rights and obligation pursuant to these Terms of Use to a third party as part of a merger or acquisition process, or as a result of other organizational changes.
9. Third Party Services
To the extent Nordic Developer Academy facilitates access to services provided by a third party, you agree to comply with the terms governing such third party services. Nordic Semiconductor shall not be held liable for any errors, omissions, inaccuracies, etc. related to such third party services.
10. Dispute resolution
The Terms of Use and any other legally binding agreement between yourself and Nordic Semiconductor shall be subject to Norwegian law and Norwegian courts’ exclusive jurisdiction.