在platform中使用stm32cubeMX自己生成的库开发

环境:

PlatformIO 6.1.15

STM32CubeMX 6.11.1

stm32f103vct6芯片

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
[platformio] 
src_dir = ./ 

[env:genericSTM32F103VC]
platform = ststm32
board = genericSTM32F103VC
; framework = stm32cube
build_flags = 
	-D STM32F103xE
	-ICore/Inc
	-IDrivers/CMSIS/Include
	-IDrivers/CMSIS/Device/ST/STM32F1xx/Include
	-IDrivers/STM32F1xx_HAL_Driver/Inc
	-IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
	
build_src_filter  = +<Core/Src/> +<startup_stm32f103xe.s> +<Drivers/>
board_build.ldscript = ./STM32F103VCTx_FLASH.ld
upload_protocol=cmsis-dap
debug_tool = cmsis-dap
extra_scripts =post:extra_script.py

stm32f407zgt6芯片

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
[platformio] 
src_dir = ./

[env:black_f407zg]
platform = ststm32
board = black_f407zg
; framework = stm32cube
build_flags = 
	-D STM32F407xG
	-ICore/Inc
	-IDrivers/CMSIS/Include
	-IDrivers/CMSIS/Device/ST/STM32F4xx/Include
	-IDrivers/STM32F4xx_HAL_Driver/Inc
	-IDrivers/STM32F4xx_HAL_Driver/Inc/Legacy
	
build_src_filter = +<Core/Src/> +<startup_stm32f407xx.s> +<Drivers/>
board_build.ldscript = ./STM32F407ZGTx_FLASH.ld

upload_protocol = cmsis-dap 
debug_tool = cmsis-dap
extra_scripts =post:extra_script.py

添加生成HEX的脚本,与platformio.ini同目录

extra_script.py

Import("env")

env.AddPostAction(
    "$BUILD_DIR/${PROGNAME}.elf",
    env.VerboseAction(" ".join([
        "$OBJCOPY", "-O", "ihex", "-R", ".eeprom",
        "$BUILD_DIR/${PROGNAME}.elf", "$BUILD_DIR/${PROGNAME}.hex"
    ]), "Building $BUILD_DIR/${PROGNAME}.hex")
)

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值