STM32H750VBTx 用Cube创建多路Uart和带有FreeRtos的项目流程,以及踩到的坑

报错汇总

问题一

error: L6236E: No section matches selector - no section to be FIRST/LAST.

        包->Device->Startup,打钩

问题二

Note: source file 'RTE\Device\STM32H750VBTx\system_stm32h7xx.c' - object file renamed from '16 STM32CubeMX_H750_DEMO\system_stm32h7xx.o' to '16 STM32CubeMX_H750_DEMO\system_stm32h7xx_1.o'.

Error: L6200E: Symbol D1CorePrescTable multiply defined (by system_stm32h7xx_1.o and system_stm32h7xx.o).

Error: L6200E: Symbol SystemCoreClock multiply defined (by system_stm32h7xx_1.o and system_stm32h7xx.o).

        system_stm32h7xx.c的问题导致的编译错误,从项目中删除它

问题三

error: expected 'volatile', 'inline', 'goto', or '('

        把Cube生成的ARM_CM4F文件夹替换为从FreeRtos官网下载的源码中的ARM_CM4F文件夹

问题四

Error: L6218E: Undefined symbol __use_two_region_memory (referred from startup_stm32h750xx.o).

Error: L6218E: Undefined symbol __initial_sp (referred fromentry2.o).

        从V6版本切换到V5版本,或者V5切到V6版本,这个时候点击rebuild 重新编译就好

详细信息请搜索查看下面文档图片

开始流程

打开Cube

通过MCU创建项目

搜索框输入STM32H750VBT6,双击芯片

YES 应用配置

打开选择每个串口

还是Uart1 先关闭掉,然后右键PB14和PB15屏蔽掉

这个时候再打开Uart1 就会自动选择PA9和PA10了

打开一路SPI和I2C,左键点击PC13选择GPIO_OUTPUT配置为LED输出

保存项目到指定位置

添加FreeRtos

添加任务 可以添加多几个

Yes 自动配置时钟

添加路径,刚刚保存过了所以这里自动添加了

选择MDK-ARM,版本可以选最新

选择自动添加创建.c .h路径

点击创建代码后.报警告,说需要修改时钟,关闭提示

关闭提示

回到SYS 选择TIM7

保存后重新创建代码

上面不用管,OK即可

打开保存的路径,进入MDK-ARM

打开工程

每个点开看一下文件结构

点击魔术棒,打开设置

设备->芯片是一开始在cube选择的STM32H750VBTx

Target 目标 选择ARM Compiler-> Use default compiler version 6

V6编译速度快,但是不能点击函数跳转

V5编译速度慢,但是可以点击函数跳转

输出 创建HEX文件

String设置

用户设置

编译器 O1是编译优化等级

Asm设置

Linker设置

选择调试器,我的是ST-LINK

电脑USB口,插入ST-LINK仿真器

无图

点击Settings->选择Download to Flash

Trace设置

Flash Download->Reset and Run,下载程序后复位并且运行

Pack设置    Enable关闭掉

Utilities设置

回到Target设置,选择V5,编译虽然慢,但是会少一些警告,等编译成功后再切换回V6

此时可以编译项目,按F7

可以看到编译的时候CPU吃满了

报第一个错误

error: L6236E: No section matches selector - no section to be FIRST/LAST.

选择包的管理->Device->Startup,打钩

重新编译,又报错

Note: source file 'RTE\Device\STM32H750VBTx\system_stm32h7xx.c' - object file renamed from '16 STM32CubeMX_H750_DEMO\system_stm32h7xx.o' to '16 STM32CubeMX_H750_DEMO\system_stm32h7xx_1.o'.

Error: L6200E: Symbol D1CorePrescTable multiply defined (by system_stm32h7xx_1.o and system_stm32h7xx.o).

Error: L6200E: Symbol SystemCoreClock multiply defined (by system_stm32h7xx_1.o and system_stm32h7xx.o).

Error: L6200E: Symbol SystemD2Clock multiply defined (by system_stm32h7xx_1.o and system_stm32h7xx.o).

Error: L6200E: Symbol __asm___18_system_stm32h7xx_c_5d646a67____REV16 multiply defined (by system_stm32h7xx_1.o and system_stm32h7xx.o).

Error: L6200E: Symbol __asm___18_system_stm32h7xx_c_5d646a67____REVSH multiply defined (by system_stm32h7xx_1.o and system_stm32h7xx.o).

Error: L6200E: Symbol __asm___18_system_stm32h7xx_c_5d646a67____RRX multiply defined (by system_stm32h7xx_1.o and system_stm32h7xx.o).

Error: L6200E: Symbol SystemCoreClockUpdate multiply defined (by system_stm32h7xx_1.o and system_stm32h7xx.o).

Error: L6200E: Symbol SystemInit multiply defined (by system_stm32h7xx_1.o and system_stm32h7xx.o).

可以看到是因为system_stm32h7xx.c的问题导致的编译错误,从项目中删除它

再F7,编译F8下载到单片机,这个时候程序应该可以跑起来

这个时候再选择V6版本重新编译

会发现居然报了一百多个错误

../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F\portmacro.h(170):

error: expected 'volatile', 'inline', 'goto', or '('

上网搜索,是因为Rtos的原因导致

“16 STM32CubeMX_H750_DEMO\Middlewares\Third_Party\FreeRTOS\Source\portable\RVDS”

把cube生成的ARM_CM4F文件夹重命名或者删除掉

“FreeRtos\FreeRTOSv202212.01\FreeRTOS\Source\portable\GCC”

把FreeRtos官网下载的ARM_CM4F复制到该路径下

回到Keil IDE,重新载入文件,选择是

再F7重新编译,此时编译可以通过了

如果遇到F8下载程序后,主板不运行,考虑重新构建.

Usart.c最底下插入以下代码,就可以实现printf()

int fputc(int ch)

{

HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 100);

return (ch);

}

在main.c引入 #include <stdio.h>

此时就可以printf()了

如果此时F8下载机器后,发现运行不了,点击Debug调试又是可以运行的,

那么问题来了!!!终于复现了.

点击魔术棒->V6->选择Use MicroLIB

此时直接F7编译会报错

Error: L6218E: Undefined symbol __use_two_region_memory (referred from startup_stm32h750xx.o).

Error: L6218E: Undefined symbol __initial_sp (referred fromentry2.o).

这个时候点击重新编译就好

F8下载到机器后能够正常运行了!

打开freertos.c,引入#include <stdio.h>

每个任务插入打印信息

打开串口工具,可以看到Rtos正常打印出来!

到此,结束.

该文档参考多位前辈的经验,但搜索解决问题的时候我忘记做记录了,以后注意都把网址复制一遍.

参考解决问题

https://blog.csdn.net/u010058695/article/details/112485056?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522172140364416800213098219%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=172140364416800213098219&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-2-112485056-null-null.142^v100^pc_search_result_base4&utm_term=CubeMX%E9%85%8D%E7%BD%AE%E7%9A%84FreeRTOS%E5%88%A9%E7%94%A8V6%E7%BC%96%E8%AF%91%E5%87%BA%E9%94%99&spm=1018.2226.3001.4187

再次感谢前辈们的无私奉献!!!

开源精神永流传

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值