Feedback
Feedback

If you are having issues with the exercises, please create a ticket on DevZone: devzone.nordicsemi.com
Click or drag files to this area to upload. You can upload up to 2 files.

Exercise 3 – Debugging the devicetree

In this exercise, the goal is to get the application building after getting an error related to the devicetree.

Exercise steps

Open the code base of the exercise by navigating to Create a new application in the nRF Connect for VS Code extension, select Copy a sample, and search for Lesson 2 – Exercise 3 . This is a simple application that prints a message every time button 1 is pressed.

Alternatively, in the GitHub repository for this course, go to the base code for this exercise, found in lesson2/inter_less2_exer3.

1. Build the application.

This build should fail and give an error similar to below:

2. Find the ID in the error message.

The build log shows we have a device error seen by __device_dts_ord_11
The “11” Node identifier. This node identifier can say something about the devicetree instance that is at fault. When you have the node identifier, you can look it up in <build>/zephyr/include/generated/devicetree_generated.h and find the ID found in the error message.

3. Investigate the reason for the build failure.

In the devicetree_generated.h we can see the following:

Our error message said the error was related to device id 11. In this case we can see it the /soc/gpio@50000000. The next step then should be to look at this module and ask the following questions:

  1. Is the device enabled?
    In order for the device to be enabled, the property “status” shall be equal to “okay” and all required properties should be populated.
    This can be verified by looking at the compiled devicetree found in <build>/zephyr/zephyr.dts
  2. Check if the device driver is enabled on Kconfig. In this case it would be to verify is CONFIG_GPIO=y

4. Fix the issue by enabling gpio0.

By now, the error should be clear. As we can see in zephyr.dts, the gpio0 is disabled

And in the overlay for the selected device, we can see the following:

To fix the application, enable gpio0 by changing the overlay file of your build target to the following

5. Pristine build the application.

Do a pristine build since we have made changes to our overlay. The application should now build.

The devicetree can be overwhelming when moving from a bare metal environment but should give some clues on how to solve potential errors you might face during development.

Register an account
Already have an account? Log in
(All fields are required unless specified optional)

  • 8 or more characters
  • Upper and lower case letters
  • At least one number or special character

Forgot your password?
Enter the email associated with your account, and we will send you a link to reset your password.