[开发板与模块] 【ESK32-30519 + ESK32-21001测评】移植RT-Thread Nano

[复制链接]
 楼主| KING阿飞 发表于 2022-9-11 15:34 | 显示全部楼层 |阅读模式
<
本帖最后由 KING阿飞 于 2022-9-11 15:37 编辑

【ESK32-30519 + ESK32-21001测评】移植RT-Thread Nano

  首先,我们了解片上存储器是28 KB 片上 Flash 存储器用作指令 和 数据和选项存储 :16 KB 片上 SRAM,所以我选择小型的国产OS:RT-Thread Nano,作为项目评测OS。

一、移植过程

     我们首先下载官方的资源包,资源包点此下载(https://www.holtek.com.cn/documents/10179/052fe018-3579-46e4-a3a8-32e53fbc0033)。我们找到例程项目,.\project_template\IP\Example\MDK_ARMv537(这里由于我的keil是537的),点开项目文件。

MCJMEH]~YCZJF019T38{BSF.png

  我们再安装RT-Thread Nano的离线安装包,离线安装包点此下载 (https://www.rt-thread.org/download/mdk/RealThread.RT-Thread.3.1.5.pack)。我们安装完成后,找到包管理器。

RX2`KE9QQMI`7[3AN069NHB.png

SFYDAZ[`4ZRT@TJ0K2OE~3N.png

  安装完毕后,需要修改的地方是:

  1、将ht32f5xxxx_01_it.c文件中的,HardFault_Handler,PendSV_Handler,SysTick_Handler注释

  2、修改RTOS中的board.c:

添加SysTick_Handler,调用rt_os_tick_callback。完善rt_hw_board_init。

  1. /*
  2. * Copyright (c) 2006-2019, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date           Author       Notes
  8. * 2021-05-24                  the first version
  9. */

  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include "ht32.h"

  13. #if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
  14. /*
  15. * Please modify RT_HEAP_SIZE if you enable RT_USING_HEAP
  16. * the RT_HEAP_SIZE max value = (sram size - ZI size), 1024 means 1024 bytes
  17. */
  18. #define RT_HEAP_SIZE (8*1024)

  19. static rt_uint8_t rt_heap[RT_HEAP_SIZE];

  20. RT_WEAK void *rt_heap_begin_get(void)
  21. {
  22.     return rt_heap;
  23. }

  24. RT_WEAK void *rt_heap_end_get(void)
  25. {
  26.     return rt_heap + RT_HEAP_SIZE;
  27. }
  28. #endif

  29. void rt_os_tick_callback(void)
  30. {
  31.     rt_interrupt_enter();
  32.    
  33.     rt_tick_increase();

  34.     rt_interrupt_leave();
  35. }
  36. u32 count = 0;

  37. void SysTick_Handler(void)
  38. {
  39.         rt_os_tick_callback();
  40.         count++;
  41. }

  42. /**
  43. * This function will initial your board.
  44. */
  45. void rt_hw_board_init(void)
  46. {
  47.     /*
  48.      * TODO 1: OS Tick Configuration
  49.      * Enable the hardware timer and call the rt_os_tick_callback function
  50.      * periodically with the frequency RT_TICK_PER_SECOND.
  51.      */
  52.         
  53.                 /* SYSTICK configuration */
  54.                 SYSTICK_ClockSourceConfig(SYSTICK_SRC_STCLK);       // Default : CK_AHB/8
  55.                 SYSTICK_SetReloadValue(SystemCoreClock / 8/ RT_TICK_PER_SECOND); // (CK_AHB/8/1000) = 1ms on chip
  56.                 SYSTICK_IntConfig(ENABLE);                          // Enable SYSTICK Interrupt
  57.                 SYSTICK_CounterCmd(SYSTICK_COUNTER_CLEAR);
  58.                 SYSTICK_CounterCmd(SYSTICK_COUNTER_ENABLE);
  59.                                 
  60.     /* Call components board initial (use INIT_BOARD_EXPORT()) */
  61. #ifdef RT_USING_COMPONENTS_INIT
  62.     rt_components_board_init();
  63. #endif

  64. #if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
  65.     rt_system_heap_init(rt_heap_begin_get(), rt_heap_end_get());
  66. #endif
  67. }

  68. #ifdef RT_USING_CONSOLE

  69. static int uart_init(void)
  70. {
  71. #error "TODO 2: Enable the hardware uart and config baudrate."
  72.     return 0;
  73. }
  74. INIT_BOARD_EXPORT(uart_init);

  75. void rt_hw_console_output(const char *str)
  76. {
  77. #error "TODO 3: Output the string 'str' through the uart."
  78. }

  79. #endif

测试:

  1.   HT32F_DVB_LEDInit(HT_LED1);
  2.   HT32F_DVB_LEDInit(HT_LED2);
  3.   HT32F_DVB_LEDInit(HT_LED3);
  4.         
  5.   HT32F_DVB_LEDOn(HT_LED1);
  6.   HT32F_DVB_LEDOff(HT_LED2);
  7.   HT32F_DVB_LEDOn(HT_LED3);


  8.   while (1)                           /* Infinite loop                                                      */
  9.   {
  10.     HT32F_DVB_LEDToggle(HT_LED1);
  11.                 rt_thread_mdelay(500);
  12.     HT32F_DVB_LEDToggle(HT_LED2);
  13.                 rt_thread_mdelay(500);
  14.     HT32F_DVB_LEDToggle(HT_LED3);
  15.                 rt_thread_mdelay(500);
  16.   }
二、效果

HT32F54253移植测试(https://www.bilibili.com/video/BV1qG411V7s6/?vd_source=9f29628860df295e99637badd1e5e6ae)



kkzz 发表于 2023-1-5 10:36 | 显示全部楼层
现在的操作系统分类真是太多了。              
gygp 发表于 2023-1-5 13:27 | 显示全部楼层
需要自己修改BootLoader吗?
eefas 发表于 2023-1-6 17:46 | 显示全部楼层
有ucos或者freertos的例程吗?
elsaflower 发表于 2023-1-7 17:04 | 显示全部楼层
RT-Thread Nano的定时器怎么单独使用?
louliana 发表于 2023-1-9 14:48 | 显示全部楼层
需要自己修改BootLoader呢?
tabmone 发表于 2023-1-10 19:49 | 显示全部楼层
RT-Thread Nano如何添加插件?
elsaflower 发表于 2023-1-10 20:30 | 显示全部楼层
RT-Thread Nano移植难吗?
houjiakai 发表于 2023-3-2 11:24 | 显示全部楼层
现在需要自己移植RT-Thread的代码吗?
hudi008 发表于 2023-3-2 11:52 | 显示全部楼层
这个建一个模板,以后就省事了。              
zerorobert 发表于 2023-3-2 15:55 | 显示全部楼层
如何在RT-Thread建立定时任务?
biechedan 发表于 2023-3-3 21:31 | 显示全部楼层
RT-Thread可以使用定时器 的吗?
nomomy 发表于 2023-3-3 21:51 | 显示全部楼层
RT-Thread会占用多大空间?
wangdezhi 发表于 2023-3-3 22:00 | 显示全部楼层
网上有移植RT-Thread的教程吗?
bartonalfred 发表于 2023-3-7 14:11 | 显示全部楼层
RTThread将占用单片机多少空间?
yorkbarney 发表于 2023-3-7 20:10 | 显示全部楼层
这个是否需要调整stack和heap的大小?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

4

主题

18

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部

4

主题

18

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部