nrf52搭配nrf SDK(而不是nrf-connect!)15.2在vscode上 – IntelliSense问题

huangapple go评论88阅读模式
英文:

nrf52 with nrf sdk (not nrf-connect!) 15.2 on vscode - intellisense issue

问题

我将翻译代码部分,以下是翻译好的内容:

I'll start with the dry details:
Host system: Ubuntu 22.04
VS Code 1.80.2
项目信息:
用于nrf52840处理器的嵌入式项目,使用nrf sdk 15.2和gcc arm工具链:gcc-arm-none-eabi-9-2020-q2-update。
项目使用makefile进行编译,makefile从环境变量中获取sdk目录,并在nrf-sdk中,工具链从sdk内的配置文件中获取。

这是我的c_cpp_properties.json:

{
    "env": {
        "nrfSDK": "/home/eyal/develop/sdks/nRF5_SDK_15.2.0_9412b96/"
    },
    "configurations": [
        {
            "name": "nrf52",
            "includePath": [
                "${workspaceFolder}/**",
                "${nrfSDK}/components",
                "${nrfSDK}/components/softdevice/common",
                "${nrfSDK}/components/softdevice/s140/headers",
                "${nrfSDK}/components/softdevice/s140/headers/nrf52",
                "${nrfSDK}/components/toolchain/cmsis/include",
                "${nrfSDK}/components/libraries/**",
                "${nrfSDK}/components/boards",
                "${nrfSDK}/modules/**",
                "${nrfSDK}/modules/",
                "${nrfSDK}/integration/nrfx",
                "${nrfSDK}/integration/nrfx/legacy",
                "${nrfSDK}/external/**"
            ],
            "defines": [
                "BOARD_PCA10056",
                "BSP_DEFINES_ONLY",
                "CONFIG_GPIO_AS_PINRESET",
                "FLOAT_ABI_HARD",
                "NRF52840_XXAA"
            ],
            "compilerPath": "/home/eyal/develop/sdks/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-gcc",
            "cStandard": "c11",
            "cppStandard": "c++14",
            "intelliSenseMode": "linux-gcc-arm",
            "compilerArgs": [
                "-O3",
                "-g3",
                "-mcpu=cortex-m4",
                "-mthumb",
                "-mabi=aapcs",
                "-Wall -Werror",
                "-mfloat-abi=hard ",
                "-mfpu=fpv4-sp-d16",
                "-ffunction-sections",
                "-fdata-sections",
                "-fno-strict-aliasing",
                "-fno-builtin",
                "-fshort-enums"
            ]
        }
    ],
    "version": 4
}

我使用的是blinky示例,所以只有一个main.c文件。
我已经正确定义了includepath中存在的文件,如果我要求VS Code跳转到定义,它会指向正确的位置。但是与编译器一起提供的库路径相关的一切似乎都会导致VS Code跳转到主机的clang目录!
我已经验证,当启动VS Code时,arm-gcc文件被调用并输出所有标志、常数和包含路径,所以插件确实完成了它的工作,但在某个环节出了问题,有经验的VS Code用户能帮助吗?
我认为也许我需要在settings.json中更改系统包含路径。

请注意,这是您提供的文本的翻译版本,不包括任何其他内容或答案。

英文:

I'll start with the dry details:
Host system : ubuntu 22.04
vs code 1.80.2
the project:
embedded for nrf52840 processor using nrf sdk 15.2 and gcc arm toolchain : gcc-arm-none-eabi-9-2020-q2-update.
the project is copiled using makefile the makefile takes the sdk dir from env variable and in nrf-sdk the toolchain is taken from configuration file inside the sdk.

this is my c_cpp_properties.json:

{
"env": {
    "nrfSDK": "/home/eyal/develop/sdks/nRF5_SDK_15.2.0_9412b96/"
},
"configurations": [
    {
        "name": "nrf52",
        "includePath": [
            "${workspaceFolder}/**",
            "${nrfSDK}/components",
            "${nrfSDK}/components/softdevice/common",
            "${nrfSDK}/components/softdevice/s140/headers",
            "${nrfSDK}/components/softdevice/s140/headers/nrf52",
            "${nrfSDK}/components/toolchain/cmsis/include",
            "${nrfSDK}/components/libraries/**",
            "${nrfSDK}/components/boards",
            "${nrfSDK}/modules/**",
            "${nrfSDK}/modules/",
            "${nrfSDK}/integration/nrfx",
            "${nrfSDK}/integration/nrfx/legacy",
            "${nrfSDK}/external/**"
        ],
        "defines": [
            "BOARD_PCA10056",
            "BSP_DEFINES_ONLY",
            "CONFIG_GPIO_AS_PINRESET",
            "FLOAT_ABI_HARD",
            "NRF52840_XXAA"
        ],
        "compilerPath": "/home/eyal/develop/sdks/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-gcc",
        "cStandard": "c11",
        "cppStandard": "c++14",
        "intelliSenseMode": "linux-gcc-arm",
        "compilerArgs": [
            "-O3",
            "-g3",
            "-mcpu=cortex-m4",
            "-mthumb",
            "-mabi=aapcs",
            "-Wall -Werror",
            "-mfloat-abi=hard ",
            "-mfpu=fpv4-sp-d16",
            "-ffunction-sections",
            "-fdata-sections",
            "-fno-strict-aliasing",
            "-fno-builtin",
            "-fshort-enums"
        ]
    }
],
"version": 4
}

I'm using blinky example so have only one main.c file.
files that exists in the includepath i have defined are directed just fine if i ask vscode to go to definition. But everything that is related to the path of libraries that arrive with the compiler - i can see that vscode takes me to clang directories of the host!
I have verified that when vscode is started the arm-gcc file is called and ouputs all flags, const and include path, so the plugin does do it's job, but something goes bad along the way, anyone with vscode experience can help ?
i thought maybe i need to change system include path in settings.json.

答案1

得分: 0

很好,没有人回答,要么不太多人使用VSCODE,要么没有人真正知道如何配置它,只是愚蠢地按照说明操作。

通过打开所有日志并查看编译器无法运行的问题,发现我的参数定义中有两个命令被空格连接在一起,VSCODE不知道如何正确传递它。

将它们分开解决了问题,现在系统路径是正确的。

英文:

nice that no 1 has answered, either not too many are using VSCODE or no one really knows how to configure it and just dumbly follow insturctions.

Problems solved by turning on all logs and seeing that the compiler could not run as two commands in my argument defs are joined by a space and vscode does not know how to pass it well.

Separating them solved the issue and now the system path is the right one.

huangapple
  • 本文由 发表于 2023年8月4日 01:00:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76830182.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定