Ubuntu18.04搭建STM32開發環境


1、安裝STM32CUbeMX

利用STM32CubeMX生成stm32工程,以及Makefile文件。(在Toolchain/IDE中記得選擇Makefile)

下載地址:https://www.st.com/content/st_com/zh/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-configurators-and-code-generators/stm32cubemx.html

STM32CubeMX-4.24.0安裝包解壓后有四個文件:

Readme.html
SetupSTM32CubeMX-4.24.0.app
SetupSTM32CubeMX-4.24.0.exe
SetupSTM32CubeMX-4.24.0.linux

執行./SetupSTM32CubeMX-4.24.0.linux安裝。

可能遇到問題:

a. 如果SetupSTM32CubeMX-4.24.0.linux是32位的可執行文件,而我的Ubuntu是64位系統。首先安裝32位運行時庫。

sudo apt install libc6-i386

b. 需要java運行環境

sudo apt install default-jre

2、安裝GDB Sever

  該工具往下用於連接jlink或stlink,往上提供reset,halt,flash等常用功能,用於程序下載和調試。此處選用OpenOCD,使用方便且開源。

2.1 指令安裝版本較低

sudo apt install openocd 

2.2 編譯安裝

git clone git://git.code.sf.net/p/openocd/code openocd
cd openocd
sudo ./bootstrap
sudo ./configure
make
sudo make install

測試是否安裝成功:

openocd --version

可能遇到問題:

 

    + aclocal
    + libtoolize --automake --copy
    + autoconf
    configure.ac:12: error: possibly undefined macro: AC_MSG_WARN
          If this token and others are legitimate, please use m4_pattern_allow.
          See the Autoconf documentation.
    configure.ac:36: error: possibly undefined macro: AC_DISABLE_SHARED
    configure.ac:37: error: possibly undefined macro: AC_PROG_LIBTOOL
    configure.ac:204: error: possibly undefined macro: AC_DEFINE
    configure.ac:608: error: possibly undefined macro: AC_MSG_NOTICE

 

 

缺少libtool和libsysfs-dev

sudo apt-get install libtool libsysfs-dev

 

 

3、編譯工具鏈

3.1 指令安裝

sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
sudo apt-get update
sudo apt-get install gcc-arm-embedded

 

4、Vscode安裝配置

4.1 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"
                ]
     
            }
        ]
    }

4.3 PlatformIO IDE插件

請戳:http://docs.platformio.org/en/latest/ide/vscode.html#quick-start


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM