【GD32E503评测】+移植TencentOS-tiny
本帖最后由 我爱下载 于 2021-1-10 22:28 编辑<p class="MsoTitle" style="text-align:center; margin-top:16px; margin-bottom:4px"><span style="font-size:16pt"><span style="font-family:Cambria,serif"><span style="font-weight:bold">TencentOS-tiny<span style="font-family:宋体">系统移植</span></span></span></span></p>
<p><span style="font-size:22pt"><span style="line-height:240%"><span style="font-family:Tahoma,sans-serif"><span style="font-family:"微软雅黑","sans-serif"">系统简介</span></span></span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">TencentOS-tiny<span style="font-family:"微软雅黑","sans-serif"">是腾讯针对</span>IoT<span style="font-family:"微软雅黑","sans-serif"">设备推出的一款操作系统。主要由一个轻量级</span>RTOS<span style="font-family:"微软雅黑","sans-serif"">内核</span>+<span style="font-family:"微软雅黑","sans-serif"">多个物联网组件构成,,从下到上主要包括:</span></span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">CPU<span style="font-family:"微软雅黑","sans-serif"">库</span> <span style="font-family:"微软雅黑","sans-serif"">:</span>TencentOS tiny<span style="font-family:"微软雅黑","sans-serif"">支持的</span>CPU IP<span style="font-family:"微软雅黑","sans-serif"">核架构,当前主要支持</span>ARM Cortex M0/3/4/7/M23/M33<span style="font-family:"微软雅黑","sans-serif"">等,还有现在很火的</span>RISC-V<span style="font-family:"微软雅黑","sans-serif"">,当然,腾讯物联网团队肯定也会支持更多种类更多</span>IP<span style="font-family:"微软雅黑","sans-serif"">核与开发板。</span></span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:"微软雅黑","sans-serif"">驱动管理层</span> <span style="font-family:"微软雅黑","sans-serif"">:包括</span>BSP<span style="font-family:"微软雅黑","sans-serif"">板级支持包,这些东西主要由</span>MCU<span style="font-family:"微软雅黑","sans-serif"">芯片厂家开发与维护,、</span>HAL<span style="font-family:"微软雅黑","sans-serif"">硬件抽象、</span>Drivers<span style="font-family:"微软雅黑","sans-serif"">设备驱动,这部分对于纯粹嵌入式开发者来说还是很重要的,肯定会越来越完善的!</span></span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:"微软雅黑","sans-serif"">内核</span> <span style="font-family:"微软雅黑","sans-serif"">:</span>TencentOS tiny<span style="font-family:"微软雅黑","sans-serif"">实时内核包括任务管理、实时调度、时间管理、中断管理、内存管理、异常处理、软件定时器、链表、消息队列、信号量、互斥锁、事件标志等模块,接下来我也将写一系列</span>TencentOS tiny<span style="font-family:"微软雅黑","sans-serif"">内核源码分析的文章,敬请期待吧!</span></span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">IoT<span style="font-family:"微软雅黑","sans-serif"">协议栈</span> <span style="font-family:"微软雅黑","sans-serif"">:</span>TencentOS tiny<span style="font-family:"微软雅黑","sans-serif"">提供</span>lwip<span style="font-family:"微软雅黑","sans-serif"">、</span>AT Adapter<span style="font-family:"微软雅黑","sans-serif"">、</span>SAL<span style="font-family:"微软雅黑","sans-serif"">层,支持不同的网络硬件,如以太网、串口</span>WIFI<span style="font-family:"微软雅黑","sans-serif"">、</span>GPRS<span style="font-family:"微软雅黑","sans-serif"">、</span>NB-IoT<span style="font-family:"微软雅黑","sans-serif"">、</span>4G<span style="font-family:"微软雅黑","sans-serif"">等通信模块。在</span>TCP/IP<span style="font-family:"微软雅黑","sans-serif"">网络协议栈上提供常用的物联网协议栈应用层,如</span>COAP<span style="font-family:"微软雅黑","sans-serif"">、</span>MQTT<span style="font-family:"微软雅黑","sans-serif"">,支撑终端业务快速接入腾讯云;</span></span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:"微软雅黑","sans-serif"">安全框架</span> <span style="font-family:"微软雅黑","sans-serif"">:</span>TencentOS tiny<span style="font-family:"微软雅黑","sans-serif"">为了确保物联网终端数据传输安全以及设备认证安全,提供了比较完整的安全解决方案。安全框架提供的</span>DTLS<span style="font-family:"微软雅黑","sans-serif"">和</span>TLS<span style="font-family:"微软雅黑","sans-serif"">安全协议加固了</span>COAP<span style="font-family:"微软雅黑","sans-serif"">及</span>MQTT<span style="font-family:"微软雅黑","sans-serif"">的传输层,可确保物联网终端在对接腾讯云时实现安全认证和数据加密;另外针对低资源的终端硬件,安全框架还提供与腾讯云</span>IoTHub<span style="font-family:"微软雅黑","sans-serif"">配套的密钥认证方案,确保资源受限设备也能在一定程度上实现设备安全认证;物联网安全是非常重要的,这些框架也是必须存在的。</span></span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:"微软雅黑","sans-serif"">组件框架</span> <span style="font-family:"微软雅黑","sans-serif"">:</span>TencentOS tiny<span style="font-family:"微软雅黑","sans-serif"">提供文件系统、</span>KV<span style="font-family:"微软雅黑","sans-serif"">存储、自组网、</span>JS<span style="font-family:"微软雅黑","sans-serif"">引擎、低功耗框架、设备框架、</span>OTA<span style="font-family:"微软雅黑","sans-serif"">、调试工具链等一系列组件,这部分我觉得还是很不错的,期待</span>ing<span style="font-family:"微软雅黑","sans-serif"">;</span></span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:"微软雅黑","sans-serif"">开放</span>API (<span style="font-family:"微软雅黑","sans-serif"">规划开发中</span>)<span style="font-family:"微软雅黑","sans-serif"">:</span>TencentOS tiny<span style="font-family:"微软雅黑","sans-serif"">将在协议中间件和框架层上提供开放</span>API<span style="font-family:"微软雅黑","sans-serif"">函数,这样子就能很方便使用中间组件的功能,我是最喜欢这种开发的,不造轮子,能直接使用。简单来说这个</span>API<span style="font-family:"微软雅黑","sans-serif"">能快速对接腾讯云,实现终端业务上云的需求,最大程度减少终端物联网产品开发周期,节省开发成本;</span></span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:"微软雅黑","sans-serif"">示例应用</span> <span style="font-family:"微软雅黑","sans-serif"">:</span>TencentOS tiny<span style="font-family:"微软雅黑","sans-serif"">提供的示例代码,模块测试代码等,方便用户参考使用。</span></span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:"微软雅黑","sans-serif"">腾讯云物联网平台(图中最上层的部分):严格来说这部分不算</span>TencentOS tiny<span style="font-family:"微软雅黑","sans-serif"">的框架内容,这是接入平台层了,腾讯云的物联网平台都是提供多种语言的</span>SDK<span style="font-family:"微软雅黑","sans-serif"">包,当然在嵌入式设备上肯定使用</span>C SDK<span style="font-family:"微软雅黑","sans-serif"">的,不过总的来说都是很不错的。</span></span></span></p>
<p> </p>
<p style="margin-bottom:13px"></p>
<p> </p>
<p style="margin-bottom:13px"><span style="font-size:22pt"><span style="line-height:240%"><span style="font-family:Tahoma,sans-serif"><span style="font-family:"微软雅黑","sans-serif"">移植过程</span>-<span style="font-family:"微软雅黑","sans-serif"">创建工程,添加文件</span></span></span></span></p>
<p></p>
<p> </p>
<p><span style="font-size:11.0pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:"微软雅黑","sans-serif"">根据上面的介绍,</span>TencentOS tiny<span style="font-family:"微软雅黑","sans-serif"">是支持</span>M33<span style="font-family:"微软雅黑","sans-serif"">内核的,而且支持了很多种的嵌入式处理器,对于</span>GD<span style="font-family:"微软雅黑","sans-serif"">的产品就支持了很多中,但是唯独没有我们这款</span>GD32E503V<span style="font-family:"微软雅黑","sans-serif"">系列。</span></span></span></p>
<p style="margin-bottom:13px"></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:"微软雅黑","sans-serif"">在</span>arch<span style="font-family:"微软雅黑","sans-serif"">目录下我们可以找到</span>cortex-m33<span style="font-family:"微软雅黑","sans-serif"">的目录,说明</span>TencentOS tiny<span style="font-family:"微软雅黑","sans-serif"">原生支持,我们应该可以轻松的移植到新的处理器上。</span></span></span></p>
<p> </p>
<p style="text-indent:36.0pt; margin-bottom:13px">总结的移植步骤:</p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:"微软雅黑","sans-serif""> 步骤</span>1<span style="font-family:"微软雅黑","sans-serif"">:建立新的目录,命名为</span>tos<span style="font-family:"微软雅黑","sans-serif"">,并复制</span>TencentOS-tiny\board\GigaDevice_GD32E230C_START<span style="font-family:"微软雅黑","sans-serif"">下文件到新的工程,并且命名文件夹为</span>application<span style="font-family:"微软雅黑","sans-serif"">。</span></span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"> <span style="font-family:"微软雅黑","sans-serif"">打开工程调整为</span>GD32E503V<span style="font-family:"微软雅黑","sans-serif"">微控制器。</span></span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"> <span style="font-family:"微软雅黑","sans-serif"">步骤</span>2<span style="font-family:"微软雅黑","sans-serif"">:复制</span>GD<span style="font-family:"微软雅黑","sans-serif"">公司提供的驱动库</span>Firmware_Library<span style="font-family:"微软雅黑","sans-serif"">到</span>tos<span style="font-family:"微软雅黑","sans-serif"">;</span></span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"> <span style="font-family:"微软雅黑","sans-serif"">步骤</span>3<span style="font-family:"微软雅黑","sans-serif"">:复制</span>TencentOS-tiny\osal\cmsis_os<span style="font-family:"微软雅黑","sans-serif"">目录到</span>tos</span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"> <span style="font-family:"微软雅黑","sans-serif"">步骤</span>4<span style="font-family:"微软雅黑","sans-serif"">:复制</span>TencentOS-tiny\kernel<span style="font-family:"微软雅黑","sans-serif"">目录到</span>tos</span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"> <span style="font-family:"微软雅黑","sans-serif"">步骤</span>5<span style="font-family:"微软雅黑","sans-serif"">:创建</span>port<span style="font-family:"微软雅黑","sans-serif"">目录,并复制</span>TencentOS-tiny\arch\arm\arm-v8m<span style="font-family:"微软雅黑","sans-serif"">目录下的</span>common<span style="font-family:"微软雅黑","sans-serif"">目录到</span>tos/port<span style="font-family:"微软雅黑","sans-serif"">下;</span></span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"> <span style="font-family:"微软雅黑","sans-serif"">步骤</span>6<span style="font-family:"微软雅黑","sans-serif"">:复制</span>TencentOS-tiny\arch\arm\arm-v8m\cortex-m33<span style="font-family:"微软雅黑","sans-serif"">目录下所有文件到</span>tos/port<span style="font-family:"微软雅黑","sans-serif"">下。</span></span></span></p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"> <span style="font-family:"微软雅黑","sans-serif"">将如上内容添加到步骤</span>1<span style="font-family:"微软雅黑","sans-serif"">建立的工程中。</span></span></span></p>
<h1 style="margin-top:23px; margin-bottom:22px"><span style="font-size:22pt"><span style="line-height:240%"><span style="font-family:Tahoma,sans-serif"><span style="font-family:"微软雅黑","sans-serif"">移植过程</span>-<span style="font-family:"微软雅黑","sans-serif"">修改相应文件</span></span></span></span></h1>
<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"> <span style="font-family:"微软雅黑","sans-serif"">删除</span>tos\application\BSP<span style="font-family:"微软雅黑","sans-serif"">下除</span>main.c<span style="font-family:"微软雅黑","sans-serif"">外的文件,找到一个</span>GD32E503V<span style="font-family:"微软雅黑","sans-serif"">工程中的</span>gd32e50x_it.c,gd32e50x_it.h,gd32e50x_libopt.h,systick.c,systick.h,uart.c<span style="font-family:"微软雅黑","sans-serif"">文件到</span>tos\application\BSP<span style="font-family:"微软雅黑","sans-serif"">的目录下</span></span></span></p>
<p> 1) <span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif">Gd32e50x_it.c<span style="font-family:"微软雅黑","sans-serif"">的移植</span></span></span></p>
<p style="margin-left:48px; margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:"微软雅黑","sans-serif"">这个比较简单,添加头文件引用</span> #include “tos_k.h” , <span style="font-family:"微软雅黑","sans-serif"">注释掉</span>pendSV_handler<span style="font-family:"微软雅黑","sans-serif"">函数,修改</span> SysTick_Handler<span style="font-family:"微软雅黑","sans-serif"">为如下形式</span></span></span></p>
<pre>
<code class="language-cpp">void SysTick_Handler(void)
{
systick_inc();
if(tos_knl_is_running())
{
tos_knl_irq_enter();
tos_tick_handler();
tos_knl_irq_leave();
}
}
</code></pre>
<p style="margin-bottom:13px"> </p>
<p style="margin-bottom:13px"><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"> 2) Main.c<span style="font-family:"微软雅黑","sans-serif"">文件修改</span></span></span></p>
<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><span style="font-family:"微软雅黑","sans-serif"">初始化调试监视串口,这里可以根据官方例程完成修改。</span></span></span></p>
<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><code style="font-family:宋体"><span style="font-size:10.5pt"><span style="background:#f9f2f4"><span style="color:#c7254e">完成修改后,编译工程,如果有错误适当调整,编译通过后,基本上已经具备调度能力。</span></span></span></code></span></span></p>
<p><span style="font-size:11pt"><span style="font-family:Tahoma,sans-serif"><code style="font-family:宋体"><span style="font-size:10.5pt"><span style="background:#f9f2f4"><span style="color:#c7254e">下面附上我的移植例子 </span></span></span></code></span></span></p>
<p><span style="font-size:22pt"><span style="line-height:240%"><span style="font-family:Tahoma,sans-serif"><span style="font-family:"微软雅黑","sans-serif"">效果展示</span></span></span></span></p>
<p> </p>
<p style="margin-bottom:13px"></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p style="margin-bottom:13px"> </p>
<p> </p>
<p> </p>
页:
[1]