在ubuntu搭建环境开发STM32

本文详细介绍了如何在Ubuntu操作系统中为STM32开发设置环境,包括创建项目目录结构,复制固件库,编写通用Makefile,编译固件库和用户应用程序,以及建立链接文件和主Makefile,旨在帮助开发者顺利进行STM32项目开发。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

创建目录 
libs目录放stm32固件库,src放用户源码,inc放用户头文件

# mkdir libs src inc
  • 1

复制文件 
STM32F10x_StdPeriph_Lib_V3.5.0复制到libs目录下 
2 
创建Makefile.common 
在主目录下创建Makefile.common文件,这个是通用Makefile文件

#This file is included in the general Makefile, the libs Makefile and the src Makefile  
#Different optimize settings for library and source files can be realized by using arguments  
#Compiler optimize settings:  
# -O0 no optimize, reduce compilation time and make debugging produce the expected results (default).  
# -O1 optimize, reduce code size and execution time, without much increase of compilation time.  
# -O2 optimize, reduce code execution time compared to ‘O1’, increase of compilation time.  
# -O3 optimize, turns on all optimizations, further increase of compilation time.  
# -Os optimize for size, enables all ‘-O2’ optimizations that do not typically increase code size and other code size optimizations.  
#Recommended optimize settings for release version: -O3  
#Recommended optimize settings for debug version: -O0  
#Valid parameters :  
# OptLIB=0 --> optimize library files using the -O0 setting  
# OptLIB=1 --> optimize library files using the -O1 setting  
# OptLIB=2 --> optimize library files using the -O2 setting  
# OptLIB=3 --> optimize library files using the -O3 setting  
# OptLIB=s --> optimize library files using the -Os setting  
# OptSRC=0 --> optimize source files using the -O0 setting  
# OptSRC=1 --> optimize source files using the -O1 setting  
# OptSRC=2 --> optimize source files using the -O2 setting  
# OptSRC=3 --> optimize source files using the -O3 setting  
# OptSRC=s --> optimize source files using the -Os setting  

TOP=$(shell readlink -f "$(dir $(lastword $(MAKEFILE_LIST)))")
PROGRAM=main
LIBDIR=$(TO
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值