IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 嵌入式 -> VsCode+OpenOCD 开发stm32系列 -> 正文阅读

[嵌入式]VsCode+OpenOCD 开发stm32系列

通常会用MDK调试stm32等arm cotex平台,但KEIL MDK很多商业公司是不能直接使用的,需要购买授权!VScode
搭配gcc-arm-none-eabi编译工具链和openocd(Open On-Chip Debugger)实现编译、下载、调试!

所需资源

环境搭建

1、mingw-w64安装(mingw-w64-install.exe)

在这里插入图片描述

并添加环境变量:C:\Program Files\mingw-w64\i686-8.1.0-release-posix-dwarf-rt_v6-rev0\mingw32\bin
同时将 C:\Program Files\mingw-w64\i686-8.1.0-release-posix-dwarf-rt_v6-rev0\mingw32\bin\mingw32-make.exe 备份并命名为make.exe

2、arm-gcc安装(gcc-arm-none-eabi-10.3-2021.10-win32.exe)

在这里插入图片描述

同时添加环境变量:C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\bin

3、openocd-20211118.7z解压到指定位置

在这里插入图片描述

并添加环境变量:D:\work\tool\OpenOCD-20211118-0.11.0\bin

4、VScode安装,并安装插件 C/C++,Cortex-Debug

在这里插入图片描述
在这里插入图片描述

工程搭建(以stm32h7为例)

1、STM32CubeMX 生成Makefile 工程

在这里插入图片描述

2、VScode 打开生成的工程,shift+ctrl+p,进入c/c++配置UI,设置如下配置

在这里插入图片描述
在这里插入图片描述

3、复制openOCD配置文件到工程目录(和makefile同一路径)

D:\work\tool\OpenOCD-20211118-0.11.0\share\openocd\scripts\interface\cmsis-dap.cfg
D:\work\tool\OpenOCD-20211118-0.11.0\share\openocd\scripts\target\stm32h7x.cfg

4、VScode配置编译和下载任务(终端->运行任务->添加配置任务)

在这里插入图片描述

tasks.json
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "make",
            "args": [
            ],
            "group": "build"
        },
        {
            "label": "download",
            "type": "shell",
            "command": "openocd",
            "args": [
                "-f",
                "cmsis-dap.cfg",
                "-f",
                "stm32h7x.cfg",
                "-c",
                "program build/stm32h7_demo.elf verify reset exit"
            ],
            "group": "build"
        }
    ]
}
5、运行"build"任务
> Executing task: make <

mkdir build
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/main.d" -Wa,-a,-ad,-alms=build/main.lst Core/Src/main.c -o build/main.o
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/gpio.d" -Wa,-a,-ad,-alms=build/gpio.lst Core/Src/gpio.c -o build/gpio.o
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/usart.d" -Wa,-a,-ad,-alms=build/usart.lst Core/Src/usart.c -o build/usart.o
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_rcc.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_rcc.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc.c -o build/stm32h7xx_hal_rcc.oarm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_rcc_ex.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_rcc_ex.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc_ex.c -o build/stm32h7xx_hal_rcc_ex.oarm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_flash.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_flash.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash.c -o build/stm32h7xx_hal_flash.oarm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_flash_ex.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_flash_ex.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash_ex.c -o build/stm32h7xx_hal_flash_ex.oarm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_gpio.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_gpio.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_gpio.c -o build/stm32h7xx_hal_gpio.oarm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_hsem.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_hsem.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_hsem.c -o build/stm32h7xx_hal_hsem.o
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_dma.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_dma.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma.c -o build/stm32h7xx_hal_dma.o
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_dma_ex.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_dma_ex.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma_ex.c -o build/stm32h7xx_hal_dma_ex.o
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_mdma.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_mdma.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_mdma.c -o build/stm32h7xx_hal_mdma.o
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_pwr.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_pwr.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr.c -o build/stm32h7xx_hal_pwr.o
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_pwr_ex.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_pwr_ex.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr_ex.c -o build/stm32h7xx_hal_pwr_ex.o
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c -o build/stm32h7xx_hal.o 
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_i2c.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_i2c.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c.c -o build/stm32h7xx_hal_i2c.o
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_i2c_ex.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_i2c_ex.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c_ex.c -o build/stm32h7xx_hal_i2c_ex.o
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_exti.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_exti.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_exti.c -o build/stm32h7xx_hal_exti.o
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_tim.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_tim.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim.c -o build/stm32h7xx_hal_tim.o
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_tim_ex.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_tim_ex.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim_ex.c -o build/stm32h7xx_hal_tim_ex.o
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_uart.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_uart.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart.c -o build/stm32h7xx_hal_uart.o
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/stm32h7xx_hal_uart_ex.d" -Wa,-a,-ad,-alms=build/stm32h7xx_hal_uart_ex.lst Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart_ex.c -o build/stm32h7xx_hal_uart_ex.o
arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/system_stm32h7xx.d" -Wa,-a,-ad,-alms=build/system_stm32h7xx.lst Core/Src/system_stm32h7xx.c -o build/system_stm32h7xx.o
arm-none-eabi-gcc -x assembler-with-cpp -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32H743xx -ICore/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"build/startup_stm32h743xx.d" startup_stm32h743xx.s -o build/startup_stm32h743xx.o
arm-none-eabi-gcc build/main.o build/gpio.o build/usart.o build/stm32h7xx_it.o build/stm32h7xx_hal_msp.o build/stm32h7xx_hal_cortex.o build/stm32h7xx_hal_rcc.o build/stm32h7xx_hal_rcc_ex.o build/stm32h7xx_hal_flash.o build/stm32h7xx_hal_flash_ex.o build/stm32h7xx_hal_gpio.o build/stm32h7xx_hal_hsem.o build/stm32h7xx_hal_dma.o build/stm32h7xx_hal_dma_ex.o build/stm32h7xx_hal_mdma.o build/stm32h7xx_hal_pwr.o build/stm32h7xx_hal_pwr_ex.o build/stm32h7xx_hal.o build/stm32h7xx_hal_i2c.o build/stm32h7xx_hal_i2c_ex.o build/stm32h7xx_hal_exti.o build/stm32h7xx_hal_tim.o build/stm32h7xx_hal_tim_ex.o build/stm32h7xx_hal_uart.o build/stm32h7xx_hal_uart_ex.o build/system_stm32h7xx.o build/startup_stm32h743xx.o -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -specs=nano.specs -TSTM32H743IITx_FLASH.ld  -lc -lm -lnosys  -Wl,-Map=build/stm32h7_demo.map,--cref -Wl,--gc-sections -o build/stm32h7_demo.elf
arm-none-eabi-size build/stm32h7_demo.elf
   text    data     bss     dec     hex filename
  13236      24    1712   14972    3a7c build/stm32h7_demo.elf
