Skip to content

Commit 21e5044

Browse files
committed
同步 nano-3.1.3-zip 的内容
1 parent 78ec1b7 commit 21e5044

File tree

410 files changed

+265593
-58
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

410 files changed

+265593
-58
lines changed

rt-thread/README.md

Lines changed: 36 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,62 @@
1-
# RT-Thread #
1+
# RT-Thread Nano 简介
22

3-
[中文页](README_zh.md) |
3+
RT-Thread Nano 是一个极简版的硬实时内核,它是由 C 语言开发,采用面向对象的编程思维,具有良好的代码风格,是一款可裁剪的、抢占式实时多任务的 RTOS。其内存资源占用极小,功能包括任务处理、软件定时器、信号量、邮箱和实时调度等相对完整的实时操作系统特性。适用于家电、消费电子、医疗设备、工控等领域大量使用的 32 位 ARM 入门级 MCU 的场合。
44

5-
[![GitHub](https://img.shields.io/github/license/RT-Thread/rt-thread.svg)](https://github.com/RT-Thread/rt-thread/blob/master/LICENSE)
6-
[![GitHub release](https://img.shields.io/github/release/RT-Thread/rt-thread.svg)](https://github.com/RT-Thread/rt-thread/releases)
7-
[![Build Status](https://travis-ci.org/RT-Thread/rt-thread.svg)](https://travis-ci.org/RT-Thread/rt-thread)
8-
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/RT-Thread/rt-thread?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
9-
[![GitHub pull-requests](https://img.shields.io/github/issues-pr/RT-Thread/rt-thread.svg)](https://github.com/RT-Thread/rt-thread/pulls)
10-
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](https://github.com/RT-Thread/rt-thread/pulls)
5+
下图是 RT-Thread Nano 的软件框图,包含支持的 CPU 架构与内核源码,还有可拆卸的 FinSH 组件:
116

12-
RT-Thread is an open source IoT operating system from China, which has strong scalability: from a tiny kernel running on a tiny core, for example ARM Cortex-M0, or Cortex-M3/4/7, to a rich feature system running on MIPS32, ARM Cortex-A8, ARM Cortex-A9 DualCore etc.
7+
![架构](docs/figures/framework.png)
138

14-
## Overview ##
9+
**支持架构**:ARM:Cortex M0/ M3/ M4/ M7 等、RISC-V 及其他。
1510

16-
RT-Thread RTOS like a traditional real-time operating system. The kernel has real-time multi-task scheduling, semaphore, mutex, mail box, message queue, signal etc. However, it has three different things:
11+
**功能**:线程管理、线程间同步与通信、时钟管理、中断管理、内存管理。
1712

18-
* Device Driver;
19-
* Component;
20-
* Dynamic Module
13+
## Nano 的特点
2114

22-
The device driver is more like a driver framework, UART, IIC, SPI, SDIO, USB device/host, EMAC, MTD NAND etc. The developer can easily add low level driver and board configuration, then combined with the upper framework, he/she can use lots of features.
15+
### 简单
2316

24-
The Component is a software concept upon RT-Thread kernel, for example a shell (finsh/msh shell), virtual file system (FAT, YAFFS, UFFS, ROM/RAM file system etc), TCP/IP protocol stack (lwIP), POSIX (thread) interface etc. One component must be a directory under RT-Thread/Components and one component can be descripted by a SConscript file (then be compiled and linked into the system).
17+
**1、下载简单**
2518

26-
The Dynamic Module, formerly named as User Applicaion (UA) is a dynamic loaded module or library, it can be compiled standalone without Kernel. Each Dynamic Module has its own object list to manage thread/semaphore/kernel object which was created or initialized inside this UA. More information about UA, please visit another [git repo](https://github.com/RT-Thread/rtthread-apps).
19+
RT-Thread Nano 以软件包的方式集成在 Keil MDK 与 CubeMX 中,可以直接在软件中下载 Nano 软件包获取源码,获取方式详见 [使用 KEIL MDK 移植 RT-Thread Nano](nano-port-keil/nano-port-keil.md)[使用 CubeMX 移植 RT-Thread Nano](nano-port-cube/nano-port-cube.md)
2720

28-
## Board Support Package ##
21+
同时也提供 [下载 Nano 源码压缩包]() 的途径,方便在其他开发环境移植 RT-Thread Nano,如 [使用 IAR 移植 RT-Thread Nano](nano-port-iar/nano-port-iar.md)
2922

30-
RT-Thread RTOS can support many architectures:
23+
**2、代码简单**
3124

32-
* ARM Cortex-M0
33-
* ARM Cortex-M3/M4/7
34-
* ARM Cortex-R4
35-
* ARM Cortex-A8/A9
36-
* ARM920T/ARM926 etc
37-
* MIPS32
38-
* x86
39-
* Andes
40-
* C-Sky
41-
* RISC-V
42-
* PowerPC
25+
与 RT-Thread 完整版不同的是,Nano 不含 Scons 构建系统,不需要 Kconfig 以及 Env 配置工具,也去除了完整版特有的 device 框架和组件,仅是一个纯净的内核。
4326

44-
## License ##
27+
**3、移植简单**
4528

46-
RT-Thread is Open Source software under the Apache License 2.0 since RT-Thread v3.1.1. License and copyright information can be found within the code.
29+
由于 Nano 的极简特性,使 Nano 的移植过程变得极为简单。添加 Nano 源码到工程,就已完成 90% 的移植工作。并且在 Keil MDK 与 Cube MX 中还提供了 Nano 的软件包,可以一键下载加入到工程。以下是使用不同开发环境时,可以选择移植 Nano 的方法:
4730

48-
/*
49-
* Copyright (c) 2006-2018, RT-Thread Development Team
50-
*
51-
* SPDX-License-Identifier: Apache-2.0
52-
*/
31+
- [使用 KEIL MDK 移植 RT-Thread Nano](nano-port-keil/nano-port-keil.md)
32+
- [使用 CubeMX 移植 RT-Thread Nano](nano-port-cube/nano-port-cube.md)
33+
- [使用 IAR 移植 RT-Thread Nano](nano-port-iar/nano-port-iar.md)
34+
- [移植 RT-Thread Nano 到 RISC-V](nano-port-gcc-riscv/nano-port-gcc-riscv.md)
5335

54-
Since 9th of September 2018, PRs submitted by the community may be merged into the main line only after signing the Contributor License Agreement(CLA).
36+
**4、使用简单**
5537

56-
## Usage ##
38+
RT-Thread Nano 在使用上也非常简单,带给开发者友好的开发体验。
5739

58-
RT-Thread RTOS uses [scons](http://www.scons.org) as building system. Therefore, please install scons and Python 2.7 firstly.
59-
So far, the RT-Thread scons building system support the command line compile or generate some IDE's project. There are some option varaibles in the scons building script (rtconfig.py):
40+
- 易裁剪:Nano 的配置文件为 rtconfig.h,该文件中列出了内核中的所有宏定义,有些默认没有打开,如需使用,打开即可。具体的配置可见 Nano 版块的 [RT-Thread Nano 配置](nano-config/nano-config.md) 教程。
41+
- 易添加 FinSH 组件:[FinSH 组件](../../programming-manual/finsh/finsh.md) 可以很方便的在 Nano 上进行移植,而不再依赖 device 框架,只需要对接两个必要的函数即可完成 [FinSH 移植](finsh-port/finsh-port.md)
42+
- 自选驱动库:可以使用厂商提供的固件驱动库,如 ST 的 STD 库、HAL 库、LL 库等,可以自行选择。
43+
- 完善的文档:包含 [内核基础](../../programming-manual/basic/basic.md)[线程管理 (例程)](../../programming-manual/thread/thread.md)[时钟管理 (例程)](../../programming-manual/timer/timer.md)[线程间同步 (例程)](../../programming-manual/ipc1/ipc1.md)[线程间通信 (例程)](../../programming-manual/ipc2/ipc2.md)[内存管理 (例程)](../../programming-manual/memory/memory.md)[中断管理](../../programming-manual/interrupt/interrupt.md) ,以及 Nano 版块的移植教程。
6044

61-
* ```CROSS_TOOL``` the compiler which you want to use, gcc/keil/iar.
62-
* ```EXEC_PATH``` the path of compiler.
45+
### 小巧
6346

64-
In SConstruct file:
47+
**资源占用小**:对 RAM 与 ROM 的开销非常小,在支持 semaphore 和 mailbox 特性,并运行两个线程 (main 线程 + idle 线程) 情况下,ROM 和 RAM 依然保持着极小的尺寸,RAM 占用约 1K 左右,ROM 占用 4K 左右。
6548

66-
```RTT_ROOT``` This variable is the root directory of RT-Thread RTOS. If you build the porting in the bsp directory, you can use the default setting. Also, you can set the root directory in ```RTT_ROOT``` environment variable and not modify SConstruct files.
49+
Nano 资源占用情况举例:在运行两个线程 (main 线程 + idle 线程) 情况下,ROM 和 RAM 依然保持着极小的尺寸。以下是基于 Cortex M3 的 MDK 工程编译结果(优化等级 3)。
6750

68-
When you set these variables correctly, you can use command:
51+
```
52+
Total RO Size (Code + RO Data) 4000 ( 3.91kB)
53+
Total RW Size (RW Data + ZI Data) 1168 ( 1.14kB)
54+
Total ROM Size (Code + RO Data + RW Data) 4092 ( 4.00kB)
55+
```
6956

70-
scons
57+
> 注:如果需要丰富的组件、驱动以及软件包等功能,则建议使用 [RT-Thread 完整版](../../index.md)
7158
72-
under BSP directory to simplely compile RT-Thread RTOS.
59+
### 开源免费(Apache 2.0)
7360

74-
If you want to generate the IDE's project file, you can use command:
61+
RT-Thread Nano 实时操作系统遵循 Apache 许可证 2.0 版本,实时操作系统内核及所有开源组件可以免费在商业产品中使用,不需要公布应用程序源码,没有潜在商业风险。
7562

76-
scons --target=mdk/mdk4/mdk5/iar/cb -s
77-
78-
to generate the project file.
79-
80-
NOTE: RT-Thread scons building system will tailor the system according to your rtconfig.h configuration header file. For example, if you disable the lwIP in the rtconfig.h by commenting the ```#define RT_USING_LWIP```, the generated project file should have no lwIP related files.
81-
82-
## Contribution ##
83-
84-
Please refer the contributors in the github. Thank all of RT-Thread Developers.

rt-thread/bsp/board.c

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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+
* 2017-07-24 Tanek the first version
9+
* 2018-11-12 Ernest Chen modify copyright
10+
*/
11+
12+
#include <stdint.h>
13+
#include <rthw.h>
14+
#include <rtthread.h>
15+
16+
#define _SCB_BASE (0xE000E010UL)
17+
#define _SYSTICK_CTRL (*(rt_uint32_t *)(_SCB_BASE + 0x0))
18+
#define _SYSTICK_LOAD (*(rt_uint32_t *)(_SCB_BASE + 0x4))
19+
#define _SYSTICK_VAL (*(rt_uint32_t *)(_SCB_BASE + 0x8))
20+
#define _SYSTICK_CALIB (*(rt_uint32_t *)(_SCB_BASE + 0xC))
21+
#define _SYSTICK_PRI (*(rt_uint8_t *)(0xE000ED23UL))
22+
23+
// Updates the variable SystemCoreClock and must be called
24+
// whenever the core clock is changed during program execution.
25+
extern void SystemCoreClockUpdate(void);
26+
27+
// Holds the system core clock, which is the system clock
28+
// frequency supplied to the SysTick timer and the processor
29+
// core clock.
30+
extern uint32_t SystemCoreClock;
31+
32+
static uint32_t _SysTick_Config(rt_uint32_t ticks)
33+
{
34+
if ((ticks - 1) > 0xFFFFFF)
35+
{
36+
return 1;
37+
}
38+
39+
_SYSTICK_LOAD = ticks - 1;
40+
_SYSTICK_PRI = 0xFF;
41+
_SYSTICK_VAL = 0;
42+
_SYSTICK_CTRL = 0x07;
43+
44+
return 0;
45+
}
46+
47+
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
48+
#define RT_HEAP_SIZE 1024
49+
static uint32_t rt_heap[RT_HEAP_SIZE]; // heap default size: 4K(1024 * 4)
50+
RT_WEAK void *rt_heap_begin_get(void)
51+
{
52+
return rt_heap;
53+
}
54+
55+
RT_WEAK void *rt_heap_end_get(void)
56+
{
57+
return rt_heap + RT_HEAP_SIZE;
58+
}
59+
#endif
60+
61+
/**
62+
* This function will initial your board.
63+
*/
64+
void rt_hw_board_init()
65+
{
66+
/* System Clock Update */
67+
SystemCoreClockUpdate();
68+
69+
/* System Tick Configuration */
70+
_SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
71+
72+
/* Call components board initial (use INIT_BOARD_EXPORT()) */
73+
#ifdef RT_USING_COMPONENTS_INIT
74+
rt_components_board_init();
75+
#endif
76+
77+
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
78+
rt_system_heap_init(rt_heap_begin_get(), rt_heap_end_get());
79+
#endif
80+
}
81+
82+
void SysTick_Handler(void)
83+
{
84+
/* enter interrupt */
85+
rt_interrupt_enter();
86+
87+
rt_tick_increase();
88+
89+
/* leave interrupt */
90+
rt_interrupt_leave();
91+
}

0 commit comments

Comments
 (0)