1. 程式人生 > >linux上搭建stm32開發環境 vscode+gcc+stm32cubeMX 和 vscode+platformIO

linux上搭建stm32開發環境 vscode+gcc+stm32cubeMX 和 vscode+platformIO

一、軟體清單:

  • VSCode應用商店安裝 或
    sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make
    sudo apt-get update
    sudo apt-get install ubuntu-make
    sudo umake web visual-studio-code
  • arm-none-eabi-gcc
sudo apt-get install gcc-arm-none-eabi
sudo apt-get install gdb-arm-none-eabi 

( 補充:VSCode的PlatformIO IDE外掛裡Platform選項安裝“ST STM32”家目錄下會自動安裝相應工具,看下面:

~/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -v
嗯。不用另外裝arm-none-eabi工具集了,如果你用PlatformIO外掛的話。  )
  • stm32flash(串列埠下載,選裝):
    sudo apt-get install stm32flash
    stm32flash -h
    檢視串列埠資訊:
    dmesg | grep tty
  • OpenOCD:(現在是0.10.0)
    sudo apt install openocd 
           openocd安裝和使用,請看此篇

  • Stm32CubeMX: 官網下載,解壓後進入資料夾
    sudo apt-get install default-jre
    sudo ./SetupSTM32CubeMX-x.xx.x.linux

二、配置vscode(待續)

  • cortex-debug外掛(感覺不錯~):

          launch.json例子:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Cortex Debug",
            "cwd": "${workspaceRoot}",
            "executable": "build/L496ZGTx_LPUASRT.elf",
            "request": "launch",
            "type": "cortex-debug",
            "servertype": "openocd",
            "BMPGDBSerialPort": "/dev/ttyACM0",
            "runToMain": true,
            "device": "STM32L496ZG",
            //"preLaunchTask": "build-elf",
            "configFiles": [
                "board/st_nucleo_l4.cfg"
            ]

        }
    ]
}

   

(有空再更新。)