Implementing 'Developing Bluetooth Low Energy products using nRF Connect' video on nRF5340-DK

I am working from this video:

https://webinars.nordicsemi.com/developing-bluetooth-low-energy-6

Which nRF5340-DK build configuration should I use please?

  • nrff5340dk_nrf5340_cpuapp
  • nrff5340dk_nrf5340_cpuapp_ns
  • nrff5340dk_nrf5340_cpunet

I've downloaded the source files and manually put the folders named 'bluetooth_remote' and 'bluetooth_remote_template' in my macOS workspace folder.

I add the 'bluetooth_remote_template' folder as a new application into VS Code, immediately I'm asked if I want to change from the current v1.9.0 version of the nRF Connect SDK. I assume that I should be working with the latest version, so confirm that I don't want to change. When I then open the project in Explorer and look at main.c I see the following Includes underlined with red squiggles.

main.c

#include <zephyr.h>
#include <logging/log.h>
#include <dk_buttons_and_leds.h>
#include "remote.h"

The same is true for the Includes in remote.c and remote.h:

remote.c
  
#include "remote.h"
    
remote.h
   
#include <zephyr.h>
#include <logging/log.h>
 
What do I need to do to provide the paths to these header files please?

Parents
  • Hi

    From the Terminal log you sent, the projetct actually builds sucessfully, and you should be able to flash it to the device if you want.

    After you do the pristine build and get these errors, try to restart VS Code and see if the errors still persists in the existing project?

    In your settings, I see you use clang as the compiler used for intellij. Try to set the ncs gnuarmemb as this instead.
    It should be located something like. ""/opt/ncs/v1.9.0/toolchain/opt/bin/arm-none-eabi-gcc"

    Does any of these suggestings fix your issue?

    Regards,
    Sigurd Hellesvik

  • Thanks Sigurd, I've done as you suggested and restarted VS Code, an I still get 10 out of 11 errors as it does at least find remote.h header file in the project folder

    How do I set the compiler to arm-none-eabi-gcc instead please? It's located here:

  • Hi

    How does your c_cpp_properties.json look now?

    According to the diagnostics your setup sees "IntelliSense Mode: macos-clang-x64" which is wrong. ("IntelliSense Mode: macos-gcc-arm" is expected) This could be because the file is not opened, the build is not selected, or maybe the intellisense extension was installed or enabled later then our extension. If the latter is true a simple quit and restart would solve the problem.

    Regards,
    Sigurd Hellesvik

  • Hi Sigurd,

    Thanks very much, please see attached text file showing c_app_properties.json both before and after quitting and restarting nRF Connect for Desktop Toolchain Manager and VS Code. As you will see, there is no difference in the file contents.

    {
        "configurations": [
            {
                "name": "Mac",
                "includePath": [
                    "${workspaceFolder}/**"
                ],
                "defines": [],
                "macFrameworkPath": [
                    "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
                ],
                "compilerPath": "/usr/bin/clang",
                "cStandard": "c11",
                "cppStandard": "c++98",
                "intelliSenseMode": "macos-clang-x64",
                "configurationProvider": "ms-vscode.cmake-tools"
            }
        ],
        "version": 4
    }
    
    
    *********** After Quit and Restart nRF Connect Toolchain Manager and VS Code ***********
    
    {
        "configurations": [
            {
                "name": "Mac",
                "includePath": [
                    "${workspaceFolder}/**"
                ],
                "defines": [],
                "macFrameworkPath": [
                    "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
                ],
                "compilerPath": "/usr/bin/clang",
                "cStandard": "c11",
                "cppStandard": "c++98",
                "intelliSenseMode": "macos-clang-x64",
                "configurationProvider": "ms-vscode.cmake-tools"
            }
        ],
        "version": 4
    }
    

  • Is this file settings you have set yourself, or is it automatically created?

    Regards,
    Sigurd Hellesvik

  • Thanks Sigurd, it’s all automatically created, I have not edited any of the filepaths.

  • Hi

    If it is possible, I think the easiest way to fix this issue would be to remove all your VS Code configurations (delete the VS Code config directory), and reinstall VS Code and its extensions.

    I would like to repeat that despite these error messages, your build looks fine, and I think you should be able to use VS code for nRF Connect despite them.

    Regards,
    Sigurd Hellesvik

Reply Children
  • Hi Sigurd,

    Thanks for the suggestion, but I've just done that to resolve another ticket:

    https://devzone.nordicsemi.com/f/nordic-q-a/84319/nrf-connect-for-vs-code-youtube-videos-having-problems-with-include-paths-and-kconfig-in-mac-os

    In this case it was of significantly greater scope as I upgraded to macOS Monterey and deleted (including all hidden files) and reinstalled nRF Connect, the toolchain and SDK, and VS Code to ensure I was running the latest code in all instances.

    So I don't think that's the issue, rather it's how nRF Connect is configuring VS Code and that the correct filepaths for the compiler etc. are not being specified.

    All I've done is follow the Nordic instructions, so with respect I feel that the issue lies with nRF Connect's configuration of VS Code, and to suggest I just live with the error messages isn't something I can accept for commercial product development.

  • It's worth noting the key difference between the two tickets, in the previous one I was automatically importing an existing Nordic project, in this ticket I'm manually creating a project. Is there a difference in how the filepaths are specified in the two cases please?

  • Hi

    Are you experiencing the error messages only in your custom project, or when building our examples as well?

    Regards,
    Sigurd Hellesvik

  • Hi Sigurd,

    On launching VS Code from nRF Connect, I get a pop-up window on the bottom right of the screen which says:

    Bad CMake executable "". Is it installed or settings contain the correct path (cmake.cmakePath)?

    Although it may be significant, I ignore it as it does not affect my ability to build and run the example projects.

    Having removed all other applications from VS Code and from my workspace folder, I import an example Nordic project such as blinky as shown in the Nordic tutorial video "nRF Connect for VS Code, 2: Create an application'.

    https://www.youtube.com/watch?v=KwJtcPZHV30

    I follow the example from the YouTube video and 'Create a new application from sample' and select blinky from the available list.

    Once I've created the application and look at main.c I see that the Include segments are underlined in red.

    I then create a Build Configuration targeting the nrF530dk_nrf5340_cpuapp and once I've done a build I no longer see the Include statements underlined in red.

    The one problem that is raised by the Build Configuration is in Kconfig.defconfig:

    boards/arm/nrf5340dk_nrf5340/Kconfig.defconfig:62: error: couldn't parse 'default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION))': macro expanded to blank string

    But this does not seem to have any effect.

    I can then Erase and Flash the target board without problem.

    Interestingly when I do CMD+P (CTRL+P) and enter c_app_properties.json, I get 'no matching results'.

    So this is different to what I saw when I manually created a custom project as shown previously in this thread. What happens to this JSON file when importing an example project versus creating a custom project please?

  • Hi

    After doing some research, I found that the error

    boards/arm/nrf5340dk_nrf5340/Kconfig.defconfig:62: error: couldn't parse 'default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION))': macro expanded to blank string

    have been spotted on MacOS VS Code before. I have reported this to our developers as a bug.

    Thank you for the report. If I find a workaround, I will let you know.
    And hopefully this will be fixed in a later update of our extension.


    EDIT, added the following:

    alwalker said:
    Bad CMake executable "". Is it installed or settings contain the correct path (cmake.cmakePath)?

    I think out extension does some configuration that is dependent of the build folders. Therefore, some error messages might appear before the build, but should disappear after your project has a build folder. My guess is that the cmake path error is of this type.

    Regards,
    Sigurd Hellesvik

Related