[原创] 将ChibiOS/RT v16.1.x移植到stm32f030f4p6开发板上

phope2000   2016-5-20 22:52 楼主
闲来无事,就将最新版本的ChibiOS/RT实时系统移植到了STM32F030F4开发板上:
开发板资源:
- 3.3v供电
- 外接8MHz的晶振作为STM32F030F4的HSE
- PA9 接有一个蓝色的LED

看这论坛上貌似没有人在玩ChibiOS/RT, 个人认为ChibiOS/RT是一个很好用的实时操作系统,官网:http://www.chibios.org/dokuwiki/doku.php
最新版本为v16.1.0, chibios系统版本的命名也挺奇怪的,从最初的v1.x, v2.x, v3.x 一下子就跳到的v16.x

虽然STM32F030F4只有16KiB的ROM(flash), 4KiB的RAM,ChibiOS/RT足以在上面跑起来。

1. 代码下载
代码可以从chibios官网进行下载:
http://www.chibios.org/dokuwiki/ ... ios:downloads:start

DEMO请从这里下载:

附件已包含编译好hex与bin文件,可以直接下载。

2. 编译
代码使用makefile编译系统,同时使用gcc(gcc-arm-none-eabi-4_9-2015q1)作为编译器,在命令行中输入make进行编译。
打开命令行,进入ChibiOS-RT/demos/STM32/RT-STM32F030F4, 执行make命令。编译完后会生成elf文件,同时会生成hex, bin文件:
Linking build/ch.elf
Creating build/ch.hex
Creating build/ch.bin
Creating build/ch.dmp

   text           data            bss            dec            hex        filename
  10548            268           4084          14900           3a34        build/ch.elf
Creating build/ch.list

Done

3. 下载
使用openocd更新固件,使用STLink v2下载固件:
openocd -f interface/stlink-v2.cfg -f target/stm32f0x_stlink.cfg -c init -c "reset halt" -c "flash write_image erase build/ch.bin 0x08000000 bin" -c "verify_image build/ch.bin 0x08000000 bin" -c "reset run" -c shutdown

4. 运行
系统运行时,开发板上蓝色LED会以1Hz的频率闪烁,同时如果UART1会以115200n8速率打印类似如下log:
*** ChibiOS/RT test suite
***
*** Kernel:       3.1.3
*** Compiled:     May 20 2016 - 22:16:21
*** Compiler:     GCC 4.9.3 20150303 (release) [ARM/embedded-4_9-branch revision 221220]
*** Architecture: ARMv6-M
*** Core Variant: Cortex-M0
*** Port Info:    Preemption through NMI
*** Platform:     STM32F030x6 Entry Level Value Line devices
*** Test Board:   STMicroelectronics STM32F030F4

----------------------------------------------------------------------------
--- Test Case 1.1 (System, critical zones)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.2 (System, interrupts handling)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.3 (System, integrity)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.1 (Threads, enqueuing test #1)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.2 (Threads, enqueuing test #2)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.3 (Threads, priority change)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.4 (Threads, delays)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.1 (Semaphores, enqueuing)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.2 (Semaphores, timeout)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.3 (Semaphores, atomic signal-wait)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.4 (Binary Semaphores, functionality)
--- Result: SUCCESS
----------------------------------------------------------------------------

Final result: SUCCESS
欢迎访问 https://www.brobwind.com

回复评论 (1)

现在照着最新版本,来一遍编译报错了,另外chibistudio中不能一个project搞定吗,我看你的另一篇文章,需要参考别的工程

点赞  2023-8-30 22:06
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复