vscode + platformio + stm32cube开发stm32f4,创建工程

一、简介

        单片机开发普遍用的是Keil,由于Keil的编辑器比较复古(Keil很多坑前人基本已经踩过,调试方便,编辑器老旧),现在打算试一下vscode + platformio + stm32cube开发单片机。

        开发环境:vscode + platformio + stm32cube

        验证开发板:正点原子探索者(STM32F407ZG)

二、步骤

图 1.0 打开vscode 选择platformio IDE 

图 1.1 创建工程 

 图 1.2 创建好工程,添加配置和移值文件

update_link_flags.py 需要添加FPU配置

# Custom settings, as referred to as "extra_script" in platformio.ini
#
# See http://docs.platformio.org/en/latest/projectconf.html#extra-script

from SCons.Script import DefaultEnvironment

env = DefaultEnvironment()

env.Append(
    LINKFLAGS=[
        "-mthumb",
        "-mfloat-abi=hard",
        "-mfpu=fpv4-sp-d16",
        "-mcpu=cortex-m4"
    ]
)

 platformio.ini 配置文件

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:black_f407zg]
platform = ststm32
board = black_f407zg
framework = stm32cube

upload_protocol = stlink                                  ; 使用stlink烧写代码
debug_tool = stlink                                       ; 使用stlink进行在线调试

build_flags = 
    -Wl,-u,_printf_float                                ;支持输出小数
	-mthumb -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16
	-Wl,-Map,output.map									;输出map
	-O0												    ;编译优先级(0,1,2,3)

    -Isrc
    -Isrc/led 

; 使用自己的stm32f4xx_hal_conf.h
board_build.stm32cube.custom_config_header = yes

board_build.ldscript = STM32F407ZGTx_FLASH.ld

board_build.stm32cube.startup_file = startup_stm32f407xx.s

; board_upload.offset_address = 0x08000000

build_type = release 

extra_scripts = update_link_flags.py

 

图 1.3 编译程序

  • 8
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值