返回列表 发新帖我要提问本帖赏金: 21.00元(功能说明)

[DemoCode下载] 在M471KI开发板跑新版的RT-Thread Nano

[复制链接]
42894|17
 楼主| gaoyang9992006 发表于 2021-8-6 19:34 | 显示全部楼层 |阅读模式
本帖最后由 gaoyang9992006 于 2021-8-6 19:39 编辑

#申请原创# @21小跑堂
RT-Thread Nano ,原来的版本是3.1.3,近期已经提供了最新版的3.1.5我们先跑一个老版本的试试
新建工程,先选中这个M471的芯片,然后在RTE里勾选一下基本内容
70839610d08a5da0e5.png 具体步骤可参考我之前在另外一个单片机上的移植过程

新唐新出单片机M0A23移植RT-Thread竟然这么容易,十分钟搞定。 - - 21ic电子技术开**坛

等一通 操作完成,编译下载,串口助手就可以打印出系统的消息了
62942610d0f7d04614.png
然后我升级了一下RT-Thread Nano 系统,重新编译烧录后就失败了
原来新版的RTT 重新设计了配置,现在的报错就是告诉你要分几步走,完城配置,按照几个错误提示的步骤重新配置,完成。
例如第三步的配置,我们屏蔽掉这个报错消息,然后填入相应的代码。
79162610d148be3be7.png

31101610d1d0d6d26b.png

M471.rar (3.44 MB, 下载次数: 16)

board.c
  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 <stdio.h>
  13. #include <NUMicro.h>

  14. #if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
  15. /*
  16. * Please modify RT_HEAP_SIZE if you enable RT_USING_HEAP
  17. * the RT_HEAP_SIZE max value = (sram size - ZI size), 1024 means 1024 bytes
  18. */
  19. #define RT_HEAP_SIZE (15*1024)
  20. static rt_uint8_t rt_heap[RT_HEAP_SIZE];

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

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

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

  35.     rt_interrupt_leave();
  36. }

  37. /**
  38. * This function will initial your board.
  39. */

  40. void SYS_Init(void)
  41. {
  42.     /* Unlock protected registers */
  43.     SYS_UnlockReg();

  44.     /* Set XT1_OUT(PF.2) and XT1_IN(PF.3) to input mode */
  45.     PF->MODE &= ~(GPIO_MODE_MODE2_Msk | GPIO_MODE_MODE3_Msk);

  46.     /* Enable HIRC clock (Internal RC 48 MHz) */
  47.     CLK_EnableXtalRC(CLK_PWRCTL_HIRCEN_Msk);

  48.     /* Wait for HIRC clock ready */
  49.     CLK_WaitClockReady(CLK_STATUS_HIRCSTB_Msk);

  50.     /* Set core clock as 96MHz from PLL */
  51.     CLK_SetCoreClock(FREQ_96MHZ);

  52.     /* Set PCLK0/PCLK1 to HCLK/2 */
  53.     CLK->PCLKDIV = (CLK_PCLKDIV_APB0DIV_DIV2 | CLK_PCLKDIV_APB1DIV_DIV2);

  54.     /* Enable UART clock */
  55.     CLK_EnableModuleClock(UART0_MODULE);

  56.     /* Select UART clock source from HIRC */
  57.     CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UART0SEL_HIRC, CLK_CLKDIV0_UART0(1));

  58.     /* Update System Core Clock */
  59.     /* User can use SystemCoreClockUpdate() to calculate SystemCoreClock. */
  60.     SystemCoreClockUpdate();

  61.     /*----------------------------------------------------------------------*/
  62.     /* Init I/O Multi-function                                              */
  63.     /*----------------------------------------------------------------------*/
  64.     /* Set GPB multi-function pins for UART0 RXD and TXD */
  65.     SYS->GPB_MFPH = (SYS->GPB_MFPH & ~(SYS_GPB_MFPH_PB12MFP_Msk | SYS_GPB_MFPH_PB13MFP_Msk)) |
  66.                     (SYS_GPB_MFPH_PB12MFP_UART0_RXD | SYS_GPB_MFPH_PB13MFP_UART0_TXD);

  67.     /* Lock protected registers */
  68.     SYS_LockReg();
  69. }


  70. void rt_hw_board_init(void)
  71. {
  72. //#error "TODO 1: OS Tick Configuration."
  73.     /*
  74.      * TODO 1: OS Tick Configuration
  75.      * Enable the hardware timer and call the rt_os_tick_callback function
  76.      * periodically with the frequency RT_TICK_PER_SECOND.
  77.      */
  78. SYS_Init();
  79.     /* Call components board initial (use INIT_BOARD_EXPORT()) */
  80. #ifdef RT_USING_COMPONENTS_INIT
  81.     rt_components_board_init();
  82. #endif

  83. #if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
  84.     rt_system_heap_init(rt_heap_begin_get(), rt_heap_end_get());
  85. #endif
  86. }

  87. #ifdef RT_USING_CONSOLE

  88. static int uart_init(void)
  89. {
  90. //#error "TODO 2: Enable the hardware uart and config baudrate."
  91.         
  92.     /* Reset UART0 */
  93.     SYS_ResetModule(UART0_RST);

  94.     /* Configure UART0 and set UART0 baud rate */
  95.     UART_Open(UART0, 115200);
  96.         
  97.     return 0;
  98. }
  99. INIT_BOARD_EXPORT(uart_init);

  100. void rt_hw_console_output(const char *str)
  101. {
  102. //#error "TODO 3: Output the string 'str' through the uart."
  103. printf("%s",str);
  104. }

  105. #endif






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

  9. #include <rthw.h>
  10. #include <rtconfig.h>
  11. #include <stdio.h>
  12. #ifndef RT_USING_FINSH
  13. #error Please uncomment the line <#include "finsh_config.h"> in the rtconfig.h
  14. #endif

  15. #ifdef RT_USING_FINSH

  16. RT_WEAK char rt_hw_console_getchar(void)
  17. {
  18.     /* Note: the initial value of ch must < 0 */
  19.     int ch = -1;

  20. //#error "TODO 4: Read a char from the uart and assign it to 'ch'."
  21.                 ch=getchar();
  22.     return ch;
  23. }

  24. #endif /* RT_USING_FINSH */

