简体   繁体   English

带有 LibOpenCM3 的 STM32 FreeRTOS

[英]STM32 FreeRTOS with LibOpenCM3

I have a STM32 BluePill Board (STM32F103C8 with 8Mhz Quarz) and tried to upload a small blink program made with LibOpenCM3 and FreeRTOS.我有一个 STM32 BluePill 板(STM32F103C8 和 8Mhz Quarz)并尝试上传一个用 LibOpenCM3 和 FreeRTOS 制作的小程序。 But for some reason FreeRTOS hangs in vTaskStartScheduler() the sys_tick_handler also doesn't do anything.但出于某种原因,FreeRTOS 挂在 vTaskStartScheduler() 中,sys_tick_handler 也没有做任何事情。

I didn't use a debugger and just placed a gpio_reset inside the sys_tick_handler function and after the vTaskStartScheduler call to test if the code gets executed but it didn't seem to do anything and I can't figure out why.我没有使用调试器,只是在 sys_tick_handler 函数中放置了一个 gpio_reset 并在 vTaskStartScheduler 调用之后测试代码是否被执行,但它似乎没有做任何事情,我不知道为什么。 The code is available here: https://gitlab.com/feldim2425/stm32-testing该代码可在此处获得: https : //gitlab.com/feldim2425/stm32-testing

UPDATE: I debugged with OpenOCD and fount out that it jumps into the hard_fault_handler UPDATE 2: The UsageFault-Status-Register has the NOCP bit set更新:我使用 OpenOCD 进行调试,发现它跳入了 hard_fault_handler 更新 2:UsageFault-Status-Register 设置了 NOCP 位

Ok I found the issue.好的,我发现了问题。 Many examples seem to rely on compiler optimization to directly link the vPortSVCHandler, xPortPendSVHandler and xPortSysTickHandler from FreeRTOS into the vector table if you call them inside your own handler vector implementation for sv_call_handler, pend_sv_handler and sys_tick_handler.如果您在自己的 sv_call_handler、pend_sv_handler 和 sys_tick_handler 的处理程序向量实现中调用它们,许多示例似乎依赖于编译器优化将来自 FreeRTOS 的 vPortSVCHandler、xPortPendSVHandler 和 xPortSysTickHandler 直接链接到向量表中。 But that didn't work here, the functions have to be called directly by the processor.但这在这里不起作用,这些函数必须由处理器直接调用。

Adding these 3 Lines to the bottom of the FreeRTOSConfig.h file and removing my own function declarations for the vectors fixed the problem:将这 3 行添加到 FreeRTOSConfig.h 文件的底部并删除我自己的向量函数声明修复了问题:

#define vPortSVCHandler sv_call_handler
#define xPortPendSVHandler pend_sv_handler
#define xPortSysTickHandler sys_tick_handler

The fix is described here: https://www.freertos.org/FreeRTOS_Support_Forum_Archive/January_2012/freertos_LPC1768_FreeRTOS_4964917.html修复方法如下: https : //www.freertos.org/FreeRTOS_Support_Forum_Archive/January_2012/freertos_LPC1768_FreeRTOS_4964917.html

It is described for CMSIS but the only difference (in this case) are just the names of the vectors/handler functions.它是为 CMSIS 描述的,但唯一的区别(在这种情况下)只是向量/处理程序函数的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM