This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to browse SDK and Zyphyr code in VSCode and nRFconnect SDK

SO I've got nRFconnect SDK 1.9.1 running on VSCode on my MAC (attempting to segregate from my Win dev system for now). Wanting to explore it a bit more to see what problems I've got to deal with in it.

Created a project from the DM example (want to know what this is going to entail).  That appears to work fine basically.

So, browsing code. In SES if I want to see the code for the SDk portions, I select the function, right click and "goto definition" Bang, in the code of the SDK itself.  Same for the OS (in my old system FreeRTOS). No problems. I can see as deep as I need to as long as it isn't in the SoftDevice.

Doing that in VSCode, I get nowhere. Nothing, Nada.  So I'm hoping that I'm missing something.  It is very, very often I have to consult SDK code or OS code to see what it's doing really.  I've had to rewrite some SDK function before to make them work right.

So, how do I get full visibility into the entire code stack?

  • Sorry... Apparently VSCode isn't smart enough to figure it out before you do some sort of build.... Once I told it what board to use (why that would matter is beyond me), it got me into OS code and that sort of thing....  Also corrected all kinds of flagged errors that shouldn' t exist.

    Gotta love MS....

  • Hi,

    VS Code is a generic text editor, and by itself doesn't have any knowledge of how our SDK works. Our nRF Connect extension gives you the tools for managing an NCS project, but we rely on Microsoft's C/C++ extension for code borwsing, code completion, etc. Which means that for the C/C++ extension to know how to "goto definition", we need to tell it where to look for the definitions.

    The smart way of doing this, is to provide a file to the C/C++ extension that includes the commands we use to compile the project. The C/C++ extension will then use those compile commands to learn where it should search. This file is generated by our extension when you create a "build configuration". So before you do your first build, VS Code and he C/C++ extension doesn't really know how to "goto definition".

    If the compile commands file isn't available, VS Code and the C/C++ extension will fall back to searching through your open files/folders for any mention of what you are trying to find the definition for. This sometimes works, but it can also just give you a list of all the places the function is mentioned. If you want, you can add the whole SDK to your VS Code workspace by opening the command pallete with Ctrl+Shift+P, and choose the command "nRF Connect: Add nRF Connect SDK To Workspace".

    Best regards,

    Didrik

  • If you want, you can add the whole SDK to your VS Code workspace by opening the command pallete with Ctrl+Shift+P, and choose the command "nRF Connect: Add nRF Connect SDK To Workspace"

    Oh that actually helps a lot for future dev... Our code base tends to have very long life (decades) and relying on the tool sets is rarely a good idea.  This solves that issue too.

    thanx

Related