【Clion开发STM32】从零搭建高效开发环境:Clion+CubeMX+OpenOCD实战指南

手把手教你用CLION加上STM32Cubemx打造无敌STM32开发环境 众所周知,STM32的常规开发环境是KEIL MDK5,但是这个编译器在很多方面做的不尽如人意,敲起代码来一点B格也没有(划重点 ),而且随着年代的更迭,标准固件库终将要退出历史的舞台(就和XP,WIN7一样),他的爸爸ST(意法半导体)已经在逐渐的放弃标准固件库了,可以说他是没有未来的。 同时有一款新的开发工具STM32CubeMX,利用可视化的界面轻松完成时钟的配置和端口的选择。来感受一下: ... 阅读详情

1. 环境准备:工具链全解析

第一次用Clion开发STM32时,我被各种工具链绕晕了——OpenOCD、CubeMX、MinGW...它们到底起什么作用?经过多次实践,我终于理清了这套工具链的协作关系。就像搭积木一样,每个工具都是不可或缺的基石。

核心工具链包含:

  • Clion:智能代码编辑和项目管理中枢
  • STM32CubeMX:图形化芯片配置工具
  • OpenOCD:开源调试和烧录桥梁
  • MinGW:Windows下的GNU工具集

具体版本选择有讲究。我推荐:

  • Clion 2023.3+(对嵌入式支持更完善)
  • STM32CubeMX 6.8+(兼容最新芯片)
  • OpenOCD 0.12+(支持更多调试器)
  • Arm GNU工具链 12.3.Rel1(优化代码生成)

安装时最容易踩的坑是路径问题。建议:

  1. 所有工具安装路径不要有中文和空格
  2. 将工具链的bin目录加入系统PATH
  3. 记录各工具安装路径(后续配置需要)

验证安装是否成功:

# 检查MinGW
gcc --version
# 检查Arm工具链
arm-none-eabi-gcc --version
# 检查OpenOCD
openocd -v

2. 工程创建:从CubeMX到Clion的无缝衔接

很多新手卡在工程创建这一步,其实关键在于理解CubeMX和Clion的协作机制。CubeMX负责硬件抽象层配置,Clion负责业务逻辑开发,二者通过CMake实现联动。

具体操作流程:

  1. 在CubeMX中:

    • 选择正确芯片型号(如STM32F103C8T6)
    • 配置时钟树(HSE值要匹配开发板晶振)
    • 开启必要外设(如GPIO、USART等)
    • Project Manager中设置IDE为"STM32CubeIDE"(这是关键!)
  2. 在Clion中:

    • 通过"File > Open"打开CubeMX生成的.ioc文件
    • 勾选"Trust Project"以允许CMake配置
    • 等待自动生成CMakeLists.txt(约1-2分钟)

遇到过的问题及解决方案:

  • 问题1:Clion无法识别.ioc文件

    • 检查CubeMX工程路径是否含中文/空格
    • 确认CubeMX
Mac下使用CLion搭建STM32开发环境 1.CLion 下载地址: https://www.jetbrains.com/clion/download/#section=mac 版本需要在CLion2019.2以上 2.安装编译器 ➜ brew cask install gcc-arm-embedded 命令行运行前两行,安装 ARM toolchain,这里使用 homebrew。 https://developer.arm.com/tools-and-software/open-source-software/developer-tools/ 阅读详情

相关推荐

基于clion下与stm32cubemx点亮LED

目录 一、环境安装 1.1首先下载clion 1.2安装完后运行clion 1.3 安装Stm32cubeMX 1.4 安装arm-none-eabi-gcc 1.5安装openocd 1.6 安装MinGW 1.7 添加系统环境变量 二、配置Clion 2.1 点击创建新工程 2.2 进入后进入settings 2.3 配置 toolchains 2.4 配置cmake 2.5 配置Embedded Development 三、实现工程 3.1生成stm32cubemx..

qq_60678931的博客 2294