arm-none-eabi-objcopy -O ihex build/stm32h7_demo.elf build/stm32h7_demo.hex
arm-none-eabi-objcopy -O binary -S build/stm32h7_demo.elf build/stm32h7_demo.bin        

终端将被任务重用,按任意键关闭。

显示编译成功

6、运行"download"任务
> Executing task: openocd -f cmsis-dap.cfg -f stm32h7x.cfg -c 'program build/stm32h7_demo.elf verify reset exit' <

Open On-Chip Debugger 0.11.0 (2021-11-18) [https://github.com/sysprogs/openocd]
Licensed under GNU GPL v2
libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : CMSIS-DAP: SWD  supported
Info : CMSIS-DAP: FW Version = 1.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0
Info : CMSIS-DAP: Interface ready
Info : clock speed 1800 kHz
Info : SWD DPIDR 0x6ba02477
Info : stm32h7x.cpu0: Cortex-M7 r1p1 processor detected
Info : stm32h7x.cpu0: target has 8 breakpoints, 4 watchpoints
Info : gdb port disabled
Info : starting gdb server for stm32h7x.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x0800328c msp: 0x20020000
** Programming Started **
Info : Device: STM32H74x/75x
Info : flash size probed value 2048k
Info : STM32H7 flash has dual banks
Info : Bank (0) size is 1024 kb, base address is 0x08000000
Info : Padding image section 1 at 0x080033cc with 20 bytes (bank write end alignment)
Warn : Adding extra erase range, 0x080033e0 .. 0x0801ffff
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
shutdown command invoked

终端将被任务重用,按任意键关闭。

显示下载成功

7、配置单步调试功能

在这里插入图片描述

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "cwd": "${workspaceRoot}",
            "executable": "./build/stm32h7_demo.elf",
            "name": "Debug Microcontroller",
            "request": "launch",
            "type": "cortex-debug",
            "showDevDebugOutput": false,
            "servertype": "openocd",
            "configFiles": [
                "cmsis-dap.cfg",
                "stm32h7x.cfg"
            ]
        }
    ]
}

8、运行调试

在这里插入图片描述


  嵌入式 最新文章
基于高精度单片机开发红外测温仪方案
89C51单片机与DAC0832
基于51单片机宠物自动投料喂食器控制系统仿
《痞子衡嵌入式半月刊》 第 68 期
多思计组实验实验七 简单模型机实验
CSC7720
启明智显分享| ESP32学习笔记参考--PWM(脉冲
STM32初探
STM32 总结
【STM32】CubeMX例程四---定时器中断(附工
上一篇文章      下一篇文章      查看所有文章
加:2022-01-17 11:38:55  更:2022-01-17 11:40:22 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2025年1日历 -2025/1/9 1:36:41-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码