配置选项如下
38740610d1e239c619.png





打赏榜单

21小跑堂 打赏了 20.00 元 2021-08-11
理由:恭喜通过原创文章审核!请多多加油哦!

巧克力娃娃 打赏了 1.00 元 2021-08-10
理由:感谢分享!

 楼主| gaoyang9992006 发表于 2021-8-6 19:35 | 显示全部楼层
新版的还是挺不错的, 不过如果按照老版本的方法做,肯定不行,新的确实很好用,对于小白,上手很容易。
yangxiaor520 发表于 2021-8-7 08:37 来自手机 | 显示全部楼层
谢谢分享
734774645 发表于 2021-8-9 22:58 | 显示全部楼层
感谢分享,回头试试看。
sparrow054 发表于 2021-8-10 13:05 | 显示全部楼层
看着挺不错,
对于新手,貌似跳过了一些东西,慢慢摸索
Fillmore 发表于 2021-8-10 14:02 | 显示全部楼层
顶  厉害了
幸福小强 发表于 2021-8-10 21:34 | 显示全部楼层
移植这么容易。
Charlene沙 发表于 2021-8-17 08:29 | 显示全部楼层
这个芯片跑系统非常合适,效率会提升很多呢
jiekou001 发表于 2023-1-12 16:06 | 显示全部楼层
按照RTT官方的移植说明移植,配置时钟与串口。
643757107 发表于 2023-1-12 17:17 | 显示全部楼层
这个操作看起来很容易的样子。
updownq 发表于 2023-2-2 12:22 | 显示全部楼层
RT-Thread  studio支持M471KI吗?
 楼主| gaoyang9992006 发表于 2023-2-2 14:10 | 显示全部楼层
支持的,支持大部分的新唐arm内核单片机。
mmbs 发表于 2023-2-7 21:09 | 显示全部楼层
RT-Thread Nano占用多大的内存?
OKAKAKO 发表于 2023-2-9 09:09 | 显示全部楼层
看着挺容易的,自己做做看吧
 楼主| gaoyang9992006 发表于 2023-2-9 09:15 | 显示全部楼层
OKAKAKO 发表于 2023-2-9 09:09
看着挺容易的,自己做做看吧

就是这个配置工程要勾选哪些要记住,主要要理清这个RTE配置器每一项对应的是什么,就好办了。
dongnanxibei 发表于 2023-9-27 19:49 | 显示全部楼层
从0创建,很少见。
huahuagg 发表于 2023-9-27 20:26 | 显示全部楼层
写的不错,给力。
小灵通2018 发表于 2023-9-27 21:56 | 显示全部楼层
轻松跑起来。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:如果你觉得我的分享或者答复还可以,请给我点赞,谢谢。

2052

主题

16403

帖子

222

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