MacOS搭建CLion+STM32CubeMX+OpenOCD嵌入式开发环境

本文详细指导如何在MacOS系统上搭建CLion+STM32CubeMX+OpenOCD嵌入式开发环境。通过Homebrew包管理器简化安装流程,涵盖ARM GCC工具链配置、OpenOCD调试设置及CLion集成技巧,为STM32开发者提供高效、稳定的跨平台开发解决方案。

sugar的博客 855

【Unity实战】HybridCLR热更快速集成

本文假设你已经通过UPM导入了HybridCLR、Addressables、il2cpp支持并具有一定的C#基础和Unity编辑器操作能力。

u012587406的博客 5000

CloudCompare点云变换保姆级教程:从平移、旋转到绕任意点旋转,一次搞定

本文提供CloudCompare点云变换的全面教程,涵盖从基础平移、旋转到绕任意点旋转的高级技巧。通过详细的操作步骤和实战案例,帮助用户掌握点云数据处理的核心技能,提升三维模型对齐和变换的效率与精度。

weixin_28717969的博客 293

Winform美化框架AntdUI中Table的使用方法

使用核心注意点: 数据模型中属性名需要完全与new Column里的列名一致否则添加数据源则无法读取到详细内容。

wevix的博客 3707

保姆级教程:用Altium Designer 24从零画一块PCB(附完整库文件与避坑清单)

本文提供了一份详细的Altium Designer 24(AD24)PCB设计教程,从工程创建到最终文件输出,涵盖元件库管理、原理图设计、PCB布局布线等全流程。特别适合初学者,包含STM32最小系统板的实战案例,附完整库文件和避坑清单,帮助用户快速掌握AD24的核心功能与技巧。

weixin_27697385的博客 257

python操作git推送自己分支并合并主分支(持续优化该工具)

python git

qq_44707265的博客 864

WinForm轻松打造AntDesign现代化工具栏

摘要: 本文介绍如何在WinForm中利用AntdUI库实现AntDesign风格工具栏,包括安装配置、动态生成按钮/下拉菜单、布局优化及主题美化。通过AntButton、AntDropdown等控件结合事件绑定,可快速构建支持图标、工具提示、权限控制的现代化工具栏,并解决常见图标加载、布局错乱问题。最后提供代码示例与响应式设计技巧,助你打造高效美观的WinForm界面。 (字数:150)

java专栏 1613

CrackerXI+脱壳实战:解决iOS应用逆向中的加密文件问题

本文详细介绍了如何使用CrackerXI+工具对iOS应用进行脱壳,解决App Store应用因FairPlay DRM加密而无法进行静态分析的难题。通过图形化界面一键操作,CrackerXI+能高效获取解密后的可执行文件,为逆向工程奠定基础。文章涵盖工具选型、实战步骤及常见问题排查,是iOS逆向入门与进阶的实用指南。

seed的博客 264

Matlab之机载雷达系统中的空时自适应处理(STAP)技术(附源码)

在第一个脉冲期间,天线 1 通过天线 N-1 接收的杂波返回与第二个脉冲期间天线 2 通过天线 N 接收的杂波返回相同。该算法可能需要搜索角度和多普勒的所有组合来定位目标,但对于示例,由于确切知道目标的位置,因此可以将处理器定向到该点。然而,接收到的信号不仅包含来自目标的反射回波,还包含来自被照亮地表的回波。然而,由于干扰器的白噪声性质,接收到的干扰信号占据了整个多普勒频段。在以下部分中,您将模拟来自目标、杂波和干扰器的返回,并说明 STAP 技术如何过滤来自接收信号的干扰。假设元件间距是波形波长的一半。

珞瑜的博客 7144

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: 西门子S7-1200与第三方设备Modbus-RTU通信实战解析
下一篇: CPU设计实战-加减法与比较指令的硬件实现与优化
神经小黑
博客等级 码龄10年 77粉丝 1万+原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值