mac下的vscode配置编译环境

基础开发环境

创建Dockerfile文件,内容如下:

复制代码
FROM ubuntu:20.04

RUN apt update & apt install make gcc cmake git ninja-build -y
CMD [ "sleep", "infinity" ]

创建docker-compose.yml文件,内容如下:

复制代码
version: '3.4'

services:
  aipiopenkits:
    volumes:
      - /Users/xxx/AiPi/AiPi-Open-Kits:/workspace
    devices:
      - /dev/ttyUSB0:/dev/ttyS0
    platform: linux/x86_64
    image: ubuntu:my
    build:
      context: .
      dockerfile: ./Dockerfile

进入容器后,下载需要的包

复制代码
apt update & apt install vim make -y

为了避免第二次启动时,把原来已经创建的容器内的文件删掉。所以之后可以去掉docker-compose.yml中的build部分,已避免第二次编译docker镜像。

vim ~/.bashrc

最后加上 export PATH=$PATH:/workspace/aithinker_Ai-M6X_SDK/toolchain/bin

这样的话,就不用每次都export了,直接就可以编译

代码的友好阅读

vscode自定义编译工具链的路径

在.vscode目录下创建

复制代码
/workspace/aithinker_Ai-M6X_SDK/toolchain/bin/riscv64-unknown-elf-gcc

vscode解决头文件无法跳转的问题

复制代码
${workspaceFolder}/**
/workspace/aithinker_Ai-M6X_SDK/toolchain/riscv64-unknown-elf/**/**
/workspace/aithinker_Ai-M6X_SDK/components/**/**
/workspace/aithinker_Ai-M6X_SDK/drivers/**/**

以上2步,可以直接操作文件来实现 .vscode/c_cpp_properties.json

复制代码
{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/workspace/aithinker_Ai-M6X_SDK/toolchain/riscv64-unknown-elf/**/**",
                "/workspace/aithinker_Ai-M6X_SDK/components/**/**",
                "/workspace/aithinker_Ai-M6X_SDK/drivers/**/**",
                "/workspace/aithinker_Ai-M6X_SDK/bsp/common/**/**"
            ],
            "defines": [],
            "cStandard": "c17",
            "cppStandard": "c++98",
            "intelliSenseMode": "linux-gcc-x64",
            "compilerPath": "/workspace/aithinker_Ai-M6X_SDK/toolchain/bin/riscv64-unknown-elf-gcc"
        }
    ],
    "version": 4
}

同时为解决vscode默认编译环境的问题,需改.vscode/settings.json中的

复制代码
{
    "C_Cpp.default.compilerPath": "/workspace/aithinker_Ai-M6X_SDK/toolchain/bin/riscv64-unknown-elf-gcc",
} 

MAC下无法编译,验证完毕

编译工具链步骤

参考文档 https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md

依赖

资源

brew install --build-from-source gawk gnu-sed gmp mpfr libmpc isl zlib expat

zlib会下载失败,想办法科学上网,一道无形的阻力,压制了无数大佬的血统😀

brew install --build-from-source coreutils

brew install --build-from-source texinfo

brew tap riscv-software-src/riscv

brew install riscv-tools

复制代码
$ git clone --recurse-submodules https://github.com/T-head-Semi/xuantie-gnu-toolchain.git
$ git clone https://github.com/bouffalolab/bl_mcu_sdk.git
相关推荐
Howrun7777 小时前
VSCode烦人的远程交互UI讲解
ide·vue.js·vscode
Ashley的成长之路8 小时前
2025 年最新:VSCode 中提升 React 开发效率的必备插件大全
ide·vscode·react.js·工作提效·react扩展
m0_555762909 小时前
VSCODE CLAUDE CODE
ide·vscode·编辑器
不能跑的代码不是好代码10 小时前
STM32窗口看门狗(WWDG)知识点及标准库使用指南
stm32·单片机·嵌入式硬件
bingquan333310 小时前
在 Ghidra 中分析STM32裸机固件
stm32·单片机·嵌入式硬件
羽获飞10 小时前
从零开始学嵌入式之STM32——11.STM32---USART串行通讯
stm32·单片机·嵌入式硬件
肖永威11 小时前
macOS环境安装/卸载python实践笔记
笔记·python·macos
宵时待雨12 小时前
STM32笔记归纳9:定时器
笔记·stm32·单片机·嵌入式硬件
逐步前行12 小时前
STM32_新建工程(寄存器版)
stm32·单片机·嵌入式硬件
bai54593613 小时前
STM32 CubeIDE 通过PWM占空比控制舵机角度
stm32·单片机·嵌入式硬件