some trouble in VSC

Hi, all

I have some issues about developing on nRF connect SDK with VSCode:

  1. Go to definition for macro always jumps to the wrong place. For example, BT_DATA_BYTES would go to definition BT_DATA in bluetooth.h, that makes me crazy.
  2.  NRF TERMINAL stops working when I Flash the chip and can't reconnect automatically. But it works in SES.
  3. How to add extra Cmake arguments, for example, I want to add set(CMAKE_CXX_FLAGS "-O3 -Wall -Wextra")
  4. When using KConfig to search for something, and Jump to item, it's hard for me to find the item since there's not any highlight for it.

Thank you very much!

  • Hello,

    Go to definition for macro always jumps to the wrong place. For example, BT_DATA_BYTES would go to definition BT_DATA in bluetooth.h, that makes me crazy.

    I agree that this is annoying, but the nRF Connect for VS Code is using some built in modules from VS Code, and these are the ones returning the wrong locations. I believe that our team is looking into this.

     NRF TERMINAL stops working when I Flash the chip and can't reconnect automatically. But it works in SES.

    Yes. RTT Viewers (Like Segger's RTT Viewer and the one in nRF Connect for VS code will disconnect when you flash the chip. The reason it works "seamlessly" in SES is that it automatically reconnects when it is done flashing (not surprisingly, since this is Segger's own IDE). I will request this feature from our developers.

    How to add extra Cmake arguments, for example, I want to add set(CMAKE_CXX_FLAGS "-O3 -Wall -Wextra")

    You can add extra CMake arguments when you create a new build configuration in nRF Connect for VS Code. Unfortunately, there is no way to add extra arguments without creating a new build configuration at this point in time.

    When using KConfig to search for something, and Jump to item, it's hard for me to find the item since there's not any highlight for it.

    Noted this one as well.

    General: Thank you for your feedback. Some of these I have noticed myself, as I use nRF Connect for VS Code daily, but it is always good to get feedback from other users, so that we can forward it to our developers. I will forward this entire post to our nRF Connect for VS Code development team. 

    Best regards,

    Edvin

  • I got some feedback from our nRF Connect for Visual Studio Code. 

    Regarding the extra CMake arguments:

    The recommended way to do this is through the target_compile_definitions cmake command in CMakeLists.txt, although they can pass them in the "Extra CMake arguments" as well.

    In cmake, they'll need to set up a flag that controls the behavior - for instance "APP_DBG_LEVEL". Then, in their cmake code, they can check this flag, and activate other settings or behavior depending on the value. Like explained in this Stack overflow answer, for instance: https://stackoverflow.com/a/48984477/2495121

    Here, he added a flag called USE_MY_LIB to control compilation flags and other things. The "unset()" in the last line of his snippet isn't technically required for this scenario.

    Where the snippet in that answer says "#add some compilation flags", they could for instance do

    target_compile_definitions(app PRIVATE ABC=5)

    which creates a define called "ABC" that can be referenced in the source code.

    This way, they don't need to specify -DCMAKE_C_FLAGS="-DABC=5" on the command line to get the expected behavior, but could enable different configuration types through more understandable command line flags, if required.

    They also mentioned that they are considering to add the possibility to add/remove CMake flags, but I don't know when/if that will be released. 

    BR,

    Edvin

Related