AWTK 在 RT-Thread 上的移植是怎样的
发表于:2025-12-03 作者:千家信息网编辑
千家信息网最后更新 2025年12月03日,AWTK 在 RT-Thread 上的移植是怎样的,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。AWTK 在 RT-Th
千家信息网最后更新 2025年12月03日AWTK 在 RT-Thread 上的移植是怎样的
AWTK 在 RT-Thread 上的移植是怎样的,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
AWTK 在 RT-Thread 上的移植笔记
下面以 STM32f103ze 为例,介绍了 AWTK 在 RTOS 上移植的经验。与其说移植,倒不如说是集成。所做的事情不过是把 AWTK 放到 RTOS 的一个线程中执行而已。
1. 加入 RT-Thread 相关文件。
AWTK 已经移植到 STM32f103ze 裸系统上,为了简单起见,直接在 awtk-stm32f103ze-raw 基础上加入 RT-Thread 支持。
在 Keil 中增加下列文件:
rtthread/rtthread/bsprtthread/cortex-m3rtthread/cortex-m3/context_gcc.Srtthread/cortex-m3/context_iar.Srtthread/cortex-m3/context_rvds.Srtthread/cortex-m3/cpuport.crtthread/cortex-m3/SConscriptrtthread/includertthread/include/libcrtthread/include/libc/libc_dirent.hrtthread/include/libc/libc_errno.hrtthread/include/libc/libc_fcntl.hrtthread/include/libc/libc_fdset.hrtthread/include/libc/libc_ioctl.hrtthread/include/libc/libc_signal.hrtthread/include/libc/libc_stat.hrtthread/include/rtdbg.hrtthread/include/rtdebug.hrtthread/include/rtdef.hrtthread/include/rthw.hrtthread/include/rtlibc.hrtthread/include/rtm.hrtthread/include/rtservice.hrtthread/include/rtthread.hrtthread/rtconfig.hrtthread/srcrtthread/src/clock.crtthread/src/cpu.crtthread/src/device.crtthread/src/idle.crtthread/src/ipc.crtthread/src/irq.crtthread/src/Kconfigrtthread/src/kservice.crtthread/src/mem.crtthread/src/memheap.crtthread/src/mempool.crtthread/src/object.crtthread/src/scheduler.crtthread/src/SConscriptrtthread/src/signal.crtthread/src/slab.crtthread/src/thread.crtthread/src/timer.c
增加 include 的路径
rtthreadrtthread/include
修改配置文件
根据自己的需要修改配置 rtthread/rtconfig.h
一般来说不需要修改,使用官方提供的即可。我用的是 stm32f103-mini-system 项目中的。
2. 加入针对 RT-Thread 实现的线程和同步的函数。
src/platforms/rtt/mutex.csrc/platforms/rtt/semaphore.csrc/platforms/rtt/thread.csrc/platforms/common/sys_tick.c
3. 实现rtos.c。
参考stm32/libraries/HAL_Drivers/drv_common.c和components.c修改的。
#include "rthw.h"#include "rtthread.h"static bool_t s_kernel_inited = FALSE;static bool_t rtos_is_inited(void) { return s_kernel_inited;}static uint32_t s_heap[2 * 1024];ret_t rtos_init(void) { rt_hw_interrupt_disable(); /* show version */ rt_show_version();#ifdef RT_USING_HEAP rt_system_heap_init((void*)s_heap, s_heap + sizeof(s_heap) / sizeof(s_heap[0]));#endif /* initialize scheduler system */ rt_system_scheduler_init(); /* initialize timer */ rt_system_timer_init(); /* initialize timer thread */ rt_system_timer_thread_init(); /* initialize idle thread */ rt_thread_idle_init(); s_kernel_inited = TRUE; return RET_OK;}ret_t rtos_start(void) { /* start scheduler */ rt_system_scheduler_start(); return RET_OK;}void rtos_tick(void) { if (rtos_is_inited()) { rt_interrupt_enter(); rt_tick_increase(); rt_interrupt_leave(); }}void rtos_delay(uint32_t ms) { rt_thread_delay(ms);}4. 在线程中启动 AWTK
void* awtk_thread(void* args) { gui_app_start(320, 480); return NULL;}static ret_t awtk_start_ui_thread(void) { tk_thread_t* ui_thread = tk_thread_create(awtk_thread, NULL); return_value_if_fail(ui_thread != NULL, RET_BAD_PARAMS); tk_thread_set_priority(ui_thread, 3); tk_thread_set_name(ui_thread, "awtk"); tk_thread_set_stack_size(ui_thread, 2048); return tk_thread_start(ui_thread);}int main() { hardware_prepare(); platform_prepare(); rtos_init(); awtk_start_ui_thread(); rtos_start();}这里与裸系统不同的地方,主要有两个:
在线程中启动 AWTK。
要提前调用 platform_prepare,platform_prepare 负责初始化内存,放在 tk_init 中就有些晚,需要单独提出来调用。
为此 platform_prepare 函数做了防重复调用的处理。
static bool_t s_inited = FALSE;static uint32_t s_heam_mem[4096];ret_t platform_prepare(void) { if(!s_inited) { s_inited = TRUE; tk_mem_init(s_heam_mem, sizeof(s_heam_mem)); } return RET_OK;}AWTK 集成 RTOS 是非常简单的,以上过程大概花了 2 个小时吧。只要 RTOS 本身好移植,集成 AWTK 和 RTOS 只是分分钟的问题。
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注行业资讯频道,感谢您对的支持。
移植
线程
文件
函数
系统
帮助
支持
配置
不同
清楚
为此
一般来说
两个
事情
内存
内容
分分钟
只是
地方
基础
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
win7支持sql数据库
刘长永 北京 网络安全
数据库 蕴涵
计算机网络技术认证等级
新会聚星辰软件开发店
华为5g网络技术有多强
软件开发职业职称
arcgis批量管理数据库
阿里云多台服务器
电力监控系统网络安全及自动化
软件开发成果管理办法
阿里云服务器 怎么建站
怎么看数据库连接端口
汪峰软件开发
我与网络安全征文活动议论文
博 期刊数据库
服务器启动电脑显示屏没反应
关系数据库理论包括哪些内容
扬州市网络安全和信息化
方舟服务器恐龙参数
仁翼通互联网科技
订票软件开发单位
数字新基建和网络安全
软件开发后台操作
阿里云服务器 怎么建站
宣传部关于开展网络安全工作
软件开发大专大专院校有哪些
数据库基础考试只有选择题吗
计算机软件开发工程师二级
边缘计算服务器的投资