diff --git a/.gitee/ISSUE_TEMPLATE.zh-CN.md b/.gitee/ISSUE_TEMPLATE.zh-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..30cb1e84b52ad712c2c34def4a437dbac1cdeb6d --- /dev/null +++ b/.gitee/ISSUE_TEMPLATE.zh-CN.md @@ -0,0 +1,8 @@ +### 问题描述 + +除了问题描述,如有问题相关的网址和截图,也请附在此处 + +### 解决方法 + +描述你对该问题建议的解决方法 + diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..13a00fc959f8e5e25dd67436d26ed45088da9fea --- /dev/null +++ b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md @@ -0,0 +1,22 @@ + + +## 拉取/合并请求描述 + + + +- [ ] 本拉取/合并符合[文档中心 PR 提交规范](https://www.rt-thread.org/document/site/#/other/pr-rule/pr-rule) (符合请打勾,[x] 表示打钩) + +[ + + + +] + diff --git a/README.md b/README.md index f1d7637f004d4bdc46a05c4c719621d5e1ede5fd..08476d7c72335aeb12d392e21828a629e12bb782 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ ## ** 标准版本 ** -RT-Thread,全称是 Real Time-Thread,顾名思义,它是一个嵌入式实时多线程操作系统,基本属性之一是支持多任务,允许多个任务同时运行并不意味着处理器在同一时刻真地执行了多个任务。事实上,一个处理器核心在某一时刻只能运行一个任务,由于每次对一个任务的执行时间很短、任务与任务之间通过任务调度器进行非常快速地切换(调度器根据优先级决定此刻该执行的任务),给人造成多个任务在一个时刻同时运行的错觉。在 RT-Thread 系统中,任务是通过线程实现的,RT-Thread 中的线程调度器也就是以上提到的任务调度器。 +RT-Thread,全称是 Real Time-Thread,顾名思义,它是一个嵌入式实时多线程操作系统,基本属性之一是支持多任务,但允许多个任务同时运行并不意味着处理器在同一时刻真的执行了多个任务。事实上,一个处理器核心在某一时刻只能运行一个任务,由于每次对一个任务的执行时间很短、任务与任务之间通过任务调度器进行非常快速地切换(调度器根据优先级决定此刻该执行的任务),所以给人造成多个任务在一个时刻同时运行的错觉。在 RT-Thread 系统中,任务是通过线程实现的,RT-Thread 中的线程调度器也就是以上提到的任务调度器。 -RT-Thread 主要采用 C 语言编写,浅显易懂,方便移植。它把面向对象的设计方法应用到实时系统设计中,使得代码风格优雅、架构清晰、系统模块化并且可裁剪性非常好。针对资源受限的微控制器(MCU)系统,可通过方便易用的工具,裁剪出仅需要 3KB Flash、1.2KB RAM 内存资源的 NANO 版本(NANO 是 RT-Thread 官方于 2017 年 7 月份发布的一个极简版内核);而对于资源丰富的物联网设备,RT-Thread 又能使用在线的软件包管理工具,配合系统配置工具实现直观快速的模块化裁剪,无缝地导入丰富的软件功能包,实现类似 Android 的图形界面及触摸滑动效果、智能语音交互效果等复杂功能。 +RT-Thread 主要采用 C 语言编写,浅显易懂,方便移植。它把面向对象的设计方法应用到实时系统设计中,使得代码风格优雅、架构清晰、系统模块化并且可裁剪性非常好。针对资源受限的微控制器(MCU)系统,可通过方便易用的工具,裁剪出仅需要 3KB Flash、1.2KB RAM 内存资源的 NANO 版本(NANO 是 RT-Thread 官方于 2017 年 7 月份发布的一个极简版内核);而对于资源丰富的物联网设备,RT-Thread 又能使用在线的软件包管理工具,配合系统配置工具实现直观快速地模块化裁剪,无缝地导入丰富的软件功能包,实现类似 Android 的图形界面及触摸滑动效果、智能语音交互效果等复杂功能。 相较于 Linux 操作系统,RT-Thread 体积小,成本低,功耗低、启动快速,除此以外 RT-Thread 还具有实时性高、占用资源小等特点,非常适用于各种资源受限(如成本、功耗限制等)的场合。虽然 32 位 MCU 是它的主要运行平台,实际上很多带有 MMU、基于 ARM9、ARM11 甚至 Cortex-A 系列级别 CPU 的应用处理器在特定应用场合也适合使用 RT-Thread。 @@ -25,9 +25,9 @@ RT-Thread 主要采用 C 语言编写,浅显易懂,方便移植。它把面 ## ** Nano 版本 ** -RT-Thread Nano 是一个极简版的硬实时内核,它是由 C 语言开发,采用面向对象的编程思维,具有良好的代码风格,是一款可裁剪的、抢占式实时多任务的 RTOS。其内存资源占用极小,功能包括任务处理、软件定时器、信号量、邮箱和实时调度等相对完整的实时操作系统特性。适用于家电、消费电子、医疗设备、工控等领域大量使用的 32 位 ARM 入门级 MCU 的场合。 +RT-Thread Nano 是一个极简版的硬实时内核,它是由 C 语言开发,采用面向对象的编程思维,具有良好的代码风格,是一款可裁剪的、抢占式实时多任务的 RTOS。其内存资源占用极小,功能包括任务处理、软件定时器、信号量、邮箱和实时调度等相对完整的实时操作系统特性。适用于家电、消费电子、医疗设备、工控等领域大量使用 32 位 ARM 入门级 MCU 的场合。 -下图是 RT-Thread Nano 的软件框图,包含支持的 CPU 架构与内核源码,还有可拆卸的 FinSH 组件: +下图是 RT-Thread Nano 的软件框图,其中包含支持的 CPU 架构与内核源码,还有可拆卸的 FinSH 组件: ![架构](other/novice-guide/figures/framework.png) @@ -40,7 +40,7 @@ RT-Thread Nano 是一个极简版的硬实时内核,它是由 C 语言开发 RT-Thread Smart 是基于 RT-Thread 操作系统上的混合操作系统,简称为 rt-smart,它把应用从内核中独立出来,形成独立的用户态应用程序,并具备独立的地址空间(32 位系统上是 4G 的独立地址空间)。 -以下是 rt-smart 的整体结构框图,在硬件平台的基础上通过 MMU、系统调用的方式把整个系统分成了内核态及用户态。[更多...](/rt-thread-version/rt-thread-smart/rt-smart-quickstart/rt-smart-quickstart.md) +以下是 rt-smart 的整体结构框图,在硬件平台的基础上通过 MMU、系统调用的方式把整个系统分成了内核态及用户态。[更多...](/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/rt-smart-intro.md) ![Software_framework_diagram](other/novice-guide/figures/5.png) @@ -66,7 +66,7 @@ RT-Thread Smart 是基于 RT-Thread 操作系统上的混合操作系统,简 #### 快速上手 -推荐使用 [潘多拉开发板](https://item.taobao.com/item.htm?id=583527145598) 配套使用 [潘多拉开发板教程. pdf](https://www.rt-thread.org/document/site/tutorial/iot_board_tutorial.pdf),或者以下主流的学习板进行学习,不建议没有任何基础就将 RT-Thread 移植到一块开发板上。 +推荐使用 [潘多拉开发板](https://item.taobao.com/item.htm?id=583527145598) 配套使用 [潘多拉开发板教程](https://gitee.com/Armink/IoT_Board),或者以下主流的学习板进行学习,不建议没有任何基础就将 RT-Thread 移植到一块开发板上。 - [RT-Thread 潘多拉 STM32L475 上手指南](/rt-thread-version/rt-thread-standard/tutorial/quick-start/iot_board/quick-start.md) - [野火霸道 STM32F103 上手指南](/rt-thread-version/rt-thread-standard/tutorial/quick-start/stm32f103-fire-arbitrary/quick-start.md) @@ -76,13 +76,14 @@ RT-Thread Smart 是基于 RT-Thread 操作系统上的混合操作系统,简 - [正点原子阿波罗 STM32F429 上手指南](/rt-thread-version/rt-thread-standard/tutorial/quick-start/stm32f429-atk-apolo/quick-start.md) - [野火 I.MX RT1052 上手指南](/rt-thread-version/rt-thread-standard/tutorial/quick-start/imxrt1052-fire-mini/quick-start.md) - [正点原子 I.MX RT1052 号令者上手指南](/rt-thread-version/rt-thread-standard/tutorial/quick-start/imxrt1052-atk-commander/quick-start.md) -- [其他...](/rt-thread-version/rt-thread-standard/tutorial/quick-start/iot_board/quick-start.md) +- [OPENHW Core-V-MCU](/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/quick-start.md) +- [其他...](/rt-thread-version/rt-thread-standard/tutorial/quick-start/more.md) #### 内核学习 -[内核视频教程](https://www.rt-thread.org/page/video.html) +[内核视频教程](https://www.rt-thread.org/video.html) -[《内核实验手册》](https://www.rt-thread.org/document/site/rt-thread-version/rt-thread-standard/tutorial/experimental-manual/experimental-manual.pdf) +[《内核实验手册》](/rt-thread-version/rt-thread-standard/tutorial/experimental-manual/experimental-manual.pdf) ### ** 有 RTOS 经验 ** @@ -94,7 +95,7 @@ RT-Thread Smart 是基于 RT-Thread 操作系统上的混合操作系统,简 准备一块板子,根据 RT-Thread 支持的板子 BSP 进行 [快速上手](/rt-thread-version/rt-thread-standard/tutorial/quick-start/more.md),或者根据 [STM32 系列 BSP 制作教程进行移植](https://github.com/RT-Thread/rt-thread/blob/master/bsp/stm32/README.md)。 -如果使用 Ubuntu 进行开发,可以参考:[在 Ubuntu 下开发 RT-Thread](/rt-thread-version/rt-thread-standard/application-note/setup/qemu/windows/an0006-qemu-windows.md)。 +如果使用 Ubuntu 进行开发,可以参考:[在 Ubuntu 下开发 RT-Thread](/rt-thread-version/rt-thread-standard/application-note/setup/qemu/ubuntu/an0005-qemu-ubuntu.md)。 #### 编程指南 @@ -118,7 +119,7 @@ RT-Thread Smart 是基于 RT-Thread 操作系统上的混合操作系统,简 ### ** 开发工具 ** #### Env 工具 -Env 工具:Env 工具用于对源码功能进行配置或裁减,可以生成 MDK/IAR/GCC 工程,需要配合 MDK/IAR/GCC 使用,详见 [Env 用户手册](/development-tools/env/env.md)。 +Env 工具:Env 工具用于对源码功能进行配置或裁剪,可以生成 MDK/IAR/GCC 工程,需要配合 MDK/IAR/GCC 使用,详见 [Env 用户手册](/development-tools/env/env.md)。 #### RT-Thread IDE @@ -185,19 +186,19 @@ RT-Thread Studio :可以在 Studio 中下载源码包并创建 rt-thread 工 | 应用开发列表 | 应用开发列表 | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| [使用 Eclipse 开发 RT-Thread](/rt-thread-version/rt-thread-standard/application-note/setup/qemu/eclipse/an0020-qemu-eclipse) | [CmBacktrace应用](https://www.rt-thread.org/document/site/application-note/debug/cmbacktrace/an0013-CmBacktrace/) | -| [使用 VS Code 开发 RT-Thread](/rt-thread-version/rt-thread-standard/application-note/setup/qemu/vscode/an0021-qemu-vscode) | [在STM32 Nucleo 开发板上使用 RW007 WiFi 模块](https://www.rt-thread.org/document/site/application-note/packages/rw007_module_using/an0034-rw007-module-using) | -| [使用 Env 创建 RT-Thread 项目工程](/rt-thread-version/rt-thread-standard/application-note/setup/standard-project/an0017-standard-project) | [在 STM32L4 上应用 littlefs 文件系统](https://www.rt-thread.org/document/site/application-note/components/dfs/an0027-littlefs/) | -| [搭建RT-Thread项目框架](https://www.rt-thread.org/document/site/application-note/setup/standard-project/an0017-standard-project/) | [在潘多拉上使用 SFUD 操作 Flash](https://www.rt-thread.org/document/site/application-note/components/sfud/an0048-sfud/) | -| [在IoT Board上实现电源管理](https://www.rt-thread.org/document/site/application-note/system/pm/an0025-pm/) | [STM32 通用 Bootloader](https://www.rt-thread.org/document/site/application-note/system/rtboot/an0028-rtboot/) | -| [网络协议栈驱动移植](https://www.rt-thread.org/document/site/application-note/components/network/an0010-lwip-driver-porting/) | [wireshark 抓取 tls 数据包](https://www.rt-thread.org/document/site/application-note/packages/mbedtls_wireshark_sniffer/an0029-mbedtls_wireshark_sniffer) | -| [在STM32F429上应用网络功能](https://www.rt-thread.org/document/site/application-note/components/network/an0011-network-started/) | [在 STM32 上应用 C++](https://www.rt-thread.org/document/site/application-note/components/cplusplus/an0035-cpp/) | -| [在STM32F429上应用文件系统](https://www.rt-thread.org/document/site/application-note/components/dfs/an0012-dfs/) | [STM32 上使用 PWM](https://www.rt-thread.org/document/site/application-note/driver/pwm/an0037-rtthread-driver-pwm/) | -| [FreeModbus 应用笔记](https://www.rt-thread.org/document/site/application-note/packages/freemodbus/an0036-freemodbus/) | [STM32 上使用 USB Host 读写 U 盘](https://www.rt-thread.org/document/site/application-note/driver/usb/an0046-rtthread-driver-usbh/) | -| [应用AT组件连接ESP8266模块](https://www.rt-thread.org/document/site/application-note/components/at/an0014-at-client/) | [QEMU网络视频教程](https://www.rt-thread.org/document/site/tutorial/qemu-network/) | -| [多线程非阻塞网络编程](https://www.rt-thread.org/document/site/application-note/components/network/an0019-tcpclient-socket/) | [使用QEMU运行动态模块组件](https://www.rt-thread.org/document/site/application-note/components/dlmodule/an0023-dlmodule/) | - -[应用设计参考...](https://www.rt-thread.org/page/projects.html) +| [使用 Eclipse 开发 RT-Thread](/rt-thread-version/rt-thread-standard/application-note/setup/qemu/eclipse/an0020-qemu-eclipse) | [CmBacktrace应用](/rt-thread-version/rt-thread-standard/application-note/debug/cmbacktrace/an0013-CmBacktrace) | +| [使用 VS Code 开发 RT-Thread](/rt-thread-version/rt-thread-standard/application-note/setup/qemu/vscode/an0021-qemu-vscode) | [在STM32 Nucleo 开发板上使用 RW007 WiFi 模块](/rt-thread-version/rt-thread-standard/application-note/packages/rw007_module_using/an0034-rw007-module-using) | +| [使用 Env 创建 RT-Thread 项目工程](/rt-thread-version/rt-thread-standard/application-note/setup/standard-project/an0017-standard-project) | [在 STM32L4 上应用 littlefs 文件系统](/rt-thread-version/rt-thread-standard/application-note/components/dfs/an0027-littlefs) | +| [搭建RT-Thread项目框架](/rt-thread-version/rt-thread-standard/application-note/setup/standard-project/an0017-standard-project) | [在潘多拉上使用 SFUD 操作 Flash](/rt-thread-version/rt-thread-standard/application-note/components/sfud/an0048-sfud) | +| [在IoT Board上实现电源管理](/rt-thread-version/rt-thread-standard/application-note/system/pm/an0025-pm) | [STM32 通用 Bootloader](/rt-thread-version/rt-thread-standard/application-note/system/rtboot/an0028-rtboot) | +| [网络协议栈驱动移植](/rt-thread-version/rt-thread-standard/application-note/components/network/an0010-lwip-driver-porting) | [wireshark 抓取 tls 数据包](/rt-thread-version/rt-thread-standard/application-note/packages/mbedtls_wireshark_sniffer/an0029-mbedtls_wireshark_sniffer) | +| [在STM32F429上应用网络功能](/rt-thread-version/rt-thread-standard/application-note/components/network/an0011-network-started) | [在 STM32 上应用 C++](/rt-thread-version/rt-thread-standard/application-note/components/cplusplus/an0035-cpp) | +| [在STM32F429上应用文件系统](/rt-thread-version/rt-thread-standard/application-note/components/dfs/an0012-dfs) | [STM32 上使用 PWM](/rt-thread-version/rt-thread-standard/application-note/driver/pwm/an0037-rtthread-driver-pwm) | +| [FreeModbus 应用笔记](/rt-thread-version/rt-thread-standard/application-note/packages/freemodbus/an0036-freemodbus) | [STM32 上使用 USB Host 读写 U 盘](/rt-thread-version/rt-thread-standard/application-note/driver/usb/an0046-rtthread-driver-usbh) | +| [应用AT组件连接ESP8266模块](/rt-thread-version/rt-thread-standard/application-note/components/at/an0014-at-client) | [QEMU网络视频教程](/rt-thread-version/rt-thread-standard/tutorial/qemu-network/README) | +| [多线程非阻塞网络编程](/rt-thread-version/rt-thread-standard/application-note/components/network/an0019-tcpclient-socket) | [使用QEMU运行动态模块组件](/rt-thread-version/rt-thread-standard/application-note/components/dlmodule/an0023-dlmodule) | + +[应用设计参考...](https://www.rt-thread.org/projects.html) ## Demo 示例 @@ -210,14 +211,62 @@ RT-Thread Studio :可以在 Studio 中下载源码包并创建 rt-thread 工 | [基于RT-Thread的人体健康监测系统](https://mp.weixin.qq.com/s/ptiz9UFzbVH-jt2gNVvlHg) | [文件系统示例代码](https://github.com/RT-Thread-packages/filesystem-sample) | | [基于RT-Thread的激光雷达避障小车](https://mp.weixin.qq.com/s/rjKExoGqhI1cPErGogEHDQ) | [网络示例代码](https://github.com/RT-Thread-packages/network-sample) | | [基于RT-Thread的蓝牙遥控平衡小车](https://mp.weixin.qq.com/s/bslr8Z2vyoT5uOVNXsafjA) | | -| [蜂鸣器播放器](https://www.rt-thread.org/document/site/tutorial/beep-player/) | | -| [分布式温度监控系统](https://www.rt-thread.org/document/site/tutorial/temperature-system/) | | -| [智能车教程](https://www.rt-thread.org/document/site/tutorial/smart-car/) | | +| [蜂鸣器播放器](/rt-thread-version/rt-thread-standard/tutorial/beep-player/) | | +| [分布式温度监控系统](/rt-thread-version/rt-thread-standard/tutorial/temperature-system/) | | +| [智能车教程](/rt-thread-version/rt-thread-standard/tutorial/smart-car/) | | ## 代码贡献 | 开发指南 | 代码规范 | 提交代码 | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -| [软件包开发指南](https://www.rt-thread.org/document/site/development-guide/package/package/) | [RT-Thread编程风格](https://github.com/RT-Thread/rt-thread/blob/master/documentation/coding_style_cn.md) | [向RT-Thread贡献代码](https://www.rt-thread.org/document/site/development-guide/github/github/) | +| [软件包开发指南](/rt-thread-version/rt-thread-standard/development-guide/package/package) | [RT-Thread编程风格](https://gitee.com/rtthread/rt-thread/blob/master/documentation/contribution_guide/coding_style_cn.md) | [向RT-Thread贡献代码](/rt-thread-version/rt-thread-standard/development-guide/github/github) | | [STM32系列BSP制作教程](https://github.com/RT-Thread/rt-thread/blob/master/bsp/stm32/docs/STM32系列BSP制作教程.md) | [BSP开发规范](https://github.com/RT-Thread/rtthread-specification) | | -| [传感器驱动开发指南](https://www.rt-thread.org/document/site/development-guide/sensor/sensor_driver_development/) | +| [传感器驱动开发指南](/rt-thread-version/rt-thread-standard/development-guide/sensor/sensor_driver_development) | | | + +# 文档中心说明 + +[![License: Apache License 2.0](/_media/license-Apache2-0.svg)](https://github.com/RT-Thread/rt-thread/blob/master/LICENSE) +star +star +star +fork + + +为加强 RT-Thread 开源社区建设,加速完善 RT-Thread 中文文档中心内容,现将文档中心编辑权限予以开放,详情参见 PR 提交规范。欢迎社区小伙伴踊跃参与修改,提交 PR。本文档中心使用 docsify 搭建。 + +## 目录说明 + +如下是 RT-Thread 在线文档中心的主要目录说明: + +development-tools:RT-Thread Studio IDE 和开发辅助工具 Env 的文档。 + +rt-thread-version:RT-Thread 各种版本:标准版本、nano 版本、smart 版本。 + +```tree + ├─development-tools # 工具 + │ ├─_sidebar.md # 侧边导航栏 + │ ├─build-config-system # 构建相关 + │ ├─env # Env 工具 + │ └─rtthread-studio # Studio IDE + ├─rt-thread-version # RT-Thread 各版本 + │ ├─rt-thread-nano # rt-thread nano 版本 + │ │ └─_sidebar.md # 侧边导航栏 + │ ├─rt-thread-smart # rt-thread smart 版本 + │ │ └─_sidebar.md # 侧边导航栏 + │ └─rt-thread-standard # rt-thread 标准版本 + │ ├─_sidebar.md # 侧边导航栏 + │ ├─application-note # 应用笔记 + │ ├─development-guide # 开发指南 + │ ├─packages-manual # 软件包指南 + │ ├─programming-manual # 编程手册 + │ └─tutorial # 小项目教程系列 + └─other + └─novice-guide # 新手入门 +``` + +## 许可协议 + +![知识共享许可协议](../../_media/creativecommons.png)
本作品采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可。 + + + diff --git a/_coverpage.md b/_coverpage.md index f56ad978d747b423e74a89b0fe9884b78a84d450..25becfdd7b4702ad27ebb57dc4969b498fffab44 100644 --- a/_coverpage.md +++ b/_coverpage.md @@ -5,5 +5,5 @@ [新手指导](/other/novice-guide/README.md) [标准版本](/rt-thread-version/rt-thread-standard/README.md) [Nano版本](/rt-thread-version/rt-thread-nano/an0038-nano-introduction.md) -[Smart版本](/rt-thread-version/rt-thread-smart/rt-smart-quickstart/rt-smart-quickstart.md) +[Smart版本](/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/rt-smart-intro.md) [开发工具](/development-tools/rtthread-studio/README.md) diff --git a/development-tools/_navbar.md b/development-tools/_navbar.md index 0cc217aab651011cd06dece91cc44b83f491691c..a239082cb8dc78270d11ddef7a282ee983da2250 100644 --- a/development-tools/_navbar.md +++ b/development-tools/_navbar.md @@ -8,7 +8,7 @@ * [新手指导](/other/novice-guide/README.md) * [标准版本](/rt-thread-version/rt-thread-standard/README.md) * [Nano 版本](/rt-thread-version/rt-thread-nano/an0038-nano-introduction.md) -* [Smart 版本](/rt-thread-version/rt-thread-smart/rt-smart-quickstart/rt-smart-quickstart.md) +* [Smart 版本](/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/rt-smart-intro.md) * [开发工具](/development-tools/rtthread-studio/README.md) diff --git a/development-tools/_sidebar.md b/development-tools/_sidebar.md index 6b066103b5d77e55bc3c1db8a01a5eeb17393b79..b5ef088b1ede0ff3be62e798fbc541d7495baca7 100644 --- a/development-tools/_sidebar.md +++ b/development-tools/_sidebar.md @@ -22,7 +22,6 @@ - [其它驱动](/development-tools/rtthread-studio/drivers/cubemx/rtthread-studio-cubemx.md) - [精彩项目集合](/development-tools/rtthread-studio/applications/project-collection/project-collection.md) - [精彩文章集合](/development-tools/rtthread-studio/applications/forum-article/forum-article.md) - - [精彩博客推荐](/development-tools/rtthread-studio/applications/user-blog/user-blog.md) - [常见问题](/development-tools/rtthread-studio/faq/studio-faq.md) - [更新日志](/development-tools/rtthread-studio/changelog/changelog.md) - RT-Thread构建与配置系统 diff --git a/development-tools/build-config-system/SCons.md b/development-tools/build-config-system/SCons.md index 633503df1e3f0dc98c7b3bf61c09d634b31532c4..98f8248b5b8d53a312533bcdda80ffba10f66a92 100644 --- a/development-tools/build-config-system/SCons.md +++ b/development-tools/build-config-system/SCons.md @@ -185,6 +185,18 @@ er\inc -ILibraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x -IF:\Project\git\rt-thre ... ``` +### 3.8 scons --buildlib + +使用指令 scons --buildlib=xxx,其中 xxx 为 Group 的名字。 + +以 bsp/qemu-vexpress-a9 为例,在其 applications 目录有定义 Sconsript: + +![Group name](figures/1.png) + +那么就可以输入 scons --buildlib=Applications,就可以将 Applications 这个 group 定义的 C 文件编译打包成一个静态库,输出也是位于 bsp 的目录中。 + +![输出结果](figures/2.png) + ## 4 SCons 函数 本章节将介绍在使用编写 SConscript 脚本中常用的函数,包含 SCons 原生标准函数以及RT-Thread扩展的函数。关于 SCons 原生标准函数,在 [SCons](http://www.scons.org/doc/production/HTML/scons-user/index.html) 的网站上可以找到详细的 SCons 原生函数介绍。 @@ -193,11 +205,11 @@ er\inc -ILibraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x -IF:\Project\git\rt-thre #### 4.1.1 Import(vars) -导入其他脚本定义的vars +导入其他脚本定义的 vars ,这里的 vars 仅仅是一个变量名,它是一个字符串,其代表的可以是一个变量,也可以是一个变量列表 #### 4.1.2 Export(vars) -导出vars,以供Import函数在其他SCons脚本使用 +导出 vars ,以供 Import 函数在其他 SCons 脚本使用,同样,这里的 vars 仅仅是一个变量的名字,是一个字符串 #### 4.1.3 SConscript(scripts, \[exports, variant\_dir, duplicate]) @@ -212,7 +224,7 @@ er\inc -ILibraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x -IF:\Project\git\rt-thre #### 4.1.4 Glob(pattern) -返回参与构建的对象,对象满足pattern模式匹配的列表。例如,获取当前Sconscript所在路径下的所有 .c 文件: +返回参与构建的对象,对象满足 pattern 模式匹配的列表。例如,获取当前 Sconscript 所在路径下的所有 .c 文件: ```python src = Glob('*.c') @@ -220,7 +232,7 @@ src = Glob('*.c') #### 4.1.5 IsDefined(depend) -判断宏是否被定义 参数: depend:宏或宏列表 返回值:已定义为True,否则为False +判断宏是否被定义 参数: depend:宏或宏列表 返回值:已定义为 True,否则为 False #### 4.1.6 Split(str) @@ -253,7 +265,7 @@ src = Glob('shell.c') #### 4.2.2 DefineGroup(name, src, depend, \*\*parameters) -定义一个参与构建的Group,并作为参与 Scons 构建的对象返回。Group 可以是一个目录(下的文件或子目录),也是后续一些 IDE 工程文件中的一个 Group 或文件夹。 +定义一个参与构建的 Group ,并作为参与 Scons 构建的对象返回。Group 可以是一个目录(下的文件或子目录),也是后续一些 IDE 工程文件中的一个 Group 或文件夹。 | **参数** | **描述** | | ---------- | ------------------------------------------------------------ | @@ -304,11 +316,11 @@ if GetDepend('MSH_USING_BUILT_IN_COMMANDS'): # 判断是否启用MSH的内建命 #### 4.2.8 GlobSubDir(sub_dir, ext_name) -对目录下所有文件(包含子目录)进行Glob +对目录下所有文件(包含子目录)进行 Glob #### 4.2.9 BuildPackage(package) -按照json提供的格式,定义一个Group。 参数: package:json文件 +按照 json 提供的格式,定义一个 Group。 参数: package:json 文件 ### 4.3 Python 函数 @@ -360,7 +372,7 @@ Return('group') # 将当前脚本指定的构建对象返回上级SCons脚本 2. 头文件路径的参数不是必选项,如果不想添加头文件目录,就不需要填写 `CPPPATH` 参数 -3. 最后一行使用 DefineGroup 创建一个名为 Finsh 的组,这个组也就对应 MDK 或者 IAR 中的分组。这个组的源代码文件为 src 指定的文件,如果depend 为空表示该组不依赖任何 rtconfig.h 的宏。 +3. 最后一行使用 DefineGroup 创建一个名为 Finsh 的组,这个组也就对应 MDK 或者 IAR 中的分组。这个组的源代码文件为 src 指定的文件,如果 depend 为空表示该组不依赖任何 rtconfig.h 的宏。 4. `CPPPATH =CPPPATH` 表示将当前路径添加到系统的头文件路径中。左边的 CPPPATH 是 DefineGroup 中内置参数,表示头文件路径。右边的 CPPPATH 是本文件上面一行定义的。这样我们就可以在其他源码中引用 drivers 目录下的头文件了。 diff --git a/development-tools/build-config-system/figures/1.png b/development-tools/build-config-system/figures/1.png new file mode 100644 index 0000000000000000000000000000000000000000..1487d0b628a34241828db76527d544899a2caa08 Binary files /dev/null and b/development-tools/build-config-system/figures/1.png differ diff --git a/development-tools/build-config-system/figures/2.png b/development-tools/build-config-system/figures/2.png new file mode 100644 index 0000000000000000000000000000000000000000..2dc05bdc1df71bfa1feed59641a59a626ba6a9df Binary files /dev/null and b/development-tools/build-config-system/figures/2.png differ diff --git a/development-tools/env/env.md b/development-tools/env/env.md index 256a7c3c7a7d9edc22c28cd9deaa3bb0d70fffdb..32acaedc1ae9c2c1e1c0b7f92b14bc618009f215 100644 --- a/development-tools/env/env.md +++ b/development-tools/env/env.md @@ -18,7 +18,7 @@ Env 是 RT-Thread 推出的开发辅助工具,针对基于 RT-Thread 操作系 Env 工具包含了 RT-Thread 源代码开发编译环境和软件包管理系统。 -- 从 RT-Thread 官网下载 [Env 工具](https://www.rt-thread.org/page/download.html)。 +- 从 RT-Thread 官网下载 [Env 工具](https://www.rt-thread.org/download.html)。 - 在电脑上装好 git,软件包管理功能需要 git 的支持。git 的下载地址为`https://git-scm.com/downloads`,根据向导正确安装 git,并将 git 添加到系统环境变量。 - 注意在工作环境中,所有的路径都不可以有中文字符或者空格。 @@ -76,7 +76,7 @@ scons --target=mdk4 scons --target=mdk5 ``` -更多 scons 教程,请参考 [《Scons 构建工具》](../scons/scons.md) +更多 scons 教程,请参考 [《Scons 构建工具》](../build-config-system/SCons.md) ### BSP 配置:menuconfig diff --git a/development-tools/rtthread-studio/applications/thread/rtthread-studio-thread.md b/development-tools/rtthread-studio/applications/thread/rtthread-studio-thread.md index 7f9ea3378fec70c8e60e0a3af082ee2783621ff2..e6f9353d94a678f114b23f63cbd322823bb0878f 100644 --- a/development-tools/rtthread-studio/applications/thread/rtthread-studio-thread.md +++ b/development-tools/rtthread-studio/applications/thread/rtthread-studio-thread.md @@ -139,4 +139,4 @@ int main(void) 从终端输出的信息可以看出,创建的第一个线程已经成功运行了。 -更多关于线程操作和示例请参考 [线程管理](https://www.rt-thread.org/document/site/programming-manual/thread/thread/) +更多关于线程操作和示例请参考 [线程管理](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/thread/thread) diff --git a/development-tools/rtthread-studio/applications/uart/rtthread-studio-uart.md b/development-tools/rtthread-studio/applications/uart/rtthread-studio-uart.md index 60a0ad78950e8b50353234ecaefb1e3a59534e5b..cfe8678f4572d8295e534e278205c79e209a474f 100644 --- a/development-tools/rtthread-studio/applications/uart/rtthread-studio-uart.md +++ b/development-tools/rtthread-studio/applications/uart/rtthread-studio-uart.md @@ -51,7 +51,7 @@ rt_device_t rt_device_find(const char* name); 当需要使用的设备成功注册到系统中时,该设备就可以直接通过系统提供的接口来进行访问了。 -例如通用设备可以使用 `rt_device_read`、`rt_device_write` 等函数来进行数据的传输, I2C 设备可以使用 `rt_i2c_transfer` 等函数进行数据传输。更多设备相关的 API 请查看 [设备与驱动程序](https://www.rt-thread.org/document/site/programming-manual/device/device/) 中对应的设备。 +例如通用设备可以使用 `rt_device_read`、`rt_device_write` 等函数来进行数据的传输, I2C 设备可以使用 `rt_i2c_transfer` 等函数进行数据传输。更多设备相关的 API 请查看 [设备与驱动程序](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/device) 中对应的设备。 本例中需要使用的是串口 2,在 `application` 目录下新建 `my_uart.c` 源文件,如下图所示 diff --git a/development-tools/rtthread-studio/applications/user-blog/.keep b/development-tools/rtthread-studio/applications/user-blog/.keep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/development-tools/rtthread-studio/applications/user-blog/user-blog.md b/development-tools/rtthread-studio/applications/user-blog/user-blog.md deleted file mode 100644 index 15585f12ec983bf5097a1f2c0ae71c6c1577e780..0000000000000000000000000000000000000000 --- a/development-tools/rtthread-studio/applications/user-blog/user-blog.md +++ /dev/null @@ -1,3 +0,0 @@ - -# 精彩博客推荐 -[2021年度CSDN & RT-Thread社区之星! 一个专注于物联网嵌入式架构设计的攻城狮!](https://blog.csdn.net/szullc) diff --git a/development-tools/rtthread-studio/changelog/changelog.md b/development-tools/rtthread-studio/changelog/changelog.md index 795d0113276a8f7b030e886f69eafac74fdb7ff4..3312af0ca0d7ef7c389a9183ebcc691bbfe306f1 100644 --- a/development-tools/rtthread-studio/changelog/changelog.md +++ b/development-tools/rtthread-studio/changelog/changelog.md @@ -1,5 +1,20 @@ # 更新日志 +##### [V2.2.6更新发布](https://club.rt-thread.org/ask/article/231be515bd217054.html) + +- 新增工程添加右键菜单可呼出 ENV +- 新增创建工程时检查当前工程的工具链配置是否存在 +- 新增支持英飞凌下载调试功能 +- 修复基于芯片创建工程编译不过的问题 +- 修复 RT-Thread Settings 部分软件包无法添加或显示异常 +- 修复 Renesas 其他芯片无法使用 RA Configure Settings 问题 +- 修复在线教程、在线设计参考打开地址不正确的问题 +- 修复同步 scons 配置到工程没有根据当前工程所用工具链同步 cconfig.h 文件内容的问题 +- 修复欢迎页显示不正确的问题 +- 根据文档中心 FAQ 同步每日提示最新内容 +- 优化支持同时查看 Markdown 文档和代码编辑 +- 升级 studio 内置 env(此功能需重新下载安装新版本,在线升级版本不可用) + ##### [V2.2.5更新发布](https://club.rt-thread.org/ask/article/541e73317e137d4b.html) - 修复切换工具链后没有更新 cconfig.h 的问题 diff --git a/development-tools/rtthread-studio/drivers/eth/rtthread-studio-eth.md b/development-tools/rtthread-studio/drivers/eth/rtthread-studio-eth.md index 3a7c7a75284ec28c646e80d09b77e60da2115ddc..262f701c68c08befbf8a0d196695b6e55fa50909 100644 --- a/development-tools/rtthread-studio/drivers/eth/rtthread-studio-eth.md +++ b/development-tools/rtthread-studio/drivers/eth/rtthread-studio-eth.md @@ -177,4 +177,4 @@ ping www.baidu.com ## 注意事项 -- 本例中只配置了 `lwIP` 协议栈以及 `ETH` 相关的驱动,更多关于 `RT-Thread` 网络部分的使用及介绍可以参考 [netdev 网卡](https://www.rt-thread.org/document/site/programming-manual/netdev/netdev/),[SAL套接字抽象层](https://www.rt-thread.org/document/site/programming-manual/sal/sal/)。 +- 本例中只配置了 `lwIP` 协议栈以及 `ETH` 相关的驱动,更多关于 `RT-Thread` 网络部分的使用及介绍可以参考 [netdev 网卡](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/netdev/netdev),[SAL套接字抽象层](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/sal/sal)。 diff --git a/development-tools/rtthread-studio/drivers/pin/rtthread-studio-pin.md b/development-tools/rtthread-studio/drivers/pin/rtthread-studio-pin.md index dcbaea58a26c7bd874c5d0efa370f884b6886d31..9de3f69a9084b9e3473e8e6931f8ecd081b4b504 100644 --- a/development-tools/rtthread-studio/drivers/pin/rtthread-studio-pin.md +++ b/development-tools/rtthread-studio/drivers/pin/rtthread-studio-pin.md @@ -66,4 +66,4 @@ int main(void) ![pin-device](figures/pin-device.png) -PIN 设备的更多使用说明请参考 [PIN 设备](https://www.rt-thread.org/document/site/programming-manual/device/pin/pin/) +PIN 设备的更多使用说明请参考 [PIN 设备](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/pin/pin) diff --git a/development-tools/rtthread-studio/drivers/soft-i2c/rtthread-studio-soft-i2c.md b/development-tools/rtthread-studio/drivers/soft-i2c/rtthread-studio-soft-i2c.md index f8a9d7c1073ade3f831b4f550b7a932d684c3622..c12d53c09d8153b7e0b8a607a67a0c37bb4f2b5c 100644 --- a/development-tools/rtthread-studio/drivers/soft-i2c/rtthread-studio-soft-i2c.md +++ b/development-tools/rtthread-studio/drivers/soft-i2c/rtthread-studio-soft-i2c.md @@ -81,7 +81,7 @@ RT-Thread Setting ![list_device](figures/list_device.png) -更多 I2C 总线的应用请参考 [I2C 总线设备应用示例](https://www.rt-thread.org/document/site/programming-manual/device/i2c/i2c/#i2c_4) +更多 I2C 总线的应用请参考 [I2C 总线设备应用示例](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/i2c/i2c) ## 注意事项 diff --git a/development-tools/rtthread-studio/drivers/spi/rtthread-studio-spi.md b/development-tools/rtthread-studio/drivers/spi/rtthread-studio-spi.md index 5e68361bc47114af0479245e714387cc4948a530..8a0c109dcc056b1a77f1cacaa88de3aaa77227d7 100644 --- a/development-tools/rtthread-studio/drivers/spi/rtthread-studio-spi.md +++ b/development-tools/rtthread-studio/drivers/spi/rtthread-studio-spi.md @@ -128,4 +128,4 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) > 提示:这里只是注册了一个 SPI 总线设备,SPI 从设备的挂载请参考 [挂载 SPI 从设备](https://www.rt-thread.org/document/site/programming-manual/device/spi/spi/#spi_2) -更多关于 SPI 总线的使用请参考 [SPI 总线设备](https://www.rt-thread.org/document/site/programming-manual/device/spi/spi/)。 +更多关于 SPI 总线的使用请参考 [SPI 总线设备](https://www.rt-thread.org/document/site/#/development-tools/rtthread-studio/drivers/spi/rtthread-studio-spi)。 diff --git a/development-tools/rtthread-studio/drivers/uart/v4.0.2/rtthread-studio-uart-v4.0.2.md b/development-tools/rtthread-studio/drivers/uart/v4.0.2/rtthread-studio-uart-v4.0.2.md index 09357cc603e49e6dced111b2eba264546e0a2dda..e907ca4e6e99a4c33c832745048d234741bf5a41 100644 --- a/development-tools/rtthread-studio/drivers/uart/v4.0.2/rtthread-studio-uart-v4.0.2.md +++ b/development-tools/rtthread-studio/drivers/uart/v4.0.2/rtthread-studio-uart-v4.0.2.md @@ -153,7 +153,7 @@ RT-Thread Setting ![dma-config](figures/dma-config.png) -将 [DMA 接收及轮询发送](https://www.rt-thread.org/document/site/programming-manual/device/uart/uart/#dma) 章节中的DMA 的测试代码添加到工程中 +将 [DMA 接收及轮询发送](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/uart/uart_v1/uart?id=dma-%e6%8e%a5%e6%94%b6%e5%8f%8a%e8%bd%ae%e8%af%a2%e5%8f%91%e9%80%81) 章节中的DMA 的测试代码添加到工程中 编译并下载程序,在控制台中输入 `uart_dma_sample` 命令,并使用 USB 转串口线连接串口 2,在串口 2 中可以看到如下打印信息 @@ -161,4 +161,4 @@ RT-Thread Setting 测试程序已经成功使用 DMA 进行了接收。 -更多关于串口的使用请查看 [UART设备](https://www.rt-thread.org/document/site/programming-manual/device/uart/uart/) +更多关于串口的使用请查看 [UART设备](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/uart/uart_v1/uart) diff --git a/development-tools/rtthread-studio/um/studio-user-begin.md b/development-tools/rtthread-studio/um/studio-user-begin.md index df69fdfadf5448351891dcd3c41aa4089ef3fbe0..2d43a37d174578a04c9826aab38de4b8be1335e4 100644 --- a/development-tools/rtthread-studio/um/studio-user-begin.md +++ b/development-tools/rtthread-studio/um/studio-user-begin.md @@ -2,7 +2,7 @@ ### 下载 RT-Thread Studio 安装包 -访问官网 [RT-Thread Studio 下载地址](https://www.rt-thread.org/page/studio.html),在官网下载最新的 RT-Thread Studio 软件安装包。 +访问官网 [RT-Thread Studio 下载地址](https://www.rt-thread.org/studio.html),在官网下载最新的 RT-Thread Studio 软件安装包。 ### 安装 RT-Thread Studio @@ -76,7 +76,7 @@ RT-Thread 的源码包,主要包括 RT-Thread 完整版本,Nano 版本,以 #### ToolChain_Support_Packages -交叉编译工具链的支持,目前支持 ARM 和 RISC-V 以及 ARM-LIUNX +交叉编译工具链的支持,目前支持 ARM 和 RISC-V 以及 ARM-LINUX ![image-20210825231231207](figures/image-20210825231231207.png) @@ -182,4 +182,4 @@ RT-Thread 的源码包,主要包括 RT-Thread 完整版本,Nano 版本,以 ## 视频教程 -访问官网 [RT-Thread Studio 视频教程](https://www.rt-thread.org/page/video.html),在官网观看视频教程。 +访问官网 [RT-Thread Studio 视频教程](https://www.rt-thread.org/video.html),在官网观看视频教程。 diff --git a/index.html b/index.html index b92ec0f064530e86ac3ea2aeba5c1e3f78fc0c40..c2e4434f3eacaf665aa7149592c8d33053d7b901 100644 --- a/index.html +++ b/index.html @@ -67,7 +67,7 @@ '/rt-thread-version/rt-thread-smart/.*/_sidebar.md': '/rt-thread-version/rt-thread-smart/_sidebar.md', '/rt-thread-version/rt-thread-standard/.*/_sidebar.md': '/rt-thread-version/rt-thread-standard/_sidebar.md', '/development-tools/.*/_sidebar.md': '/development-tools/_sidebar.md', - '/other/.*/_navbar.md': '/other/_sidebar.md', + '/other/.*/_sidebar.md': '/other/_sidebar.md', '/rt-thread-version/rt-thread-nano/.*/_navbar.md': '/rt-thread-version/rt-thread-nano/_navbar.md', '/rt-thread-version/rt-thread-smart/.*/_navbar.md': '/rt-thread-version/rt-thread-smart/_navbar.md', '/rt-thread-version/rt-thread-standard/.*/_navbar.md': '/rt-thread-version/rt-thread-standard/_navbar.md', diff --git a/other/_navbar.md b/other/_navbar.md index 0cc217aab651011cd06dece91cc44b83f491691c..a239082cb8dc78270d11ddef7a282ee983da2250 100644 --- a/other/_navbar.md +++ b/other/_navbar.md @@ -8,7 +8,7 @@ * [新手指导](/other/novice-guide/README.md) * [标准版本](/rt-thread-version/rt-thread-standard/README.md) * [Nano 版本](/rt-thread-version/rt-thread-nano/an0038-nano-introduction.md) -* [Smart 版本](/rt-thread-version/rt-thread-smart/rt-smart-quickstart/rt-smart-quickstart.md) +* [Smart 版本](/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/rt-smart-intro.md) * [开发工具](/development-tools/rtthread-studio/README.md) diff --git a/other/novice-guide/README.md b/other/novice-guide/README.md index 17b6a89e7fc9eaec95337a7ee7a41006ac89bfdf..c62c1381ed2cead68ecf7098a05d4f3c51fc948d 100644 --- a/other/novice-guide/README.md +++ b/other/novice-guide/README.md @@ -13,9 +13,9 @@ ## ** 标准版本 ** -RT-Thread,全称是 Real Time-Thread,顾名思义,它是一个嵌入式实时多线程操作系统,基本属性之一是支持多任务,允许多个任务同时运行并不意味着处理器在同一时刻真地执行了多个任务。事实上,一个处理器核心在某一时刻只能运行一个任务,由于每次对一个任务的执行时间很短、任务与任务之间通过任务调度器进行非常快速地切换(调度器根据优先级决定此刻该执行的任务),给人造成多个任务在一个时刻同时运行的错觉。在 RT-Thread 系统中,任务是通过线程实现的,RT-Thread 中的线程调度器也就是以上提到的任务调度器。 +RT-Thread,全称是 Real Time-Thread,顾名思义,它是一个嵌入式实时多线程操作系统,基本属性之一是支持多任务,但允许多个任务同时运行并不意味着处理器在同一时刻真的执行了多个任务。事实上,一个处理器核心在某一时刻只能运行一个任务,由于每次对一个任务的执行时间很短、任务与任务之间通过任务调度器进行非常快速地切换(调度器根据优先级决定此刻该执行的任务),所以给人造成多个任务在一个时刻同时运行的错觉。在 RT-Thread 系统中,任务是通过线程实现的,RT-Thread 中的线程调度器也就是以上提到的任务调度器。 -RT-Thread 主要采用 C 语言编写,浅显易懂,方便移植。它把面向对象的设计方法应用到实时系统设计中,使得代码风格优雅、架构清晰、系统模块化并且可裁剪性非常好。针对资源受限的微控制器(MCU)系统,可通过方便易用的工具,裁剪出仅需要 3KB Flash、1.2KB RAM 内存资源的 NANO 版本(NANO 是 RT-Thread 官方于 2017 年 7 月份发布的一个极简版内核);而对于资源丰富的物联网设备,RT-Thread 又能使用在线的软件包管理工具,配合系统配置工具实现直观快速的模块化裁剪,无缝地导入丰富的软件功能包,实现类似 Android 的图形界面及触摸滑动效果、智能语音交互效果等复杂功能。 +RT-Thread 主要采用 C 语言编写,浅显易懂,方便移植。它把面向对象的设计方法应用到实时系统设计中,使得代码风格优雅、架构清晰、系统模块化并且可裁剪性非常好。针对资源受限的微控制器(MCU)系统,可通过方便易用的工具,裁剪出仅需要 3KB Flash、1.2KB RAM 内存资源的 NANO 版本(NANO 是 RT-Thread 官方于 2017 年 7 月份发布的一个极简版内核);而对于资源丰富的物联网设备,RT-Thread 又能使用在线的软件包管理工具,配合系统配置工具实现直观快速地模块化裁剪,无缝地导入丰富的软件功能包,实现类似 Android 的图形界面及触摸滑动效果、智能语音交互效果等复杂功能。 相较于 Linux 操作系统,RT-Thread 体积小,成本低,功耗低、启动快速,除此以外 RT-Thread 还具有实时性高、占用资源小等特点,非常适用于各种资源受限(如成本、功耗限制等)的场合。虽然 32 位 MCU 是它的主要运行平台,实际上很多带有 MMU、基于 ARM9、ARM11 甚至 Cortex-A 系列级别 CPU 的应用处理器在特定应用场合也适合使用 RT-Thread。 @@ -25,9 +25,9 @@ RT-Thread 主要采用 C 语言编写,浅显易懂,方便移植。它把面 ## ** Nano 版本 ** -RT-Thread Nano 是一个极简版的硬实时内核,它是由 C 语言开发,采用面向对象的编程思维,具有良好的代码风格,是一款可裁剪的、抢占式实时多任务的 RTOS。其内存资源占用极小,功能包括任务处理、软件定时器、信号量、邮箱和实时调度等相对完整的实时操作系统特性。适用于家电、消费电子、医疗设备、工控等领域大量使用的 32 位 ARM 入门级 MCU 的场合。 +RT-Thread Nano 是一个极简版的硬实时内核,它是由 C 语言开发,采用面向对象的编程思维,具有良好的代码风格,是一款可裁剪的、抢占式实时多任务的 RTOS。其内存资源占用极小,功能包括任务处理、软件定时器、信号量、邮箱和实时调度等相对完整的实时操作系统特性。适用于家电、消费电子、医疗设备、工控等领域大量使用 32 位 ARM 入门级 MCU 的场合。 -下图是 RT-Thread Nano 的软件框图,包含支持的 CPU 架构与内核源码,还有可拆卸的 FinSH 组件: +下图是 RT-Thread Nano 的软件框图,其中包含支持的 CPU 架构与内核源码,还有可拆卸的 FinSH 组件: ![架构](figures/framework.png) @@ -40,7 +40,7 @@ RT-Thread Nano 是一个极简版的硬实时内核,它是由 C 语言开发 RT-Thread Smart 是基于 RT-Thread 操作系统上的混合操作系统,简称为 rt-smart,它把应用从内核中独立出来,形成独立的用户态应用程序,并具备独立的地址空间(32 位系统上是 4G 的独立地址空间)。 -以下是 rt-smart 的整体结构框图,在硬件平台的基础上通过 MMU、系统调用的方式把整个系统分成了内核态及用户态。[更多...](/rt-thread-version/rt-thread-smart/rt-smart-quickstart/rt-smart-quickstart.md) +以下是 rt-smart 的整体结构框图,在硬件平台的基础上通过 MMU、系统调用的方式把整个系统分成了内核态及用户态。[更多...](/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/rt-smart-intro.md) ![Software_framework_diagram](figures/5.png) @@ -66,7 +66,7 @@ RT-Thread Smart 是基于 RT-Thread 操作系统上的混合操作系统,简 #### 快速上手 -推荐使用 [潘多拉开发板](https://item.taobao.com/item.htm?id=583527145598) 配套使用 [潘多拉开发板教程. pdf](https://www.rt-thread.org/document/site/tutorial/iot_board_tutorial.pdf),或者以下主流的学习板进行学习,不建议没有任何基础就将 RT-Thread 移植到一块开发板上。 +推荐使用 [潘多拉开发板](https://item.taobao.com/item.htm?id=583527145598) 配套使用 [潘多拉开发板教程](https://gitee.com/Armink/IoT_Board),或者以下主流的学习板进行学习,不建议没有任何基础就将 RT-Thread 移植到一块开发板上。 - [RT-Thread 潘多拉 STM32L475 上手指南](/rt-thread-version/rt-thread-standard/tutorial/quick-start/iot_board/quick-start.md) - [野火霸道 STM32F103 上手指南](/rt-thread-version/rt-thread-standard/tutorial/quick-start/stm32f103-fire-arbitrary/quick-start.md) @@ -76,13 +76,13 @@ RT-Thread Smart 是基于 RT-Thread 操作系统上的混合操作系统,简 - [正点原子阿波罗 STM32F429 上手指南](/rt-thread-version/rt-thread-standard/tutorial/quick-start/stm32f429-atk-apolo/quick-start.md) - [野火 I.MX RT1052 上手指南](/rt-thread-version/rt-thread-standard/tutorial/quick-start/imxrt1052-fire-mini/quick-start.md) - [正点原子 I.MX RT1052 号令者上手指南](/rt-thread-version/rt-thread-standard/tutorial/quick-start/imxrt1052-atk-commander/quick-start.md) -- [其他...](/rt-thread-version/rt-thread-standard/tutorial/quick-start/iot_board/quick-start.md) +- [其他...](/rt-thread-version/rt-thread-standard/tutorial/quick-start/more.md) #### 内核学习 -[内核视频教程](https://www.rt-thread.org/page/video.html) +[内核视频教程](https://www.rt-thread.org/video.html) -[《内核实验手册》](https://www.rt-thread.org/document/site/rt-thread-version/rt-thread-standard/tutorial/experimental-manual/experimental-manual.pdf) +[《内核实验手册》](/rt-thread-version/rt-thread-standard/tutorial/experimental-manual/experimental-manual.pdf) ### ** 有 RTOS 经验 ** @@ -94,7 +94,7 @@ RT-Thread Smart 是基于 RT-Thread 操作系统上的混合操作系统,简 准备一块板子,根据 RT-Thread 支持的板子 BSP 进行 [快速上手](/rt-thread-version/rt-thread-standard/tutorial/quick-start/more.md),或者根据 [STM32 系列 BSP 制作教程进行移植](https://github.com/RT-Thread/rt-thread/blob/master/bsp/stm32/README.md)。 -如果使用 Ubuntu 进行开发,可以参考:[在 Ubuntu 下开发 RT-Thread](/rt-thread-version/rt-thread-standard/application-note/setup/qemu/windows/an0006-qemu-windows.md)。 +如果使用 Ubuntu 进行开发,可以参考:[在 Ubuntu 下开发 RT-Thread](/rt-thread-version/rt-thread-standard/application-note/setup/qemu/ubuntu/an0005-qemu-ubuntu.md)。 #### 编程指南 @@ -185,19 +185,19 @@ RT-Thread Studio :可以在 Studio 中下载源码包并创建 rt-thread 工 | 应用开发列表 | 应用开发列表 | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| [使用 Eclipse 开发 RT-Thread](/rt-thread-version/rt-thread-standard/application-note/setup/qemu/eclipse/an0020-qemu-eclipse) | [CmBacktrace应用](https://www.rt-thread.org/document/site/application-note/debug/cmbacktrace/an0013-CmBacktrace/) | -| [使用 VS Code 开发 RT-Thread](/rt-thread-version/rt-thread-standard/application-note/setup/qemu/vscode/an0021-qemu-vscode) | [在STM32 Nucleo 开发板上使用 RW007 WiFi 模块](https://www.rt-thread.org/document/site/application-note/packages/rw007_module_using/an0034-rw007-module-using) | -| [使用 Env 创建 RT-Thread 项目工程](/rt-thread-version/rt-thread-standard/application-note/setup/standard-project/an0017-standard-project) | [在 STM32L4 上应用 littlefs 文件系统](https://www.rt-thread.org/document/site/application-note/components/dfs/an0027-littlefs/) | -| [搭建RT-Thread项目框架](https://www.rt-thread.org/document/site/application-note/setup/standard-project/an0017-standard-project/) | [在潘多拉上使用 SFUD 操作 Flash](https://www.rt-thread.org/document/site/application-note/components/sfud/an0048-sfud/) | -| [在IoT Board上实现电源管理](https://www.rt-thread.org/document/site/application-note/system/pm/an0025-pm/) | [STM32 通用 Bootloader](https://www.rt-thread.org/document/site/application-note/system/rtboot/an0028-rtboot/) | -| [网络协议栈驱动移植](https://www.rt-thread.org/document/site/application-note/components/network/an0010-lwip-driver-porting/) | [wireshark 抓取 tls 数据包](https://www.rt-thread.org/document/site/application-note/packages/mbedtls_wireshark_sniffer/an0029-mbedtls_wireshark_sniffer) | -| [在STM32F429上应用网络功能](https://www.rt-thread.org/document/site/application-note/components/network/an0011-network-started/) | [在 STM32 上应用 C++](https://www.rt-thread.org/document/site/application-note/components/cplusplus/an0035-cpp/) | -| [在STM32F429上应用文件系统](https://www.rt-thread.org/document/site/application-note/components/dfs/an0012-dfs/) | [STM32 上使用 PWM](https://www.rt-thread.org/document/site/application-note/driver/pwm/an0037-rtthread-driver-pwm/) | -| [FreeModbus 应用笔记](https://www.rt-thread.org/document/site/application-note/packages/freemodbus/an0036-freemodbus/) | [STM32 上使用 USB Host 读写 U 盘](https://www.rt-thread.org/document/site/application-note/driver/usb/an0046-rtthread-driver-usbh/) | -| [应用AT组件连接ESP8266模块](https://www.rt-thread.org/document/site/application-note/components/at/an0014-at-client/) | [QEMU网络视频教程](https://www.rt-thread.org/document/site/tutorial/qemu-network/) | -| [多线程非阻塞网络编程](https://www.rt-thread.org/document/site/application-note/components/network/an0019-tcpclient-socket/) | [使用QEMU运行动态模块组件](https://www.rt-thread.org/document/site/application-note/components/dlmodule/an0023-dlmodule/) | - -[应用设计参考...](https://www.rt-thread.org/page/projects.html) +| [使用 Eclipse 开发 RT-Thread](/rt-thread-version/rt-thread-standard/application-note/setup/qemu/eclipse/an0020-qemu-eclipse) | [CmBacktrace应用](/rt-thread-version/rt-thread-standard/application-note/debug/cmbacktrace/an0013-CmBacktrace) | +| [使用 VS Code 开发 RT-Thread](/rt-thread-version/rt-thread-standard/application-note/setup/qemu/vscode/an0021-qemu-vscode) | [在STM32 Nucleo 开发板上使用 RW007 WiFi 模块](/rt-thread-version/rt-thread-standard/application-note/packages/rw007_module_using/an0034-rw007-module-using) | +| [使用 Env 创建 RT-Thread 项目工程](/rt-thread-version/rt-thread-standard/application-note/setup/standard-project/an0017-standard-project) | [在 STM32L4 上应用 littlefs 文件系统](/rt-thread-version/rt-thread-standard/application-note/components/dfs/an0027-littlefs) | +| [搭建RT-Thread项目框架](/rt-thread-version/rt-thread-standard/application-note/setup/standard-project/an0017-standard-project) | [在潘多拉上使用 SFUD 操作 Flash](/rt-thread-version/rt-thread-standard/application-note/components/sfud/an0048-sfud) | +| [在IoT Board上实现电源管理](/rt-thread-version/rt-thread-standard/application-note/system/pm/an0025-pm) | [STM32 通用 Bootloader](/rt-thread-version/rt-thread-standard/application-note/system/rtboot/an0028-rtboot) | +| [网络协议栈驱动移植](/rt-thread-version/rt-thread-standard/application-note/components/network/an0010-lwip-driver-porting) | [wireshark 抓取 tls 数据包](/rt-thread-version/rt-thread-standard/application-note/packages/mbedtls_wireshark_sniffer/an0029-mbedtls_wireshark_sniffer) | +| [在STM32F429上应用网络功能](/rt-thread-version/rt-thread-standard/application-note/components/network/an0011-network-started) | [在 STM32 上应用 C++](/rt-thread-version/rt-thread-standard/application-note/components/cplusplus/an0035-cpp) | +| [在STM32F429上应用文件系统](/rt-thread-version/rt-thread-standard/application-note/components/dfs/an0012-dfs) | [STM32 上使用 PWM](/rt-thread-version/rt-thread-standard/application-note/driver/pwm/an0037-rtthread-driver-pwm) | +| [FreeModbus 应用笔记](/rt-thread-version/rt-thread-standard/application-note/packages/freemodbus/an0036-freemodbus) | [STM32 上使用 USB Host 读写 U 盘](/rt-thread-version/rt-thread-standard/application-note/driver/usb/an0046-rtthread-driver-usbh) | +| [应用AT组件连接ESP8266模块](/rt-thread-version/rt-thread-standard/application-note/components/at/an0014-at-client) | [QEMU网络视频教程](/rt-thread-version/rt-thread-standard/tutorial/qemu-network/README) | +| [多线程非阻塞网络编程](/rt-thread-version/rt-thread-standard/application-note/components/network/an0019-tcpclient-socket) | [使用QEMU运行动态模块组件](/rt-thread-version/rt-thread-standard/application-note/components/dlmodule/an0023-dlmodule) | + +[应用设计参考...](https://www.rt-thread.org/projects.html) ## Demo 示例 @@ -210,17 +210,17 @@ RT-Thread Studio :可以在 Studio 中下载源码包并创建 rt-thread 工 | [基于RT-Thread的人体健康监测系统](https://mp.weixin.qq.com/s/ptiz9UFzbVH-jt2gNVvlHg) | [文件系统示例代码](https://github.com/RT-Thread-packages/filesystem-sample) | | [基于RT-Thread的激光雷达避障小车](https://mp.weixin.qq.com/s/rjKExoGqhI1cPErGogEHDQ) | [网络示例代码](https://github.com/RT-Thread-packages/network-sample) | | [基于RT-Thread的蓝牙遥控平衡小车](https://mp.weixin.qq.com/s/bslr8Z2vyoT5uOVNXsafjA) | | -| [蜂鸣器播放器](https://www.rt-thread.org/document/site/tutorial/beep-player/) | | -| [分布式温度监控系统](https://www.rt-thread.org/document/site/tutorial/temperature-system/) | | -| [智能车教程](https://www.rt-thread.org/document/site/tutorial/smart-car/) | | +| [蜂鸣器播放器](/rt-thread-version/rt-thread-standard/tutorial/beep-player/) | | +| [分布式温度监控系统](/rt-thread-version/rt-thread-standard/tutorial/temperature-system/) | | +| [智能车教程](/rt-thread-version/rt-thread-standard/tutorial/smart-car/) | | ## 代码贡献 | 开发指南 | 代码规范 | 提交代码 | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -| [软件包开发指南](https://www.rt-thread.org/document/site/development-guide/package/package/) | [RT-Thread编程风格](https://github.com/RT-Thread/rt-thread/blob/master/documentation/coding_style_cn.md) | [向RT-Thread贡献代码](https://www.rt-thread.org/document/site/development-guide/github/github/) | +| [软件包开发指南](/rt-thread-version/rt-thread-standard/development-guide/package/package) | [RT-Thread编程风格](https://gitee.com/rtthread/rt-thread/blob/master/documentation/contribution_guide/coding_style_cn.md) | [向RT-Thread贡献代码](/rt-thread-version/rt-thread-standard/development-guide/github/github) | | [STM32系列BSP制作教程](https://github.com/RT-Thread/rt-thread/blob/master/bsp/stm32/docs/STM32系列BSP制作教程.md) | [BSP开发规范](https://github.com/RT-Thread/rtthread-specification) | | -| [传感器驱动开发指南](https://www.rt-thread.org/document/site/development-guide/sensor/sensor_driver_development/) | | | +| [传感器驱动开发指南](/rt-thread-version/rt-thread-standard/development-guide/sensor/sensor_driver_development) | | | # 文档中心说明 diff --git a/other/novice-guide/figures/5.png b/other/novice-guide/figures/5.png index 922cf5588427f43234c0ea005898e703ebba02d1..6a89707b82099fbe4f6573fab370489ca0e12e29 100644 Binary files a/other/novice-guide/figures/5.png and b/other/novice-guide/figures/5.png differ diff --git a/other/pr-rule/pr-rule.md b/other/pr-rule/pr-rule.md index 26ba7fb816df1d7daee32c9ac3a1dfcae254f0e3..aed708f7de3f7fcc124f7c9f9e69653edb54ec6d 100644 --- a/other/pr-rule/pr-rule.md +++ b/other/pr-rule/pr-rule.md @@ -13,11 +13,11 @@ PR 标题规范要求如下所示,请按照要求填写 PR 标题,否则 PR | 删除文档 | 【删除】xxx 文档,原因:xxxx | PR 标题示例: -1. 修改**已有**的文档:【修改】pin 设备驱动开发文档中引脚编号错误 -1. 修改**已有**的文档:【修改】为 spi 设备驱动开发文档增加了 xxx 描述 -1. 修改**已有**的文档:【修改】删除了 i2c 设备驱动开发文档中 xxx 段落 -1. 新增文档:【新增】pr 提交规则文档 -1. 删除文档:【删除】xxx 文档,由于 yyy,该文档不再使用 +1. 【修改】pin 设备驱动开发文档中引脚编号错误 +1. 【修改】为 spi 设备驱动开发文档增加了 xxx 描述 +1. 【修改】删除了 i2c 设备驱动开发文档中 xxx 段落 +1. 【新增】pr 提交规则文档 +1. 【删除】xxx 文档,由于 yyy,该文档不再使用 ## 图片要求 @@ -60,7 +60,7 @@ PR 标题示例: > >(1)修改文档段落或添加文章后,文档中包含的中英文之间需要添加空格,可以使用 vscode-pangu 插件进行格式化。注意 pangu 格式化会**破坏加粗格式**,格式化完成请再次检查加粗格式并修改。 > ->(2)在编辑文档中的代码段时,需要符合 [RT-Thread 代码规范](https://github.com/RT-Thread/rt-thread/blob/master/documentation/coding_style_cn.md);若进行代码修改,请描述清楚修改原因。 +>(2)在编辑文档中的代码段时,需要符合 [RT-Thread 代码规范](https://gitee.com/rtthread/rt-thread/blob/master/documentation/contribution_guide/coding_style_cn.md);若进行代码修改,请描述清楚修改原因。 > >(3)中文正文中标点符号需要使用中文标点符号;若出现连续、段落性英文,需在句子间或该段落使用英文标点符号。 > diff --git a/rt-thread-version/rt-thread-nano/_navbar.md b/rt-thread-version/rt-thread-nano/_navbar.md index 0cc217aab651011cd06dece91cc44b83f491691c..a239082cb8dc78270d11ddef7a282ee983da2250 100644 --- a/rt-thread-version/rt-thread-nano/_navbar.md +++ b/rt-thread-version/rt-thread-nano/_navbar.md @@ -8,7 +8,7 @@ * [新手指导](/other/novice-guide/README.md) * [标准版本](/rt-thread-version/rt-thread-standard/README.md) * [Nano 版本](/rt-thread-version/rt-thread-nano/an0038-nano-introduction.md) -* [Smart 版本](/rt-thread-version/rt-thread-smart/rt-smart-quickstart/rt-smart-quickstart.md) +* [Smart 版本](/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/rt-smart-intro.md) * [开发工具](/development-tools/rtthread-studio/README.md) diff --git a/rt-thread-version/rt-thread-nano/nano-port-studio/an0047-nano-port-studio.md b/rt-thread-version/rt-thread-nano/nano-port-studio/an0047-nano-port-studio.md index bd80f19f69e77b2df94931f689f5b32ff4a13937..fbc5815d5d293246c1a1cc105834431e74367e7e 100644 --- a/rt-thread-version/rt-thread-nano/nano-port-studio/an0047-nano-port-studio.md +++ b/rt-thread-version/rt-thread-nano/nano-port-studio/an0047-nano-port-studio.md @@ -4,7 +4,7 @@ ## 准备工作 -[安装 RT-Thread Studio](https://www.rt-thread.org/page/studio.html)。 +[安装 RT-Thread Studio](https://www.rt-thread.org/studio.html)。 ## 新建 Nano 工程 diff --git a/rt-thread-version/rt-thread-nano/nano-ref/nano-device-i2c/nano-device-i2c.md b/rt-thread-version/rt-thread-nano/nano-ref/nano-device-i2c/nano-device-i2c.md index 1730f223d148cf18df3b7498e6b9c1036f718fda..0737698e71a11d0f2d19308f702e2bb96931f6a1 100644 --- a/rt-thread-version/rt-thread-nano/nano-ref/nano-device-i2c/nano-device-i2c.md +++ b/rt-thread-version/rt-thread-nano/nano-ref/nano-device-i2c/nano-device-i2c.md @@ -136,7 +136,7 @@ int rt_i2c_core_init(void); ``` -3. 我们需要适配如上 6 个 I2C 设备 API ,参考实例:[drv_i2c.c](./demo_code/drv_i2c.c) 和 [drv_i2c.h](./demo_code/drv_i2c.h)。 +3. 我们需要适配如上 6 个 I2C 设备 API ,参考实例:[drv_i2c.c](https://gitee.com/rtthread/docs-online/blob/master/rt-thread-version/rt-thread-nano/nano-ref/nano-device-i2c/demo_code/drv_i2c.c) 和 [drv_i2c.h](https://gitee.com/rtthread/docs-online/blob/master/rt-thread-version/rt-thread-nano/nano-ref/nano-device-i2c/demo_code/drv_i2c.h)。 |**函数**|**描述** | | --------------- | ---------------------------------- | @@ -300,7 +300,7 @@ MSH_CMD_EXPORT(i2c_aht10_sample, i2c aht10 sample); 实例代码运行现象: -```c +​```c msh >i2c_aht10_sample i2c1 read aht10 sensor humidity : 90.0 % read aht10 sensor temperature: 25.33°C diff --git a/rt-thread-version/rt-thread-nano/nano-ref/nano-device-pin/nano-device-pin.md b/rt-thread-version/rt-thread-nano/nano-ref/nano-device-pin/nano-device-pin.md index 526688bc1c50cda2bb15e9df754d196f75aae4d6..3fa15aeb73c8822d2f3f663457e724326c3f36f6 100644 --- a/rt-thread-version/rt-thread-nano/nano-ref/nano-device-pin/nano-device-pin.md +++ b/rt-thread-version/rt-thread-nano/nano-ref/nano-device-pin/nano-device-pin.md @@ -119,6 +119,7 @@ rt_base_t rt_pin_get(const char *name); ## 编写 PIN 设备使用示例 ```c +/* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 diff --git a/rt-thread-version/rt-thread-smart/_navbar.md b/rt-thread-version/rt-thread-smart/_navbar.md index cc051fadfe5417a6ef035807d33b9c34f64d250d..99cde98e0b69feb63a8bf40f33489762d66442dd 100644 --- a/rt-thread-version/rt-thread-smart/_navbar.md +++ b/rt-thread-version/rt-thread-smart/_navbar.md @@ -7,7 +7,7 @@ * [新手指导](/other/novice-guide/README.md) * [标准版本](/rt-thread-version/rt-thread-standard/README.md) * [Nano 版本](/rt-thread-version/rt-thread-nano/an0038-nano-introduction.md) -* [Smart 版本](/rt-thread-version/rt-thread-smart/rt-smart-quickstart/rt-smart-quickstart.md) +* [Smart 版本](/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/rt-smart-intro.md) * [开发工具](/development-tools/rtthread-studio/README.md) diff --git a/rt-thread-version/rt-thread-smart/_sidebar.md b/rt-thread-version/rt-thread-smart/_sidebar.md index b237ed69aad321f079e274379653d234426e971f..092c7078c146531678ca5afc12c444f867b26233 100644 --- a/rt-thread-version/rt-thread-smart/_sidebar.md +++ b/rt-thread-version/rt-thread-smart/_sidebar.md @@ -1,17 +1,28 @@ -- RT-Thread Smart版本 +- **RT-Thread Smart版本** - - [入门指南](/rt-thread-version/rt-thread-smart/rt-smart-quickstart/rt-smart-quickstart.md) - - - [架构说明](/rt-thread-version/rt-thread-smart/architecture/architecture.md) - - - [进程概述](/rt-thread-version/rt-thread-smart/rt-smart-lwp/rt-smart-lwp.md) - - - 应用开发 - - - [开箱体验](/rt-thread-version/rt-thread-smart/application-note/quick_start/quick_start.md) - - [使用 VS Code 开发 GUI 应用](/rt-thread-version/rt-thread-smart/application-note/sdl2/sdl2.md) - - [基于 FFmpeg + SDL2 实现视频播放](/rt-thread-version/rt-thread-smart/application-note/sdl2_ffmpeg/sdl2_ffmpeg.md) +- 简介 + - [smart简介](/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/rt-smart-intro.md) + - [smart进程概述](/rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/rt-smart-lwp.md) + +- 快速上手 + - [QEMU快速上手(Win)](/rt-thread-version/rt-thread-smart/quick-start/qemu-win/quickstart.md) + - [QEMU快速上手(Linux)](/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/quickstart.md) +- 设备和驱动 + - [DevFS设备管理](/rt-thread-version/rt-thread-smart/device/DevFS/DevFS.md) +- 开发调试 + - [使用VSCode调试用户态应用(Win)](/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/qemu-arm-win.md) + - [使用VSCode调试用户态应用(Linux)](/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/qemu-arm-linux.md) + - [RT-Thread smart插件](/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/vsc-plug-in.md) + + + + +- 应用开发 + - [移植Linux应用到smart](/rt-thread-version/rt-thread-smart/application-note/port-app/port-app.md) + - [使用VSCode开发GUI应用](/rt-thread-version/rt-thread-smart/application-note/sdl2/sdl2.md) + - [基于FFmpeg+SDL2实现视频播放](/rt-thread-version/rt-thread-smart/application-note/sdl2_ffmpeg/sdl2_ffmpeg.md) + - [应用合集](/rt-thread-version/rt-thread-smart/application-note/app-list/app-list.md) diff --git a/rt-thread-version/rt-thread-smart/application-note/app-list/app-list.md b/rt-thread-version/rt-thread-smart/application-note/app-list/app-list.md new file mode 100644 index 0000000000000000000000000000000000000000..9d0f58fa96b52e82731a6f97b347125f86e8c4ed --- /dev/null +++ b/rt-thread-version/rt-thread-smart/application-note/app-list/app-list.md @@ -0,0 +1,20 @@ +# Smart 应用精彩合集 + +如下是基于Smart开发或移植的应用列表: + +- 应用名:应用名使用中文描述。 +- 仓库:作者移植好的应用仓库或者开发好的应用仓库,需写明仓库名及仓库地址。 +- 状态:进行中、已完成。 +- 作者:作者的社区名,以及 github 主页链接。 +- 移植教程:仓库的 README.md 文件链接,该文件说明该仓库如何使用。 + +如果你有什么想法,也可以更新该列表。 + +| 应用名 | 仓库或链接 | 状态 | 作者 / 移植者 | 移植教程 | +| --------------------- | ------------------------------------------- | ------ | ------------- | ------------------------------------------------------------ | +| 在 Smart 上跑 2048 小游戏 | [2048_for_rt-smart](https://github.com/yangjie11/2048_for_rt-smart) | 已完成 | RT-Thread 官方 | [教程链接](https://github.com/yangjie11/2048_for_rt-smart/blob/master/README.md) | +| 在 Smart 上运行主线 LVGL 图形引擎 | [littleVGL for rt-smart](https://github.com/Rbb666/RT-Smart-UserAPP/tree/main/userapps/media/lvgl) | 已完成 | RT-Thread 官方 | [教程链接](https://club.rt-thread.org/ask/article/e8bc90918bd055eb.html) | +| 在 Smart 上跑 nes 游戏 | [nes for rt-smart](https://github.com/Rbb666/RT-Smart-UserAPP/tree/main/userapps/media/lvgl-nes) | 已完成 | RT-Thread 官方 | | +| 在此更新我的想法 | | | | | +| 在此更新我的想法 | | | | | + diff --git a/rt-thread-version/rt-thread-smart/application-note/port-app/figures/2048-ok.png b/rt-thread-version/rt-thread-smart/application-note/port-app/figures/2048-ok.png new file mode 100644 index 0000000000000000000000000000000000000000..e7548676d9ae9fe73a35f86031deb0ac6f1ce942 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/application-note/port-app/figures/2048-ok.png differ diff --git a/rt-thread-version/rt-thread-smart/application-note/port-app/figures/2048.png b/rt-thread-version/rt-thread-smart/application-note/port-app/figures/2048.png new file mode 100644 index 0000000000000000000000000000000000000000..66a72b2ae277d7cafcea03b071e75d8fcdd28817 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/application-note/port-app/figures/2048.png differ diff --git a/rt-thread-version/rt-thread-smart/application-note/port-app/figures/new-app.png b/rt-thread-version/rt-thread-smart/application-note/port-app/figures/new-app.png new file mode 100644 index 0000000000000000000000000000000000000000..6158c777ffdb1c74f783ffbeae6ada2b17b72927 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/application-note/port-app/figures/new-app.png differ diff --git a/rt-thread-version/rt-thread-smart/application-note/port-app/port-app.md b/rt-thread-version/rt-thread-smart/application-note/port-app/port-app.md new file mode 100644 index 0000000000000000000000000000000000000000..b22c661c9f85f299c554aa6c1e1df2d4d005f7ed --- /dev/null +++ b/rt-thread-version/rt-thread-smart/application-note/port-app/port-app.md @@ -0,0 +1,85 @@ +# 移植 Linux 应用到 RT-Smart + +RT-Smart 用户态对 POSIX 接口的支持较为完善,所以在移植应用时,可以很方便地移植使用 POSIX 接口的应用。我们在 Github 上找到一个 star 数量较多的 linux [2048 小游戏](https://github.com/mevdschee/2048.c) ,希望将它移植到 RT-Smart 上运行,本文就以移植 2048 小游戏为例,讲解如何将 linux 应用移植到 RT-Smart 上。 + + +## 应用文件夹介绍 + +新应用工程文件夹包含应用源码、构建脚本、VSCode 配置文件,如下所示: + +``` +│ main.c # 应用源码文件 +│ SConscript # 构建脚本 +│ SConstruct # 构建脚本 +│ +└─.vscode # VSCode 配置文件 + settings.json # 新应用的配置文件 + smart.json # 设置 vscode 底部状态栏功能按钮 +``` + +## 移植步骤 + +移植一个新的用户态程序步骤:创建一个新的应用工程,更新用户态程序源文件。 + +**手动移植过程**:手动移植需要新建工程文件夹,并修改配置。 + +1. 创建一个新应用工程文件夹:在 userapps/apps 目录下,复制 hello 文件夹并改名为目标 app 名; +1. 修改构建脚本; +1. 修改 VSCode 配置文件; +1. 在目标 app 文件夹中新增用户态程序 c 源文件。 + +**VSCode 移植过程【推荐】**:只需新建工程并更新源码。 + +1. 创建新的工程,参考 [RT-Thread Smart 插件:创建工程示例](../../debug/vsc-plug-in/vsc-plug-in.md)。 +2. 在新的工程文件夹中更新源文件。 + +这样一个用户态程序就移植完成了,后续可以进行编译、打包 sd.bin、用户态调试,参考 [使用 VSCode 调试用户态应用 (arm-Windows)](../../debug/qemu-arm-win/qemu-arm-win.md)。 + +## 移植示例 + +这是手动移植的示例,按照上述移植步骤,将 2048 小游戏移植到 RT-Smart 上。 + +1. 在 userapps/apps 下,复制 hello 文件夹并改名为 2048; + +2. 修改构建脚本 SConscript 和 SConstruct。 + + 修改 SConscript,修改分组名为 2048: + + ```python + ... + group = DefineGroup('2048', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) + ... + ``` + + 修改 SConstruct,修改应用名为 2048: + + ```python + ... + BuildApplication('2048', 'SConscript', usr_root = '../../..') + ... + ``` + +3. 修改 VSCode 配置文件 `.vscode` 文件夹中的 settings.json,修改目标文件名即可; + + ```json + { + "RT-Thread Smart.Program": "2048.elf", // 修改为目标文件名 + "RT-Thread Smart.Target Path": "/root/bin/", // 目标文件存储位置 + "RT-Thread Smart.SDK ROOT": "../.." // ROOT 根目录 + } + ``` + +4. 将下载的 2048 小游戏源文件 2048.c 放入新建的 2048 文件夹中,该应用文件夹最终需要包含文件:`.vscode、源码、Sconscript、Sconstruct`。 + +![](figures/new-app.png) + +5. 在 userapps 下设置工具链、编译、打包 sd.bin,QEMU 模拟运行,最后进行用户态调试,参考 [使用 VSCode 调试用户态应用 (arm-Windows)](../../debug/qemu-arm-win/qemu-arm-win.md)。2048 移植结果演示:终端输入 `qemu.bat`,smart 运行起来之后,再输入 `mnt/bin/2048.elf` 运行 2048 应用。如下是运行结果: + +![](figures/2048.png) + +如发现问题,可以对当前应用进行调试修改,最终显示正常: + +![img](figures/2048-ok.png) + +综上,基于 VSCode 移植会更简单,推荐使用。 + diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/1.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/1.png deleted file mode 100644 index 7b6ed2c171bb707d78d34bb131ce541ab4b07d2c..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/1.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/10.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/10.png deleted file mode 100644 index 4aa6156fed6f248988dc2565f24774eaa5064f46..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/10.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/11.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/11.png deleted file mode 100644 index e1159d2ceb174d8fe5ff420423036c14ab755775..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/11.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/124.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/124.png deleted file mode 100644 index 36cf7577efceed5d995d45a550d80a296b14f453..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/124.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/132.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/132.png deleted file mode 100644 index c139114e3e810ccda21bfd36e15360999623ddd9..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/132.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/14.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/14.png deleted file mode 100644 index 62fe91c762c2bc212cf8355c07d0285e472c43c6..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/14.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/15.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/15.png deleted file mode 100644 index 59c7617856881bc6a48f38687a6960e277cb8ce5..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/15.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/16.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/16.png deleted file mode 100644 index c6556e01ff947563a8f0287e6a02f339d0f2efdf..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/16.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/17.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/17.png deleted file mode 100644 index 5486480ab3593b657f9b3fa8fb537fe18b01f303..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/17.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/18.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/18.png deleted file mode 100644 index 6fa6fefcdfb239e559413af5c736efa095e326f2..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/18.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/19.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/19.png deleted file mode 100644 index 13c6df71076f1d72077d7e78f434656b7bc5a4ef..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/19.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/2.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/2.png deleted file mode 100644 index 2303b9888af5c3c053624cb0195ab98576ea06e1..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/2.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/20.gif b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/20.gif deleted file mode 100644 index faaf1f9f71dc8037d3fdc327091220597b671038..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/20.gif and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/21.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/21.png deleted file mode 100644 index 72b66d0bd7bc476ba531f1a95c814adee153a818..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/21.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/22.gif b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/22.gif deleted file mode 100644 index 3f6580f1d46b757094257c1a6d12281216a7ed95..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/22.gif and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/3a.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/3a.png deleted file mode 100644 index fcc86e76532b2f06f5de757ab15007fe4b0705e2..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/3a.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/4.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/4.png deleted file mode 100644 index ba7f6f224f1e21da8cca119a1dc31a06ca3a351e..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/4.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/5.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/5.png deleted file mode 100644 index 61e5db091954068422f5d14282e3a28720c280eb..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/5.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/6.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/6.png deleted file mode 100644 index 70054f552ea47f1d59cf73d23aa5286eb498847a..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/6.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/7.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/7.png deleted file mode 100644 index 16f93a1d84e7db24383ae3856369b96ebf8c4ccf..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/7.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/8.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/8.png deleted file mode 100644 index 47a46437602a26a13c4154c25a170d7a41eae76c..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/8.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/9.png b/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/9.png deleted file mode 100644 index a5c10b53f7e45388a18665de97502b4f52d9461a..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/application-note/quick_start/figures/9.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/architecture/figures/ipc-seq.png b/rt-thread-version/rt-thread-smart/architecture/figures/ipc-seq.png deleted file mode 100644 index 0f12f7596b425ad90fe866e759194db514108d08..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/architecture/figures/ipc-seq.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/architecture/figures/rt-smart.drawio.png b/rt-thread-version/rt-thread-smart/architecture/figures/rt-smart.drawio.png deleted file mode 100644 index 922cf5588427f43234c0ea005898e703ebba02d1..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/architecture/figures/rt-smart.drawio.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/brk-hello-main.png b/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/brk-hello-main.png new file mode 100644 index 0000000000000000000000000000000000000000..73406a41265165ef792b946b8f9fdb2aa78a1739 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/brk-hello-main.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/debug-app-1.png b/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/debug-app-1.png new file mode 100644 index 0000000000000000000000000000000000000000..0e7aae205d070a9be64c6ce3e9f594b5574b62dc Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/debug-app-1.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/debug.png b/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/debug.png new file mode 100644 index 0000000000000000000000000000000000000000..7e1d929eb937f3c8de221f8df5b4c384aa8bc191 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/debug.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/gdb-path.png b/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/gdb-path.png new file mode 100644 index 0000000000000000000000000000000000000000..a5de58be5ce031b543401a0ac9f23e7bae41ed72 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/gdb-path.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/vsc-debug.png b/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/vsc-debug.png new file mode 100644 index 0000000000000000000000000000000000000000..6463cdb1980a81dc49dd5ddd2d66677f0ec70aab Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/vsc-debug.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/qemu-arm-linux.md b/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/qemu-arm-linux.md new file mode 100644 index 0000000000000000000000000000000000000000..9b8a83f5c78116beea3c7343ec766e63734c45aa --- /dev/null +++ b/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/qemu-arm-linux.md @@ -0,0 +1,144 @@ +# 使用 VSCode 调试用户态应用 (arm-Linux) + +本教程的内容是如何在 Ubuntu 上使用 VSCode 调试 RT-Smart 内核及用户态应用,基于 qemu-vexpress-a9 BSP 完成。 + +## 准备工作 + +1. 下载源码: + + - rt-thread(https://github.com/RT-Thread/rt-thread.git) 切换到 rt-smart 分支。 + + ```bash + $ git clone https://github.com/RT-Thread/rt-thread.git + $ + $ git checkout rt-smart + $ + # update kernel's rt-smart branch to the latest version + $ git pull origin rt-smart + ``` + + - 用户态应用程序 (https://github.com/RT-Thread/userapps.git) + + ```bash + $ git clone https://github.com/RT-Thread/userapps.git + ``` + +2. 安装 VSCode:安装 VSCode 并安装 c/c++ 扩展插件。 + + ```bash + $ sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make + $ sudo apt-get update + $ sudo apt-get install ubuntu-make + $ umake ide visual-studio-code + + # 提示输入 a 即可 + ``` + +3. 安装 GDB:gcc-arm-none-eabi 已经不再包含 arm-none-eabi-gdb 调试工具,需要去官方网站下载对应的 toolchain 压缩包,然后解压到 /opt 下: + + ```bash + $ wget https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 + $ + $ sudo tar xf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 -C /opt + ``` + + 然后设置 GDB 环境变量设置,打开 ~/.bashrc + + ```bash + $ sudo gedit ~/.bashrc + ``` + 在里面设置 PATH 环境变量 `export PATH=$PATH:/opt/gcc-arm-none-eabi-10-2020-q4-major/bin:/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/bin`,保存。 + + ![image-20221026140628406](figures/gdb-path.png) + +## 编译 userapps 与内核 + +在 userapps 中,配置 gcc 工具链并编译 app: +1. 在 `userapps\tools` 目录下,使用如下 python 命令 `python get_toolchain.py arm` 下载工具链(若之前执行过则无需再次执行); +2. 在 `userapps` 目录下,使用命令 `source smart-env.sh arm` 设置工具链路径; +3. 在 `userapps` 目录下,使用命令 `scons` 编译。编译顺利的话,将在 `userapps\root` 文件夹中得到一系列可执行 elf 文件。 + +在 `\rt-thread\bsp\qemu-vexpress-a9` 目录下,编译系统内核: +1. 使用命令 `scons` 编译,会生成 rtthread.elf 与 rtthread.bin; +2. 使用命令 `./qemu-nographic.sh`,测试 qemu 正常运行后,使用 ctrl a,x 结束运行。 + +## VSCode 配置 + +要想使用 VSCode 调试用户态应用,需要先在工程路径下添加调试配置。 + +1. 首先在终端使用命令 `code . `,使用 VSCode 打开该目录。 +2. 修改 `\rt-thread\bsp\qemu-vexpress-a9` 目录下 `.vscode` 文件夹中的 `launch.json` 配置,如下所示(需要更新实际的 gdb 路径): + +```json +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug smart @ Linux", + "type": "cppdbg", + "request": "launch", + "args": [], + "stopAtEntry": true, + "externalConsole": true, + "cwd": "${workspaceRoot}", + "program": "${workspaceRoot}/rtthread.elf", + "serverLaunchTimeout": 2000, + "miDebuggerPath":"/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gdb", + "miDebuggerServerAddress": ":1234", + "setupCommands": [ + { + "text": "cd ${workspaceRoot}" + }, + { + "text": "file rtthread.elf" + }, + { + "text": "break main" + } + ], + "customLaunchSetupCommands": [], + "launchCompleteCommand": "exec-run" + }, + ] + } +``` + +### 将待调试的 app 拷贝到 sd.bin + +如果 sd.bin 不存在,可以通过下面方法创建并格式化: + +```bash +$ dd if=/dev/zero of=sd.bin bs=1024 count=65536 +$ mkfs.vfat sd.bin +``` + +然后后拷贝 app 到 sd.bin 中 (调试过程中每次修改重新编译 app 后,都需要更新 sd.bin 里面的 app 文件): + +```bash +$ sudo mount sd.bin /mnt +$ sudo cp ../../../userapps/root/bin/hello.elf /mnt/hello.elf +$ sudo umount /mnt +``` + +## 调试用户态应用 + +这部分开始正式调试用户态应用,先进入内核的调试界面,然后添加用户态应用的符号表,再在内核中运行用户态应用即可进入用户态应用调试,具体步骤如下: + +1. 在 VSCode 终端输入 `./qemu-dbg.sh`,此时弹出 qemu 窗口。可以看到启动过程被挂起,等待调试前端来连接。 + +2. 在 VSCode 中按下 F5 开始调试内核,运行的代码将停在 main 断点处,并且控制台打印 rt-thread logo,表示系统已经正常启动,文件系统也已经成功挂载。 + + ![image-20221026104404817](figures/vsc-debug.png) + +3. 断点在 main 处时,可以加载待调试应用程序的符号,如调试 hello.elf,在 VSCode 调试控制台输入如下命令后回车(注意调整 elf 文件的正确的相对路径) `-exec add-symbol-file ../../../userapps/root/bin/hello.elf`,之后输入 `-exec b main` 命令并回车,这将会在 app main 上打断点。 + + ![image-20221026103535098](figures/debug.png) + +4. 按下 F5 全速运行程序,这时系统正常运行,可以在终端输入 MSH 调试命令。在终端输入用户态应用的文件路径执行相应的用户态应用,如 `mnt/hello.elf`。应用会被加载运行,并自动停在应用程序入口处。从 VSCode 可以看到应用的源码文件被打开,并且断点停在应用入口 main 处。 + + ![image-20221026104738963](figures/brk-hello-main.png) + +5. 后续就可以单步调试用户态应用了。单步运行后,应用代码执行的打印将显示在终端上。 + + ![image-20221026104855575](figures/debug-app-1.png) + diff --git a/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/figures/debug-1.png b/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/figures/debug-1.png new file mode 100644 index 0000000000000000000000000000000000000000..bd8686754be3a65cf62f00411d6db17e36a4a1d7 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/figures/debug-1.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/figures/debug-app-1.png b/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/figures/debug-app-1.png new file mode 100644 index 0000000000000000000000000000000000000000..9a48e46f9e078f9b2e364212242da31cdabaf374 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/figures/debug-app-1.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/figures/debug-app.png b/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/figures/debug-app.png new file mode 100644 index 0000000000000000000000000000000000000000..417a061bc4dd79cd8e2f5b59489747c01c463fbd Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/figures/debug-app.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/figures/debug-menu.png b/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/figures/debug-menu.png new file mode 100644 index 0000000000000000000000000000000000000000..3b200c323ae1991f0dd86824a4e4cd601cd01012 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/figures/debug-menu.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/figures/debug.png b/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/figures/debug.png new file mode 100644 index 0000000000000000000000000000000000000000..aef107017c19a6649d5c0fa0ba43755ff9b5f423 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/figures/debug.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/qemu-arm-win.md b/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/qemu-arm-win.md new file mode 100644 index 0000000000000000000000000000000000000000..436733991d385b0cd1822fba76466b9d78434372 --- /dev/null +++ b/rt-thread-version/rt-thread-smart/debug/qemu-arm-win/qemu-arm-win.md @@ -0,0 +1,82 @@ +# 使用 VSCode 调试用户态应用 (arm-Windows) +本教程的内容是如何在 Windows 上使用 VSCode 调试 RT-Smart 内核及用户态应用,基于 qemu-vexpress-a9 BSP 完成。 + +## 准备工作 + +下载源码: +- rt-thread: https://github.com/RT-Thread/rt-thread ,需要切换到 rt-smart 分支 +- 用户态应用程序: https://github.com/RT-Thread/userapps + +安装 VSCode: + +- 安装 VSCode 并安装 c/c++ 扩展插件 + +## 编译 userapps 与内核 + +> 这部分内容详细步骤请参考 [QEMU 快速上手](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-smart/quick-start/qemu-win/quickstart),本篇只做简单介绍。 + +在 userapps 中,配置 gcc 工具链并编译 app: +1. 在 `userapps\tools` 目录下,使用 python 命令 `python get_toolchain.py arm` 下载工具链(若之前执行过则无需再次执行); +2. 在 `userapps` 目录下,使用命令 `smart-env.bat arm` 设置工具链路径; +3. 在 `userapps` 目录下, 使用命令 `scons` 编译。编译顺利的话,将在 `userapps\root` 文件夹中得到一系列可执行 elf 文件。 + +按照 [QEMU 快速上手](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-smart/quick-start/qemu-win/quickstart) 教程中的 “制作 QEMU SD 卡章节” 将 root 文件夹中的 elf 打包进 sd.bin,并将新生成的 sd.bin 更新到内核仓库的 `\rt-thread\bsp\qemu-vexpress-a9` 目录。 + +在 `\rt-thread\bsp\qemu-vexpress-a9` 目录下,编译系统内核: +1. 使用命令 `scons` 编译,会生成 rtthread.elf 与 rtthread.bin; +2. 输入 `qemu-nographic.bat`,测试 qemu 正常运行后,使用 `ctrl c` 结束运行; + +## 添加 VSCode 调试配置 + +要想使用 VSCode 调试用户态应用,需要先在工程路径下添加调试配置。 + +1. 首先在 Env 工具里使用命令 `code . `,使用 VSCode 打开该目录。 +2. 修改 `\rt-thread\bsp\qemu-vexpress-a9` 目录下 `.vscode` 文件夹中的 `launch.json` 配置,如下所示: + +```json +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug @ Windows", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceRoot}\\rtthread.elf", + "args": [], + "stopAtEntry": true, + "cwd": "${workspaceRoot}", + "environment": [], + "externalConsole": true, + "miDebuggerServerAddress": "localhost:1234", + "serverLaunchTimeout": 2000, + "targetArchitecture": "ARM", + "MIMode": "gdb", + "miDebuggerPath": "arm-none-eabi-gdb.exe", + "customLaunchSetupCommands": [], + "launchCompleteCommand": "exec-run", + }, + ] +} +``` + +## 调试用户态应用 + +这部分开始正式调试用户态应用,先进入内核的调试界面,然后添加用户态应用的符号表,再在内核中运行用户态应用即可进入用户态应用调试,具体步骤如下: + +1. 在 Env 工具中运行命令 `qemu-dbg.bat` :此时弹出 qemu 窗口,可以看到启动过程被挂起,等待调试前端来连接。 +2. 切换到 vscode,按下 F5 开始调试内核,运行的代码将停在 main 断点处,并且控制台打印 rt-thread logo,表示系统已经正常启动,文件系统也已经成功挂载。 + +![img](figures/debug.png) + +3. 断点在 main 处时,可以通过 VSCode 的调试控制台加载待调试应用程序的符号。如调试 hello.elf,在 VSCode 调试控制台输入如下命令后回车(注意调整正确的路径,支持相对和绝对路径) `-exec add-symbol-file ../../../userapps/root/bin/hello.elf`,之后输入命令 `-exec b main` 在应用 hello.elf 的入口添加断点。 + +![img](figures/debug-1.png) + +4. 按下 F5 全速运行程序,这时系统正常运行,可以在 Env 的终端输入 MSH 调试命令。在终端输入用户态应用的文件路径执行相应的用户态应用,如 `mnt/bin/hello.elf`。应用会被加载运行,并自动停在应用程序入口处。从 VSCode 可以看到应用的源码文件被打开,并且断点停在应用入口 main 处。 + +![img](figures/debug-app.png) + +5. 后续就可以单步调试用户态应用了。单步运行后,应用代码执行的打印将显示在终端上。 + +![img](figures/debug-app-1.png) + diff --git a/rt-thread-version/rt-thread-smart/application-note/quick_start/quick_start.md b/rt-thread-version/rt-thread-smart/debug/vsc-debug/vsc-debug.md similarity index 35% rename from rt-thread-version/rt-thread-smart/application-note/quick_start/quick_start.md rename to rt-thread-version/rt-thread-smart/debug/vsc-debug/vsc-debug.md index 8bbdbbafd854bb1c41dbc0afd3e7f54a39a5385b..d47d76a39068c382f7f34bc68b910becb8326a2d 100644 --- a/rt-thread-version/rt-thread-smart/application-note/quick_start/quick_start.md +++ b/rt-thread-version/rt-thread-smart/debug/vsc-debug/vsc-debug.md @@ -1,217 +1,6 @@ -# 上手体验以及 vscode 插件使用 +# smart vscode 插件 -## 开箱 - -包装内自带了两根 Type-C 线和一根网线。开发板整体接口还是很丰富的:SDIO、USB、ETH、LCD、Camera: - -![1](figures/1.png) - -![1](figures/2.png) - -## 上电 - -拿到新开发板的第一件事,当然是插电,开机,打印 `hello, world`! - -1. 插入 Type-C 电源和网线,打开终端,波特率设置为 115200 - - ![0.png](figures/3a.png) - -2. 上电调试信息: - - ```shell - U-Boot 2017.03-g002b758ac9-dirty (Nov 24 2021 - 20:08:02 +0800) - - CPU: Freescale i.MX6ULL rev1.1 696 MHz (running at 396 MHz) - CPU: Industrial temperature grade (-40C to 105C) at 38C - Reset cause: WDOG - Model: Freescale i.MX6 ULL 14x14 EVK Board - Board: MX6ULL 14x14 EVK - DRAM: 512 MiB - MMC: FSL_SDHC: 0, FSL_SDHC: 1 - *** Warning - bad CRC, using default environment - - Display: TFT7016 (1024x600) - Video: 1024x600x24 - In: serial - Out: serial - Err: serial - switch to partitions #0, OK - mmc1(part 0) is current device - Net: eth1: ethernet@020b4000, eth0: ethernet@02188000 [PRIME] - Normal Boot - Hit any key to stop autoboot: 0 - reading /kernel/rtthread.bin - 1149312 bytes read in 73 ms (15 MiB/s) - ## Starting application at 0x80001000 ... - - \ | / - - RT - Thread Smart Operating System - / | \ 5.0.0 build Dec 15 2021 - 2006 - 2020 Copyright by rt-thread team - lwIP-2.1.2 initialized! - [15] E/drv.enet: emac device init success - - [20] I/I2C: I2C bus [i2c3] registered - [24] I/I2C: I2C bus [i2c4] registered - [83] E/drv.enet: - PHY Link down, please check the cable connection and link partner setting. - - [94] I/SDIO: SD card capacity 31166976 KB. - [156] I/SDIO: emmc card capacity 3817472 KB. - found part[0], begin: 2098176, size: 500.0MB - found part[1], begin: 526386176, size: 1.0GB - found part[2], begin: 1600128000, size: 10.0MB - found part[3], begin: 1610613760, size: 200.0MB - [266] I/touch: rt_touch init success - [270] I/gt911: touch device gt911 init success - [275] I/sal.skt: Socket Abstraction Layer initialize success. - emmc file system initialization done! - Dir / sd0 mount failed! - [1751] E/[RW007]: The wifi Stage 1 status 0 0 0 1 - [1758] I/WLAN.dev: wlan init success - [1763] I/WLAN.lwip: eth device init ok name:w0 - [1768] I/WLAN.dev: wlan init success - [1773] I/WLAN.lwip: eth device init ok name:w1 - - rw007 sn: [rw00700000000fc584a2c5001] - rw007 ver: [RW007_2.1.0-a7a0d089-57] - - [5247] D/drv.enet: enet1 link up - - [5789] W/WLAN.mgnt: F:rt_wlan_connect L:1091 not find ap! ssid:rt-thread - hello rt-smart! - /sd/wifi.sh wi-fi configuration file not exist in sd card! - [5807] I/mcf.link.tcp: TCPServer Waiting for client on port 5555... - - [5814] I/mcf.link: MCF link port(3) register successfully. - msh />[5850] I/mcf.trans: MCF(V0.1.0) initialized successfully. - [5855] I/urpc: uRPC(V0.1.0) initialize successfully. - [5861] I/mcf.trans: MCF protocol started successfully. - - -3. 在终端输入命令 `help` 查看帮助信息 - - ```shell - msh />help - RT-Thread shell commands: - reboot - reboot system - cpu_usage - display cpu usage - dbg - dbg - memcheck - check memory data - memtrace - dump memory trace information - gic_dump - show gic status - list_page - show page info - list_fd - list file descriptor - lsof - list open files - mount - mount - unmount - unmount the mountpoint - hello - say hello world - clear - clear the terminal screen - version - show RT-Thread version information - list_thread - list thread - list_sem - list semaphore in system - list_event - list event in system - list_mutex - list mutex in system - list_mailbox - list mail box in system - list_msgqueue - list message queue in system - list_memheap - list memory heap in system - list_mempool - list memory pool in system - list_timer - list timer in system - list_device - list device in system - list - list all symbol in system - help - RT-Thread shell help. - ps - List threads in the system. - free - Show the memory usage in the system. - ls - List information about the FILEs. - cp - Copy SOURCE to DEST. - mv - Rename SOURCE to DEST. - cat - Concatenate FILE(s) - rm - Remove(unlink) the FILE(s). - cd - Change the shell working directory. - pwd - Print the name of the current working directory. - mkdir - Create the DIRECTORY. - mkfs - format disk with file system - df - disk free - echo - echo string to file - set - set or show environment variable - list_channel - list IPC channel information - list_process - list process - kill - send a signal to a process - killall - kill processes by name - list_shm - show share memory info - sys_log - sys_log 1(enable)/0(disable) - ifconfig - list the information of all network interfaces - ping - ping network host - dns - list and set the information of dns - netstat - list the information of TCP / IP - pwm_enable - pwm_enable pwm1 1 - pwm_disable - pwm_disable pwm1 1 - pwm_set - pwm_set pwm1 1 100 50 - date - get date and time or set [year month day hour min sec] - wifi - wifi command. - - ``` - -4. 执行用户 app。用户 app 存放在目录 **/root/bin** 目录下 - - ```shell - msh /root/bin>pong.elf & - msh /root/bin> - Pong: wait on the IPC channel: 3 - - msh /root/bin>ping - msh /root/bin>ping.elf - msh /root/bin> - Ping: send count = 0 - Pong: receive count = 0 - Pong: reply count = 0 - Ping: receive the reply 0 - - Ping: send count = 1 - Pong: receive count = 1 - Pong: reply count = 1 - Ping: receive the reply 1 - - Ping: send count = 2 - Pong: receive count = 2 - Pong: reply count = 2 - Ping: receive the reply 2 - - Ping: send count = 3 - Pong: receive count = 3 - Pong: reply count = 3 - Ping: receive the reply 3 - - Ping: send count = 4 - Pong: receive count = 4 - Pong: reply count = 4 - Ping: receive the reply 4 - - Ping: send count = 5 - Pong: receive count = 5 - Pong: reply count = 5 - Ping: receive the reply 5 - - Ping: send count = 6 - Pong: receive count = 6 - Pong: reply count = 6 - Ping: receive the reply 6 - - Ping: send count = 7 - Pong: receive count = 7 - Pong: reply count = 7 - Ping: receive the reply 7 - ``` - -## 下载源码 - -ART-Pi Smart 的最新源码仓库地址:[ART-Pi-smart: ART-Pi smart开发板的SDK仓库 (gitee.com)](https://gitee.com/rtthread/ART-Pi-smart) - -使用 git 工具下载源码:`git clone https://gitee.com/rtthread/ART-Pi-smart.git ` - -## vscode 插件体验 - -RT-Thread 官方提供了 vscode 插件用来开发用户 app 代码。下面分享一下 ART-Pi Smart Vscode 插件的使用体验。 +RT-Thread 官方提供了 vscode 插件用来开发用户 app 代码。下面分享一下 Vscode 插件 ART-Pi Smart 的使用体验。 ### 安装插件 diff --git a/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/creat-proj-1.png b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/creat-proj-1.png new file mode 100644 index 0000000000000000000000000000000000000000..b08fb4bceeca5ad049a9199b85147303b039add8 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/creat-proj-1.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/creat-proj.png b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/creat-proj.png new file mode 100644 index 0000000000000000000000000000000000000000..01b255770d6054cfa9ab484a3c40784bccb5a98e Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/creat-proj.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/home-0.png b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/home-0.png new file mode 100644 index 0000000000000000000000000000000000000000..c02eb489a1a7c29f2a21ae5a4e998aa535a13554 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/home-0.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/home.png b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/home.png new file mode 100644 index 0000000000000000000000000000000000000000..86285e3abe4d46d7330ffa3b5ffbead13fbfe30c Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/home.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/new-app.png b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/new-app.png new file mode 100644 index 0000000000000000000000000000000000000000..914ca2eb93750cc34f6383f12ad17387fc77465c Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/new-app.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/set-state-menu.png b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/set-state-menu.png new file mode 100644 index 0000000000000000000000000000000000000000..9c946930e54046a18ff8e7d514c2dc87facf0c4d Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/set-state-menu.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/smart-plugin.png b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/smart-plugin.png new file mode 100644 index 0000000000000000000000000000000000000000..7a268ed7802275d5d8907f1692ca20e5fab35717 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/smart-plugin.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/state-menu.png b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/state-menu.png new file mode 100644 index 0000000000000000000000000000000000000000..707f38fac1b972a50ca1de7340ef3ac4ae452e0e Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/figures/state-menu.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/vsc-plug-in.md b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/vsc-plug-in.md new file mode 100644 index 0000000000000000000000000000000000000000..61fec6b1f84dae28a3066b03852741f7f422a877 --- /dev/null +++ b/rt-thread-version/rt-thread-smart/debug/vsc-plug-in/vsc-plug-in.md @@ -0,0 +1,104 @@ +# RT-Thread Smart 插件 + +为了使 RT-Thread Smart 开发者更方便的开发用户态应用,RT-Thread 开发了 VSCode 插件。包括下面的功能: + +- SDK 管理界面(提供应用列表展示、下载工具链、创建应用工程等功能) + +- 针对不用工程的快捷操作(如:编译工程、清理工程、安装并打包等) + +这些功能都以按钮的形式存在于 VSCode 的底部状态栏上,如下图所示: + + ![image-20221019145632712](figures/home-0.png) + +其中 HOME 按钮对应的就是 SDK 管理界面,右侧的两个按钮(编译、清理)是针对 SDK 工程提供的快捷操作,对于不同的项目工程,右侧的快捷操作按钮可以自由定制。下面来详细介绍 Vscode 插件的各项功能。 + +## 准备工作 + +- 下载 rt-thread: https://github.com/RT-Thread/rt-thread ,需要切换到 rt-smart 分支; + +- 下载用户态应用程序: https://github.com/RT-Thread/userapps ; + +- 打开 VSCode,在扩展 (Ctrl+Shift+X) 中查找 RT-Thread Smart 插件并安装: + + ![img](figures/smart-plugin.png) + +## SDK 管理界面 + +使用 VSCode 打开 userapps 目录(将打开该 userapps 目录的窗口称为主窗口),在底部的状态栏中有一些功能按钮,这里介绍常用的三个: + +![image-20221019145632712](figures/home-0.png) + +1. HOME:点击进入SDK 管理界面,该界面包含一些信息展示及常用功能,例如版本展示、创建工程等。 +2. 编译:点击编译,将执行 `scons` 命令,会编译 userapps/app 下所有的 app,并在 root/bin 中生成所有 app 的 `.elf` 可执行文件。 +3. 清理:点击清理,将执行 `scons -c` 命令,清除之前编译生成的文件。 + +点击状态栏的 HOME 功能按钮后,将显示 SDK 管理界面,如下所示: + +![](figures/home.png) + +**SDK 信息展示区**: + +- 版本:RT-Smart 版本显示。 +- HOME:userapps 的路径,即用户态应用路径。 +- 内核:rt-thread 内核的路径,即可以编译 smart 的 bsp 路径,例如当前使用的 bsp 为:rt-thread\bsp\qemu-vexpress-a9,那么应当显示为该 bsp 的路径。 + +若内核路径不正确,请在 `userapps/.vscode/home.json` 中修改 kernel 项的文件路径,填入相对路径与绝对路径均可。 + +```json +"kernel": { + "folder": "/../rt-thread/bsp/qemu-vexpress-a9" +} +``` + +**功能区**: + +- 创建工程:点击创建工程按钮创建新的工程,详见创建工程示例。 +- 打开终端:创建一个新的终端并打开。 +- 打开内核:打开内核代码。 + +**工具链**: + +- 点击下载按钮,自动下载安装 Windows 下所需的工具链。 + +**应用列表区**: + +- 模板应用:展示 userapps/app 目录下的模板应用。 +- 用户应用:展示使用 VSCode 新建在 userapps/workspse 目录下的用户应用。 +- 预编译:展示 userapps/prebuilt 目录下的已经预编译好的 bsp 文件,如 qemu-vexpress-a9 和 qemu-virt64-riscv。 + +应用列表区的应用都可以通过点击位置在 VSCode 新窗口中打开。 + +## 快捷操作按钮 + +在不同的工程下,VSCode 底部的快捷按钮是不同的,在主窗口,提供的是针对 userapps sdk 的一些快捷操作,编译所有应用,清理所有应用等。在每个具体的应用工程下,也提供类似的快捷操作。 + +在应用列表区打开模板应用或者用户应用,会创建一个新的 VSCode 窗口(将该窗口称为应用窗口),可以把应用窗口底部的状态栏称为应用窗口状态栏。如点击模板应用中的 hello(或者其他均可): + +![](figures/new-app.png) + +该应用窗口的状态栏有 HOME、编译、清理、安装并打包、下载功能按钮: +- 编译:仅编译当前 app,点击编译后,在当前 app 路径下生成对应的单个 `.elf` 文件。 +- 安装并打包:将上述编译的单个 `.elf` 文件复制一份到 root/bin 路径下。 +- 下载:针对拥有 udb 服务的内核提供下载功能,一般用户用不到。 + +用户也可以自定义当前工程的快捷操作按钮,通过修改当前工程目录下 `.vscode/smart.json` 文件。 + +## 创建工程 + +在 SDK 管理界面,点击创建工程。 + +填入 SDK 根目录,即 userapps 用户态应用的上级目录(例如:实际路径为 `F:\2-daily-work\2022\06.smart\userapps`,则填入 `F:\2-daily-work\2022\06.smart`),回车;之后输入工程名如 test_app,回车;选择编译工具为 SCons;选择在新窗口或当前窗口打开应用。 + +![creat-proj-1](figures/creat-proj-1.png) + +这样就在 `userapps\workspace` 中创建了一个 test_app 工程,用户可以在该工程中开发应用。 + +## FAQ + +Q: VSCode 底部状态栏未显示。 + +A: 如果下方没有显示状态栏,可以通过左下角 “管理 - 设置”,在搜索栏输入 “状态栏” 并重新勾选, 这样状态栏将重新显示在底部。 + +![](figures/set-state-menu.png) + + diff --git a/rt-thread-version/rt-thread-smart/device/DevFS/DevFS.md b/rt-thread-version/rt-thread-smart/device/DevFS/DevFS.md new file mode 100644 index 0000000000000000000000000000000000000000..fb52544dacaed7efc8e451f1420384ede3d2c0fa --- /dev/null +++ b/rt-thread-version/rt-thread-smart/device/DevFS/DevFS.md @@ -0,0 +1,285 @@ +# DevFS设备管理 + +## 简介 + +DevFS 设备管理即使用文件系统的接口访问设备。在用户态程序中只允许使用这种方式访问设备。 + +整体框架图如下所示: + +![devfs](figures/devfs.png) + +最上面一层是用户层, + +第二层就是 DevFS 设备管理层,向上层提供标准接口,DevFS 设备框架提供给用户层的接口是 open/close/read/write/ioctl/poll/lseek ;并向下层提供 fops(文件操作函数集合) 集合,供驱动注册设备。 + +第三层是驱动的实现,对于 UART 来说,它有对应的设备框架,因此需要先注册成标准 Device 设备,然后由框架完成 fops 的对接。对于 I2C总线、SPI总线设备来说,他们和 UART 一样也需要先注册成标准 Device 设备,但是总线类设备并不会注册 fops 接口,因此用户态 APP 无法访问总线设备。对于 EEPROM、LCD、ESAM 等功能外设来说,他们需要自己实现 fops 里需要实现的接口,并完成设备的注册。 + +最下面一层是,芯片厂商提供的标准库。 + +> 注意:由上图可以看出,使用 open/close/read/... 这些 DevFS 设备管理框架提供的 API 既可以操作 UART设备,又可以操作 EEPROM 等功能外设设备。但是 Device 设备框架提供的 rt_device_open/rt_device_close/... 等API 就只可以控制 UART 和 I2C/SPI 总线设备,不能控制 EEPROM 等功能外设。 + +## APP访问外设示例 + +DevFS 设备底层驱动实现之后会向内核注册对应的设备,例如,UART驱动里就可能会向系统注册一个名称为 “UART1”、一个 “UART2” 的设备。LCD 驱动实现之后就会向内核注册一个名称为 "LCD" 的设备。那么如何访问这些设备呢? + + DevFS 设备框架提供给用户层的接口是 `open/close/read/write/ioctl/poll/lseek` + +假设我们有一个按键设备,名称为 key0,我们规定读此按键设备的意义是:读按键是否有事件发生。这里只检查按 键按下的事件,如果有按键按下的事件发生,就会返回此事件,否则返回错误。 + +示例程序如下: + +```c +#include +#include +#include + +/* Defines the event in which the key is pressed */ +#define EVENT_KEY_PRESS 10 +#define KEY0_DEVICE_PATH "/dev/key0" + +int main(void) +{ + int fd; + int value; + + /* Open the device, default by blocking mode */ + fd = open(KEY0_DEVICE_PATH, O_RDONLY); + if (fd < 0) + { + printf("open device failed\n"); + return 0; + } + + printf("Please press the USER button\n"); + /* read data */ + if(read(fd, &value, 1) == 1) + { + if (value == EVENT_KEY_PRESS) + printf("key press\n"); + } + + close(fd); + + printf("The program will exit\n"); + + return 0; +} +``` + +这个程序将以阻塞的模式打开 KEY0 设备,然后阻塞的去读设备的事件,只有当设备发生事件时才返回。然后判断发生的事件是否为按键按下事件。 + +**poll 接口使用示例:** + +假设我们规定 KEY0 外设驱动注册的实现需要 poll 接口,当按键事件发生时上报 POLLIN 事件的发生。这样应用层就可以使用 poll 接口监听按键按下事件的发生了。 + +这个示例程序利用 poll 接口监听 KEY0 设备的 POLLIN 事件的发生,并设置超时时间为 1S, 若连续 5 次都监听超时就退出程序。如果监听到 POLLIN 事件的发生就打印 `Key press` 。 + +```c +#include +#include +#include +#include + +#define KEY0_DEVICE_PATH "/dev/key0" + +int main(void) +{ + int fd; + int count = 0; + struct pollfd fds[1]; + + /* Open the device by non-blocking mode */ + fd = open(KEY0_DEVICE_PATH, O_RDONLY | O_NONBLOCK); + if (fd < 0) + { + printf("open device failed\n"); + return -1; + } + + /* Add the fd to monitor */ + fds[0].fd = fd; + fds[0].events = POLLIN; + + printf("Please press the USER button\n"); + printf("If the button is not pressed within 5S, the program will exit\n"); + do + { + /* Monitor button status, timeout 1S */ + if (poll(fds, 1, 1000) > 0 && fds[0].revents & POLLIN) + { + printf("Key press\n"); + count = 0; + } + else + { + count++; + } + } + while(count < 5); + + close(fd); + + printf("The program will exit\n"); + + return 0; +} +``` + +## 功能外设注册示例 + +功能外设,顾名思义就是完成特定功能的外设,这些外设需要按照规范的要求,完成 fops 里对应的函数,并注册成为一个设备,就可以了。下面以按键设备 KEY0 为例演示功能外设的注册。 + +功能外设的注册,分为如下几步: + +1. 实现 DevFS 设备框架提供的相应的 fops 接口 +2. 定义设备框架 fops 结构体,并完成成员的赋值。 +3. 实现设备初始化函数,在函数里完成设备的注册。 +4. 利用自动初始化的宏将设备初始化的函数导出 + +```c +#include +#include +#include +#include +#include + +#define GET_PIN(PORTx, PIN) (32 * (PORTx - 1) + (PIN & 31)) +#define USER_KEY GET_PIN(7, 13) // PG13 + +static uint8_t is_init; +static uint8_t key_state; +static uint8_t key_state_old; +static rt_device_t device; + +void irq_callback() +{ + /* enter interrupt */ + key_state = rt_pin_read(USER_KEY); + rt_interrupt_enter(); + rt_wqueue_wakeup(&(device->wait_queue), (void *)POLLIN); + /* leave interrupt */ + rt_interrupt_leave(); +} + +static void drv_key_init(void) +{ + key_state = 1; + key_state_old = 1; + rt_pin_mode(USER_KEY, PIN_MODE_INPUT); + rt_pin_attach_irq(USER_KEY, PIN_IRQ_MODE_RISING_FALLING, irq_callback, RT_NULL); + rt_pin_irq_enable(USER_KEY, PIN_IRQ_ENABLE); +} + +/* Open the key device, and initialize the hardware the first time you open it */ +static int drv_key_open(struct dfs_fd *fd) +{ + if (!is_init) + { + is_init = 1; + /* Initialize the hardware */ + drv_key_init(); + } + /* Increase reference count */ + device->ref_count ++; + return 0; +} +/* Close the key device, and reset the hardware when the device is no longer in use */ +static int drv_key_close(struct dfs_fd *fd) +{ + /* Reduced reference count */ + device->ref_count --; + /* Reset the hardware when the device is no longer in use */ + if (device->ref_count == 0) + { + /* ... */ + is_init = 0; + } + return 0; +} + +/* Read key state */ +static int drv_key_read(struct dfs_fd *fd, void *buf, size_t count) +{ + *(int *)buf = !rt_pin_read(USER_KEY); + return 1; +} + +/* Use poll to check the state of the key */ +static int drv_key_poll(struct dfs_fd *fd, struct rt_pollreq *req) +{ + int mask = 0; + int flags = 0; + + /* only support POLLIN */ + flags = fd->flags & O_ACCMODE; + if (flags == O_RDONLY || flags == O_RDWR) + { + /* Add to wait queue, suspend the current thread */ + rt_poll_add(&(device->wait_queue), req); + /* If the key is pressed, mark a POLLIN event */ + if (key_state != key_state_old) + { + key_state_old = key_state; + mask |= POLLIN; + } + } + return mask; +} + +/* + * Realize the fops variables. + */ +static struct dfs_file_ops drv_key_fops = +{ + drv_key_open, + drv_key_close, + RT_NULL, + drv_key_read, + RT_NULL, + RT_NULL, + RT_NULL, + RT_NULL, + drv_key_poll, +}; + +/* + * Key device initialization function. + */ +static int rt_hw_key_init(void) +{ + rt_err_t ret; + + /* 1. Allocates memory for device structures, Use the calloc function */ + device = rt_calloc(1, sizeof(struct rt_device)); + if (device == RT_NULL) + { + return -1; + } + + /* 2. Set to miscellaneous device */ + device->type = RT_Device_Class_Miscellaneous; + + /* 3. register a key device */ + ret = rt_device_register(device, "key0", RT_DEVICE_FLAG_RDONLY); + if (ret != RT_EOK) + { + rt_free(device); + return ret; + } + /* 4. set fops */ + device->fops = &drv_key_fops; + + return ret; +} +/* Using below macro to export this function, the function will be called automatically after kernel startup */ +INIT_DEVICE_EXPORT(rt_hw_key_init); +``` + +## 注意事项 + +- 在实现设备初始化代码时,应只包含设备注册代码,不能进行相应硬件的初始化。硬件的初始化应在设备第一 +次打开被使用时。 +- fops 的赋值一定要放在设备注册之后。 +- fops 的实现应根据各自功能外设的特性,选择需要实现的函数并进行实现。 +- fops 里面的 close 函数会在空闲处理函数里被调用,所以请不要在 close 里使用可能会挂起当前线程的的 API, 如:suspend,rt_sem_take 等,以防挂起 idle 线程导致系统异常。 +- INIT_BOARD_EXPORT 宏导出的函数的运行环境是 OS 调度器还没启动的时候,因此,在函数内部不可以使用有关系统调度相关的 API, 如:rt_thread_delay/mdelay。 diff --git a/rt-thread-version/rt-thread-smart/device/DevFS/figures/devfs.png b/rt-thread-version/rt-thread-smart/device/DevFS/figures/devfs.png new file mode 100644 index 0000000000000000000000000000000000000000..a375305fe1c5443984a644e70d82024ccea5b822 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/device/DevFS/figures/devfs.png differ diff --git a/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/figures/ipc-seq.png b/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/figures/ipc-seq.png new file mode 100644 index 0000000000000000000000000000000000000000..3e0b1949e3fe8b37ed2949414bade5e6ac1b6562 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/figures/ipc-seq.png differ diff --git a/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/figures/ipc.seq b/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/figures/ipc.seq new file mode 100644 index 0000000000000000000000000000000000000000..390bf5054a1a1bc4685e5cd4ce55e76ad6739df1 --- /dev/null +++ b/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/figures/ipc.seq @@ -0,0 +1,28 @@ +# https://sequencediagram.org/ + +participant ping +participant channel +participant shm +participant pong + +pong->>channel:rt_channel_recv +abox over ping,pong#yellow:ping/pong流程 +activate ping +ping->>shm:lwp_shmget +shm-->>ping:return shmid +ping->>shm:lwp_shmat +shm-->>ping:return shm +ping->>ping:prepare_data +ping->>shm:lwp_shmdt +ping->>channel:rt_channel_send_recv +activate pong +deactivate ping +channel-->>pong:recved_shmid +pong->>shm:lwp_shmat +shm-->>pong:return shm +pong->>pong:handle data +pong->>shm:lwp_shmdt +pong->>channel:rt_channel_reply +deactivate pong +channel-->>ping:recved_reply +ping->>shm:lwp_shmrm \ No newline at end of file diff --git a/rt-thread-version/rt-thread-smart/architecture/figures/memlayout.drawio.png b/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/figures/memlayout.drawio.png similarity index 100% rename from rt-thread-version/rt-thread-smart/architecture/figures/memlayout.drawio.png rename to rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/figures/memlayout.drawio.png diff --git a/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/figures/smart_arch_full.drawio.png b/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/figures/smart_arch_full.drawio.png new file mode 100644 index 0000000000000000000000000000000000000000..6a89707b82099fbe4f6573fab370489ca0e12e29 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/figures/smart_arch_full.drawio.png differ diff --git a/rt-thread-version/rt-thread-smart/architecture/figures/user_signal.drawio.png b/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/figures/user_signal.drawio.png similarity index 100% rename from rt-thread-version/rt-thread-smart/architecture/figures/user_signal.drawio.png rename to rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/figures/user_signal.drawio.png diff --git a/rt-thread-version/rt-thread-smart/architecture/architecture.md b/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/rt-smart-intro.md similarity index 92% rename from rt-thread-version/rt-thread-smart/architecture/architecture.md rename to rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/rt-smart-intro.md index 3b495201c0932b09573e411c0b67e713eb9626d5..c725aee8f67483ae6cb02130cc1acab0a8c80d79 100644 --- a/rt-thread-version/rt-thread-smart/architecture/architecture.md +++ b/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/rt-smart-intro.md @@ -1,14 +1,18 @@ -# RT-Thread Smart 架构说明 - -## RT-Thread Smart 的架构 +# RT-Thread Smart 简介 RT-Thread Smart 是基于 RT-Thread 操作系统上的混合操作系统,简称为 rt-smart,它把应用从内核中独立出来,形成独立的用户态应用程序,并具备独立的地址空间(32 位系统上是 4G 的独立地址空间)。 +RT-Thread Smart 源码位于 [rt-thread 仓库](https://github.com/RT-Thread/rt-thread) 的 `rt-smart` 分支上。下载 rt-thread 源码后,需要切换到 `rt-smart` 分支上使用。 + +> 注意:自 V5.0.0 起,rt-smart 分支已合并至 master 分支上,下载 rt-thread 源码后,无需再切换至 rt-smart 分支,但需要为 BSP 配置 Smart 内核。 + +## RT-Thread Smart 的架构 + 以下是 rt-smart 的整体结构框图,在硬件平台的基础上通过 MMU、系统调用的方式把整个系统分成了内核态及用户态。 -![arch](figures/rt-smart.drawio.png) +![arch](figures/smart_arch_full.drawio.png) -RT-Thread Smart 的核心实现是 lwP,进程管理模块( `rtthread-smart/kernel/components/lwp` )。它包括了如下的几个部分: +RT-Thread Smart 的核心实现是 lwP,进程管理模块( `rt-thread/components/lwp` )。它包括了如下的几个部分: * 面向用户态的系统调用(system call,`lwp_syscall.c/h`); * 用户态进程管理(`lwp_pid.c/h, lwp.c/h`); @@ -38,7 +42,7 @@ RT-Thread Smart 的用户态是固定地址方式运行,当需要系统服务 ## 基本的 IPC 客户端与服务端 -IPC 服务(`rtthread-smart/kernel/components/lwp/lwp_ipc.c/h`)是实现用户应用程序和其他服务的桥梁,同时也可以是用户进程与用户进程之间的通信机制、内核与用户进程之间的通信机制。 +IPC 服务(`rt-thread/components/lwp/lwp_ipc.c/h`)是实现用户应用程序和其他服务的桥梁,同时也可以是用户进程与用户进程之间的通信机制、内核与用户进程之间的通信机制。 在使用 IPC 服务时,需要先创建出对应的通道(channel),然后在通道上进行数据收发。一个 IPC 通道是一个双向数据传递的软件抽象,数据收发过程包括如下几种操作: diff --git a/rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/.DS_Store b/rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/.DS_Store similarity index 100% rename from rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/.DS_Store rename to rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/.DS_Store diff --git a/rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-Kernel_Address_Space.jpg b/rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-Kernel_Address_Space.jpg similarity index 100% rename from rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-Kernel_Address_Space.jpg rename to rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-Kernel_Address_Space.jpg diff --git a/rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-Memory_Map.jpg b/rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-Memory_Map.jpg similarity index 100% rename from rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-Memory_Map.jpg rename to rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-Memory_Map.jpg diff --git a/rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-PageBuddy.jpg b/rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-PageBuddy.jpg similarity index 100% rename from rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-PageBuddy.jpg rename to rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-PageBuddy.jpg diff --git a/rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-Process_Organization.jpg b/rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-Process_Organization.jpg similarity index 100% rename from rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-Process_Organization.jpg rename to rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-Process_Organization.jpg diff --git a/rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-Process_Resources.jpg b/rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-Process_Resources.jpg similarity index 100% rename from rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-Process_Resources.jpg rename to rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-Process_Resources.jpg diff --git a/rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-RT_Object.jpg b/rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-RT_Object.jpg similarity index 100% rename from rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-RT_Object.jpg rename to rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-RT_Object.jpg diff --git a/rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-Threads-FDT.jpg b/rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-Threads-FDT.jpg similarity index 100% rename from rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-Threads-FDT.jpg rename to rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-Threads-FDT.jpg diff --git a/rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-Threads.jpg b/rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-Threads.jpg similarity index 100% rename from rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-Threads.jpg rename to rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-Threads.jpg diff --git a/rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-Total_Address_Space.jpg b/rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-Total_Address_Space.jpg similarity index 100% rename from rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro-Total_Address_Space.jpg rename to rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro-Total_Address_Space.jpg diff --git a/rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro.drawio b/rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro.drawio similarity index 100% rename from rt-thread-version/rt-thread-smart/rt-smart-lwp/figures/lwp_intro.drawio rename to rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/figures/lwp_intro.drawio diff --git a/rt-thread-version/rt-thread-smart/rt-smart-lwp/rt-smart-lwp.md b/rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/rt-smart-lwp.md similarity index 100% rename from rt-thread-version/rt-thread-smart/rt-smart-lwp/rt-smart-lwp.md rename to rt-thread-version/rt-thread-smart/introduction/rt-smart-lwp/rt-smart-lwp.md diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/build_app-res.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/build_app-res.png new file mode 100644 index 0000000000000000000000000000000000000000..93d137086202eb475f58dbcf7b73eb6a906e1852 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/build_app-res.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/build_app.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/build_app.png new file mode 100644 index 0000000000000000000000000000000000000000..8c19c1b3f4563c1282cc8c7bcd7ebb59d732a7cc Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/build_app.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/build_kernel1.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/build_kernel1.png new file mode 100644 index 0000000000000000000000000000000000000000..4c55cc32c8ff03f3faaeb465688ecebeb569a92b Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/build_kernel1.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/build_kernel2.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/build_kernel2.png new file mode 100644 index 0000000000000000000000000000000000000000..464916b0324f266fd06369c8f5b211befa8198ae Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/build_kernel2.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/prebuilt-file.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/prebuilt-file.png new file mode 100644 index 0000000000000000000000000000000000000000..dc3cf1f68cd297bd5ee08a7ddad2a4b86b9aab11 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/prebuilt-file.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/qemu_run.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/qemu_run.png new file mode 100644 index 0000000000000000000000000000000000000000..c0deb1290a10929024165b0546e5e11ae90d61e9 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/qemu_run.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/qemu_run2.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/qemu_run2.png new file mode 100644 index 0000000000000000000000000000000000000000..f57a217a2085ad99493f2c3f17be17b00f1bcafd Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/qemu_run2.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/samrt-cfg.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/samrt-cfg.png new file mode 100644 index 0000000000000000000000000000000000000000..190b4cb5d2ae53424427c1d0a186bf540e01671e Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/samrt-cfg.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/sd.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/sd.png new file mode 100644 index 0000000000000000000000000000000000000000..1e5301bb3ccfce40b3a6cd85c988ee9d9f81cc5c Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/sd.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/set.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/set.png new file mode 100644 index 0000000000000000000000000000000000000000..73a894fcb1e1187522a13c052878a6ea338ba2e2 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/set.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/smart-cfg-first-stages.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/smart-cfg-first-stages.png new file mode 100644 index 0000000000000000000000000000000000000000..2ce7a454af5c2309e68b240f1b9651e36d51c668 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/smart-cfg-first-stages.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/usr-space-cfg.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/usr-space-cfg.png new file mode 100644 index 0000000000000000000000000000000000000000..8e04de35f11b3e960eb4e15906f7273f6a1f9b09 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/usr-space-cfg.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/quickstart.md b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/quickstart.md new file mode 100644 index 0000000000000000000000000000000000000000..1d95acf42beee61ccf23651394df3db809c89821 --- /dev/null +++ b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/quickstart.md @@ -0,0 +1,167 @@ +# QEMU 快速上手 (Linux) + +本教程在 Ubuntu 平台上使用 QEMU 快速上手 RT-Smart,运行 RT-Smart 用户态应用,内核基于 qemu-vexpress-a9 ,其他内核可以用同样的方式运行。 + +> 注意:运行环境的 QEMU 版本太低会导致执行脚本后终端无输出。 + +## 如何构建用户态应用 + +### 下载代码 + +下载 smart 用户态应用代码: + +``` +git clone https://github.com/RT-Thread/userapps.git +``` + +源码目录说明: + +``` +. +├── apps ---- app 体验示例 +├── configs ---- 不同平台 app 的通用配置 +├── linker_scripts ---- 编译 app 使用的链接脚本 +├── prebuilt ---- 预编译好的内核镜像 +├── rtconfig.h ---- app 使用的公共配置文件 +├── sdk ---- 开发 app 使用的 sdk +├── smart-env.bat ---- 配置 Win 上环境变量的脚本 +├── smart-env.sh ---- 配置 Linux 上环境变量的脚本 +└── tools ---- 开发 app 使用的脚本工具 + ├── get_toolchain.py ---- 下载工具链的脚本 + └── gnu_gcc ---- 下载下来的工具链存放的路径 +``` + +### 配置工具链 + +在 userapps\tools 目录下运行 get_toolchain.py 的脚本,会下载对应的工具链并展开到 userapps\tools\gun_gcc 目录。后面的工具链名称可以是 arm | riscv64。 + +本文以 ARM 平台为例,输入下面的命令: + +``` +python get_toolchain.py arm +``` + +在 userapps 目录下, 运行 smart-env.sh 配置工具链路径,配置完会显示配置好的工具链路径。(这一步包括后面步骤编译内核都需要保留的工具链路径,重开一个终端都要重新source一次) + +``` +source smart-env.sh arm +``` + +![image-20221021144625013](figures/set.png) + +### 编译用户态应用 + +在 userapps 目录下使用 scons 编译,编译顺利的话,将在 root 文件夹中得到一系列可执行 elf 文件。 + +![img](figures/build_app.png) + +![image-20221021145335403](figures/build_app-res.png) + + +## 构建内核镜像 + +rt-thread 中默认的镜像并非 Smart 需要先编译替换 + +下载 rt-thread 源码(如有则跳过),之后切换到 rt-smart 分支并从远端同步更新。(RT-Thread 版本大于等于 5.0.0 时,直接查看下面的注意事项) + +``` +git clone https://github.com/RT-Thread/rt-thread.git + +git checkout rt-smart +# update kernel's rt-smart branch to the latest version +git pull origin rt-smart +``` + +基于 rt-thread 仓库 rt-smart 分支的 qemu-vexprss-a9 BSP 构建内核镜像,在该目录下执行 scons 编译。 + +![img](figures/build_kernel1.png) + +![image-20221021153136199](figures/build_kernel2.png) + +将生成的内核镜像 rtthread.bin 更新到 userapps\prebuilt\ qemu-vexpress-a9 目录即可。 + +> 注意事项: +> +> RT-Thread 版本大于等于 5.0.0 时,rt-smart 分支合并进 master 分支,下载 rt-thread 源码(如有则跳过)。 +> +> ``` +> git clone https://github.com/RT-Thread/rt-thread.git +> cd ./rt-thread/bsp/qemu-vexpress-a9/ #打开rt-thread项目目录中的 bsp/qemu-vexpress-a9目录 +> scons --menuconfig +> ``` +> +> 基于 rt-thread 仓库的 qemu-vexprss-a9 BSP 构建内核镜像: +> +> 1. 选择 RT-Thread Kernel 选项 +> +> ![img](figures/smart-cfg-first-stages.png) +> +> +> 2. 使能 Smart 内核 +> +> ![img](figures/samrt-cfg.png) +> +> +> 3. 然后在该目录下执行 scons 编译 +> +> ![img](figures/build_kernel1.png) +> +> ![image-20221021153136199](figures/build_kernel2.png) +> +> 将生成的内核镜像 rtthread.bin 更新到 userapps\prebuilt\qemu-vexpress-a9 目录即可。 + + + +## 运行用户态应用 + +在本仓库的 prebuilt 目录下存放有预构建好的针对 QEMU ARM 平台的内核镜像 qemu-vexpress-a9\rtthread.bin,可以直接运行体验。 + +### 将待调试的 app 拷贝到 sd.bin + +如果 sd.bin 不存在,可以通过下面方法创建并格式化: + +``` +dd if=/dev/zero of=sd.bin bs=1024 count=65536 +mkfs.vfat sd.bin +``` + +然后后拷贝 app 到 sd.bin 中 (调试过程中每次修改重新编译 app 后,都需要更新 sd.bin 里面的 app 文件): + +``` +sudo mount sd.bin /mnt +sudo cp root/bin/hello.elf /mnt/hello.elf +sudo umount /mnt +``` + +![image-20221021153444835](figures/sd.png) + +### 运行 QEMU + +将 sd.bin 复制到 userapps\prebuilt\qemu-vexpress-a9 中,终端也切换到该目录下 + +![image-20221021152537185](figures/prebuilt-file.png) + +在 userapps\prebuilt\qemu-vexpress-a9 目录下创建 qemu-nographic.sh 文件,写入以下命令(如果当前目录已有 qemu-nographic.sh 请忽略) +``` +#!/bin/bash +SHELL_FOLDER=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) + +if [ ! -f ${SHELL_FOLDER}/"sd.bin" ]; then +qemu-img create -f raw ${SHELL_FOLDER}/sd.bin 64M +fi +qemu-system-arm -M vexpress-a9 -kernel rtthread.bin -nographic -sd sd.bin +``` +然后执行 `./qemu-nographic.sh`。 + +![image-20221024180626302](figures/qemu_run.png) + +Smart 运行起来后输入 ls 可以看到我们存储到 QEMU SD 卡里的文件和文件夹了。 + +![image-20221024180816610](figures/qemu_run2.png) + +在最后执行了 hello 示例,输出 "hello world!"。 + +执行 ctrl a,x 可退出 QEMU。 + + + diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/build_app.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/build_app.png new file mode 100644 index 0000000000000000000000000000000000000000..cc11c8c34afab06ee49fdb75fd64fcc77153636b Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/build_app.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/build_kernel1.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/build_kernel1.png new file mode 100644 index 0000000000000000000000000000000000000000..46dd88f42f7d194f337f17d8fad3806a6c249289 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/build_kernel1.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/build_kernel2.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/build_kernel2.png new file mode 100644 index 0000000000000000000000000000000000000000..c9ad7e7b479c93fbcd3d2d17ce623028cffec6d2 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/build_kernel2.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/build_sd1.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/build_sd1.png new file mode 100644 index 0000000000000000000000000000000000000000..e90aa76a327d898963f2efeaf953d8f65ae2e7ba Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/build_sd1.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/build_sd2.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/build_sd2.png new file mode 100644 index 0000000000000000000000000000000000000000..a4f190548749ee8c70a8b47d159ec3c5d25fd283 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/build_sd2.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/qemu_run.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/qemu_run.png new file mode 100644 index 0000000000000000000000000000000000000000..a57dab18714758a7cfc04b130d54d4cff2d25a95 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/qemu_run.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/qemu_run2.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/qemu_run2.png new file mode 100644 index 0000000000000000000000000000000000000000..8c6fa862fba218ec57724e55f5ab7694e9d0f53f Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/qemu_run2.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/samrt-cfg.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/samrt-cfg.png new file mode 100644 index 0000000000000000000000000000000000000000..190b4cb5d2ae53424427c1d0a186bf540e01671e Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/samrt-cfg.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/set.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/set.png new file mode 100644 index 0000000000000000000000000000000000000000..b8a9c4dc1040d4151c212e5ad9a59b088addc325 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/set.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/usr-space-cfg.png b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/usr-space-cfg.png new file mode 100644 index 0000000000000000000000000000000000000000..8e04de35f11b3e960eb4e15906f7273f6a1f9b09 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/figures/usr-space-cfg.png differ diff --git a/rt-thread-version/rt-thread-smart/quick-start/qemu-win/quickstart.md b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/quickstart.md new file mode 100644 index 0000000000000000000000000000000000000000..9bc8288440a7f90b3ab69d6e85d9a59cc1d96991 --- /dev/null +++ b/rt-thread-version/rt-thread-smart/quick-start/qemu-win/quickstart.md @@ -0,0 +1,181 @@ +# QEMU 快速上手 (Windows) + +本教程在 Windows 平台上使用 QEMU 快速上手 RT-Smart,运行 RT-Smart 用户态应用。 + +## 如何构建用户态应用 + +### 下载代码 + +下载 smart 用户态应用代码: + +``` +git clone https://github.com/RT-Thread/userapps.git +``` + +源码目录说明: + +``` +. +├── apps ---- app 体验示例 +├── configs ---- 不同平台 app 的通用配置 +├── linker_scripts ---- 编译 app 使用的链接脚本 +├── prebuilt ---- 预编译好的内核镜像 +├── rtconfig.h ---- app 使用的公共配置文件 +├── sdk ---- 开发 app 使用的 sdk +├── smart-env.bat ---- 配置 Win 上环境变量的脚本 +├── smart-env.sh ---- 配置 Linux 上环境变量的脚本 +└── tools ---- 开发 app 使用的脚本工具 + ├── get_toolchain.py ---- 下载工具链的脚本 + └── gnu_gcc ---- 下载下来的工具链存放的路径 +``` + +### 配置工具链 + +在 userapps\tools 目录下运行 get_toolchain.py 的脚本,会下载对应的工具链并展开到 userapps\tools\gun_gcc 目录。后面的工具链名称可以是 arm | riscv64。 + +本文以 RISC-V 平台为例,输入下面的命令: + +``` +python get_toolchain.py riscv64 +``` + +在 userapps 目录下, 运行 smart-env.bat 配置工具链路径 + +``` +smart-env.bat riscv64 +``` + +可使用 set 命令检查 RTT_EXEC_PATH 是否设置成功 + +![img](figures/set.png) + +### 编译用户态应用 + +在 userapps 目录下使用 scons 编译,编译顺利的话,将在 root 文件夹中得到一系列可执行 elf 文件。 + +![img](figures/build_app.png) + +## 运行用户态应用 + +在本仓库的 prebuilt 目录下存放有预构建好的针对 QEMU RISC-V 平台的内核镜像 qemu-virt64-riscv\rtthread.bin,可以直接运行体验。 + +### 更新 Env + +将 Env 工具更新到新版本([V1.3.5](https://github.com/RT-Thread/env-windows/releases/tag/v1.3.5) 或更高版本),该版本对 QEMU 进行了升级。 + +### 制作 QEMU SD 卡 + +在 Env 工具的 tools\fatdisk 目录下有一个打包 FAT 格式文件的工具 fatdisk.exe,我们可以利用这个工具将我们要存储到 QEMU SD 卡里的文件打包成 sd.bin 文件。 + +1. 将 userapps 下的 root 目录复制到 env\tools\fatdisk 目录下 + +![img](figures/build_sd1.png) + +2. 修改 env\tools\fatdisk 目录下 fatdisk.xml 文件为下面的内容 + +``` + + + 65536 + 512 + root + sd.bin + 0 + +``` + +3. 在 env\tools\fatdisk 目录下右键打开 Env 工具,输入命令 fatdisk 运行,就会在当前目录下生成 sd.bin 文件了。 + +![img](figures/build_sd2.png) + +4. 将新生成的 sd.bin 放入 userapps\prebuilt\qemu-virt64-riscv 目录。 + +### 运行 QEMU + +在 userapps\prebuilt\qemu-virt64-riscv 目录下打开 Env,执行 qemu-norgraphic.bat 运行 QEMU。 + +![img](figures/qemu_run.png) + +Smart 运行起来后输入 ls 可以看到我们存储到 QEMU SD 卡里的文件和文件夹了。 + +![img](figures/qemu_run2.png) + +在最后执行了 hello 示例,输出 "hello world!"。 + +执行 ctrl c 可退出 QEMU。 + +## 构建内核镜像 + +当需要更新内核镜像文件时,查看本节内容。 + +下载 rt-thread 源码(如有则跳过),之后切换到 rt-smart 分支并从远端同步更新。(RT-Thread 版本大于等于 5.0.0 时,直接查看下面的注意事项) + +``` +git clone https://github.com/RT-Thread/rt-thread.git + +git checkout rt-smart +# update kernel's rt-smart branch to the latest version +git pull origin rt-smart +``` + +基于 rt-thread 仓库 rt-smart 分支的 qemu-virt64-riscv BSP 构建内核镜像。 + +![img](figures/build_kernel1.png) + +![img](figures/build_kernel2.png) + +将生成的内核镜像 rtthread.bin 更新到 userapps\prebuilt\qemu-virt64-riscv 目录即可。 + +> 注意事项: +> +> RT-Thread 版本大于等于 5.0.0 时,rt-smart 分支合并进 master 分支,下载 rt-thread 源码(如有则跳过)。 +> +> ``` +> git clone https://github.com/RT-Thread/rt-thread.git +> +> ``` +> +> 基于 rt-thread 仓库的 qemu-virt64-riscv BSP 构建内核镜像: +> +> 1. 首先是使能 Smart 内核 +> +> ![img](figures/samrt-cfg.png) +> +> 2. 打开 Isolated user space 选项,之后退出并保存 +> +> ![img](figures/usr-space-cfg.png) +> +> 3. 然后在该目录下执行 scons 编译 +> +> ![img](figures/build_kernel1.png) +> +> ![img](figures/build_kernel2.png) +> +> 将生成的内核镜像 rtthread.bin 更新到 userapps\prebuilt\qemu-virt64-riscv 目录即可。 + +## QA + +### scons 时找不到工具链 + +编译时出现如下信息: + +``` +> scons +scons: Reading SConscript files ... +scons: done reading SConscript files. +scons: Building targets ... +CC apps\webclient\packages\webclient-v2.1.2\src\webclient.o +Error in calling command:riscv64-unknown-linux-musl-gcc +Exception: No such file or directory + +Please check Toolchains PATH setting. + +scons: *** [apps\webclient\packages\webclient-v2.1.2\src\webclient.o] Error 2 +scons: building terminated because of errors. +``` + +请检查工具链路径是否设置正确,按照文中步骤进行设置。 + +### scons 时出现 zlib1.dll 丢失的弹窗 + +重新下载 [zlib1.dll 文件](https://www.dlldownloader.com/zlib1-dll/) 并分别放在 C:\Windows\System32 与 C:\Windows\SysWOW64 文件夹中。 diff --git a/rt-thread-version/rt-thread-smart/rt-smart-quickstart/figures/Rapi4B.jpg b/rt-thread-version/rt-thread-smart/rt-smart-quickstart/figures/Rapi4B.jpg deleted file mode 100644 index 067a4b97a914e50100f18cdb6215d05700ebc85d..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/rt-smart-quickstart/figures/Rapi4B.jpg and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/rt-smart-quickstart/figures/boot.png b/rt-thread-version/rt-thread-smart/rt-smart-quickstart/figures/boot.png deleted file mode 100644 index 5ef2839ab0d711e42ce511f8e58f1eeb53b40b4a..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/rt-smart-quickstart/figures/boot.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/rt-smart-quickstart/figures/contents.png b/rt-thread-version/rt-thread-smart/rt-smart-quickstart/figures/contents.png deleted file mode 100644 index 8234ce0e1a1dfbc8966e09d9379b4aa4bb18fc15..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/rt-smart-quickstart/figures/contents.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/rt-smart-quickstart/figures/uart.png b/rt-thread-version/rt-thread-smart/rt-smart-quickstart/figures/uart.png deleted file mode 100644 index 64d5f77aad33de446a7a3ea08007164d4c1f5d9c..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-smart/rt-smart-quickstart/figures/uart.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-smart/rt-smart-quickstart/rt-smart-quickstart.md b/rt-thread-version/rt-thread-smart/rt-smart-quickstart/rt-smart-quickstart.md deleted file mode 100644 index e3c02d4499837cde5ed9ac5aea600819218e4f80..0000000000000000000000000000000000000000 --- a/rt-thread-version/rt-thread-smart/rt-smart-quickstart/rt-smart-quickstart.md +++ /dev/null @@ -1,256 +0,0 @@ -# RT-Thread Smart 入门指南 - -RT-Thread Smart(简称 rt-smart)是基于 RT-Thread 操作系统衍生的新分支,面向带 MMU,中高端应用的芯片,例如 ARM Cortex-A 系列芯片,MIPS 芯片,带 MMU 的 RISC-V 芯片等。rt-smart 在 RT-Thread 操作系统的基础上启用独立、完整的进程方式,同时以混合微内核模式执行。 - -rt-smart 软件包是 RT-Thread Smart 的用户体验软件包,可在 QEMU 模拟的 VExpress-A9 机器中或树莓派 4B 开发板上执行。本文档是针对 QEMU、树莓派 4B 开发板上快速上手 rt-smart 入门指南文档。 - -## 软件包说明 -### 下载 rt-smart 软件包 - -下载 [rt-smart.zip](http://117.143.63.254:9012/www/rt-smart/) 软件包,解压后的目录说明如下图所示: - -![contents](figures/contents.png) - -### 准备工具链 - -针对 Linux 和 Windows 环境需要下载对应的 arm-linux-musleabi 工具链,如果是 rt-smart 的软件包,则自带 Linux 环境下的工具链。 - -- Linux 版本工具链下载:[Linux 版本工具链](http://117.143.63.254:9012/www/rt-smart/) - -- Windows 版本工具链下载:[Windows 版本工具链](http://117.143.63.254:9012/www/rt-smart/) - -请根据自己的开发环境选择对用的工具链下载使用。 - -下载下来后分别解压展开到 `rt-smart/tools/gnu_gcc` 目录下,rt-smart 目录下的 smart-env.bat/sh 设置的环境变量,其中工具链路径都指向到这个目录下。 - -## Linux 下编译并在 QEMU 模拟环境上执行 - -在 Linux 系统下,需要安装一些基本的环境,然后才能编译 rt-smart。本文档是基于 Ubuntu16.04 系统环境操作,其它 Linux 版本类似。 - -### 安装编译环境 - -首先安装编译时需要用到的其他工具,软件包,可以通过如下的一些命令来安装: - -```bash -sudo apt-get update -sudo apt-get install vim scons git bzip2 net-tools -sudo apt-get install python-all python-all-dev -sudo apt-get install qemu-system-arm qemu-system-common qemu-utils -``` - -以上命令会安装一些系统基础工具、python 环境、scons、qemu 工具等。 - -### 编译应用程序 - -```bash -# 进入到 rt-smart 目录 -cd rt-smart - -# 设置对应的环境变量,和原 RT-Thread 相比,多了 RTT_CC_PREFIX 环境变量 -source smart-env.sh - -# 编译用户态程序 -cd userapps -scons - -scons: Reading SConscript files ... -scons: done reading SConscript files. -scons: Building targets ... -CC build/hello/main.o -CC build/ping/main.o -CC build/pong/main.o -CC build/vi/optparse-v1.0.0/optparse.o -CC build/vi/vi.o -CC build/vi/vi_utils.o -CC build/webclient/main.o -LINK root/bin/hello.elf -LINK root/bin/ping.elf -LINK root/bin/pong.elf -LINK root/bin/vi.elf -LINK root/bin/webclient.elf -scons: done building targets. -``` - -编译成功后,`userapps/apps` 下的应用程序会编译成一个个的 elf 可执行文件,并放置于 `userapps/root/bin` 目录下,可以把它转换成 romfs、C 语言数组的方式给 rt-smart 内核使用,这样可以不依赖于其他文件系统就可以直接执行,生成 romfs、C 语言数组可以用如下的命令行: - -```bash -cd userapps -python ../tools/mkromfs.py root ../kernel/bsp/qemu-vexpress-a9/applications/romfs.c -``` - -### 编译 rt-smart 内核 - -```bash -cd rt-smart/kernel/bsp/qemu-vexpress-a9 -scons -... ... -CC build/kernel/src/thread.o -CC build/kernel/src/timer.o -LINK rtthread.elf -arm-linux-musleabi-objcopy -O binary rtthread.elf rtthread.bin -arm-linux-musleabi-size rtthread.elf - text data bss dec hex filename -1219480 40652 122444 1382576 1518b0 rtthread.elf -scons: done building targets. -``` - -如果编译无误,会生成 rtthread.elf 内核文件。 - -### 模拟执行 - -通过 qemu 模拟的 vexpress-a9 开发板来直接运行: - -```bash -cd rt-smart/kernel/bsp/qemu-vexpress-a9 -./qemu-nographic.sh - - \ | / -- RT - Thread Smart Operating System - / | \ 5.0.0 build Nov 15 2020 - 2006 - 2020 Copyright by rt-thread team -lwIP-2.0.2 initialized! -try to allocate fb... | w - 640, h - 480 | done! -fb => 0x61100000 -[I/sal.skt] Socket Abstraction Layer initialize success. -[I/SDIO] SD card capacity 65536 KB. -Dir /mnt mount failed! -hello rt-thread -msh /> -msh />/bin/hello.elf -msh />hello world! -``` - -退出 qemu 的方法: "Ctrl+A, X"。上面我们也运行了这次编译的应用程序 `/bin/hello.elf`,并看到它输出 `hello world!`。 - -在第一次执行时,会输出 `Dir /mnt mount failed!`,这个是因为最开始执行时,qemu 的脚本会生成一个空的 sd.bin 文件做为一个 sd 卡给到 vexpress-a9 使用。所以在第一次执行时,需要对 sd0 进行格式化: - -```bash - \ | / -- RT - Thread Smart Operating System - / | \ 5.0.0 build Nov 24 2020 - 2006 - 2020 Copyright by rt-thread team -lwIP-2.0.2 initialized! -try to allocate fb... | w - 640, h - 480 | done! -fb => 0x61100000 -[I/sal.skt] Socket Abstraction Layer initialize success. -[I/SDIO] SD card capacity 65536 KB. -[I/SDIO] switching card to high speed failed! -Dir /mnt mount failed! -hello rt-thread -msh />mkfs sd0 -msh /> - -# Ctrl + A, X 退出 -QEMU: Terminated - -bernard@fuchsia-NUC8i7BEH:~/workspace/rt-smart/smart/kernel/bsp/qemu-vexpress-a9$ ./qemu-nographic.sh - \ | / -- RT - Thread Smart Operating System - / | \ 5.0.0 build Nov 24 2020 - 2006 - 2020 Copyright by rt-thread team -lwIP-2.0.2 initialized! -try to allocate fb... | w - 640, h - 480 | done! -fb => 0x61100000 -[I/sal.skt] Socket Abstraction Layer initialize success. -[I/SDIO] SD card capacity 65536 KB. -[I/SDIO] switching card to high speed failed! -file system initialization done! -hello rt-thread -msh /> -``` -## Windows 下编译并在树莓派 4B 上执行 - -在 Windows 上同样也可以进行编译,在 qemu 或树莓派 4B 开发板上执行起来,这里主要提及如何在树莓派 4B 上执行的方式。 - -![Rapi4](figures/Rapi4B.jpg) - -### 准备编译环境 - -在 Windows 上编译 rt-smart,可以借助 RT-Thread 的 env 工具,env 工具下载及安装请参考 [这里](https://www.rt-thread.org/page/download.html), 请确保 env 可以正常使用。因为 rt-smart 软件包并不携带 Windows 环境下的工具链,所以务必记得安装前面描述的 准备工具链 章节下载 Windows 工具链并在 `rt-smart\tools\gnu_gcc` 下解压展开。打开 env 的终端窗口,切换到这个 rt-smart 代码包根目录,运行 smart-env.bat,它会设置一定的环境变量,然后整体的 smart 开发环境就可以使用了。 - -```bash -# 进入 rt-smart 目录,设置环境变量 -cd rt-smart -> smart-env.bat -``` - -注:此处运行 smart-env.bat 设置环境,它包括编译器设置,同时它也会设置工具链的前缀,可以在 env 终端下输入以下命令查看返回结果是否生效: - -```bash -# 查看环境变量是否生效 -> set RTT_CC_PREFIX -RTT_CC_PREFIX=arm-linux-musleabi- -``` - -### 编译应用程序 -当要编译应用程序时,使用方式和 Linux 的类似: - -```bash -# 进入 userapps 目录进行编译 -cd rt-smart\userapps -scons -``` - -### 编译 rt-smart 内核 - -```bash -# 进入 raspberry-pi\raspi4-32 目录进行编译 -cd rt-smart\kernel\bsp\raspberry-pi\raspi4-32 -scons -... ... -CC build/kernel/src/signal.o -CC build/kernel/src/thread.o -CC build/kernel/src/timer.o -LINK rtthread.elf -arm-linux-musleabi-objcopy -O binary rtthread.elf kernel7.img -arm-linux-musleabi-size rtthread.elf - text data bss dec hex filename - 710780 40448 64730 815958 c7356 rtthread.elf -scons: done building targets. -``` - -编译无误后,会在当前目录下生成 kernel7.img 文件,这个是树莓派上 32 位的版本。目前 rt-smart 还只支持 32 位系统,所以在树莓派 4B 上是以 32 位模式来执行。 - -### 在树莓派上执行 -#### 准备硬件连接 - -为了在树莓派 4B 上执行,需要准备如下硬件清单,并连接串口线到开发板,连接图示如下: - -- 树莓派 4B -- SD 卡(32GB 或 32GB 以下) -- USB 转 TTL 串口线 -- 网线 -- TYPE-C(用于供电) -- 读卡器(用于把编译好的文件写入到 SD 卡中) - -![uart](figures/uart.png) - -#### 准备 SD 卡上的软件 - -树莓派的加载需要将一些 boot 文件放到 sd 卡中。[rpi4_rt-smart_boot.zip](http://117.143.63.254:9012/www/rt-smart/) 为树莓派的加载需要的一些 boot 文件,将下载后的文件解压后和 kernel7.img 一起放入空的 SD 卡根目录,如下图所示,其中 bin 文件夹中存放 `userapps\root\bin` 目录下已编译好的可执行 elf 文件。 - -![boot](figures/boot.png) - -打开串口调试助手,插上电源,可以看到程序已经正常的运行起来,进入 bin 目录下即可执行示例程序: - -```bash -heap: 0xc00c9a0a - 0xc40c9a0a -\ | / -- RT - Thread Smart Operating System -/ | \ 5.0.0 build Nov 15 2020 - 2006 - 2020 Copyright by rt-thread team -lwIP-2.0.2 initialized! -version is B1 -bcmgenet: PHY startup ok! -[I/sal.skt] Socket Abstraction Layer initialize success. -[I/SDIO] SD card capacity 31465472 KB. -found part[0], begin: 4194304, size: 256.0MB -found part[1], begin: 272629760, size: 29.772GB -file system initialization done! -hello rt-thread! -msh />/bin/hello.elf -msh />hello world! -``` - - - diff --git a/rt-thread-version/rt-thread-standard/_navbar.md b/rt-thread-version/rt-thread-standard/_navbar.md index cc051fadfe5417a6ef035807d33b9c34f64d250d..99cde98e0b69feb63a8bf40f33489762d66442dd 100644 --- a/rt-thread-version/rt-thread-standard/_navbar.md +++ b/rt-thread-version/rt-thread-standard/_navbar.md @@ -7,7 +7,7 @@ * [新手指导](/other/novice-guide/README.md) * [标准版本](/rt-thread-version/rt-thread-standard/README.md) * [Nano 版本](/rt-thread-version/rt-thread-nano/an0038-nano-introduction.md) -* [Smart 版本](/rt-thread-version/rt-thread-smart/rt-smart-quickstart/rt-smart-quickstart.md) +* [Smart 版本](/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/rt-smart-intro.md) * [开发工具](/development-tools/rtthread-studio/README.md) diff --git a/rt-thread-version/rt-thread-standard/_sidebar.md b/rt-thread-version/rt-thread-standard/_sidebar.md index 12f442a01118ff1a6ee32f170d5d82083adb1204..7e7e7d2bbdff295afc399ac01c34e9592126f26b 100644 --- a/rt-thread-version/rt-thread-standard/_sidebar.md +++ b/rt-thread-version/rt-thread-standard/_sidebar.md @@ -8,17 +8,14 @@ - [RT-Thread潘多拉STM32L475](/rt-thread-version/rt-thread-standard/tutorial/quick-start/iot_board/quick-start.md) - [野火霸道STM32F103](/rt-thread-version/rt-thread-standard/tutorial/quick-start/stm32f103-fire-arbitrary/quick-start.md) - [正点原子nanoSTM32F103](/rt-thread-version/rt-thread-standard/tutorial/quick-start/stm32f103-atk-nano/quick-start.md) - - [新唐NuMaker-M032KI](/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m032ki/quick-start.md) - [野火挑战者STM32F429](/rt-thread-version/rt-thread-standard/tutorial/quick-start/stm32f429-fire-challenger/quick-start.md) - [正点原子探索者STM32F407](/rt-thread-version/rt-thread-standard/tutorial/quick-start/stm32f407-atk-explorer/quick-start.md) - - [新唐 NuMaker-M2354](/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m2354/quick-start.md) - [正点原子阿波罗STM32F429](/rt-thread-version/rt-thread-standard/tutorial/quick-start/stm32f429-atk-apolo/quick-start.md) - - [新唐NuMaker-PFM-M487](/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-pfm-m487/quick-start.md) - [野火I.MX RT1052](/rt-thread-version/rt-thread-standard/tutorial/quick-start/imxrt1052-fire-mini/quick-start.md) - [正点原子号令者I.MX RT1052](/rt-thread-version/rt-thread-standard/tutorial/quick-start/imxrt1052-atk-commander/quick-start.md) - - [新唐NK-980IOT](/rt-thread-version/rt-thread-standard/tutorial/quick-start/nk-980iot/quick-start.md) - [Nordic-nRF5x](/rt-thread-version/rt-thread-standard/tutorial/quick-start/nordic-nrf5x/quick-start.md) - - [英飞凌 CY8CPROTO-062-4343W](/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/quick-start.md) + - [英飞凌 CY8CKIT-062S2-43012](/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/quick-start.md) + - [OPENHW Core-V-MCU](/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/quick-start.md) - [其他开发板...](/rt-thread-version/rt-thread-standard/tutorial/quick-start/more.md) - 内核 - [内核基础](/rt-thread-version/rt-thread-standard/programming-manual/basic/basic.md) @@ -29,6 +26,7 @@ - [内存管理](/rt-thread-version/rt-thread-standard/programming-manual/memory/memory.md) - [中断管理](/rt-thread-version/rt-thread-standard/programming-manual/interrupt/interrupt.md) - [内核移植](/rt-thread-version/rt-thread-standard/programming-manual/porting/porting.md) + - [原子操作](/rt-thread-version/rt-thread-standard/programming-manual/atomic/atomic.md) - [SMP 介绍与移植](/rt-thread-version/rt-thread-standard/programming-manual/smp/smp.md) - 设备和驱动 - [I/O设备模型](/rt-thread-version/rt-thread-standard/programming-manual/device/device.md) @@ -39,6 +37,7 @@ - [DAC设备](/rt-thread-version/rt-thread-standard/programming-manual/device/dac/dac.md) - [CAN设备](/rt-thread-version/rt-thread-standard/programming-manual/device/can/can.md) - [HWTIMER设备](/rt-thread-version/rt-thread-standard/programming-manual/device/hwtimer/hwtimer.md) + - [CPUTIME设备](/rt-thread-version/rt-thread-standard/programming-manual/device/cputime/cputime.md) - [I2C总线设备](/rt-thread-version/rt-thread-standard/programming-manual/device/i2c/i2c.md) - [PWM设备](/rt-thread-version/rt-thread-standard/programming-manual/device/pwm/pwm.md) - [RTC设备](/rt-thread-version/rt-thread-standard/programming-manual/device/rtc/rtc.md) @@ -83,6 +82,7 @@ - [FinSH 控制台](/rt-thread-version/rt-thread-standard/programming-manual/finsh/finsh.md) - [FAL 组件](/rt-thread-version/rt-thread-standard/programming-manual/fal/fal.md) - [虚拟文件系统](/rt-thread-version/rt-thread-standard/programming-manual/filesystem/filesystem.md) + - [TMPFS文件系统](/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/tmpfs.md) - [ulog 日志](/rt-thread-version/rt-thread-standard/programming-manual/ulog/ulog.md) - [utest 测试框架](/rt-thread-version/rt-thread-standard/programming-manual/utest/utest.md) - [电源管理](/rt-thread-version/rt-thread-standard/programming-manual/pm/pm.md) @@ -183,8 +183,13 @@ - [FSP配置外设教程](/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA系列使用FSP配置外设驱动.md) - [外设驱动添加指南](/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA系列外设驱动添加指南.md) +- 官方开发板 + - [ART-PI](/rt-thread-version/rt-thread-standard/hw-board/art-pi/art-pi.md) + - [英飞凌评估套件](/rt-thread-version/rt-thread-standard/hw-board/ifx-eval-kit/ifx-eval-kit.md) - Demo示例 + - 开源参考设计 + - [英飞凌网关Demo](/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/Infineon/Infineon-gateway-demo.md) - 蜂鸣器播放器 - [简介](/rt-thread-version/rt-thread-standard/tutorial/beep-player/README.md) - [使用PIN设备控制LED](/rt-thread-version/rt-thread-standard/tutorial/beep-player/pin.md) diff --git a/rt-thread-version/rt-thread-standard/application-note/bsp/bsp-selfcheck/bsp-selfcheck.md b/rt-thread-version/rt-thread-standard/application-note/bsp/bsp-selfcheck/bsp-selfcheck.md index 07b6f74eded79c66d47bcc998c279512ef52051b..e764d6a2a746b82f0ca86cdd609b2b3f61971740 100644 --- a/rt-thread-version/rt-thread-standard/application-note/bsp/bsp-selfcheck/bsp-selfcheck.md +++ b/rt-thread-version/rt-thread-standard/application-note/bsp/bsp-selfcheck/bsp-selfcheck.md @@ -17,7 +17,7 @@ dir_path: ## 代码规范部分 -首先了解代码规范,可以查看 rt-thread 源码中的文档:[代码格式](https://gitee.com/rtthread/rt-thread/blob/gitee_master/documentation/coding_style_cn.md),请仔细阅读每一条内容。 +首先了解代码规范,可以查看 rt-thread 源码中的文档:[代码格式](https://gitee.com/rtthread/rt-thread/blob/master/documentation/contribution_guide/coding_style_cn.md),请仔细阅读每一条内容。 举例代码格式要求: @@ -72,7 +72,7 @@ dir_path: - 所有文件都要有 license 文件头 - 不能有 GPL 等与 Apache2.0 版权冲突的版权 -- 非 Apache2.0 的兼容 license,需要更新 bsp 目录下的 license 声明:[Copyright_Notice.md](https://gitee.com/rtthread/rt-thread/blob/gitee_master/bsp/Copyright_Notice.md),bsp 按照字母顺序排列。 +- 非 Apache2.0 的兼容 license,需要更新 bsp 目录下的 license 声明:[Copyright_Notice.md](https://gitee.com/rtthread/rt-thread/blob/master/bsp/Copyright_Notice.md),bsp 按照字母顺序排列。 ## 工程文件检查 @@ -86,7 +86,7 @@ dir_path: ## 使用工具格式化代码 -本部分在 [代码格式](https://gitee.com/rtthread/rt-thread/blob/gitee_master/documentation/coding_style_cn.md) 中有记录。 +本部分在 [代码格式](https://gitee.com/rtthread/rt-thread/blob/master/documentation/contribution_guide/coding_style_cn.md) 中有记录。 1、astyle 格式化代码,参数: @@ -109,7 +109,7 @@ dir_path: ## 添加 bsp 到 CI -打开源码根目录下 [.github/workflows/action.yml](https://gitee.com/rtthread/rt-thread/blob/gitee_master/.github/workflows/action.yml) 文件,添加 bsp 到 ci。 +打开源码根目录下 [.github/workflows/action.yml](https://gitee.com/rtthread/rt-thread/blob/master/.github/workflows/action.yml) 文件,添加 bsp 到 ci。 ## 提交 PR 之后的检查项 diff --git a/rt-thread-version/rt-thread-standard/application-note/components/at/an0014-at-client.md b/rt-thread-version/rt-thread-standard/application-note/components/at/an0014-at-client.md index 95f5b980766b0b81a5950fada22d5e452d804b13..4ac58b18599e150873c95660078f4effaba07220 100644 --- a/rt-thread-version/rt-thread-standard/application-note/components/at/an0014-at-client.md +++ b/rt-thread-version/rt-thread-standard/application-note/components/at/an0014-at-client.md @@ -8,9 +8,9 @@ 本文准备资料如下: -* [RT-Thread 源码](https://www.rt-thread.org/page/download.html) +* [RT-Thread 源码](https://www.rt-thread.org/download.html) -* [Env 工具](https://www.rt-thread.org/page/download.html) +* [Env 工具](https://www.rt-thread.org/download.html) ## AT Client 功能 diff --git a/rt-thread-version/rt-thread-standard/application-note/components/cplusplus/an0035-cpp.md b/rt-thread-version/rt-thread-standard/application-note/components/cplusplus/an0035-cpp.md index f619c5cb42ba290f41bb8a157ae05f3b4ad0b1b2..a3e0b57ea7defab62a93792ac048d56eac8f38ae 100644 --- a/rt-thread-version/rt-thread-standard/application-note/components/cplusplus/an0035-cpp.md +++ b/rt-thread-version/rt-thread-standard/application-note/components/cplusplus/an0035-cpp.md @@ -16,7 +16,7 @@ 1. 下载 [RT-Thread 源码](https://github.com/RT-Thread/rt-thread) -2. 下载 [ENV 工具](https://www.rt-thread.org/page/download.html) +2. 下载 [ENV 工具](https://www.rt-thread.org/download.html) 3. 进入 `rt-thread\bsp\stm32f411-st-nucleo` 目录,检查 BSP `rtconfig.py` 文件和 `SConstruct` 文件是否支持 `C++` 配置,如下图所示 @@ -248,7 +248,7 @@ MSH_CMD_EXPORT(throw_exceptions, throw cpp exceptions); ``` ## 参考资料 -* [ENV 用户手册](https://www.rt-thread.org/document/site/programming-manual/env/env/) +* [ENV 用户手册](https://www.rt-thread.org/document/site/#/development-tools/env/env) * [STM32F411-ST-NUCLEO BSP 源码](https://github.com/RT-Thread/rt-thread/tree/master/bsp/stm32/stm32f411-st-nucleo) diff --git a/rt-thread-version/rt-thread-standard/application-note/components/dfs/an0012-dfs.md b/rt-thread-version/rt-thread-standard/application-note/components/dfs/an0012-dfs.md index d2137376d87acebca1715beefbed973523cadda1..b3156b193142df8d1e8f3b41fe225b023f47398b 100644 --- a/rt-thread-version/rt-thread-standard/application-note/components/dfs/an0012-dfs.md +++ b/rt-thread-version/rt-thread-standard/application-note/components/dfs/an0012-dfs.md @@ -8,9 +8,9 @@ 本文准备资料如下: -* [RT-Thread 源码](https://www.rt-thread.org/page/download.html) +* [RT-Thread 源码](https://www.rt-thread.org/download.html) -* [Env 工具](https://www.rt-thread.org/page/download.html) +* [Env 工具](https://www.rt-thread.org/download.html) ## 文件系统的移植 diff --git a/rt-thread-version/rt-thread-standard/application-note/components/dfs/an0027-littlefs.md b/rt-thread-version/rt-thread-standard/application-note/components/dfs/an0027-littlefs.md index 5da85bc8ffe7f14186c91f5729be1a23631dcd91..14ef120c38b7d69545d3da512e6f62ccb354866b 100644 --- a/rt-thread-version/rt-thread-standard/application-note/components/dfs/an0027-littlefs.md +++ b/rt-thread-version/rt-thread-standard/application-note/components/dfs/an0027-littlefs.md @@ -42,7 +42,7 @@ littlefs 在 RT-Thread 上运行的层级关系图如下所示: ## littlefs 的移植 -社区热心开发者 [geniusgogo](https://github.com/geniusgogo) 为 RT-Thread 移植了 [littlefs](http://packages.rt-thread.org/itemDetail.html?package=littlefs) 的软件包,开发者只需要提供一个 MTD 设备即可使用 littlefs。开发者可以自己实现一个 MTD 设备,也可以利用 RT-Thread 提供的 fal 组件,非常方便的创建出一个 MTD 设备。相比于直接使用 flash 底层函数来自己构造一个 MTD 设备,使用 fal 创建 MTD 设备有以下三个优点: +社区热心开发者 [geniusgogo](https://github.com/geniusgogo) 为 RT-Thread 移植了 [littlefs](https://packages.rt-thread.org/search.html?search=littlefs) 的软件包,开发者只需要提供一个 MTD 设备即可使用 littlefs。开发者可以自己实现一个 MTD 设备,也可以利用 RT-Thread 提供的 fal 组件,非常方便的创建出一个 MTD 设备。相比于直接使用 flash 底层函数来自己构造一个 MTD 设备,使用 fal 创建 MTD 设备有以下三个优点: - 创建 MTD 设备方便 - 驱动的可移植性和可重用性强 diff --git a/rt-thread-version/rt-thread-standard/application-note/components/dlmodule/an0023-dlmodule.md b/rt-thread-version/rt-thread-standard/application-note/components/dlmodule/an0023-dlmodule.md index ff9c35b0a007e0afee5c63443024a5dbfcedc52b..d5baed927f301742e0d6b2ebc6fc74ce80f38a02 100644 --- a/rt-thread-version/rt-thread-standard/application-note/components/dlmodule/an0023-dlmodule.md +++ b/rt-thread-version/rt-thread-standard/application-note/components/dlmodule/an0023-dlmodule.md @@ -13,9 +13,9 @@ RT-Thread 的动态模块组件目前支持两种格式: 本文准备资料如下: -* [RT-Thread 源码](https://www.rt-thread.org/page/download.html) +* [RT-Thread 源码](https://www.rt-thread.org/download.html) -* [Env 工具](https://www.rt-thread.org/page/download.html) +* [Env 工具](https://www.rt-thread.org/download.html) * [rtthread-apps](https://github.com/RT-Thread/rtthread-apps) diff --git a/rt-thread-version/rt-thread-standard/application-note/components/network/an0010-lwip-driver-porting.md b/rt-thread-version/rt-thread-standard/application-note/components/network/an0010-lwip-driver-porting.md index 40796fd63326ee5b37e6b2fcdc851df29e91b298..29bfa9940b3b7d0749138400b4b967d7bc761032 100644 --- a/rt-thread-version/rt-thread-standard/application-note/components/network/an0010-lwip-driver-porting.md +++ b/rt-thread-version/rt-thread-standard/application-note/components/network/an0010-lwip-driver-porting.md @@ -8,9 +8,9 @@ 本文准备资料如下: -* [RT-Thread 源码](https://www.rt-thread.org/page/download.html) +* [RT-Thread 源码](https://www.rt-thread.org/download.html) -* [Env 工具](https://www.rt-thread.org/page/download.html) +* [Env 工具](https://www.rt-thread.org/download.html) ## 以太网相关概念简介 diff --git a/rt-thread-version/rt-thread-standard/application-note/components/network/an0011-network-started.md b/rt-thread-version/rt-thread-standard/application-note/components/network/an0011-network-started.md index 0ca798521ec606e4a798b9c24a95076123dbbdab..74a20159c1f311046aafb0afbd34441d382314e4 100644 --- a/rt-thread-version/rt-thread-standard/application-note/components/network/an0011-network-started.md +++ b/rt-thread-version/rt-thread-standard/application-note/components/network/an0011-network-started.md @@ -10,9 +10,9 @@ 本文准备资料如下: -* [RT-Thread 源码](https://www.rt-thread.org/page/download.html) +* [RT-Thread 源码](https://www.rt-thread.org/download.html) -* [Env 工具](https://www.rt-thread.org/page/download.html) +* [Env 工具](https://www.rt-thread.org/download.html) * 一块能上网的开发板, 这里以正点原子 STM32F4 探索者开发板为例 @@ -396,7 +396,7 @@ msh />ntp_sync edu.ntp.org.cn ### MQTT -[Paho MQTT](http://www.eclipse.org/paho/downloads.php) 是 Eclipse 实现的 MQTT 协议的客户端,本软件包是在 Eclipse [paho-mqtt](https://github.com/eclipse/paho.mqtt.embedded-c) 源码包的基础上设计的一套 MQTT 客户端程序。 +[Paho MQTT](https://www.eclipse.org/paho/) 是 Eclipse 实现的 MQTT 协议的客户端,本软件包是在 Eclipse [paho-mqtt](https://github.com/eclipse/paho.mqtt.embedded-c) 源码包的基础上设计的一套 MQTT 客户端程序。 MQTT 使用发布 / 订阅消息模式,发送消息时要指定发给哪个主题名(Topic Name),接收消息前要订阅一个主题名,然后才能接收到发送给这个主题名的消息内容。 diff --git a/rt-thread-version/rt-thread-standard/application-note/components/network/an0019-tcpclient-socket.md b/rt-thread-version/rt-thread-standard/application-note/components/network/an0019-tcpclient-socket.md index 860c46720823f19c769555c170a322765565f509..a84765e057f51dae2a14217712f8d66deb4ce5f0 100644 --- a/rt-thread-version/rt-thread-standard/application-note/components/network/an0019-tcpclient-socket.md +++ b/rt-thread-version/rt-thread-standard/application-note/components/network/an0019-tcpclient-socket.md @@ -10,9 +10,9 @@ 本文准备资料如下: -* [RT-Thread 源码](https://www.rt-thread.org/page/download.html) +* [RT-Thread 源码](https://www.rt-thread.org/download.html) -* [Env 工具](https://www.rt-thread.org/page/download.html) +* [Env 工具](https://www.rt-thread.org/download.html) * [README.md](https://github.com/neverxie/tcpclient) diff --git a/rt-thread-version/rt-thread-standard/application-note/components/sfud/an0048-sfud.md b/rt-thread-version/rt-thread-standard/application-note/components/sfud/an0048-sfud.md index 72fb543888cc529c897fe129cd5b3b5186b175a1..18892306c61fd7b5467dab5a2f0b873a34548750 100644 --- a/rt-thread-version/rt-thread-standard/application-note/components/sfud/an0048-sfud.md +++ b/rt-thread-version/rt-thread-standard/application-note/components/sfud/an0048-sfud.md @@ -4,8 +4,8 @@ 在使用 SFUD 时候需要进行移植,可以参考文件 [sfud/port/sfud_port.c](https://github.com/armink/SFUD/blob/master/sfud/port/sfud_port.c)。本篇文档将说明如何在潘多拉上使用 SFUD 操作 Flash(SFUD 部分已经移植完成),本文准备资料如下: -- [RT-Thread 源码](https://www.rt-thread.org/page/download.html) -- [Env 工具](https://www.rt-thread.org/page/download.html) +- [RT-Thread 源码](https://www.rt-thread.org/download.html) +- [Env 工具](https://www.rt-thread.org/download.html) - 板载 spi flash 的开发板,以潘多拉为例 ## Env 配置 diff --git a/rt-thread-version/rt-thread-standard/application-note/debug/cmbacktrace/an0013-CmBacktrace.md b/rt-thread-version/rt-thread-standard/application-note/debug/cmbacktrace/an0013-CmBacktrace.md index 41b0e9e9933e7da919e6c49822cd46200cff9cc5..0053cc400dc1a2ab635b74068e77f6af23976f84 100644 --- a/rt-thread-version/rt-thread-standard/application-note/debug/cmbacktrace/an0013-CmBacktrace.md +++ b/rt-thread-version/rt-thread-standard/application-note/debug/cmbacktrace/an0013-CmBacktrace.md @@ -10,9 +10,9 @@ 本文准备资料如下: -* [RT-Thread 源码](https://www.rt-thread.org/page/download.html) +* [RT-Thread 源码](https://www.rt-thread.org/download.html) -* [Env 工具](https://www.rt-thread.org/page/download.html) +* [Env 工具](https://www.rt-thread.org/download.html) * 在 https://github.com/armink/CmBacktrace/tree/master/tools/addr2line 页面中下载 addr2line(需要按照自己的系统版本下载),然后将下载下来的 addr2line 拷贝至 `C:\Windows` 下 ,这样就可以使用 addr2line 了。 diff --git a/rt-thread-version/rt-thread-standard/application-note/debug/systemview/an0009-systemview.md b/rt-thread-version/rt-thread-standard/application-note/debug/systemview/an0009-systemview.md index e983f4d34dbd93ff719f7307715a0719cd0a211b..f8d44b2ecc1a4a29621b5c66206670a258c32a49 100644 --- a/rt-thread-version/rt-thread-standard/application-note/debug/systemview/an0009-systemview.md +++ b/rt-thread-version/rt-thread-standard/application-note/debug/systemview/an0009-systemview.md @@ -11,7 +11,7 @@ * [SystemView 软件包](https://github.com/RT-Thread-packages/SEGGER_SystemView) -* [Env 工具](https://www.rt-thread.org/page/download.html) +* [Env 工具](https://www.rt-thread.org/download.html) ## SystemView 简介 @@ -27,7 +27,7 @@ SystemView 由两个部分组成: ![SystemView 的主界面](figures/view.png) -RT-Thread 提供的 [SystemView 软件包](https://github.com/RT-Thread-packages/SEGGER_SystemView) 是 SystemView 工具的嵌入式端程序实现,主要功能有:配置 SYSTEMVIEW 和 RTT 的具体参数,收集和格式化监视数据,将数据通过 J-Link 发送给 PC 端等。只需要利用 RT-Thread 推出的 [Env 工具](https://www.rt-thread.org/page/download.html) 使能 SystemView 软件包,并对其进行简单的配置,就能完成 SystemView 的嵌入式端程序的配置。 +RT-Thread 提供的 [SystemView 软件包](https://github.com/RT-Thread-packages/SEGGER_SystemView) 是 SystemView 工具的嵌入式端程序实现,主要功能有:配置 SYSTEMVIEW 和 RTT 的具体参数,收集和格式化监视数据,将数据通过 J-Link 发送给 PC 端等。只需要利用 RT-Thread 推出的 [Env 工具](https://www.rt-thread.org/download.html) 使能 SystemView 软件包,并对其进行简单的配置,就能完成 SystemView 的嵌入式端程序的配置。 ## 配置 SystemView 软件包 diff --git a/rt-thread-version/rt-thread-standard/application-note/driver/pwm/an0037-rtthread-driver-pwm.md b/rt-thread-version/rt-thread-standard/application-note/driver/pwm/an0037-rtthread-driver-pwm.md index eb83e4a8206c03f7346856f22939332703fc420f..4ca56a38780adab5124b73908aee777f004f3aaf 100644 --- a/rt-thread-version/rt-thread-standard/application-note/driver/pwm/an0037-rtthread-driver-pwm.md +++ b/rt-thread-version/rt-thread-standard/application-note/driver/pwm/an0037-rtthread-driver-pwm.md @@ -167,7 +167,7 @@ MSH_CMD_EXPORT(pwm_test, pwm sample); ## 参考资料 -* [ENV 用户手册](https://www.rt-thread.org/document/site/programming-manual/env/env/) +* [ENV 用户手册](https://www.rt-thread.org/document/site/#/development-tools/env/env) * [PWM 设备](https://www.rt-thread.org/document/site/programming-manual/device/pwm/pwm/) * [STM32L475-atk-pandora BSP 源码](https://github.com/RT-Thread/rt-thread/tree/master/bsp/stm32/stm32l475-atk-pandora) * [STM32 系列驱动添加指南](https://github.com/RT-Thread/rt-thread/blob/master/bsp/stm32/docs/STM32%E7%B3%BB%E5%88%97%E5%A4%96%E8%AE%BE%E9%A9%B1%E5%8A%A8%E6%B7%BB%E5%8A%A0%E6%8C%87%E5%8D%97.md) diff --git a/rt-thread-version/rt-thread-standard/application-note/driver/spi/an0004-rtthread-driver-spi.md b/rt-thread-version/rt-thread-standard/application-note/driver/spi/an0004-rtthread-driver-spi.md index c591781bc20bb850f45dfcf9f6ee1d707af31703..e031f542b65424cc352abd3c83f19a848603ad33 100644 --- a/rt-thread-version/rt-thread-standard/application-note/driver/spi/an0004-rtthread-driver-spi.md +++ b/rt-thread-version/rt-thread-standard/application-note/driver/spi/an0004-rtthread-driver-spi.md @@ -19,7 +19,7 @@ ### 示例代码软硬件资源 ### 1. [RT-Thread 源码](https://github.com/RT-Thread/rt-thread) -2. [ENV工具](https://www.rt-thread.org/document/site/docs/tools/env/env-user-manual/) +2. [ENV工具](https://www.rt-thread.org/download.html#download-rt-thread-env-tool) 3. [SPI设备驱动示例代码](spi-oled.rar) 4. 5. [正点原子STM32F4探索者开发板](http://www.openedv.com/thread-13912-1-1.html) diff --git a/rt-thread-version/rt-thread-standard/application-note/driver/usb/an0046-rtthread-driver-usbh.md b/rt-thread-version/rt-thread-standard/application-note/driver/usb/an0046-rtthread-driver-usbh.md index 627c475598c311bfdfd112d582c8df9885e7b96b..7d1f362564d9019bef7e05c89ef989dcecdce34e 100644 --- a/rt-thread-version/rt-thread-standard/application-note/driver/usb/an0046-rtthread-driver-usbh.md +++ b/rt-thread-version/rt-thread-standard/application-note/driver/usb/an0046-rtthread-driver-usbh.md @@ -24,7 +24,7 @@ USB(Universal Serial Bus)是一种支持热插拔的通用串行总线。它使 本文准备资料如下: - [RT-Thread 源码](https://github.com/RT-Thread/rt-thread) -- [Env 工具](https://www.rt-thread.org/page/download.html) +- [Env 工具](https://www.rt-thread.org/download.html) - U 盘 依赖 @@ -160,7 +160,7 @@ MSH_CMD_EXPORT(readwrite, usb host read write test); ## 参考资料 -[ENV 用户手册](https://www.rt-thread.org/document/site/programming-manual/env/env/) +[ENV 用户手册](https://www.rt-thread.org/document/site/#/development-tools/env/env) [虚拟文件系统](https://www.rt-thread.org/document/site/programming-manual/filesystem/filesystem/) diff --git a/rt-thread-version/rt-thread-standard/application-note/packages/rw007_module_using/an0034-rw007-module-using.md b/rt-thread-version/rt-thread-standard/application-note/packages/rw007_module_using/an0034-rw007-module-using.md index f00d25a6b48f91fd32fa173b4400c9d05f6c4489..91787878f23c90bde0f0a42427799e47b23217cc 100644 --- a/rt-thread-version/rt-thread-standard/application-note/packages/rw007_module_using/an0034-rw007-module-using.md +++ b/rt-thread-version/rt-thread-standard/application-note/packages/rw007_module_using/an0034-rw007-module-using.md @@ -55,7 +55,7 @@ RW007 是由上海睿赛德电子科技有限公司开发的高速 WiFi 模块 1. STM32 Nucleo-64 开发板(或其他支持 RTT 的板子) 2. RW007 WiFi 模块 3. Mini-USB 连接线(连接开发板与电脑) -4. ENV 编译构建环境([安装使用说明](https://www.rt-thread.org/document/site/programming-manual/env/env/)) +4. ENV 编译构建环境([安装使用说明](https://www.rt-thread.org/document/site/#/development-tools/env/env)) 5. 开发常用软件(git、Keil5、串口调试等) 6. 一颗爱折腾的心 @@ -111,7 +111,7 @@ pin 序号与引脚名对应关系如下表: 打开 `rt-thread\bsp\stm32` 目录,能看到 RT-Thread 所支持的开发板型号,把 RT-Thread 在 STM32 上跑起来并不是一件难事,但在编译内核组件之前,要先对 bsp 进行简单配置(别慌,通过 Menuconfig 图形化界面即可完成)。 -本次实验所使用的 bsp 为 `stm32f401-st-nucleo`,Github 仓库链接:[rt-thread/bsp/stm32/stm32f401-st-nucleo at master · RT-Thread/rt-thread](https://github.com/RT-Thread/rt-thread/bsp/stm32/stm32f401-st-nucleo), Gitee 仓库链接:[rt-thread/bsp/stm32/stm32f401-st-nucleo at master · RT-Thread/rt-thread](https://gitee.com/rtthread/rt-thread/tree/gitee_master/bsp/stm32/stm32f401-st-nucleo). +本次实验所使用的 bsp 为 `stm32f401-st-nucleo`,Github 仓库链接:[rt-thread/bsp/stm32/stm32f401-st-nucleo at master · RT-Thread/rt-thread](https://github.com/RT-Thread/rt-thread/tree/master/bsp/stm32/stm32f401-st-nucleo), Gitee 仓库链接:[rt-thread/bsp/stm32/stm32f401-st-nucleo at master · RT-Thread/rt-thread](https://gitee.com/rtthread/rt-thread/tree/master/bsp/stm32/stm32f401-st-nucleo). 从 RT-Thread SDK 中分离 stm32f401-st-nucleo 分离 BSP 出来。 进入 `rt-thread\bsp\stm32\stm32f401-st-nucleo` 文件夹,右键打开 ENV 窗口(前提是已在 windows 下搭好 ENV 环境),输入 `scons --dist`命令。 diff --git a/rt-thread-version/rt-thread-standard/application-note/setup/qemu/eclipse/an0020-qemu-eclipse.md b/rt-thread-version/rt-thread-standard/application-note/setup/qemu/eclipse/an0020-qemu-eclipse.md index 2080ee881bdb1db5ccf4ea4a984b4cc3e10fe30c..9a40ba3688b101ad8752110893a1d39c08ca266a 100644 --- a/rt-thread-version/rt-thread-standard/application-note/setup/qemu/eclipse/an0020-qemu-eclipse.md +++ b/rt-thread-version/rt-thread-standard/application-note/setup/qemu/eclipse/an0020-qemu-eclipse.md @@ -8,9 +8,9 @@ Eclipse 是跨平台的自由集成开发环境(IDE)。最初主要用来 Ja 本文准备资料如下: -* [RT-Thread 源码](https://www.rt-thread.org/page/download.html) +* [RT-Thread 源码](https://www.rt-thread.org/download.html) -* [Env 工具](https://www.rt-thread.org/page/download.html) +* [Env 工具](https://www.rt-thread.org/download.html) * [Eclipse](https://www.eclipse.org/downloads/) diff --git a/rt-thread-version/rt-thread-standard/application-note/setup/qemu/vscode/an0021-qemu-vscode.md b/rt-thread-version/rt-thread-standard/application-note/setup/qemu/vscode/an0021-qemu-vscode.md index 82a5c86ee8872373e4af8e1e990de702576976cd..b4fa990fdf099593ea65b144976d920fc1ae33c6 100644 --- a/rt-thread-version/rt-thread-standard/application-note/setup/qemu/vscode/an0021-qemu-vscode.md +++ b/rt-thread-version/rt-thread-standard/application-note/setup/qemu/vscode/an0021-qemu-vscode.md @@ -8,9 +8,9 @@ VS Code(全称 Visual Studio Code)是一个轻量且强大的代码编辑器 本文准备资料如下: -* [RT-Thread 源码](https://www.rt-thread.org/page/download.html) +* [RT-Thread 源码](https://www.rt-thread.org/download.html) -* [Env 工具](https://www.rt-thread.org/page/download.html) +* [Env 工具](https://www.rt-thread.org/download.html) * [VS Code](https://code.visualstudio.com/Download) diff --git a/rt-thread-version/rt-thread-standard/application-note/setup/qemu/windows/an0006-qemu-windows.md b/rt-thread-version/rt-thread-standard/application-note/setup/qemu/windows/an0006-qemu-windows.md index 7aeefe5b60a534feadf668f0d678b322c0aee1e2..ff568c170c611e4d12e7198516ea4edbdcf6489d 100644 --- a/rt-thread-version/rt-thread-standard/application-note/setup/qemu/windows/an0006-qemu-windows.md +++ b/rt-thread-version/rt-thread-standard/application-note/setup/qemu/windows/an0006-qemu-windows.md @@ -16,7 +16,7 @@ ## 准备工作 -* [下载 RT-Thread 源码](https://www.rt-thread.org/page/download.html),推荐下载3.1.0及以上版本。 +* [下载 RT-Thread 源码](https://www.rt-thread.org/download.html),推荐下载3.1.0及以上版本。 * 下载 RT-Thread Env 工具,推荐下载1.0.0及以上版本。参考编程指南-《Env 用户手册了解如何下载及使用。 diff --git a/rt-thread-version/rt-thread-standard/application-note/setup/standard-project/an0017-standard-project.md b/rt-thread-version/rt-thread-standard/application-note/setup/standard-project/an0017-standard-project.md index d5be479a83be881b76e6d94f31ad3485a2263fbc..fb485aef09456c2d07aa0dd68dafb0cba7b93edb 100644 --- a/rt-thread-version/rt-thread-standard/application-note/setup/standard-project/an0017-standard-project.md +++ b/rt-thread-version/rt-thread-standard/application-note/setup/standard-project/an0017-standard-project.md @@ -8,9 +8,9 @@ RT-Thread 完全开源开放,支持几十款 BSP,支持多种编译器,支 本文准备资料如下: -* [RT-Thread 源码](https://www.rt-thread.org/page/download.html) +* [RT-Thread 源码](https://www.rt-thread.org/download.html) -* [Env 工具](https://www.rt-thread.org/page/download.html) +* [Env 工具](https://www.rt-thread.org/download.html) * 安装好 MDK 软件或者 IAR 软件。 diff --git a/rt-thread-version/rt-thread-standard/application-note/system/pm/an0025-pm.md b/rt-thread-version/rt-thread-standard/application-note/system/pm/an0025-pm.md index ae60fd31e03d8e208dc5f895f152d6b48c4873c7..cea4f75e222d9310fc28270187a04bb10ed72179 100644 --- a/rt-thread-version/rt-thread-standard/application-note/system/pm/an0025-pm.md +++ b/rt-thread-version/rt-thread-standard/application-note/system/pm/an0025-pm.md @@ -23,7 +23,7 @@ MCU通常提供了多种时钟源供用户选择。例如潘多拉开发板上 在潘多拉开发板上运行电源管理组件,需要下载潘多拉开发板的相关资料、RT-Thread 源码和 ENV 工具。 * [RT-Thread 源码](https://github.com/RT-Thread/rt-thread) -* [ENV 工具](https://www.rt-thread.org/page/download.html) +* [ENV 工具](https://www.rt-thread.org/download.html) 开启 Env 工具,进入潘多拉开发板的 BSP 目录(`rt-thread\bsp\stm32\stm32l475-atk-pandora`),在 Env 命令行里输入 `menuconfig` 进入配置界面配置工程。 diff --git a/rt-thread-version/rt-thread-standard/development-guide/bsp-selfcheck/bsp_selfcheck.md b/rt-thread-version/rt-thread-standard/development-guide/bsp-selfcheck/bsp_selfcheck.md index 4f070d6d1bbbad8bf270cc3a1a8bbb9e559d5ff8..7d79500ce8e976ee263091ca51d31158d992a8cb 100644 --- a/rt-thread-version/rt-thread-standard/development-guide/bsp-selfcheck/bsp_selfcheck.md +++ b/rt-thread-version/rt-thread-standard/development-guide/bsp-selfcheck/bsp_selfcheck.md @@ -67,7 +67,7 @@ bsp 函数命名规范: - 所有文件都要有 license 文件头 - 不能有 GPL 等与 apache 版权冲突的版权 -- 非 apache 的兼容 license,需要更新 bsp 目录下的 license 声明:[Copyright_Notice.md](https://gitee.com/rtthread/rt-thread/blob/gitee_master/bsp/Copyright_Notice.md)。bsp 按照字母顺序排列。 +- 非 apache 的兼容 license,需要更新 bsp 目录下的 license 声明:[Copyright_Notice.md](https://gitee.com/rtthread/rt-thread/blob/master/bsp/Copyright_Notice.md)。bsp 按照字母顺序排列。 ## 工程文件检查 @@ -103,7 +103,7 @@ astyle 格式化参数: - bsp 添加到 ci -打开源码根目录下 [.github/workflows/action.yml](https://gitee.com/rtthread/rt-thread/blob/gitee_master/.github/workflows/action.yml) 文件,添加 bsp 到 ci +打开源码根目录下 [.github/workflows/action.yml](https://gitee.com/rtthread/rt-thread/blob/master/.github/workflows/action.yml) 文件,添加 bsp 到 ci ## PR 后的检查项 diff --git a/rt-thread-version/rt-thread-standard/development-guide/github/github.md b/rt-thread-version/rt-thread-standard/development-guide/github/github.md index 270642b13c31b1da03f1c1e8f6cc1c008fb9e2bd..4959c554f31a5e2df5a0e0a10665a8134fb234aa 100644 --- a/rt-thread-version/rt-thread-standard/development-guide/github/github.md +++ b/rt-thread-version/rt-thread-standard/development-guide/github/github.md @@ -54,7 +54,7 @@ RT-Thread 代码编程风格请参考 rt_thread 项目 documentation/contributio ![image](figures/bug1.png) -注意:开发时,代码需要符合 [RT-Thread 代码规范](https://github.com/RT-Thread/rt-thread/blob/master/documentation/contribution_guide/coding_style_cn.md),请仔细检查。 +注意:开发时,代码需要符合 [RT-Thread 代码规范](https://gitee.com/rtthread/rt-thread/blob/master/documentation/contribution_guide/coding_style_cn.md),请仔细检查。 ## 提交(commit) diff --git a/rt-thread-version/rt-thread-standard/development-guide/package/figures/make_software_index-new.png b/rt-thread-version/rt-thread-standard/development-guide/package/figures/make_software_index-new.png new file mode 100644 index 0000000000000000000000000000000000000000..b51a51eec212c4612b238353fce84396fcec854e Binary files /dev/null and b/rt-thread-version/rt-thread-standard/development-guide/package/figures/make_software_index-new.png differ diff --git a/rt-thread-version/rt-thread-standard/development-guide/package/package.md b/rt-thread-version/rt-thread-standard/development-guide/package/package.md index 3b01de162f7d7175daf79688d404d78d17e9f5b2..44ebe3a60a635a652a9b9490865ff27975b5f790 100644 --- a/rt-thread-version/rt-thread-standard/development-guide/package/package.md +++ b/rt-thread-version/rt-thread-standard/development-guide/package/package.md @@ -39,9 +39,10 @@ #### 使用索引生成向导 -我们可以使用 Env 的软件包索引生成向导功能来制作软件包索引,命令为 `pkgs --wizard`,大致流程如下如图所示: +我们可以使用 Env 的软件包索引生成向导功能来制作软件包索引,命令为 `pkgs --wizard`,大致流程如下如图所示,需要填入一下信息:包括软件包名称、软件包版本、软件包分类、作者信息、软件包使用的license、软件包地址等。 + +![image-20220922102421432](figures/make_software_index-new.png) -![image](./figures/make_software_index.png) 生成内容如下图所示: @@ -53,61 +54,79 @@ #### 修改 package.json 文件 -- **package.json 文件**介绍: +- **package.json 文件**介绍:**package.json** 是软件包的描述信息文件,由索引生成向导生成,如下所示,有一部分信息需要再次手动修改或者添加。 ```json { - "name" : "pahomqtt", - "description" : "a pahomqtt package for rt-thread", # 软件包描述信息 - "keywords" : [ - "pahomqtt" - ], - "site" : [ + "name": "pahomqtt", + "description": "Please add description of pahomqtt in English.", # 软件包的英文描述需要自行添加 + "description_zh": "请添加软件包 pahomqtt 的中文描述。", # 软件包的中文描述需要自行添加 + "enable": "PKG_USING_PAHOMQTT", + "keywords": [ + "pahomqtt" + ], + "category": "iot", + "author": { + "name": "RealThread", + "email": "package_team@rt-thread.com", + "github": "RealThread" + }, + "license": "EPL-1.0", + "repository": "https://github.com/RT-Thread-packages/paho-mqtt", + "icon": "unknown", # 软件包的中文描述需要自行添加 + "homepage": "https://github.com/RT-Thread-packages/paho-mqtt#readme", + "doc": "unknown", # 软件包的中文描述需要自行添加 + "site": [ { - "version" : "v1.0.0", - "URL" : "https://pahomqtt-1.0.0.zip", # 根据版本号修改软件包压缩包的下载地址 - "filename" : "pahomqtt-1.0.0.zip", - "VER_SHA" : "fill in the git version SHA value" # 压缩包形式无需填写 + "version": "v1.0.0", + "URL": "https://pahomqtt-1.0.0.zip", # 软件包的压缩包地址需要自行修改 + "filename": "pahomqtt-1.0.0.zip" }, { - "version" : "latest", # latest 版本 - "URL" : "https://xxxxx.git", # 可以填入 Git 仓库地址 - "filename" : "Null for git package", - "VER_SHA" : "fill in latest version branch name,such as mater" # 填入 SHA 值或者分支名 + "version": "latest", + "URL": "https://github.com/RT-Thread-packages/paho-mqtt.git", + "filename": "", + "VER_SHA": "master" } - ] + ] } ``` -关于文件中 `URL` 值,每个版本可以填入两种类型 : - -- **Git** :可以填入 Git 仓库地址和对应版本的 SHA 值。一般 `latest` 版本会在 **SHA** 填入`master`。 -- **压缩包** : 指定软件包压缩包的下载地址,此时无需填入 **SHA** 。 - -**package.json** 是软件包的描述信息文件,包括软件包名称,软件包描述,作者等信息,以及必须的 package 代码下载链接。另外,请务必包含许可证的说明,使用了哪种许可证( GPLv2,LGPLv2.1,MIT,Apache license v2.0,BSD 等)。 - 修改后的 package.json 大致如下: ```json { - "name" : "pahomqtt", - "description" : "Eclipse Paho MQTT C/C++ client for Embedded platforms", # 更新了描述信息 - "keywords" : [ - "pahomqtt" - ], - "site" : [ + "name": "pahomqtt", + "description": "Eclipse Paho MQTT C/C++ client for Embedded platforms", + "description_zh": "Eclipse 开源的 MQTT C/C++ 客户端", + "enable": "PKG_USING_PAHOMQTT", + "keywords": [ + "pahomqtt" + ], + "category": "iot", + "author": { + "name": "RealThread", + "email": "package_team@rt-thread.com", + "github": "RT-Thread-packages" + }, + "license": "EPL-1.0", + "repository": "https://github.com/RT-Thread-packages/paho-mqtt", + "icon": "https://www.rt-thread.org/qa/template/fxiaomi/style/image/logo.png", + "homepage": "https://github.com/RT-Thread-packages/paho-mqtt#readme", + "doc": "https://www.rt-thread.org/document/site/submodules/paho-mqtt/docs/introduction/", + "readme": "A mqtt package for rt-thread", + "site": [ { - "version" : "v1.0.0", # v1.0.0 版本 - "URL" : "https://github.com/RT-Thread-packages/paho-mqtt.git", # 更新了 git 仓库地址 - "filename" : "paho-mqtt-1.0.0.zip", - "VER_SHA" : "cff7e82e3a7b33e100106d34d1d6c82e7862e6ab" # 填入了指定版本的 SHA 值 + "version": "v1.0.0", + "URL": "https://github.com/RT-Thread-packages/paho-mqtt/archive/1.0.0.zip", + "filename": "paho-mqtt-1.0.0.zip", }, { - "version" : "latest", # 最新版本 - "URL" : "https://github.com/RT-Thread-packages/paho-mqtt.git", - "filename" : "paho-mqtt.zip", - "VER_SHA" : "master" # 填入 master + "version": "latest", + "URL": "https://github.com/RT-Thread-packages/paho-mqtt.git", + "filename": "paho-mqtt.zip", + "VER_SHA": "master" } - ] + ] } ``` diff --git a/rt-thread-version/rt-thread-standard/development-guide/sensor/sensor_driver_development.md b/rt-thread-version/rt-thread-standard/development-guide/sensor/sensor_driver_development.md index 464c103973bda07aa166bf736550df750aecef7a..15dab12a81740e1e2aaedf5e836948a69a69d212 100644 --- a/rt-thread-version/rt-thread-standard/development-guide/sensor/sensor_driver_development.md +++ b/rt-thread-version/rt-thread-standard/development-guide/sensor/sensor_driver_development.md @@ -37,7 +37,7 @@ sensor 框架共给出了两个接口(`fetch_data` / `control`),需要在驱动中实现这两个接口。 -**fetchdata** +**fetch_data** 作用: 获取传感器的数据。接口原型: @@ -254,7 +254,7 @@ INIT_APP_EXPORT(lps22hb_port); ### 提交 -Sensor 驱动需要按 `软件包` 的方式提交,具体的结构可以参考已有的 Sensor 软件包。具体的提交流程也可以参考文档中心:[软件包开发指南](https://www.rt-thread.org/document/site/development-guide/package/package/) +Sensor 驱动需要按 `软件包` 的方式提交,具体的结构可以参考已有的 Sensor 软件包。具体的提交流程也可以参考文档中心:[软件包开发指南](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/development-guide/package/package) ### 注意事项 diff --git a/rt-thread-version/rt-thread-standard/hw-board/art-pi/art-pi.md b/rt-thread-version/rt-thread-standard/hw-board/art-pi/art-pi.md new file mode 100644 index 0000000000000000000000000000000000000000..4f3707c9992a89dfae8e3e8805cf74b2d243ec1a --- /dev/null +++ b/rt-thread-version/rt-thread-standard/hw-board/art-pi/art-pi.md @@ -0,0 +1,70 @@ +# ART-PI 开发板 + +ART-PI 是 RT-Thread 团队经过半年的精心准备,专门为前入式软件工程师、开源创客设计的一款极具扩展功的的 DIY 开源硬件。 + +![image-20230426134844479](figures/image-20230426134844479.png) + +- ART-PI 开源网站:[https://art-pi.gitee.io/website/](https://art-pi.gitee.io/website/) +- ART-PI github 仓库地址 : [https://github.com/RT-Thread-Studio/sdk-bsp-stm32h750-realthread-artpi](https://github.com/RT-Thread-Studio/sdk-bsp-stm32h750-realthread-artpi) +- ART-PI gitee 仓库地址 : [https://gitee.com/mirrors/ART-Pi](https://gitee.com/mirrors/ART-Pi) + +## 开发板资源 + +板载资源: + +- STM32H750XBH6 微控制器,TFBGA240 封装,具有 128Kbytes FLASH,1024Kbytes RAM +- 板载 ST-LINK V2.1 +- 带 Type-C 接口的 USB OTG +- SDlO TF 卡插槽 +- SDIO WIFI:AP6212 +- HDC UART 蓝牙:AP6212 +- RGB888 FPC 连接器 +- 32-Mbytes SDRAM +- 16-Mbytes SPI FLASH +- 8-Mbytes QSPI FLASH +- D3(蓝色):3.3 V 电源指示 +- 两个用户 led:D2(蓝色),D2(红色) +- 两个 ST-LINK led:D4(蓝色),D4(红色) +- 两个按钮:用户和复位 + +扩展接口: + +- 4 路 UART(LPUART) +- 3 路 SPI +- 2 路 hardware iic +- 1 路 USB-FS +- 1 路 ETH +- 1 路 SAI +- 1 路 DCMI +- 2 路 CANFD +- 超过 5 路 ADC (支持差分输入 ADC) +- 超过 15 路 PWM(支持高精度定时器 HRTIM) +- [查看更多的扩展接口](https://art-pi.gitee.io/website/docs/#/tutorial/pin-description) + +驱动支持: + +- UART +- SPI +- SDMMC +- CAN +- QSPI +- ADC +- PWM +- DCMI +- SAI +- LTDC +- USB +- ETH +- SDRAM +- HRTIM +- I2C + +## ART-PI 配套开发板 + +ART-PI 多媒体口展板 + +![img](figures/pro3.png) + +ART-PI 工业扩展板 + +![img](figures/pro2.png) diff --git a/rt-thread-version/rt-thread-standard/hw-board/art-pi/figures/image-20230426134844479.png b/rt-thread-version/rt-thread-standard/hw-board/art-pi/figures/image-20230426134844479.png new file mode 100644 index 0000000000000000000000000000000000000000..58ded937a9faf1795b525c30f1371345506ff6c1 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/hw-board/art-pi/figures/image-20230426134844479.png differ diff --git a/rt-thread-version/rt-thread-standard/hw-board/art-pi/figures/pro2.png b/rt-thread-version/rt-thread-standard/hw-board/art-pi/figures/pro2.png new file mode 100644 index 0000000000000000000000000000000000000000..65e22cc740f081ab5c8c55f2f5af78ad00a03733 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/hw-board/art-pi/figures/pro2.png differ diff --git a/rt-thread-version/rt-thread-standard/hw-board/art-pi/figures/pro3.png b/rt-thread-version/rt-thread-standard/hw-board/art-pi/figures/pro3.png new file mode 100644 index 0000000000000000000000000000000000000000..6f56046b4f20a425ba35ddfcfb3a8278f35c8ea0 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/hw-board/art-pi/figures/pro3.png differ diff --git a/rt-thread-version/rt-thread-standard/hw-board/ifx-eval-kit/figures/image-20230426141152022.png b/rt-thread-version/rt-thread-standard/hw-board/ifx-eval-kit/figures/image-20230426141152022.png new file mode 100644 index 0000000000000000000000000000000000000000..655c22ea5e4d46f6729c2ead5139293675b212eb Binary files /dev/null and b/rt-thread-version/rt-thread-standard/hw-board/ifx-eval-kit/figures/image-20230426141152022.png differ diff --git a/rt-thread-version/rt-thread-standard/hw-board/ifx-eval-kit/figures/image-20230427104552221.png b/rt-thread-version/rt-thread-standard/hw-board/ifx-eval-kit/figures/image-20230427104552221.png new file mode 100644 index 0000000000000000000000000000000000000000..38749ba91c114990f8f2a9255d2c811050bb2c72 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/hw-board/ifx-eval-kit/figures/image-20230427104552221.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/studio3-build.png b/rt-thread-version/rt-thread-standard/hw-board/ifx-eval-kit/figures/studio3-build.png similarity index 100% rename from rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/studio3-build.png rename to rt-thread-version/rt-thread-standard/hw-board/ifx-eval-kit/figures/studio3-build.png diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/studio4-download.png b/rt-thread-version/rt-thread-standard/hw-board/ifx-eval-kit/figures/studio4-download.png similarity index 100% rename from rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/studio4-download.png rename to rt-thread-version/rt-thread-standard/hw-board/ifx-eval-kit/figures/studio4-download.png diff --git a/rt-thread-version/rt-thread-standard/hw-board/ifx-eval-kit/ifx-eval-kit.md b/rt-thread-version/rt-thread-standard/hw-board/ifx-eval-kit/ifx-eval-kit.md new file mode 100644 index 0000000000000000000000000000000000000000..c003919d2f85163a607a45f3e31d2454b8d0609a --- /dev/null +++ b/rt-thread-version/rt-thread-standard/hw-board/ifx-eval-kit/ifx-eval-kit.md @@ -0,0 +1,58 @@ +# 英飞凌评估套件 + +Psoc6-evaluationkit-062S2 是 RT-Thread 联合英飞凌推出的一款集成 32 位双核 CPU 子系统( ARM Cortex-M4 和 ARM Cortex-M0)的开发板,其具有单周期乘法的150-MHz Arm Cortex-M4F CPU (浮点和存储器保护单元),100-MHz Cortex M0+ CPU,带单周期乘法和 MPU,可以充分发挥 PSoC6 双核芯片性能。 + +![image-20230426141152022](figures/image-20230426141152022.png) + +开发板的原理图和 MDK 安装包地址:[https://gitee.com/rt-thread-board/ifx-psoc62-evalkit](https://gitee.com/rt-thread-board/ifx-psoc62-evalkit) + +该开发板核心 **板载资源** 如下: + +- MCU:CY8C624ABZI-S2D44,Cortex-M4主频 150MHz,Cortex-M0主频 100MHz,2MB Flash 和 1MB SRAM。 MCU手册更多详细信息请参考文档 [PSoC 6 MCU: CY8C62x8, CY8C62xA Datasheet (infineon.com)](https://www.infineon.com/dgdl/Infineon-PSOC_6_MCU_CY8C62X8_CY8C62XA-DataSheet-v17_00-EN.pdf?fileId=8ac78c8c7d0d8da4017d0ee7d03a70b1) +- 板载资源:microSD card , 触摸滑条,Arduino 接口 +- 开发环境:ModusToolbox 2.0/MDK V5 + PSoC® Creator™ 下载链接 [ModusToolbox™ Software - Infineon Technologies](https://www.infineon.com/cms/en/design-support/tools/sdk/modustoolbox-software/) + +## 外设支持 + +Studio BSP 目前对外设的支持情况如下: + +| **片上外设** | **支持情况** | **备注** | +| :----------: | :----------: | :------: | +| USB 转串口 | 支持 | UART0 | +| GPIO | 支持 | — | +| UART | 支持 | UART0-5 | +| Touch | 支持 | 触摸滑条 | + +## 使用 RT-Thread Studio 开发 + +在 RT-Thread Studio 的 SDK 管理器中安装该 BSP 资源包,然后基于该资源包新建工程。 + +![image-20230427104552221](figures/image-20230427104552221.png) + +### 编译下载 + +* 点击 IDE 左上角的构建选项进行工程的编译。 + + ![](figures/studio3-build.png) + +* 当编译无错误警告时,点击 `Debug` 或 `Download` 选项进行调试/下载。 + + 注:若点击下载并下载成功后串口终端无显示信息,请手动按下复位按键进行重启运行。 + + ![](figures/studio4-download.png) + +### 运行结果 + +下载程序成功之后,系统会自动运行。打开终端工具串口助手,选择波特率为 115200。复位设备后,LED 将会以一秒 2 次的频率闪烁,而且在终端上可以看到 `RT-Thread` 的输出信息: + +注:推荐使用串口调试助手如:`MobaXterm` + +``` + \ | / +- RT - Thread Operating System + / | \ 4.1.1 build Jul 25 2022 18:03:35 + 2006 - 2022 Copyright by RT-Thread team +msh > +``` + diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/external_c_modules.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/external_c_modules.md index e5504fdbc8512b4b59622768570b5e241b032672..b88f6a52f7e70c4b61858a81ced34bea617ea829 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/external_c_modules.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/external_c_modules.md @@ -2,7 +2,7 @@ 当使用原生 MicroPython 进行开发时,你可能会遇到这样一些限制,比如官方没有实现自己想要的功能,或者你觉得这些实现不符合自己的工作需求。此时,添加自己的 C 模块到 MicroPython 中是一个不错的选择,你可以按照自己的想法,设计适合自己的 Python 函数调用。 -为了帮助各位开发者快速添加 C 模块,RT-Thread 提供了相应的辅助工具 [C 绑定代码自动生成器](https://summerlife.github.io/RT-MicroPython-Generator/)。该工具可以帮助开发者自动生成 C 代码和 MicroPython 之间的接口层,开发者只需将 C 语言编写的功能代码添加到指定位置,MicroPython 即可直接调用该功能。 +为了帮助各位开发者快速添加 C 模块,RT-Thread 提供了相应的辅助工具 [C 绑定代码自动生成器](https://summergift.github.io/RT-MicroPython-Generator/)。该工具可以帮助开发者自动生成 C 代码和 MicroPython 之间的接口层,开发者只需将 C 语言编写的功能代码添加到指定位置,MicroPython 即可直接调用该功能。 ## Python 调用 C 函数的实现原理 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/spec-librarys/machine/I2C.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/spec-librarys/machine/I2C.md index 7eb29b9c4fd639067d1c7d345c6b27f022179cfc..646143a304ff2d1a9b7dd853b76f11ebeecaa3e0 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/spec-librarys/machine/I2C.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/spec-librarys/machine/I2C.md @@ -107,5 +107,5 @@ b'\x12' # starting at memory-address 8 in the slav [81] # Decimal representation ``` - 更多内容可参考 [machine.I2C](http://docs.micropython.org/en/latest/pyboard/library/machine.I2C.html) 。 + 更多内容可参考 [machine.I2C](http://docs.micropython.org/en/latest/library/machine.I2C.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/spec-librarys/machine/Pin.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/spec-librarys/machine/Pin.md index 24f73109a7768c43bdd44a2527ed79d3917e1910..b4aaaaf354a671e619aae9c93ac0d67f4e88c885 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/spec-librarys/machine/Pin.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/spec-librarys/machine/Pin.md @@ -107,4 +107,4 @@ def func(v): key_0.irq(trigger=Pin.IRQ_RISING, handler=func) ``` -更多内容可参考 [machine.Pin](http://docs.micropython.org/en/latest/pyboard/library/machine.Pin.html) 。 +更多内容可参考 [machine.Pin](http://docs.micropython.org/en/latest/library/machine.Pin.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/spec-librarys/machine/SPI.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/spec-librarys/machine/SPI.md index 84f07cf8ee1c9ea10ac3b894c57d4318622fe68a..83f39fc5f389ef0ad610f482f20d1a464c3097e1 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/spec-librarys/machine/SPI.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/spec-librarys/machine/SPI.md @@ -96,4 +96,4 @@ bytearray(b'\xef') >>> spi.init(100000,0,0,8,1) # Resetting SPI parameter ``` - 更多内容可参考 [machine.SPI](http://docs.micropython.org/en/latest/pyboard/library/machine.SPI.html) 。 + 更多内容可参考 [machine.SPI](http://docs.micropython.org/en/latest/library/machine.SPI.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/spec-librarys/machine/UART.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/spec-librarys/machine/UART.md index 7055db34ef99da40430f1e3fc27520f177f3777d..10471de0720de0f203cc18844c327b92709b8f0c 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/spec-librarys/machine/UART.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/spec-librarys/machine/UART.md @@ -57,4 +57,4 @@ uart.readinto(buf) # read and store into the given buffer uart.write('abc') # write the 3 characters ``` - 更多内容可参考 [machine.UART](http://docs.micropython.org/en/latest/pyboard/library/machine.UART.html) 。 + 更多内容可参考 [machine.UART](http://docs.micropython.org/en/latest/library/machine.UART.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/_thread.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/_thread.md index 29faf523684409748ee82dd0707d5e9ecdc718d9..81df431e2fda8ca76338e3593363d4a5cde2324c 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/_thread.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/_thread.md @@ -25,4 +25,4 @@ Hello from thread Hello from thread Hello from thread -更多内容可参考 [_thread](http://docs.micropython.org/en/latest/pyboard/library/_thread.html) 。 +更多内容可参考 [_thread](http://docs.micropython.org/en/latest/library/_thread.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/cmath.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/cmath.md index 2040001a82734c494f48716cfbaa02926eb4f5e8..a4ac1a1648bd61f5facc1c2080618217c5c63021 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/cmath.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/cmath.md @@ -39,4 +39,4 @@ #### **cmath.pi** 圆周率。 -更多内容可参考 [cmath](http://docs.micropython.org/en/latest/pyboard/library/cmath.html) 。 +更多内容可参考 [cmath](http://docs.micropython.org/en/latest/library/cmath.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/gc.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/gc.md index 3ee838eefb1dcc7e8292d96ec18fbc2c9069fd71..cbb354dbcdad56c56a7e639a1f9ad30e0c815820 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/gc.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/gc.md @@ -19,4 +19,4 @@ #### **gc.mem_free**() 返回剩余的内存数量。 -更多内容可参考 [gc](http://docs.micropython.org/en/latest/pyboard/library/gc.html) 。 +更多内容可参考 [gc](http://docs.micropython.org/en/latest/library/gc.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/math.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/math.md index 8c0faf70d6bcfcb8fea9690904d5bba3877f168f..309d86538ffac0f800ca7a175e6c1e33fa39ba2d 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/math.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/math.md @@ -280,4 +280,4 @@ -6 ``` -更多内容可参考 [math](http://docs.micropython.org/en/latest/pyboard/library/math.html) 。 +更多内容可参考 [math](http://docs.micropython.org/en/latest/library/math.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/sys.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/sys.md index 1593f0247239ce1f8f09aa49ac0a2a6e8b7aaa8d..6a4c4edda4d2575e23de926ee9bd4646b706ec04 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/sys.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/sys.md @@ -66,4 +66,4 @@ 'little' ``` -更多内容可参考 [sys](http://docs.micropython.org/en/latest/pyboard/library/sys.html) 。 +更多内容可参考 [sys](http://docs.micropython.org/en/latest/library/sys.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uarray.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uarray.md index 0f658f3594e0ae1d5e35b219b180bfd75323c9e7..3a00b227e69d3472c28bb2c7587950724768efe3 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uarray.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uarray.md @@ -53,4 +53,4 @@ array('f', [3.0, 6.0, 7.0]) array('i', [1, 2, 3, 4, 5]) ``` -更多内容可参考 [array](http://docs.micropython.org/en/latest/pyboard/library/array.html) 。 +更多内容可参考 [array](http://docs.micropython.org/en/latest/library/array.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ubinascii.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ubinascii.md index 0b32ab3a01a6404a24c8e3de547006ecbab01779..95bc06747a7c2be23a1cdee03cad832ddc591daf 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ubinascii.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ubinascii.md @@ -44,4 +44,4 @@ Base64编码的数据转换为二进制表示。返回字节串。 #### **ubinascii.b2a_base64**(data) 编码base64格式的二进制数据。返回的字符串。 -更多内容可参考 [ubinascii](http://docs.micropython.org/en/latest/pyboard/library/ubinascii.html) 。 +更多内容可参考 [ubinascii](http://docs.micropython.org/en/latest/library/binascii.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ucollections.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ucollections.md index 2bcf1602507acfd27a27906df92eb9918f43d8f9..91ee4f4a8d7caabbd5ae1ae9ee94c919e6371f12 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ucollections.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ucollections.md @@ -41,4 +41,4 @@ a 2 w 5 b 3 -更多的内容可参考 [ucollections](http://docs.micropython.org/en/latest/pyboard/library/ucollections.html) 。 +更多的内容可参考 [ucollections](http://docs.micropython.org/en/latest/library/collections.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uctypes.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uctypes.md index 79a92172d787ef108b9dc45833eb35310217bdf6..6498a8d401b60baf88718b7f1fca7643e03af847 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uctypes.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uctypes.md @@ -79,4 +79,4 @@ b'0123' bytearray(b'01') ``` -更多内容可参考 [uctypes](http://docs.micropython.org/en/latest/pyboard/library/uctypes.html) 。 +更多内容可参考 [uctypes](http://docs.micropython.org/en/latest/library/uctypes.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uerrno.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uerrno.md index 07872df3fb13fcd75837b1dc3f22a6b739b84ad5..c5f6e033d79d0ba0ddb2f49cbbd2f55f0524020b 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uerrno.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uerrno.md @@ -17,4 +17,4 @@ Dictionary mapping numeric error codes to strings with symbolic error code (see EEXIST ``` -更多内容可参考 [uerrno](http://docs.micropython.org/en/latest/pyboard/library/uerrno.html) 。 +更多内容可参考 [uerrno](http://docs.micropython.org/en/latest/library/errno.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uhashlib.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uhashlib.md index c2f77c66dcef71a0daf7a489c80a92d76ff8df9a..e1172a44c49be7ce7347739c245e798ba9a164b9 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uhashlib.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uhashlib.md @@ -33,4 +33,4 @@ #### **hash.hexdigest**() 此方法没有实现, 使用 ubinascii.hexlify(hash.digest()) 达到类似效果。 -更多内容可参考 [uhashlib](http://docs.micropython.org/en/latest/pyboard/library/uhashlib.html) 。 +更多内容可参考 [uhashlib](http://docs.micropython.org/en/latest/library/hashlib.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uheapq.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uheapq.md index 219a7f76949cb44dfdf9aed59d819d738310a166..ff0629f145fad17a95f105f1e03739c6318eafe0 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uheapq.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uheapq.md @@ -13,4 +13,4 @@ #### **uheapq.heapify**(x) 将列表 x 转换成堆。 -更多内容可参考 [uheapq](http://docs.micropython.org/en/latest/pyboard/library/uheapq.html) 。 +更多内容可参考 [uheapq](http://docs.micropython.org/en/latest/library/heapq.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uio.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uio.md index 32cbcdf38796b413e573d1989266df5f7a3278ba..a523f13fad25a8fbb265bf39200413831f802203 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uio.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uio.md @@ -24,4 +24,4 @@ #### **getvalue**() 获取缓存区内容。 -更多内容可参考 [uio](http://docs.micropython.org/en/latest/pyboard/library/uio.html) 。 +更多内容可参考 [uio](http://docs.micropython.org/en/latest/library/io.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ujson.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ujson.md index efc2b30ad7b0b029965302d7b7d2f011880b7061..3dea31a6029762fc40c01008283af5bd4c44888f 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ujson.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ujson.md @@ -39,4 +39,4 @@ obj:要转换的对象 {'a': 6, 1: 2, 3: 4} ``` -更多内容可参考 [ujson](http://docs.micropython.org/en/latest/pyboard/library/ujson.html) 。 +更多内容可参考 [ujson](http://docs.micropython.org/en/latest/library/json.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uos.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uos.md index 9fdb190ab543c137ea26fea4a3c28227de5e05ea..59682bd9f71e21f5bf10b6902413b589794424f9 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uos.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uos.md @@ -53,4 +53,4 @@ stat unlink mount umount >>> ``` -更多内容可参考 [uos](http://docs.micropython.org/en/latest/pyboard/library/uos.html) 。 +更多内容可参考 [uos](http://docs.micropython.org/en/latest/library/os.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ure.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ure.md index 4d13c098d7758185fd9198d377a6e2cf597876e3..5675e4e32e6667c0129e0b5294a46e9d3724e47d 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ure.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ure.md @@ -49,4 +49,4 @@ #### **match.group**([index]) 只支持数字组。 -更多内容可参考 [ure](http://docs.micropython.org/en/latest/pyboard/library/ure.html) 。 +更多内容可参考 [ure](http://docs.micropython.org/en/latest/library/re.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uselect.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uselect.md index c201cd8c6c460272f57393de705388bed7310fb4..63028d8df667e567ef70a0834ac440c3fc80df50 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uselect.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uselect.md @@ -99,4 +99,4 @@ flag:修改为的监控标志 #### **poll.poll**([timeout]) 等待至少一个已注册的对象准备就绪。返回 (obj, event, ...) 元组, event 元素指定了一个流发生的事件,是上面所描述的 `select.POLL*`常量组合。 根据平台和版本的不同,在元组中可能有其他元素,所以不要假定元组的大小是 2 。如果超时,则返回空列表。 -更多内容可参考 [uselect](http://docs.micropython.org/en/latest/pyboard/library/uselect.html) 。 +更多内容可参考 [uselect](http://docs.micropython.org/en/latest/library/select.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/usocket.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/usocket.md index e6a08c794d194b627de08bbc93cddde1890fd4c4..c7f7697bf548cbb4292d2e57fd8f5e5d597ba7d3 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/usocket.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/usocket.md @@ -192,4 +192,4 @@ s = socket.socket() s.connect(socket.getaddrinfo('www.micropython.org', 80)[0][-1]) ``` -更多的内容可参考 [usocket](http://docs.micropython.org/en/latest/pyboard/library/usocket.html) 。 +更多的内容可参考 [usocket](http://docs.micropython.org/en/latest/library/socket.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ustruct.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ustruct.md index 903ecbf27c259af03a60233ecacfd4a62310e747..7e90746067656332ef9c1a2f4cb4e05088c51e0b 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ustruct.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/ustruct.md @@ -79,4 +79,4 @@ b'\x01\x02' >>> print(struct.unpack_from("b", buf, 1)) (2,) ``` -更多的内容可参考 [ustruct](http://docs.micropython.org/en/latest/pyboard/library/ustruct.html) 。 +更多的内容可参考 [ustruct](http://docs.micropython.org/en/latest/library/struct.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/utime.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/utime.md index a629749309744284122bf39e53e8235a3430ce3e..2a8744eb034337f90cf9d8c07101ce0c53bbaefd 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/utime.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/utime.md @@ -118,4 +118,4 @@ while pin.value() == 0: 1073741823 ``` -更多内容可参考 [utime](http://docs.micropython.org/en/latest/pyboard/library/utime.html#module-utime) 。 +更多内容可参考 [utime](http://docs.micropython.org/en/v1.9/pyboard/library/utime.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uzlib.md b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uzlib.md index cc4dfe8e496f3478ff2dca71fc90cc95afd17721..9fd20d6829f8059727ea926ea8d84b417397c3ab 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uzlib.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/micropython-docs/std-librarys/uzlib.md @@ -7,4 +7,4 @@ #### **uzlib.decompress**(data) 返回解压后的 bytes 数据。 -更多内容可参考 [uzlib](http://docs.micropython.org/en/latest/pyboard/library/uzlib.html) 。 +更多内容可参考 [uzlib](http://docs.micropython.org/en/latest/library/zlib.html) 。 diff --git a/rt-thread-version/rt-thread-standard/packages-manual/pikascript-docs/introduction.md b/rt-thread-version/rt-thread-standard/packages-manual/pikascript-docs/introduction.md index 1b06fa2fa2b5252f171672ffd2b9d93c72dcf9eb..b811e8a2b28738ff323e4b7e51c43d70abb49318 100644 --- a/rt-thread-version/rt-thread-standard/packages-manual/pikascript-docs/introduction.md +++ b/rt-thread-version/rt-thread-standard/packages-manual/pikascript-docs/introduction.md @@ -12,7 +12,7 @@ PikaScript 软件包支持**全部的 RT-Thread BSP** 。 [PikaScript GitHub 仓库](https://github.com/pikasTech/pikascript) -[PikaScript Gitee 仓库](https://gitee.com/Lyon1998/pikascript) +[PikaScript Gitee 仓库](https://gitee.com/Lyon1998/pikapython) ## 文档 @@ -36,4 +36,4 @@ PikaScript 软件包支持**全部的 RT-Thread BSP** 。 [1. PikaScript 论坛](https://whycan.com/f_55.html) -[2. QQ 交流群](https://gitee.com/Lyon1998/pikascript#tencent-qq-group) +[2. QQ 交流群](https://gitee.com/Lyon1998/pikapython#tencent-qq-group) diff --git a/rt-thread-version/rt-thread-standard/programming-manual/at/at.md b/rt-thread-version/rt-thread-standard/programming-manual/at/at.md index a35117172f758c3197709d85844fae5bc5ccb562..3c343d1c8030b64b1cdb003f9b30d9a1e32b0516 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/at/at.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/at/at.md @@ -92,21 +92,21 @@ AT 组件是基于 RT-Thread 系统的 `AT Server` 和 `AT Client` 的实现, 上面配置选项可以直接在 `rtconfig.h` 文件中添加使用,也可以通过组件包管理工具 Env 配置选项加入,ENV 中具体路径如下: ```c -RT-Thread Components ---> - Network ---> - AT commands ---> - [*] Enable AT commands - [*] Enable debug log output - [*] Enable AT commands server - (uart3) Server device name - (256) The maximum length of server data accepted - The commands new line sign (\r\n) ---> - [ ] Enable AT commands client - [*] Enable command-line interface for AT commands - [ ] Enable print RAW format AT command communication data -``` - -添加配置完成之后可以使用命令行重新生成工程,或使用 scons 来进行编译生成。 + -> RT-Thread Components + -> Network + --- Enable AT commands + [*] Enable debug log output + [*] Enable AT commands server + (uart3) Server device name + (256) The maximum length of server data accepted + The commands new line sign (\r\n) ---> + [ ] Enable AT commands client + [*] Enable CLI(Command-Line Interface) for AT commands + [ ] Enable print RAW format AT command communication data + (128) The maximum length of AT Commands buffer +``` + +添加配置完成之后可以使用命令行重新生成工程,或使用 scons 来进行编译。 ### AT Server 初始化 ### @@ -354,17 +354,18 @@ AT Server 默认已支持多种基础命令(ATE、ATZ 等),其中部分命 上面配置选项可以直接在 `rtconfig.h` 文件中添加使用,也可以通过组件包管理工具 Env 配置选项加入,ENV 中具体路径如下: ```c -RT-Thread Components ---> - Network ---> - AT commands ---> - [*] Enable AT commands - [ ] Enable debug log output - [ ] Enable AT commands server - [*] Enable AT commands client - (1) The maximum number of supported clients - [*] Enable BSD Socket API support by AT commnads - [*] Enable command-line interface for AT commands - [ ] Enable print RAW format AT command communication data + -> RT-Thread Components + -> Network + --- Enable AT commands + [ ] Enable debug log output + [ ] Enable AT commands server + [*] Enable AT commands client + (1) The maximum number of supported clients + [*] Enable BSD Socket API support by AT commnads + [ ] Enable BSD Socket API support about AT server + [*] Enable CLI(Command-Line Interface) for AT commands + [ ] Enable print RAW format AT command communication data + (128) The maximum length of AT Commands buffer ``` 添加配置完成之后可以使用命令行重新生成工程,或使用 scons 来进行编译生成。 @@ -481,7 +482,7 @@ rt_err_t at_exec_cmd(at_response_t resp, const char *cmd_expr, ...); #include #include /* AT 组件头文件 */ -int at_client_send(int argc, char**argv) +int at_Client_send(int argc, char**argv) { at_response_t resp = RT_NULL; @@ -503,7 +504,7 @@ int at_client_send(int argc, char**argv) if (at_exec_cmd(resp, argv[1]) != RT_EOK) { LOG_E("AT client send commands failed, response error or timeout !"); - return -ET_ERROR; + return -RT_ERROR; } /* 命令发送成功 */ @@ -677,7 +678,7 @@ struct at_urc { const char *cmd_prefix; // URC 数据前缀 const char *cmd_suffix; // URC 数据后缀 - void (*func)(const char *data, rt_size_t size); // URC 数据执行函数 + void (*func)(struct at_client *client, const char *data, rt_size_t size); // URC 数据执行函数 }; typedef struct at_urc *at_urc_t; ``` @@ -701,19 +702,19 @@ void at_set_urc_table(const struct at_urc *table, rt_size_t size); 下面给出 AT Client 移植具体示例,该示例主要展示 `at_client_port_init()` 移植函数中 URC 数据的具体处理方式,开发者可直接应用到自己的移植文件中,或者自定义修改实现功能,完成 AT Client 的移植。 ```c -static void urc_conn_func(const char *data, rt_size_t size) +static void urc_conn_func(struct at_client *client ,const char *data, rt_size_t size) { /* WIFI 连接成功信息 */ LOG_D("AT Server device WIFI connect success!"); } -static void urc_recv_func(const char *data, rt_size_t size) +static void urc_recv_func(struct at_client *client ,const char *data, rt_size_t size) { /* 接收到服务器发送数据 */ LOG_D("AT Client receive AT Server data!"); } -static void urc_func(const char *data, rt_size_t size) +static void urc_func(struct at_client *client ,const char *data, rt_size_t size) { /* 设备启动信息 */ LOG_D("AT Server device startup!"); diff --git a/rt-thread-version/rt-thread-standard/programming-manual/atomic/atomic.md b/rt-thread-version/rt-thread-standard/programming-manual/atomic/atomic.md new file mode 100644 index 0000000000000000000000000000000000000000..792c44655eec5e017b163a41a4c109645af99787 --- /dev/null +++ b/rt-thread-version/rt-thread-standard/programming-manual/atomic/atomic.md @@ -0,0 +1,303 @@ +# 原子操作 # + +## 原子操作简介 + +原子操作(Atomic operation)是指一种不可分割的操作,要么完全执行成功,要么完全不执行。原子操作的执行过程中不允许有任何中断,如果出现了中断,那么操作的结果就无法保证。原子操作通常用于多线程编程中,保证多个线程之间的并发执行不会出现数据竞争等问题。在实现原子操作时,通常使用硬件指令或者操作系统提供的原子操作函数来保证操作的原子性。 在应用层面,原子操作可以用于实现一些高级的同步和并发控制机制。例如,在多线程编程中,如果多个线程都需要访问同一个共享变量,为了避免数据竞争问题,可以使用原子操作来保证对该变量的操作是原子的。我们以 ARM 内核执行一个 i++操作为例: + +```c +movl i, %eax //内存访问,读取 i 变量到 cpu 的 eax 寄存器 +addl $1, %eax //修改寄存器的值 +movl %eax, i //将寄存器中的值写回内存 +``` + +我们看到对于编码的工程师我们执行一个 i++的操作仅需一行代码,在编译后 i++就会被翻译成三条指令,所以在这三条指令之间是可能会被系统调度、中断等事件打断的,因而我们在一些场景就需要一气呵成执行完上述操作,原子操作就具备这样的能力。 + +## 原子操作的优点 + +在 RT-Thread 中我们可以采取开关全局中断,调度器上锁等方式对临界区资源进行保护,其他 OS 也会提供类似的操作,若采用原子操作后我们可以提高临界区代码的执行效率,大幅提升系统的运行效率,同时也会在一定程度上降低编程的复杂度,下文是一个简单变量自增的示例: + +采用开关全局中断的方式实现的对临界区的保护: + +```c + ... + int a = 5; + level = rt_hw_interrupt_disable(); + a++; + rt_hw_interrupt_enable(level); + ... +``` + +我们若采用 RT-Thread 提供的原子操作 API 可以这么做: + +```c + ... + int a = 5; + rt_atomic_add(&a,1); + ... +``` + +显然采用原子操作的方式更加简单一些,且避免了开关全局中断带来的性能损失。 + +## RT-Thread 原子操作的实现与使用方法 ## + +RT-Thread 对 32-bit 的 ARM、32-bit 的 RISC-V 与 64-bit 的 RISC-V 中支持原子操作的内核提供了原子操作支持,使用对应平台的原子操作指令与相关指令实现,默认支持,无需用户关心实现,用户使用时仅需在工程包含`rtatomic.h`即可使用该文件提供的原子操作 API,详细支持情况如下: + +| 指令架构 | RT-Thread 适配内核的原子指令支持情况 | +| :-----------: | :----------------------------------------------------------: | +| 32-bit ARM | 采用 ARM 指令集的绝大多数内核支持原子指令,不支持的内核有 cortex-m0,cortex-m0+,arm926,lpc214x,lpc24xx,s3c24x0,AT91SAM7。 | +| 32-bit RISC-V | 采用 RV32 指令集的大部分内核支持原子操作,部分不支持的 BSP 有:core-v-mcu,rv32m1_vega。 | +| 64-bit RISC-V | 采用 RV64 指令集的大部分内核支持原子操作,部分不支持的 BSP 有:juicevm。 | + +若工具链支持 C11 标准的原子操作 API 也可以使用 menuconfig 配置`RT_USING_STDC_ATOMIC` 宏,此时调用`rtatomic.h`中提供的宏实际上最终会调用 C11 标准提供的 API,menuconfig 的配置方法如下: +```shell +RT-Thread Kernel ---> + [*]Use atomic implemented in stdatomic.h +``` + +上述不支持原子操作的内核,用户在工程中包含`rtatomic.h`并使用该文件提供的 API 时,此时会采用开关全局中断的方式软实现原子操作。 + +## RT-Thread 原子操作 API + +RT-Thread 提供了 11 个使用频率较高的原子操作 API。 + +| RT-Thread 原子操作 API | 作用 | +| :----------------------------------------------------------: | :------------------------------------------------------: | +| rt_atomic_t rt_hw_atomic_load(volatile rt_atomic_t *ptr) | 原子的从 ptr 地址加载一个字 | +| void rt_atomic_store(volatile rt_atomic_t *ptr, rt_atomic_t val) | 原子的将 val 写入 ptr 地址 | +| rt_atomic_t rt_atomic_exchange(volatile rt_atomic_t *ptr, rt_atomic_t val) | 原子的将 ptr 地址处的值替换为 val | +| rt_atomic_t rt_atomic_add(volatile rt_atomic_t *ptr, rt_atomic_t val) | 原子的将 ptr 地址处的值与 val 相加 | +| rt_atomic_t rt_atomic_sub(volatile rt_atomic_t *ptr, rt_atomic_t val) | 原子的将 ptr 地址处的值与 val 相减 | +| rt_atomic_t rt_atomic_xor(volatile rt_atomic_t *ptr, rt_atomic_t val) | 原子的将 ptr 地址处的值与 val 按位异或 | +| rt_atomic_t rt_atomic_and(volatile rt_atomic_t *ptr, rt_atomic_t val) | 原子的将 ptr 地址处的值与 val 按位与 | +| rt_atomic_t rt_atomic_or(volatile rt_atomic_t *ptr, rt_atomic_t val) | 原子的将 ptr 地址处的值与 val 按位或 | +| rt_atomic_t rt_atomic_flag_test_and_set(volatile rt_atomic_t *ptr) | 原子的将 ptr 地址处的值置 1 | +| void rt_atomic_flag_clear(volatile rt_atomic_t *ptr) | 原子的将 ptr 地址处的值清 0 | +| rt_atomic_t rt_atomic_compare_exchange_strong(volatile rt_atomic_t *ptr, rt_atomic_t *old, rt_atomic_t new) | 原子的将 ptr 地址处的值与 val 进行比较与交换,并返回比较结果 | + +原子操作函数详细的释义: + +#### 原子读 + +```c +rt_atomic_t rt_atomic_load(volatile rt_atomic_t *ptr); +``` + +该操作函数的语义为:使用原子操作方式从 ptr 地址指向的 4 字节空间加载一个字。 + +| **参数** | **描述** | +|------|-------------------------| +| ptr | 原子对象地址 | +| **返回值** | 返回 ptr 地址处的 4 字节数据 | + +#### 原子写 + +```c +void rt_atomic_store(volatile rt_atomic_t *ptr, rt_atomic_t val); +``` + +该操作函数的语义为:使用原子操作方式将 val 写入 ptr 地址指向的 4 字节空间。 + +| **参数** | **描述** | +|------|-------------------------| +| ptr | 原子对象地址 | +| val | 期望写入 ptr 地址处的数据 | +| **返回值** | NULL | + +#### 原子数据交换 + +```c +rt_atomic_t rt_atomic_exchange(volatile rt_atomic_t *ptr, rt_atomic_t val); +``` + +该操作函数的语义为:使用原子操作方式将 ptr 地址指向的 4 字节空间的数据交换为 val,返回 ptr 地址处修改前的 4 字节数据。 + +| **参数** | **描述** | +|------|-----------------| +| ptr | 原子对象地址 | +| val | 期望交换的数据 | +| **返回值** | 返回 ptr 地址处交换前的 4 字节数据 | + +#### 原子加 + +```c +rt_atomic_t rt_atomic_add(volatile rt_atomic_t *ptr, rt_atomic_t val); +``` + +该操作函数的语义为:使用原子操作方式将 ptr 地址指向的 4 字节数据与 val 相加,将结果写入 ptr 地址指向的 4 字节空间,返回 ptr 地址处修改前的 4 字节数据。 + +| **参数** | **描述** | +| ---------- | ------------------------------ | +| ptr | 原子对象地址 | +| val | 期望相加的值 | +| **返回值** | 返回 ptr 地址处修改前的 4 字节数据 | + +#### 原子减 + +```c +rt_atomic_t rt_atomic_sub(volatile rt_atomic_t *ptr, rt_atomic_t val); +``` + +该操作函数的语义为:使用原子操作方式将 ptr 地址指向的 4 字节数据减去 val,将结果写入 ptr 地址指向的 4 字节空间,返回 ptr 地址处修改前的 4 字节数据。 + +| **参数** | **描述** | +| ---------- | ------------------------------ | +| ptr | 原子对象地址 | +| val | 期望减去的值 | +| **返回值** | 返回 ptr 地址处修改前的 4 字节数据 | + +#### 原子异或 + +```c +rt_atomic_t rt_atomic_xor(volatile rt_atomic_t *ptr, rt_atomic_t val); +``` + +该操作函数的语义为:使用原子操作方式将 ptr 地址指向的 4 字节数据与 val 进行按位异或,将结果写入 ptr 地址指向的 4 字节空间,返回 ptr 地址处修改前的 4 字节数据。 + +| **参数** | **描述** | +| ---------- | ------------------------------ | +| ptr | 原子对象地址 | +| val | 期望异或的值 | +| **返回值** | 返回 ptr 地址处修改前的 4 字节数据 | + +#### 原子与 + +```c +rt_atomic_t rt_atomic_and(volatile rt_atomic_t *ptr, rt_atomic_t val); +``` + +该操作函数的语义为:使用原子操作方式将 ptr 地址指向的 4 字节数据与 val 进行按位相与,将结果写入 ptr 地址指向的 4 字节空间,返回 ptr 地址处修改前的 4 字节数据。 + +| **参数** | **描述** | +| ---------- | ------------------------------ | +| ptr | 原子对象地址 | +| val | 期望相与的值 | +| **返回值** | 返回 ptr 地址处修改前的 4 字节数据 | + +#### 原子或 + +```c +rt_atomic_t rt_atomic_or(volatile rt_atomic_t *ptr, rt_atomic_t val); +``` + +该操作函数的语义为:使用原子操作方式将 ptr 地址指向的 4 字节数据与 val 进行按位相或,将结果写入 ptr 地址指向的 4 字节空间,返回 ptr 地址处修改前的 4 字节数据。 + +| **参数** | **描述** | +| ---------- | ------------------------------ | +| ptr | 原子对象地址 | +| val | 期望相或的值 | +| **返回值** | 返回 ptr 地址处修改前的 4 字节数据 | + +#### 原子标志检查与置位 + +```c +rt_atomic_t rt_atomic_flag_test_and_set(volatile rt_atomic_t *ptr); +``` + +该操作函数的语义为:对 ptr 地址指向的 4 字节原子标志进行设置,并返回该原子标志对象做设置操作之前的值。若 ptr 地址指向的 4 字节数据之前状态为 0,那么经过此操作之后,该原子标志对象的状态变为了状态 1,并且返回 0 。如果 ptr 地址指向的 4 字节数据之前为状态 1,那么经过此操作之后,它仍然为状态 1,并且返回 1。所以若我们将原子标志对象作为一个“锁”来用的话,可判断这个函数接口的返回值,若返回 0,则说明锁成功,可以对多线程共享对象做相关的修改操作;如果返回的是 状态 1,则该原子标志已经被其他线程占用,需等待释放。 + +| **参数** | **描述** | +| ---------- | ----------------------------------------------- | +| ptr | 原子对象地址,此处地址指向的 4 字节数据只能为 0 或 1 | +| **返回值** | 设置状态 | + +#### 原子标志清除 + +```c +void rt_atomic_flag_clear(volatile rt_atomic_t *ptr); +``` + +该操作函数的语义为:清除标志,将标志清 0,对 ptr 地址指向原子标志进行清零操作。如果我们将原子标志对象用作“锁”的话,那么执行此操作就相当于释放锁。 + +| **参数** | **描述** | +| ---------- | ------------ | +| ptr | 原子对象地址 | +| **返回值** | NULL | + +#### 原子比较与交换 + +```c +rt_atomic_t rt_atomic_compare_exchange_strong(volatile rt_atomic_t *ptr, rt_atomic_t *old, rt_atomic_t new); +``` + +该操作函数的语义为:第一个参数指向原子类型对象;第二个参数指向要进行比较的对象,并且如果比较失败,那么该操作会将原子对象的当前值拷贝到该参数所指向的对象中;第三个参数指定存储到原子对象中的值。 如果比较成功,那么 new 值会被存放到原子对象中,并且返回 1;如果比较失败,那么当前原子对象的值会被拷贝到 old 所指向的对象中,并且返回 0。 + +| **参数** | **描述** | +| ---------- | -------------- | +| ptr | 原子对象地址 | +| old | 被比较的对象 | +| new | 期望更新的对象 | +| **返回值** | 比较结果 | + +## 综合示例 + +在工程中包含`rtatomic.h`,然后将示例添加至工程即可进行简单的原子操作验证。 + +```c +/* 在工程中添加该头文件 */ +#include + +rt_atomic_t value1 = 10; +rt_atomic_t value2 = 5; +int main(void) +{ + /* atomic add */ + result = rt_atomic_add(&value1, value2); + rt_kprintf("result = %d value1 = %d value2 = %d\r\n", result, value1, value2); + + value1 = 10; + value2 = 5; + /* atomic sub */ + result = rt_atomic_sub(&value1, value2); + rt_kprintf("result = %d value1 = %d value2 = %d\r\n", result, value1, value2); + + value1 = 10; + value2 = 5; + /* atomic xor */ + result = rt_atomic_xor(&value1, value2); + rt_kprintf("result = %d value1 = %d value2 = %d\r\n", result, value1, value2); + + value1 = 10; + value2 = 5; + /* atomic or */ + result = rt_atomic_or(&value1, value2); + rt_kprintf("result = %d value1 = %d value2 = %d\r\n", result, value1, value2); + + value1 = 10; + value2 = 5; + /* atomic and */ + result = rt_atomic_and(&value1, value2); + rt_kprintf("result = %d value1 = %d value2 = %d\r\n", result, value1, value2); + + value1 = 10; + value2 = 5; + /* atomic exchange */ + result = rt_atomic_exchange(&value1, value2); + rt_kprintf("result = %d value1 = %d value2 = %d\r\n", result, value1, value2); + + value1 = 10; + value2 = 5; + /* atomic compare and exchange */ + result = rt_atomic_compare_exchange_strong(&value1, value2, 6); + rt_kprintf("result = %d value1 = %d value2 = %d\r\n", result, value1, value2); + + value1 = 10; + /* atomic load */ + result = rt_atomic_load(&value1); + rt_kprintf("result = %d value1 = %d value2 = %d\r\n", result, value1, value2); + + value1 = 10; + value2 = 5; + /* atomic store */ + result = rt_atomic_store(&value1, value2); + rt_kprintf("result = %d value1 = %d value2 = %d\r\n", result, value1, value2); + + value1 = 0; + /* atomic flag test and set */ + result = rt_atomic_flag_test_and_set(&value1); + rt_kprintf("result = %d value1 = %d value2 = %d\r\n", result, value1, value2); + + /* atomic flag clear */ + result = rt_atomic_flag_clear(&value1); + rt_kprintf("result = %d value1 = %d value2 = %d\r\n", result, value1, value2); +} +``` diff --git a/rt-thread-version/rt-thread-standard/programming-manual/basic/basic.md b/rt-thread-version/rt-thread-standard/programming-manual/basic/basic.md index 0091a213448171bf506ff695e476ea2f960e2352..0b0883aee4da91ec0addbb6e495064a6f6987697 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/basic/basic.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/basic/basic.md @@ -7,7 +7,7 @@ RT-Thread 内核的简单介绍,从软件架构入手讲解实时内核的组 RT-Thread 内核介绍 ----------------- -内核是操作系统最基础也是最重要的部分。下图为 RT-Thread 内核架构图,内核处于硬件层之上,内核部分包括内核库、实时内核实现。 +内核是一个操作系统的核心,是操作系统最基础也是最重要的部分。它负责管理系统的线程、线程间通信、系统时钟、中断及内存等。下图为 RT-Thread 内核架构图,可以看到内核处于硬件层之上,内核部分包括内核库、实时内核实现。 ![RT-Thread 内核及底层结构](figures/03kernel_Framework.png) diff --git a/rt-thread-version/rt-thread-standard/programming-manual/device-ipc/workqueue/workqueue.md b/rt-thread-version/rt-thread-standard/programming-manual/device-ipc/workqueue/workqueue.md index b3c38dae6b9847de828ec0cb6ff3635166ab5751..21bb0c22ea0aef50f07277b2301c13bf0ef0b7b8 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/device-ipc/workqueue/workqueue.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/device-ipc/workqueue/workqueue.md @@ -276,7 +276,7 @@ void work_func(struct rt_work *work, void *work_data) int workqueue_example(void) { - printf("hello rt-thread!\n"); + rt_kprintf("hello rt-thread!\n"); struct rt_workqueue *wq = rt_workqueue_create("my_wq", 2048, 20); RT_ASSERT(wq); diff --git a/rt-thread-version/rt-thread-standard/programming-manual/device/can/can.md b/rt-thread-version/rt-thread-standard/programming-manual/device/can/can.md index 90e87e2cd8840fbc0ce32238699189505ae63271..7515226cb022b697e651ec11679c7c5d9f77f896 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/device/can/can.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/device/can/can.md @@ -200,7 +200,7 @@ struct rt_can_filter_item rt_uint32_t id : 29; /* 报文 ID */ rt_uint32_t ide : 1; /* 扩展帧标识位 */ rt_uint32_t rtr : 1; /* 远程帧标识位 */ - rt_uint32_t mode : 1; /* 过滤表模式 */ + rt_uint32_t mode : 1; /* 过滤表模式,0 表示标识符列表模式,1 表示标识符屏蔽位模式 */ rt_uint32_t mask; /* ID 掩码,0 表示对应的位不关心,1 表示对应的位必须匹配 */ rt_int32_t hdr; /* -1 表示不指定过滤表号,对应的过滤表控制块也不会被初始化,正数为过滤表号,对应的过滤表控制块会被初始化 */ #ifdef RT_CAN_USING_HDR diff --git a/rt-thread-version/rt-thread-standard/programming-manual/device/cputime/cputime.md b/rt-thread-version/rt-thread-standard/programming-manual/device/cputime/cputime.md new file mode 100644 index 0000000000000000000000000000000000000000..65fa72ba139b5cb8d165919bab2782066f0138d7 --- /dev/null +++ b/rt-thread-version/rt-thread-standard/programming-manual/device/cputime/cputime.md @@ -0,0 +1,156 @@ +# CPUTIME 设备 + +内核中的定时器是以 tick 为精度实现的。出现精度不高的情况。cputime 通过对接硬件定时器来实现,提高了精度,不过作为代价是,在每个 bsp 中都需要具体实现 cputime 的对接工作。 + +#### cputime 相关接口 + +这些定时器接口除了定时器控制块与内核中的定时器不同外,其他的参数、返回值以及用法基本一致,详情请看:[定时器管理方式](/rt-thread-version/rt-thread-standard/programming-manual/timer/timer?id=定时器的管理方式) + +| **函数** | **描述** | +| -------------------- | ---------------------------------- | +| rt_cputimer_detach();|定时器脱离| +| rt_cputimer_create();|定时器创建| +| rt_cputimer_delete();|定时器删除| +| rt_cputimer_start();|定时器启动| +| rt_cputimer_stop();|定时器停止| +| rt_cputimer_control();|定时器控制| + +这些是一些高精度延时的接口(这里只提供了接口,具体精度能不能达到还是要看硬件定时器中的实现) + +| **函数** | **描述** | +| -------------------- | ---------------------------------- | +| rt_cputime_sleep();|cputime tick 精度延时| +| rt_cputime_ndelay();|纳秒精度延时| +| rt_cputime_udelay();|微秒精度延时| +| rt_cputime_mdelay();|毫秒精度延时| + +#### 如何对接 cputime? + +1. 对接硬件定时器,使其形成单调递增的时钟,并且到达指定时间可以触发回调 +2. 根据硬件定时器的精度情况来对接 cputime 的 ops + +下面是一些如何对接到 cputime 的示例代码 + +```c + +#include +#include +#include + +#include + +#define HWTIMER_DEV_NAME "timer7" + +/* 递增 count 作为 cpu tick 使用,不可被设置,只可单调递增 */ +rt_uint64_t count = 0; + +/* 当 CPU tick 到达 timeout_tick 时触发回调 */ +rt_uint64_t timeout_tick = 0; + +void (*hwtimer_timeout)(void *param); +void *parameter = RT_NULL; + +/* 精度 ns */ +static double cortexm_cputime_getres(void) +{ + return 10000; +} + +/* cpu tick */ +static uint64_t cortexm_cputime_gettime(void) +{ + return count; +} + +/* 设置超时时间及函数 */ +static int cortexm_cputime_settimeout(uint64_t tick, void (*timeout)(void *param), void *param) +{ + timeout_tick = tick; + hwtimer_timeout = timeout; + parameter = param; + return 0; +} + +/* 定义 ops */ +const static struct rt_clock_cputime_ops _cortexm_ops = +{ + cortexm_cputime_getres, + cortexm_cputime_gettime, + cortexm_cputime_settimeout +}; + +/* 初始化 ops */ +int cortexm_cputime_init(void) +{ + /* bsp 在这样使用的时候,不用管内部有没有实现,这个函数会覆盖掉内部的实现 */ + clock_cpu_setops(&_cortexm_ops); + return 0; +} +INIT_BOARD_EXPORT(cortexm_cputime_init); + +/* 硬件定时器超时函数 */ +static rt_err_t timeout_cb(rt_device_t dev, rt_size_t size) +{ + count++; + if(count == timeout_tick) + { + /* 到达指定时间后清空到达时间,并触发回调 */ + timeout_tick = 0; + if(hwtimer_timeout != RT_NULL) + hwtimer_timeout(parameter); + } + return 0; +} + +/* 硬件定时器初始化 */ +static int hwtimer_init() +{ + rt_err_t ret = RT_EOK; + rt_hwtimerval_t timeout_s; + rt_device_t hw_dev = RT_NULL; + rt_hwtimer_mode_t mode; + rt_uint32_t freq = 1000000; + + hw_dev = rt_device_find(HWTIMER_DEV_NAME); + if (hw_dev == RT_NULL) + { + /* 硬件定时器失败时,清空设置超时的函数,使 cputime 不可用, + 防止使用 rt_cputime_sleep() 时卡死 */ + _cortexm_ops.cputime_settimeout = RT_NULL; + rt_kprintf("hwtimer sample run failed! can't find %s device!\n", HWTIMER_DEV_NAME); + return RT_ERROR; + } + + ret = rt_device_open(hw_dev, RT_DEVICE_OFLAG_RDWR); + if (ret != RT_EOK) + { + _cortexm_ops.cputime_settimeout = RT_NULL; + rt_kprintf("open %s device failed!\n", HWTIMER_DEV_NAME); + return ret; + } + /* 设置硬件定时器的超时时间 */ + rt_device_set_rx_indicate(hw_dev, timeout_cb); + + rt_device_control(hw_dev, HWTIMER_CTRL_FREQ_SET, &freq); + mode = HWTIMER_MODE_PERIOD; + ret = rt_device_control(hw_dev, HWTIMER_CTRL_MODE_SET, &mode); + if (ret != RT_EOK) + { + _cortexm_ops.cputime_settimeout = RT_NULL; + rt_kprintf("set mode failed! ret is :%d\n", ret); + return ret; + } + timeout_s.sec = 0; + timeout_s.usec = 10; + + /* 设置硬件定时器的精度,这里应和上述的 cortexm_cputime_getres 函数保持一致 */ + if (rt_device_write(hw_dev, 0, &timeout_s, sizeof(timeout_s)) != sizeof(timeout_s)) + { + _cortexm_ops.cputime_settimeout = RT_NULL; + rt_kprintf("set timeout value failed\n"); + return RT_ERROR; + } + return ret; +} +INIT_APP_EXPORT(hwtimer_init); +``` diff --git a/rt-thread-version/rt-thread-standard/programming-manual/device/dac/dac.md b/rt-thread-version/rt-thread-standard/programming-manual/device/dac/dac.md index 6a076a58f1da2840773ea7f7e78862f5e68f791d..a0bc3b8ddfd75839d5d97a011c93b6ff80eb84fc 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/device/dac/dac.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/device/dac/dac.md @@ -243,7 +243,7 @@ static int dac_vol_sample(int argc, char *argv[]) /* 设置输出值 */ value = atoi(argv[1]); - rt_dac_write(dac_dev, DAC_DEV_NAME, DAC_DEV_CHANNEL, &value); + rt_dac_write(dac_dev, DAC_DEV_NAME, DAC_DEV_CHANNEL, value); rt_kprintf("the value is :%d \n", value); /* 转换为对应电压值 */ diff --git a/rt-thread-version/rt-thread-standard/programming-manual/device/device.md b/rt-thread-version/rt-thread-standard/programming-manual/device/device.md index 65d0669cdf9556e7a3aae448624610212d1184e0..20c9cbd126ca2c0f2ee75c9c63848ec8761e6720 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/device/device.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/device/device.md @@ -14,7 +14,7 @@ RT-Thread 提供了一套简单的 I/O 设备模型框架,如下图所示, 应用程序通过 I/O 设备管理接口获得正确的设备驱动,然后通过这个设备驱动与底层 I/O 硬件设备进行数据(或控制)交互。 -I/O 设备管理层实现了对设备驱动程序的封装。应用程序通过 I/O 设备层提供的标准接口访问底层设备,设备驱动程序的升级、更替不会对上层应用产生影响。这种方式使得设备的硬件操作相关的代码能够独立于应用程序而存在,双方只需关注各自的功能实现,从而降低了代码的耦合性、复杂性,提高了系统的可靠性。 +I/O 设备管理层实现了对设备驱动程序的封装。应用程序通过图中的"I/O设备管理层"提供的标准接口访问底层设备,设备驱动程序的升级、更替不会对上层应用产生影响。这种方式使得设备的硬件操作相关的代码能够独立于应用程序而存在,双方只需关注各自的功能实现,从而降低了代码的耦合性、复杂性,提高了系统的可靠性。 设备驱动框架层是对同类硬件设备驱动的抽象,将不同厂家的同类硬件设备驱动中相同的部分抽取出来,将不同部分留出接口,由驱动程序实现。 @@ -449,7 +449,7 @@ rt_err_t rt_device_set_tx_complete(rt_device_t dev, rt_err_t (*tx_done)(rt_devic #include #include -#define IWDG_DEVICE_NAME "iwg" +#define IWDG_DEVICE_NAME "wdt" static rt_device_t wdg_dev; @@ -463,7 +463,7 @@ static void idle_hook(void) int main(void) { rt_err_t res = RT_EOK; - rt_uint32_t timeout = 1000; /* 溢出时间 */ + rt_uint32_t timeout = 10; /* 溢出时间 */ /* 根据设备名称查找看门狗设备,获取设备句柄 */ wdg_dev = rt_device_find(IWDG_DEVICE_NAME); diff --git a/rt-thread-version/rt-thread-standard/programming-manual/device/rtc/rtc.md b/rt-thread-version/rt-thread-standard/programming-manual/device/rtc/rtc.md index 2f6b858860bf89ec2539440e22eaed25e7158dcb..b505ee863f3906d5236822888368e2281f724ba3 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/device/rtc/rtc.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/device/rtc/rtc.md @@ -172,10 +172,28 @@ RTC 设备的具体使用方式可以参考如下示例代码,首先设置了 #include #include +#define RTC_NAME "rtc" + static int rtc_sample(int argc, char *argv[]) { rt_err_t ret = RT_EOK; time_t now; + rt_device_t device = RT_NULL; + + /*寻找设备*/ + device = rt_device_find(RTC_NAME); + if (!device) + { + LOG_E("find %s failed!", RTC_NAME); + return RT_ERROR; + } + + /*初始化RTC设备*/ + if(rt_device_open(device, 0) != RT_EOK) + { + LOG_E("open %s failed!", RTC_NAME); + return RT_ERROR; + } /* 设置日期 */ ret = set_date(2018, 12, 3); diff --git a/rt-thread-version/rt-thread-standard/programming-manual/device/sensor/sensor_list.md b/rt-thread-version/rt-thread-standard/programming-manual/device/sensor/sensor_list.md index 8448d36be17876e6f1f4f2562d70f7510abb5d04..46870697e3517266477d6b0eaf23cac23c07bb0c 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/device/sensor/sensor_list.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/device/sensor/sensor_list.md @@ -3,7 +3,7 @@ 下面是一份已经对接到 RT-Therad Sensor 框架上的传感器的列表,点击传感器名称即可跳转到相应软件包主页。(本文档不定时更新,如要查看所有支持的传感器的列表,可以查看最新的[软件包索引](https://github.com/RT-Thread/packages/tree/master/peripherals/sensors)。 | 厂商 | 传感器 | 备注 | -| -------------- | ------------------------------------------------------------ | ------------------------ | +| :------------- | ------------------------------------------------------------ | ------------------------ | | **BOSCH** | | | | | **[bma400](https://github.com/RT-Thread-packages/bma400)** | 加速度计、计步计 | | | **[bmi160](https://github.com/RT-Thread-packages/bmi160_bmx160)** | 加速计、陀螺仪 | @@ -17,18 +17,24 @@ | | **[hts221](https://github.com/RT-Thread-packages/hts221)** | 气压计、气温计 | | | **[lps22hb](https://github.com/RT-Thread-packages/lps22hb)** | 气压计、气温计 | | **MiraMEMS** | | | -| | **[da270]()** | 加速度计 | -| | **[df220]()** | 压力计 | +| | **[da270]()** | 加速度计 | +| | **[df220]()** | 压力计 | | **ALPSALPINE** | | | -| | **[hshcal001]()** | 湿度计、温度计 | +| | **[hshcal001]()** | 湿度计、温度计 | | **MEAS** | | | -| | **[MS5611]()** | 气压计、温度计 | +| | **[MS5611]()** | 气压计、温度计 | | **invensense** | | | -| | **[mpu6xxx(mpu6050/mpu6000/icm20608)]()** | 加速度计、陀螺仪 | +| | **[mpu6xxx(mpu6050/mpu6000/icm20608)]()** | 加速度计、陀螺仪 | | **ASAIR** | | | -| | **[aht10]()** | 温度计、湿度计 | +| | **[aht10]()** | 温度计、湿度计 | | **ROHM** | | | -| | **[BH1750FVI]()** | 环境光照强度 | +| | **[BH1750FVI]()** | 环境光照强度 | | **Richtek** | | | -| | **[RT3020](http://packages.rt-thread.org/itemDetail.html?package=rt3020)** | 加速度计 | +| | **[RT3020](https://packages.rt-thread.org/detail.html?package=rt3020)** | 加速度计 | +| **Sensirion** | | | +| | **[SHT3x](https://github.com/haodongnj/sht3x)** | 温度计、湿度计 | + + + + diff --git a/rt-thread-version/rt-thread-standard/programming-manual/device/spi/spi.md b/rt-thread-version/rt-thread-standard/programming-manual/device/spi/spi.md index 8139c6612480e02160c9eb366fd54b52496cb1d6..01873bf2bff8cb5cbc486e9caffb6290a45f7977 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/device/spi/spi.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/device/spi/spi.md @@ -38,6 +38,46 @@ SPI 以主从方式工作,通常有一个主设备和一个或多个从设备 SPI 驱动会注册 SPI 总线,SPI 设备需要挂载到已经注册好的 SPI 总线上。 +```c +rt_err_t rt_spi_bus_attach_device_cspin(struct rt_spi_device *device, + const char *name, + const char *bus_name, + rt_base_t cs_pin, + void *user_data) +``` + +| **参数** | **描述** | +| ---------- | --------------------------- | +| device | SPI 设备句柄 | +| name | SPI 设备名称 | +| bus_name | SPI 总线名称 | +| cs_pin | SPI 片选引脚号(基于PIN框架) | +| user_data | 用户数据指针 | +| **返回** | —— | +| RT_EOK | 成功 | +| 其他错误码 | 失败 | + +此函数用于挂载一个 SPI 设备到指定的 SPI 总线,并向内核注册 SPI 设备。并且可以依赖RT-Thread的PIN框架来绑定SPI的片选引脚(cs_pin),避免了不同bsp的上层应用对片选引脚操作不统一的问题。 + +一般 SPI 总线命名原则为 spix, SPI 设备命名原则为 spixy ,如 spi10 表示挂载在 spi1 总线上的 0 号设备。cs_pin可以通过PIN框架`rt_pin_get`函数来获取,也可以使用BSP级提供的`GET_PIN`宏定义来获取。user_data 在用户使用不到的情况下可以设置为`RT_NULL`。 + +使用示例: + +```c +struct rt_spi_device *spi_device; +spi_device = (struct rt_spi_device *)rt_malloc(sizeof(struct rt_spi_device)); +/* BSP级 GET_PIN 宏定义方式 */ +rt_hw_spi_device_attach(spi_device, "spi1", "spi10", GET_PIN(B, 14), RT_NULL); +/* PIN框架级 rt_pin_get api方式 */ +rt_hw_spi_device_attach(spi_device, "spi1", "spi10", rt_pin_get("PB.14"), RT_NULL); +``` + +> [!NOTE] +> +> 此函数是RT-Thread 5.0.0 添加的新函数,如果低于5.0.0版本不支持这个函数。 + +为了兼容RT-Thread 5.0.0 版本前的SPI设备片选引脚通过user_data挂载的方式,我们保留了`rt_spi_bus_attach_device`这个api,但是希望大家在今后使用的时候,尽量使用`rt_spi_bus_attach_device_cspin`这个新特性api。 + ```c rt_err_t rt_spi_bus_attach_device(struct rt_spi_device *device, const char *name, @@ -59,27 +99,33 @@ rt_err_t rt_spi_bus_attach_device(struct rt_spi_device *device, 一般 SPI 总线命名原则为 spix, SPI 设备命名原则为 spixy ,如 spi10 表示挂载在 spi1 总线上的 0 号设备。user_data 一般为 SPI 设备的 CS 引脚指针,进行数据传输时 SPI 控制器会操作此引脚进行片选。 -若使用 rt-thread/bsp/stm32 目录下的 BSP 则可以使用下面的函数挂载 SPI 设备到总线: - -```c -rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, GPIO_TypeDef* cs_gpiox, uint16_t cs_gpio_pin); -``` - 下面的示例代码挂载 SPI FLASH W25Q128 到 SPI 总线: ```c static int rt_hw_spi_flash_init(void) { - __HAL_RCC_GPIOB_CLK_ENABLE(); - rt_hw_spi_device_attach("spi1", "spi10", GPIOB, GPIO_PIN_14); - + struct rt_spi_device *spi_device = RT_NULL; + + spi_device = (struct rt_spi_device *)rt_malloc(sizeof(struct rt_spi_device)); + if(RT_NULL == spi_device) + { + LOG_E("Failed to malloc the spi device."); + return -RT_ENOMEM; + } + if (RT_EOK != rt_spi_bus_attach_device_cspin(spi_device, "spi1", "spi10",GET_PIN(B, 14), RT_NULL)) + { + LOG_E("Failed to attach the spi device."); + return -RT_ERROR; + } if (RT_NULL == rt_sfud_flash_probe("W25Q128", "spi10")) { + LOG_E("Failed to probe the W25Q128."); return -RT_ERROR; }; return RT_EOK; } + /* 导出到自动初始化 */ INIT_COMPONENT_EXPORT(rt_hw_spi_flash_init); ``` diff --git a/rt-thread-version/rt-thread-standard/programming-manual/device/uart/uart_v2/uart.md b/rt-thread-version/rt-thread-standard/programming-manual/device/uart/uart_v2/uart.md index 500ba63f00771ec79da5ca986206d579790947d7..ee0684a3d9976457635d588a8d4b21122ea6a7a2 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/device/uart/uart_v2/uart.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/device/uart/uart_v2/uart.md @@ -1,7 +1,7 @@ # UART 设备 v2 版本 > [!NOTE] -> 注:目前只有 github 的 master 分支上的 stm32l475-pandora 的 BSP 进行了串口 V2 版本的适配。 +> 注:目前主要在 RT-Thread V4.1.0 版本后的 stm32 的 BSP 进行了串口 V2 版本的适配。 > [!NOTE] > 注:如果用户已经清楚了解[旧版本的串口框架](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/uart/uart_v1/uart),那么可直接跳过该文档的前部分关于串口介绍的内容,从[访问串口设备](uart?id=%e8%ae%bf%e9%97%ae%e4%b8%b2%e5%8f%a3%e8%ae%be%e5%a4%87)章节开始查阅即可。 @@ -140,7 +140,7 @@ rt_device_open(dev, RT_DEVICE_FLAG_RX_NON_BLOCKING | RT_DEVICE_FLAG_TX_BLOCKING) 对于编号 (1) 模式,如果必须使用轮询模式时,一定要将缓冲区大小配置为 0,因为如果缓冲区大小不为 0,在应用层使用发送阻塞模式时,将会使用中断模式(如果开 DMA,则使用 DMA 模式)。 -对于编号 (2) 模式,当用户设置为 DMA 阻塞模式时,虽然设置了缓冲区不为 0,但是该缓冲区并不会进行初始化,而是直接进行 DMA 数据搬运。从而省去了内存搬运造成的性能下降的问题。需要注意的是,当使用 DMA 阻塞模式时,虽然不用缓冲区,但是也要将缓冲区长度设置为大于 0 的值,因为当缓冲区长度为 0 时,将会错误地使用轮询模式。 +对于编号 (5) 模式,当用户设置为 DMA 阻塞模式时,虽然设置了缓冲区不为 0,但是该缓冲区并不会进行初始化,而是直接进行 DMA 数据搬运。从而省去了内存搬运造成的性能下降的问题。需要注意的是,当使用 DMA 阻塞模式时,虽然不用缓冲区,但是也要将缓冲区长度设置为大于 0 的值,因为当缓冲区长度为 0 时,将会错误地使用轮询模式。 **接收端的模式对应关系如下表所示:** @@ -193,7 +193,7 @@ rt_device_open(dev, RT_DEVICE_FLAG_RX_NON_BLOCKING | RT_DEVICE_FLAG_TX_BLOCKING) ![menuconfig](figures/mcfg_txpoll_rxint.jpg) -上图所示,对于 UART1 的配置为关闭 DMA RX 和 DMA TX,且发送和接收缓存区大小设置为 1024 字节。并且设置 `UART1 TX buffer size` 为 0。 +上图所示,对于 UART1 的配置为关闭 DMA RX 和 DMA TX,接收缓存区大小设置为 1024 字节,但设置 `UART1 TX buffer size` 为 0。 由此用户在应用层对串口的接收和发送的操作模式进行配置时,发送只能使用阻塞模式,接收可以使用阻塞和非阻塞模式。串口控制台默认使用这样的配置模式,且操作模式为阻塞发送和非阻塞接收。 diff --git a/rt-thread-version/rt-thread-standard/programming-manual/device/watchdog/watchdog.md b/rt-thread-version/rt-thread-standard/programming-manual/device/watchdog/watchdog.md index 363d9b8a7e106b8fc3182acc8d004fbf3e64505d..12aa1d33284311cadf45293c4acd2496faace8aa 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/device/watchdog/watchdog.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/device/watchdog/watchdog.md @@ -203,7 +203,8 @@ static int wdt_sample(int argc, char *argv[]) rt_kprintf("find %s failed!\n", device_name); return RT_ERROR; } - + /* 初始化设备 */ + rt_device_init(wdg_dev); /* 设置看门狗溢出时间 */ ret = rt_device_control(wdg_dev, RT_DEVICE_CTRL_WDT_SET_TIMEOUT, &timeout); if (ret != RT_EOK) diff --git a/rt-thread-version/rt-thread-standard/programming-manual/finsh/finsh.md b/rt-thread-version/rt-thread-standard/programming-manual/finsh/finsh.md index 4a2d95ce889f4bbaed2eab9f0cd3469805c362ca..3babef77cad151697ea017baba2c11753a0bdd4f 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/finsh/finsh.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/finsh/finsh.md @@ -29,11 +29,7 @@ FinSH 支持自动补全、查看历史命令等功能,通过键盘上的按 | 退格键 | 删除符 | | ←→键 | 向左或向右移动标 | -FinSH 支持两种输入模式,分别是传统命令行模式和 C 语言解释器模式。 - -### 传统命令行模式 - -此模式又称为 msh(module shell),msh 模式下,FinSH 与传统 shell(dos/bash)执行方式一致,例如,可以通过 `cd /` 命令将目录切换至根目录。 +FinSH 支持命令行模式,此模式又称为 msh(module shell),msh 模式下,FinSH 与传统 shell(dos/bash)执行方式一致,例如,可以通过 `cd /` 命令将目录切换至根目录。 msh 通过解析,将输入字符分解成以空格区分开的命令和参数。其命令执行格式如下所示: @@ -41,55 +37,63 @@ msh 通过解析,将输入字符分解成以空格区分开的命令和参数 其中 command 既可以是 RT-Thread 内置的命令,也可以是可执行的文件。 -### C 语言解释器模式 - -此模式又称为 C-Style 模式。C 语言解释器模式下,FinSH 能够解析执行大部分 C 语言的表达式,并使用类似 C 语言的函数调用方式访问系统中的函数及全局变量,此外它也能够通过命令行方式创建变量。在该模式下,输入的命令必须类似 C 语言中的函数调用方式,即必须携带 () 符号,例如,要输出系统当前所有线程及其状态,在 FinSH 中输入 `list_thread()` 即可打印出需要的信息。FinSH 命令的输出为此函数的返回值。对于一些不存在返回值的函数(void 返回值),这个打印输出没有意义。 - -最初 FinSH 仅支持 C-Style 模式,后来随着 RT-Thread 的不断发展,C-Style 模式在运行脚本或者程序时不太方便,而使用传统的 shell 方式则比较方便。另外,C-Style 模式下,FinSH 占用体积比较大。出于这些考虑,在 RT-Thread 中增加了 msh 模式,msh 模式体积小,使用方便,推荐大家使用 msh 模式。 - -如果在 RT-Thread 中同时使能了这两种模式,那它们可以动态切换,在 msh 模式下输入 exit 后回车,即可切换到 C-Style 模式。在 C-Style 模式输入 msh() 后回车,即可进入 msh 模式。两种模式的命令不通用,msh 命令无法在 C-Style 模式下使用,反之同理。 ## FinSH 内置命令 -在 RT-Thread 中默认内置了一些 FinSH 命令,在 FinSH 中输入 help 后回车或者直接按下 Tab 键,就可以打印当前系统支持的所有命令。C-Style 和 msh 模式下的内置命令基本一致,这里就以 msh 为例。 +在 RT-Thread 中默认内置了一些 FinSH 命令,在 FinSH 中输入 help 后回车或者直接按下 Tab 键,就可以打印当前系统支持的所有命令。 msh 模式下,按下 Tab 键后可以列出当前支持的所有命令。默认命令的数量不是固定的,RT-Thread 的各个组件会向 FinSH 输出一些命令。例如,当打开 DFS 组件时,就会把 ls,cp,cd 等命令加到 FinSH 中,方便开发者调试。 以下为按下 Tab 键后打印出来的当前支持的所有显示 RT-Thread 内核状态信息的命令,左边是命令名称,右边是关于命令的描述: ```c +msh /> RT-Thread shell commands: -version - show RT-Thread version information -list_thread - list thread -list_sem - list semaphore in system -list_event - list event in system -list_mutex - list mutex in system -list_mailbox - list mail box in system -list_msgqueue - list message queue in system -list_timer - list timer in system -list_device - list device in system -exit - return to RT-Thread shell mode. -help - RT-Thread shell help. -ps - List threads in the system. -time - Execute command with time. -free - Show the memory usage in the system. +pin - pin [option] +reboot - Reboot System +help - RT-Thread shell help. +ps - List threads in the system. +free - Show the memory usage in the system +clear - clear the terminal screen +version - show RT-Thread version information +list - list objects + + +msh />list +Usage: list [options] +[options]: + thread - list threads + timer - list timers + sem - list semaphores + mutex - list mutexs + event - list events + mailbox - list mailboxs + msgqueue - list message queues + memheap - list memory heaps + mempool - list memory pools + device - list devices + fd - list file descriptors +msh /> + ``` 这里列出输入常用命令后返回的字段信息,方便开发者理解返回的信息内容。 ### 显示线程状态 -使用 ps 或者 list_thread 命令来列出系统中的所有线程信息,包括线程优先级、状态、栈的最大使用量等。 +使用 ps 或者 list thread 命令来列出系统中的所有线程信息,包括线程优先级、状态、栈的最大使用量等。 ```c -msh />list_thread +msh />list thread thread pri status sp stack size max used left tick error -------- --- ------- ---------- ---------- ------ ---------- --- -tshell 20 ready 0x00000118 0x00001000 29% 0x00000009 000 -tidle 31 ready 0x0000005c 0x00000200 28% 0x00000005 000 -timer 4 suspend 0x00000078 0x00000400 11% 0x00000009 000 +tshell 20 running 0x00000160 0x00001000 15% 0x00000003 OK +aio 128 suspend 0x00000084 0x00000800 06% 0x0000000a OK +sys work 23 suspend 0x00000084 0x00000800 06% 0x0000000a OK +tidle0 255 ready 0x0000005c 0x00001000 04% 0x00000016 OK +timer 4 suspend 0x00000078 0x00000400 11% 0x00000009 OK ``` -list_thread 返回字段的描述: +list thread 返回字段的描述: |**字段** |**描述** | |------------|----------------------------| @@ -104,17 +108,22 @@ list_thread 返回字段的描述: ### 显示信号量状态 -使用 list_sem 命令来显示系统中所有信号量信息,包括信号量的名称、信号量的值和等待这个信号量的线程数目。 +使用 list sem 命令来显示系统中所有信号量信息,包括信号量的名称、信号量的值和等待这个信号量的线程数目。 ```c -msh />list_sem -semaphore v suspend thread +msh />list sem +semaphor v suspend thread -------- --- -------------- shrx 000 0 -e0 000 0 +sem_sd0 001 0 +psem 001 0 +pmq 001 0 +wqueue 000 0 +sd_ack 000 0 +wqueue 000 0 ``` -list_sem 返回字段的描述: +list sem 返回字段的描述: |**字段** |**描述** | |----------------|--------------------------| @@ -124,15 +133,15 @@ list_sem 返回字段的描述: ### 显示事件状态 -使用 list_event 命令来显示系统中所有的事件信息,包括事件名称、事件的值和等待这个事件的线程数目。 +使用 list event 命令来显示系统中所有的事件信息,包括事件名称、事件的值和等待这个事件的线程数目。 ```c -msh />list_event +msh />list event event set suspend thread ----- ---------- -------------- ``` -list_event 返回字段的描述: +list event 返回字段的描述: |**字段** |**描述** | |----------------|----------------------------------| @@ -142,17 +151,21 @@ list_event 返回字段的描述: ### 显示互斥量状态 -使用 list_mutex 命令来显示系统中所有的互斥量信息,包括互斥量名称、互斥量的所有者和所有者在互斥量上持有的嵌套次数等。 +使用 list mutex 命令来显示系统中所有的互斥量信息,包括互斥量名称、互斥量的所有者和所有者在互斥量上持有的嵌套次数等。 ```c -msh />list_mutex -mutex owner hold suspend thread --------- -------- ---- -------------- -fat0 (NULL) 0000 0 -sal_lock (NULL) 0000 0 +msh />list mutex +mutex owner hold suspend thread priority +-------- -------- ---- -------------- -------- +fat0 (NULL) 0000 0 255 +sd_bus_l (NULL) 0000 0 255 +fdlock (NULL) 0000 0 255 +fslock (NULL) 0000 0 255 +dfs_mgr (NULL) 0000 0 255 +heap (NULL) 0000 0 255 ``` -list_mutex 返回字段的描述: +list mutex 返回字段的描述: |**字段** |**描述** | |----------------|------------------------------------| @@ -160,39 +173,40 @@ list_mutex 返回字段的描述: | owner | 当前持有互斥量的线程 | | hold | 持有者在这个互斥量上嵌套持有的次数 | | suspend thread | 等待这个互斥量的线程数目 | +| priority | 持有线程的优先级 | ### 显示邮箱状态 -使用 list_mailbox 命令显示系统中所有的邮箱信息,包括邮箱名称、邮箱中邮件的数目和邮箱能容纳邮件的最大数目等。 +使用 list mailbox 命令显示系统中所有的邮箱信息,包括邮箱名称、邮箱中邮件的数目和邮箱能容纳邮件的最大数目等。 ```c -msh />list_mailbox +msh />list mailbox mailbox entry size suspend thread -------- ---- ---- -------------- -etxmb 0000 0008 1:etx -erxmb 0000 0008 1:erx +mmcsdhot 0001 0004 0 +mmcsdmb 0000 0004 1:mmcsd_de ``` -list_mailbox 返回字段的描述: +list mailbox 返回字段的描述: |**字段** |**描述** | |----------------|----------------------------| | mailbox | 邮箱的名称 | | entry | 邮箱中包含的邮件数目 | | size | 邮箱能够容纳的最大邮件数目 | -| suspend thread | 等待这个邮箱的线程数目 | +| suspend thread | 等待这个邮箱的线程数目 | ### 显示消息队列状态 -使用 list_msgqueue 命令来显示系统中所有的消息队列信息,包括消息队列的名称、包含的消息数目和等待这个消息队列的线程数目。 +使用 list msgqueue 命令来显示系统中所有的消息队列信息,包括消息队列的名称、包含的消息数目和等待这个消息队列的线程数目。 ```c -msh />list_msgqueue +msh />list msgqueue msgqueue entry suspend thread -------- ---- -------------- ``` -list_msgqueue 返回字段的描述: +list msgqueue 返回字段的描述: |**字段** |**描述** | |----------------|----------------------------| @@ -202,16 +216,16 @@ list_msgqueue 返回字段的描述: ### 显示内存池状态 -使用 list_mempool 命令来显示系统中所有的内存池信息,包括内存池的名称、内存池的大小和最大使用的内存大小等。 +使用 list mempool 命令来显示系统中所有的内存池信息,包括内存池的名称、内存池的大小和最大使用的内存大小等。 ```c -msh />list_mempool +msh />list mempool mempool block total free suspend thread ------- ---- ---- ---- -------------- signal 0012 0032 0032 0 ``` -list_mempool 返回字段的描述: +list mempool 返回字段的描述: |**字段** |**描述** | |----------------|--------------------| @@ -223,39 +237,50 @@ list_mempool 返回字段的描述: ### 显示定时器状态 -使用 list_timer 命令来显示系统中所有的定时器信息,包括定时器的名称、是否是周期性定时器和定时器超时的节拍数等。 +使用 list timer 命令来显示系统中所有的定时器信息,包括定时器的名称、是否是周期性定时器和定时器超时的节拍数等。 ```c -msh />list_timer -timer periodic timeout flag --------- ---------- ---------- ----------- -tshell 0x00000000 0x00000000 deactivated -tidle 0x00000000 0x00000000 deactivated -timer 0x00000000 0x00000000 deactivated +msh />list timer +timer periodic timeout activated mode +-------- ---------- ---------- ----------- --------- +tshell 0x00000000 0x00000000 deactivated one shot +aio 0x00000000 0x00000000 deactivated one shot +mmcsd_de 0x00000001 0x0000000d deactivated one shot +sys work 0x00000000 0x00000000 deactivated one shot +tidle0 0x00000000 0x00000000 deactivated one shot +timer 0x00000000 0x00000000 deactivated one shot +current tick:0x00017c0d ``` -list_timer 返回字段的描述: +list timer 返回字段的描述: |**字段**|**描述** | |----------|--------------------------------| | timer | 定时器的名称 | | periodic | 定时器是否是周期性的 | | timeout | 定时器超时时的节拍数 | -| flag | 定时器的状态,activated 表示活动的,deactivated 表示不活动的 | +| activated | 定时器的状态,activated 表示活动的,deactivated 表示不活动的 | +| mode | 定时器类型,one shot 表示单次定时,periodic 表示周期定时 | + +current tick 表示当前系统的 tick 数。 ### 显示设备状态 -使用 list_device 命令来显示系统中所有的设备信息,包括设备名称、设备类型和设备被打开次数。 +使用 list device 命令来显示系统中所有的设备信息,包括设备名称、设备类型和设备被打开次数。 ```c -msh />list_device -device type ref count ------- ----------------- ---------- -e0 Network Interface 0 -uart0 Character Device 2 +msh />list device +device type ref count +-------- -------------------- ---------- +sd Block Device 1 +rtc RTC 0 +zero Miscellaneous Device 0 +shm Unknown 0 +uart1 Character Device 0 +uart0 Character Device 2 ``` -list_device 返回字段的描述: +list device 返回字段的描述: |**字段** |**描述** | |-----------|----------------| @@ -269,9 +294,10 @@ list_device 返回字段的描述: ```c msh />free -total memory: 7669836 -used memory : 15240 -maximum allocated memory: 18520 +total : 66606976 +used : 17792 +maximum : 20000 +available: 66589184 ``` free 返回字段的描述: @@ -281,6 +307,7 @@ free 返回字段的描述: | total memory | 内存总大小 | | used memory | 已使用的内存大小 | | maximum allocated memory | 最大分配内存 | +| available | 可用内存大小 | ## 自定义 FinSH 命令 @@ -319,44 +346,6 @@ static void atcmd(int argc, char**argv) MSH_CMD_EXPORT(atcmd, atcmd sample: atcmd ); ``` -### 自定义 C-Style 命令和变量 - -将自定义命令导出到 C-Style 模式可以使用如下接口: - -`FINSH_FUNCTION_EXPORT(name, desc);` - -|**参数**|**描述** | -|----------|----------------| -| name | 要导出的命令 | -| desc | 导出命令的描述 | - -以下示例定义了一个 hello 函数,并将它导出成 C-Style 模式下的命令: - -```c -void hello(void) -{ - rt_kprintf("hello RT-Thread!\n"); -} - -FINSH_FUNCTION_EXPORT(hello , say hello to RT-Thread); -``` - -按照类似的方式,也可以导出一个变量,可以通过如下接口: - -`FINSH_VAR_EXPORT(name, type, desc);` - -|**参数**|**描述** | -|----------|----------------| -| name | 要导出的变量 | -| type | 变量的类型 | -| desc | 导出变量的描述 | - -以下示例定义了一个 dummy 变量,并将它导出成 C-Style 模式下的变量命令: - -```c -static int dummy = 0; -FINSH_VAR_EXPORT(dummy, finsh_type_int, dummy variable for finsh) -``` ### 自定义命令重命名 FinSH 的函数名字长度有一定限制,它由 finsh.h 中的宏定义 FINSH_NAME_MAX 控制,默认是 16 字节,这意味着 FinSH 命令长度不会超过 16 字节。这里有个潜在的问题:当一个函数名长度超过 FINSH_NAME_MAX 时,使用 FINSH_FUNCTION_EXPORT 导出这个函数到命令表中后,在 FinSH 符号表中看到完整的函数名,但是完整输入执行会出现 null node 错误。这是因为虽然显示了完整的函数名,但是实际上 FinSH 中却保存了前 16 字节作为命令,过多的输入会导致无法正确找到命令,这时就可以使用 FINSH_FUNCTION_EXPORT_ALIAS 来对导出的命令进行重命名。 @@ -392,7 +381,6 @@ FinSH 功能可以裁剪,宏配置选项在 rtconfig.h 文件中定义,具 | #define FINSH_USING_SYMTAB | 无 | 可以在 FinSH 中使用符号表 | 开启 | |#define FINSH_USING_DESCRIPTION | 无 | 给每个 FinSH 的符号添加一段描述 | 开启 | | #define FINSH_USING_MSH| 无 | 使能 msh 模式 | 开启 | -| #define FINSH_USING_MSH_ONLY | 无 | 只使用 msh 模式 | 开启 | | #define FINSH_ARG_MAX | 整数型 | 最大输入参数数量 | 10 | | #define FINSH_USING_AUTH | 无 | 使能权限验证 | 关闭 | | #define FINSH_DEFAULT_PASSWORD | 字符串 | 权限验证密码 | 关闭 | @@ -425,8 +413,6 @@ rtconfig.h 中的参考配置示例如下所示,可以根据实际功能需求 /* 开启 msh 功能 */ #define FINSH_USING_MSH -/* 默认使用 msh 功能 */ -#define FINSH_USING_MSH_DEFAULT /* 最大输入参数数量为 10 个 */ #define FINSH_ARG_MAX 10 ``` @@ -455,7 +441,6 @@ msh /> RT-Thread shell commands: hello - say hello to RT-Thread version - show RT-Thread version information -list_thread - list thread …… ``` @@ -507,7 +492,6 @@ RT-Thread shell commands: hello - say hello to RT-Thread atcmd - atcmd sample: atcmd version - show RT-Thread version information -list_thread - list thread …… ``` diff --git a/rt-thread-version/rt-thread-standard/programming-manual/libc/introduction.md b/rt-thread-version/rt-thread-standard/programming-manual/libc/introduction.md index 9bec21b4f6ee8b8b29e8e6fca817ba6975c84ba3..cb5da7648d3151456ed74146e65fdd7a891b7f18 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/libc/introduction.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/libc/introduction.md @@ -91,7 +91,7 @@ ANSI C、ISO C、Standard C是指美国国家标准协会(ANSI)和国际标 | | [pthread_attr_getschedpolicy()](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getschedpolicy.html) | * | * | * | * | √ | | | [pthread_attr_getscope()](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getscope.html) | * | * | * | * | √ | | | [pthread_attr_getstack()](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getstack.html) | * | * | * | * | √ | -| | [pthread_attr_getstackaddr()](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getstackaddr.html) | * | * | * | * | √ | +| | [pthread_attr_getstackaddr()](https://pubs.opengroup.org/onlinepubs/009696799/functions/pthread_attr_getstackaddr.html) | * | * | * | * | √ | | | [pthread_attr_getstacksize()](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getstacksize.html) | * | * | * | * | √ | | | [pthread_attr_init()](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_init.html) | * | * | * | * | √ | | | [pthread_attr_setdetachstate()](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setdetachstate.html) | * | * | * | * | √ | diff --git a/rt-thread-version/rt-thread-standard/programming-manual/net/net_introduce.md b/rt-thread-version/rt-thread-standard/programming-manual/net/net_introduce.md index bc6a7d3c1e93bee5916783f03dba7c3d27aaf122..afc526f897ca29407e2ba7f2d0981a5f2a440dbd 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/net/net_introduce.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/net/net_introduce.md @@ -4,18 +4,16 @@ ![](./docs/Kconfig_file.png) -从图片中的信息也可以了解到,AT,Lwip,Netdev,Sal 这些我们相对熟悉的功能也位于该目录中。这四个基础组件,可以驱动的网络设备的种类多到各个方面。从有线网络的各种 ETH 的方式,带 PHY 的 enc28j60,纯接口的 RJ45,还有自带网络协议栈的 W5500都可以直接经过配置,通过我们的 net 组件实现设备联网的需求;除了有线网络的接入方式,无线网络的接入方式则更多,2G模块,3G模块,4G模块,Cat-1模块,Cat-4模块,NB-IOT模块,乃至 5G 模块这些依赖基站运营商的入网方式,例如 SIM800,EC20,AIR720,L610,N58,M5311 等,这些不同厂家,不同工作频率的模组均可以通过 NET 组件入网;WIFI 这种无需运营商直接提供的网络的入网方式,例如 ESP8266,W60x,rw007 等。 +从图片中的信息也可以了解到,AT,Lwip,Netdev,SAL 这些我们相对熟悉的功能也位于该目录中。这四个基础组件,可以驱动的网络设备的种类多到各个方面。从有线网络的各种 ETH 的方式,带 PHY 的 enc28j60,纯接口的 RJ45,还有自带网络协议栈的 W5500都可以直接经过配置,通过我们的 net 组件实现设备联网的需求;除了有线网络的接入方式,无线网络的接入方式则更多,2G模块,3G模块,4G模块,Cat-1模块,Cat-4模块,NB-IOT模块,乃至 5G 模块这些依赖基站运营商的入网方式,例如 SIM800,EC20,AIR720,L610,N58,M5311 等,这些不同厂家,不同工作频率的模组均可以通过 NET 组件入网;WIFI 这种无需运营商直接提供的网络的入网方式,例如 ESP8266,W60x,rw007 等。 -通过上面的简单介绍,大家应该可以基本了解 Net 组件的作用,即为使用 RT-Thread 的设备提供上网能力。上面的联网设备,品类繁多,方式各异,但其实追踪到依赖的基础 net 能力其实也没有多复杂。实际上大部分的功能依赖的基础能力,只有两组而已,即 AT ,Lwip;而到用户,也就开发者层面,大部分就只用到 Sal 这一个概念。 +通过上面的简单介绍,大家应该可以基本了解 Net 组件的作用,即为使用 RT-Thread 的设备提供上网能力。上面的联网设备,品类繁多,方式各异,但其实追踪到依赖的基础 net 能力其实也没有多复杂。实际上大部分的功能依赖的基础能力,只有两组而已,即 AT ,Lwip;而到用户,也就开发者层面,大部分就只用到 SAL 这一个概念。 ![](./docs/network_frame.jpg) -相信大家看过这份[文档](https://www.rt-thread.org/document/site/programming-manual/sal/sal/ ),主要描述了 Sal 提供的编程接口,也就是大家常用的 socket 接口;通过 Sal 接口大家已经可以实现 MQTT,NTP,TFTP,TCP Client,TCP Server,webclient,UDP Client,UDP Server,webnet 等这些大家经常会使用的工具。像浏览器一样访问网站,webclient;模拟一个网站,webnet;连接各种云平台,Mqtt;获取准确授时,NTP ;通过网络传输文件 ,TFTP ;诸如此类功能, Sal 提供了轻松访问网络的一把钥匙。你可以理解这把钥匙是向上的,但是这篇文章现在要讲的,是向下的,看看 Sal 这样组件,又是谁在支撑着它。 +相信大家看过这份[文档](../sal/sal.md),主要描述了 SAL 提供的编程接口,也就是大家常用的 socket 接口;通过 SAL 接口大家已经可以实现 MQTT,NTP,TFTP,TCP Client,TCP Server,webclient,UDP Client,UDP Server,webnet 等这些大家经常会使用的工具。像浏览器一样访问网站,webclient;模拟一个网站,webnet;连接各种云平台,Mqtt;获取准确授时,NTP ;通过网络传输文件 ,TFTP ;诸如此类功能, SAL 提供了轻松访问网络的一把钥匙。你可以理解这把钥匙是向上的,但是这篇文章现在要讲的,是向下的,看看 SAL 这样组件,又是谁在支撑着它。 Net 组件的主要内容有 4 个方面,分别是 sal ,AT,lwip 与 netdev,我们先从 AT 和 Lwip 讲起,在不同的方式中介绍 sal 的用途;然后讲 netdev 的作用。 - - ### 1. 总概 对于一个给定的模组,他的联网方式有时并不是单一的;以常见的 Cat-4 (4G) 模块为例,一方面它可以使用 AT 命令这种经典的方式来实现网络连接;另一方面又可以通过 PPP 拨号,使用 lwip 的方式来实现网络连接。或者在以 W60x 为例,一方面可以使用 AT 的方式来实现联网功能;另一方面又可以使用裸 IP 包的方式来实现网络连接。**在选取上网模块时,应当考虑片上资源的情况,以及网络质量的问题,选择比较适合的联网方式。**条条大路通罗马,短途长途,步行开车还是有些小区别的。 @@ -31,12 +29,12 @@ RT-Thread 的 AT 组件的设计目的就是使设备能发送和解析 AT 命 * 对于 AT Client 来说,是由 MCU 去向 Modem 发送 AT 命令,由 Modem 响应命令,并给出回复。这种方式我们常用的,也是我们通过支持 AT 的模组上网的常用方式。 * 对于 AT Server 来说,是由 MCU 作为类似 Modem 的功能,由其他 MCU 向这个 MCU 发送 AT 命令,由这个 MCU 响应 AT 命令并做出回复。 -具体的 AT 的使用,可以参考 [AT 文档](https://www.rt-thread.org/document/site/programming-manual/at/at/);更加详细,底层的实操的内容在专门的文档中有描述;在查阅文档时,可以同时浏览代码,通过文章的说明,我们应该能了解到 AT 组件的使用方法。AT 组件的适用范围也进而清晰起来: +具体的 AT 的使用,可以参考 [AT 文档](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/at/at);更加详细,底层的实操的内容在专门的文档中有描述;在查阅文档时,可以同时浏览代码,通过文章的说明,我们应该能了解到 AT 组件的使用方法。AT 组件的适用范围也进而清晰起来: * AT 命令用作模块控制 * AT 命令用作数据的解析 -对 AT Client 功能做大规模应用的软件包为 [at_device ](https://github.com/RT-Thread-packages/at_device),作为一款使用频次很高的软件包,可以看到他充分利用了 AT 组件的能力,一方面针对模块控制的能力设置了 at_device_xxx.c 来提供模块的基础控制操作;一方面也提供了 at_socket_xxx.c 来提供数据解析能力。对于整体的 net 组件而言,at_socket_xxx.c 实际上沟通了 AT 组件与 Sal,使得上层应用能依赖 at_socket_xxx.c 的函数,实现对应的网络功能 MQTT,HTTP.... +对 AT Client 功能做大规模应用的软件包为 [at_device ](https://github.com/RT-Thread-packages/at_device),作为一款使用频次很高的软件包,可以看到他充分利用了 AT 组件的能力,一方面针对模块控制的能力设置了 at_device_xxx.c 来提供模块的基础控制操作;一方面也提供了 at_socket_xxx.c 来提供数据解析能力。对于整体的 net 组件而言,at_socket_xxx.c 实际上沟通了 AT 组件与 SAL,使得上层应用能依赖 at_socket_xxx.c 的函数,实现对应的网络功能 MQTT,HTTP.... ```c static const struct sal_socket_ops at_socket_ops = @@ -100,7 +98,7 @@ struct at_socket_ops 除了这些使用 at_device 能搜索到的问题,还有一些因为使用了 at_device 而产生的问题;这些问题的出现,对于在使用 AT 组件时的使用体验影响是很大的。 -在遇到问题时,希望能小心得验证问题,尝试解决问题;在问题难以解决时,详细描述问题复现的场景,按照格式在论坛中提问。问题描述清晰,复现手段准确,更能吸引小伙伴们的参与,共同解决问题。 +在遇到问题时,希望能小心地验证问题,并尝试解决问题;在问题难以解决时,请详细描述问题复现的场景,按照格式在论坛中提问。问题描述清晰,复现手段准确,更能吸引小伙伴们的参与,共同解决问题。 ![](./docs/at_menuconfig.png) @@ -186,7 +184,7 @@ static const struct sal_netdb_ops wiz_netdb_ops = | LINK_UP / LINK_DOWN | 链路是否正常 | | INTERNET_UP / INTERNET_DOWN | 网络是否正常 | -* LINK_UP 的意义为链路是否正常,在 netdev 启用后,LINK_UP 是作为 PING 命令是否可用的关键。如果 为 LINK_DOWN ,PING 命令将禁用。毕竟,网线都没有连接,PING 命令不可以用也是合情合理的喽。**LINK_DOWN 状态下禁用 PING 命令很合理,但是如果 netdev 的状态被异常置为 LINK_DOWN 就很苦恼了。如果被代码错误执行到设置为 LINK_DOWN,PING 命令将不可用。**netdev 的使用,可以参考[文档介绍](https://www.rt-thread.org/document/site/programming-manual/netdev/netdev/)。 +* LINK_UP 的意义为链路是否正常,在 netdev 启用后,LINK_UP 是作为 PING 命令是否可用的关键。如果 为 LINK_DOWN ,PING 命令将禁用。毕竟,网线都没有连接,PING 命令不可以用也是合情合理的喽。**LINK_DOWN 状态下禁用 PING 命令很合理,但是如果 netdev 的状态被异常置为 LINK_DOWN 就很苦恼了。如果被代码错误执行到设置为 LINK_DOWN,PING 命令将不可用。**netdev 的使用,可以参考[文档介绍](../netdev/netdev.md)。 * INTERNET_UP 的意义为网络是否正常。实际上,RT-Thread 的代码逻辑中,把这个位作为标志位,但很少利用这个标志位做逻辑判断。这样做的原因,是因为判断 INTERNET_UP 的方式为访问 ```link.rt-thread.org```,如果能有回复,就把标志位置为 INTERNET_UP,否则置为 INTERNET_DOWN。这个逻辑在一般情况下算是正常,但是在一些网络拓扑中,很有可能被网络标记位不可达(被墙了,PS :也有可能是 RT-Thread 的网络主机重启了),所以哪怕实际上是可以连接网络的,却显示为 INTERNET_DOWN。 除此以外,netdev 还有 PING 功能的抽象,就是上面提到的 LINK_DOWN 状态不可用的那个。说它是抽象,是因为 netdev 中并没有直接实现全部的 ping 逻辑,而是依赖底层的提供提供的 PING 能力。 diff --git a/rt-thread-version/rt-thread-standard/programming-manual/netdev/netdev.md b/rt-thread-version/rt-thread-standard/programming-manual/netdev/netdev.md index 742cee16723c882f5ffff8b5e6fa67e701b51bca..4e2c88ddcf7f570c79fc4cd3b5b64b33d22c3627 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/netdev/netdev.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/netdev/netdev.md @@ -85,14 +85,14 @@ netdev 相关的宏定义如下所示,使用时需要将对应宏定义添加 上面配置选项可以直接在 `rtconfig.h` 文件中添加使用,也可以通过组件包管理工具 ENV 配置选项加入,ENV 工具中具体配置路径如下: ```c -RT-Thread Components ---> - Network ---> - Network interface device ---> - [*] Enable network interface device - [*] Enable ifconfig features - [*] Enable ping features - [*] Enable netstat features - [*] Enable default netdev automatic change features + -> RT-Thread Components + -> Network + --- Enable network interface device + [*] Enable ifconfig features + -*- Enable ping features + [*] Enable netstat features + [*] Enable default netdev automatic change features + [ ] Enable IPV6 protocol support ``` 配置完成可以通过 scons 命令重新生成功能,完成 netdev 组件的添加。 diff --git a/rt-thread-version/rt-thread-standard/programming-manual/rtlink/rtlink.md b/rt-thread-version/rt-thread-standard/programming-manual/rtlink/rtlink.md index 8db5e8b6eac0df646379d79a13f0c16f22d141a3..54ac62f92189d4977f48319db7cf04b0a563ea6c 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/rtlink/rtlink.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/rtlink/rtlink.md @@ -25,7 +25,7 @@ rtthread # 工作原理 -## 整体框架: +RT-Link 整体框架如下所示: ![rtlink整体框架](./figures/rtlink应用框架.jpg) @@ -114,7 +114,7 @@ state 标记了 service 通道的连接状态,分为以下三种连接状态 # 使用指南 -## 如何添加、使用 RT-Link: +## 配置 RT-Link 组件 这里以 studio 为例,在配置页找到 组件 —>工具 —>RT-Link,选择开启并进行配置。如下图所示。 @@ -134,9 +134,10 @@ state 标记了 service 通道的连接状态,分为以下三种连接状态 - 这里选择了两块潘多拉开发板来测试运行效果,在文档尾部有[示例代码](#示例代码)。运行效果如下: ![收发测试](./figures/收发测试.jpg) - ## 上层应用接口介绍 +上层应用接口列表如下所示,小节中将分别对这些接口进行介绍。 + ```c /* rtlink init and deinit */ int rt_link_init(void); diff --git a/rt-thread-version/rt-thread-standard/programming-manual/sal/sal.md b/rt-thread-version/rt-thread-standard/programming-manual/sal/sal.md index 1e0730ff773318e5cde67d58748835536dea900b..730f0a8be90d1176c9b10e5149c93d16cbe8a055 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/sal/sal.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/sal/sal.md @@ -235,15 +235,15 @@ MSH_CMD_EXPORT(sal_tls_test, SAL TLS function test); 上面配置选项可以直接在 `rtconfig.h` 文件中添加使用,也可以通过组件包管理工具 ENV 配置选项加入,ENV 工具中具体配置路径如下: ```c -RT-Thread Components ---> - Network ---> - Socket abstraction layer ---> - [*] Enable socket abstraction layer - protocol stack implement ---> - [ ] Support lwIP stack - [ ] Support AT Commands stack - [ ] Support MbedTLS protocol - [*] Enable BSD socket operated by file system API + -> RT-Thread Components + -> Network + --- SAL: socket abstraction layer + [*] Enable the ability that check internet status (NEW) + Docking with protocol stacks ---> + [ ] Docking with lwIP stack (NEW) + -*- Docking with AT commands stack + [ ] Docking with MbedTLS protocol (NEW) + (16) the maximum number of sockets (NEW) ``` 配置完成可以通过 scons 命令重新生成功能,完成 SAL 组件的添加。 @@ -414,7 +414,7 @@ int accept(int s, struct sockaddr *addr, socklen_t *addrlen); | **参数** | **描述** | |-------|-------------------------------| | s | 套接字描述符 | -| addr | 表示一次能够等待的最大连接数目 | +| addr | 表示发起连接请求的客户端的地址信息 | | addrlen | 客户端设备地址结构体的长度 | | **返回** | -- | | 0 | 成功,返回新创建的套接字描述符 | diff --git a/rt-thread-version/rt-thread-standard/programming-manual/thread/thread.md b/rt-thread-version/rt-thread-standard/programming-manual/thread/thread.md index 74649bf7902c1bf3e1df150bac14fb908cd43ed0..c1c95d839fe39e482b5e000c32c4f0d27977f746 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/thread/thread.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/thread/thread.md @@ -1,6 +1,6 @@ # 线程管理 -在日常生活中,我们要完成一个大任务,一般会将它分解成多个简单、容易解决的小问题,小问题逐个被解决,大问题也就随之解决了。在多线程操作系统中,也同样需要开发人员把一个复杂的应用分解成多个小的、可调度的、序列化的程序单元,当合理地划分任务并正确地执行时,这种设计能够让系统满足实时系统的性能及时间的要求,例如让嵌入式系统执行这样的任务,系统通过传感器采集数据,并通过显示屏将数据显示出来,在多线程实时系统中,可以将这个任务分解成两个子任务,如下图所示,一个子任务不间断地读取传感器数据,并将数据写到共享内存中,另外一个子任务周期性的从共享内存中读取数据,并将传感器数据输出到显示屏上。 +在日常生活中,我们要完成一个大任务,一般会将它分解成多个简单、容易解决的小问题,小问题逐个被解决,大问题也就随之解决了。在多线程操作系统中,也同样需要开发人员把一个复杂的应用分解成多个小的、可调度的、序列化的程序单元,当合理地划分任务并正确地执行时,这种设计能够让系统满足实时系统的性能及时间的要求。例如让嵌入式系统执行这样的任务,系统通过传感器采集数据,并通过显示屏将数据显示出来,在多线程实时系统中,可以将这个任务分解成两个子任务,如下图所示,一个子任务不间断地读取传感器数据,并将数据写到共享内存中,另外一个子任务周期性的从共享内存中读取数据,并将传感器数据输出到显示屏上。 ![传感器数据接收任务与显示任务的切换执行](figures/04Task_switching.png) @@ -70,7 +70,7 @@ struct rt_thread }; ``` -其中 init_priority 是线程创建时指定的线程优先级,在线程运行过程当中是不会被改变的(除非用户执行线程控制函数进行手动调整线程优先级)。cleanup 会在线程退出时,被空闲线程回调一次以执行用户设置的清理现场等工作。最后的一个成员 user_data 可由用户挂接一些数据信息到线程控制块中,以提供类似线程私有数据的实现。 +其中 init_priority 是线程创建时指定的线程优先级,在线程运行过程当中是不会被改变的(除非用户执行线程控制函数进行手动调整线程优先级)。cleanup 会在线程退出时,被空闲线程回调一次以执行用户设置的清理现场等工作。最后的一个成员 user_data 可由用户挂接一些数据信息到线程控制块中,以提供一种类似线程私有数据的实现方式。 ### 线程重要属性 @@ -186,7 +186,7 @@ RT-Thread 提供一系列的操作系统调用接口,使得线程的状态在 若某线程运行完毕,系统将自动删除线程:自动执行 rt_thread_exit() 函数,先将该线程从系统就绪队列中删除,再将该线程的状态更改为关闭状态,不再参与系统调度,然后挂入 rt_thread_defunct 僵尸队列(资源未回收、处于关闭状态的线程队列)中,最后空闲线程会回收被删除线程的资源。 -空闲线程也提供了接口来运行用户设置的钩子函数,在空闲线程运行时会调用该钩子函数,适合钩入功耗管理、看门狗喂狗等工作。空闲线程必须有得到执行的机会,即其他线程不允许一直while(1)死卡,必须调用具有阻塞性质的函数;否则例如线程删除、回收等操作将无法得到正确执行。 +空闲线程也提供了接口来运行用户设置的钩子函数,在空闲线程运行时会调用该钩子函数,适合处理功耗管理、看门狗喂狗等工作。空闲线程必须有得到执行的机会,即其他线程不允许一直while(1)死卡,必须调用具有阻塞性质的函数;否则例如线程删除、回收等操作将无法得到正确执行。 #### 主线程 diff --git a/rt-thread-version/rt-thread-standard/programming-manual/tls/tls.md b/rt-thread-version/rt-thread-standard/programming-manual/tls/tls.md index 8fa729966d54cc47f4b746e5fafae8916140ee23..bc8be1d3f58dfb2f8583a3625ccfe9a072b1db1a 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/tls/tls.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/tls/tls.md @@ -32,14 +32,16 @@ TLS 协议主要解决如下三个网络安全问题。 ![tls_ssl_version.png](./figure/tls_ssl_version.png) - ## 2.3 TLS 报文结构 TLS \(Transport Layer Security\)协议是由TLS 记录协议(TLS Record Protocol)和TLS 握手协议(TLS Handshake Protocol)这两层协议叠加而成的,位于底层的TLS 记录协议负责进行信息传输和认证加密,位于上层的TLS 握手协议则负责除加密以外的其它各种操作,比如密钥协商交换等。上层的TLS 握手协议又可以分为4个子协议,TLS 协议的层次结构如下图所示: + ![tls_http_layer.png](./figure/tls_http_layer.png) + 前面已经介绍了 TLS 协议的认证加密算法,这里先介绍 TLS 记录协议的报文结构,每一条 TLS 记录以一个短标头起始,标头包含记录内容的类型(或子协议)、协议版本和长度,消息数据紧跟在标头之后,如下图所示: ![tls_protocol.png](./figure/tls_protocol.png) + 了解了 TLS 记录报文结构,前面也介绍了认证加密过程,下面以 AES-GCM 为例,看看密文(消息明文 AES-CNT 加密而来,当不需要对消息加密时,此处保持明文即可)和 MAC(将序列号、标头等附加信息与密文一起通过 Galois-MAC 计算而来)是如何添加进 TLS 记录报文的: 上图中的几个字段作用如下: @@ -58,10 +60,15 @@ TLS \(Transport Layer Security\)协议是由TLS 记录协议(TLS Record Protoc 配置开启任意网络协议栈支持(如 lwIP 协议栈); ![menuconfig_lwip_conf.png](./figure/menuconfig_lwip_conf.png) + 配置开启 MbedTLS 软件包(目前RT-Thread只支持 MbedTLS 类型加密方式); + ![menuconfig_mbedtls_conf.png](./figure/menuconfig_mbedtls_conf.png) + 配置开启 SAL\_TLS 功能支持(如下配置选项章节所示); + ![menuconfig_sal_tls_conf.png](./figure/menuconfig_sal_tls_conf.png) + 配置完成之后,只要在 socket 创建时传入的 protocol 类型使用 PROTOCOL\_TLS 或 **PROTOCOL\_DTLS** ,即可使用标准 BSD Socket API 接口,完成 TLS 连接的建立和数据的收发。示例代码如下所示: ```c @@ -364,8 +371,10 @@ static int webclient_get_comm(const char *uri) ``` ![http.png](./figure/http.png) + ![http.png](./figure/http_wireshark.png) -![http.png](./figure/http_protocol_message.png) + +![http.png](./figure/http_protocol_message.png) 4. webclient 抓包 https 协议,密文数据 @@ -383,5 +392,7 @@ static int webclient_get_comm(const char *uri) ``` ![http.png](./figure/https.png) + ![http.png](./figure/https_wireshark.png) + ![http.png](./figure/https_protocol_message.png) \ No newline at end of file diff --git a/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/dfs-config.png b/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/dfs-config.png new file mode 100644 index 0000000000000000000000000000000000000000..c331acb08858d23b09054f0cea77d4324df2b442 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/dfs-config.png differ diff --git a/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/menuconfig.png b/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/menuconfig.png new file mode 100644 index 0000000000000000000000000000000000000000..9eb7d03c4ff887ced08fecc43c4bea781d937368 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/menuconfig.png differ diff --git a/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/qemu-run.png b/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/qemu-run.png new file mode 100644 index 0000000000000000000000000000000000000000..bfb121946d58de7c7629e2b3354ba9674be1ed0b Binary files /dev/null and b/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/qemu-run.png differ diff --git a/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/uml-1.png b/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/uml-1.png new file mode 100644 index 0000000000000000000000000000000000000000..962780b91db25a2025f0a047190b62f7b1e12dc2 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/uml-1.png differ diff --git a/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/uml-file.png b/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/uml-file.png new file mode 100644 index 0000000000000000000000000000000000000000..28189d31135974e0a6975f5f014c9a525878bf06 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/uml-file.png differ diff --git a/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/uml.txt b/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/uml.txt new file mode 100644 index 0000000000000000000000000000000000000000..78079635612d55755b82a32e81e30e8fd7e449d5 --- /dev/null +++ b/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/figures/uml.txt @@ -0,0 +1,42 @@ +### uml-1 ### + +```plantuml +@startuml + +participant 应用 +participant DFS +participant tmpfs + +应用->DFS: dfs_init()\n初始化虚拟文件系统 +tmpfs->tmpfs: dfs_tmpfs_init()\n自动初始化临时文件系统 +tmpfs-->DFS: dfs_register()\n注册tmpfs到DFS + +应用->DFS: dfs_mount()\n挂载文件系统 +DFS->tmpfs: ops:mount()\n挂载临时文件系统 + +应用->DFS: 其他操作,如:\n卸载文件系统、\n查看文件系统状态等 +DFS->tmpfs: ops:... + +@enduml +``` + + +### uml-file ### + +```plantuml +@startuml + +应用->POSIX: open()\n打开文件 +POSIX->DFS: dfs_file_open() +DFS->tmpfs: ops:open() + +应用->POSIX: read()\n打开文件 +POSIX->DFS: dfs_file_read() +DFS->tmpfs: ops:read() + +应用->POSIX: 其他文件操作... +POSIX->DFS: ... +DFS->tmpfs: ops:... + +@enduml +``` \ No newline at end of file diff --git a/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/tmpfs.md b/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/tmpfs.md new file mode 100644 index 0000000000000000000000000000000000000000..4107683fa4fa830e2cf64e189e41d02bae203358 --- /dev/null +++ b/rt-thread-version/rt-thread-standard/programming-manual/tmpfs/tmpfs.md @@ -0,0 +1,131 @@ +# TMPFS 临时文件系统 + +tmpfs 是临时文件系统,是一种基于内存的文件系统,优势是: + +- 动态调整虚拟内存 +- 读写速度快 + +tmpfs 还有一个特点,它不是存在于一个底层块设备上面,而是直接建立在虚拟内存之上的,无需使用 mkfs 格式化,直接 mount 就可以创建 tmpfs 文件系统。由于是在内存中存储数据,那么在断电后数据也会丢失。 + +在 RT-Thread 中,tmpfs 和 ramfs 的区别如下表: + +| 特性 | tmpfs | ramfs | +| --------------------- | ---------------- | -------------------- | +| 是否固定大小 | 否 | 是 | +| 是否支持文件夹操作 | 是 | 否 | +| 具有易失性 | 是 | 是 | + +目前 tmpfs 已经作为一个组件存在于 RT-Thread(rt-smart 分支) 中,位于 `rt-thread\components\dfs\filesystems\tmpfs`,可以进行裁剪配置。 + +## 文件管理 + +对 tmpfs 文件的操作,应用层可以直接使用 POSIX 进行访问,操作文件的访问序列图如下所示: + +![image-20221101172133720](figures/uml-file.png) + +对文件的操作有: + +- open:打开文件 +- close:关闭文件 +- read:读取文件数据 +- write:向文件中写数据 +- lseek:改变读写一个文件时读写指针位置 +- getdents:获取目录项 +- stat:获取文件状态 + +## 目录管理 + +对目录的管理可以使用 POSIX 接口,其访问序列图与访问文件序列图类似,对目录的操作有: + +- mkdir:创建目录 +- rmdir:删除目录 +- opendir:打开目录 +- readdir:读取目录 +- closedir:关闭目录 +- dirent:读取目录 +- telldir:取得目录流的读取位置 +- seekdir:设置下次读取目录的位置 +- rewinddir:重设读取目录的位置为开头位置 + +## MSH 命令 + +可以使用 DFS 的 MSH 命令对 tmpfs 进行操作,文件系统操作常用的 MSH 命令如下表所示: + +| MSH 命令 | 描述 | +| -------- | ------------------------------------------------------------ | +| ls | 显示文件和目录的信息 | +| cd | 进入指定目录 | +| cp | 复制文件 | +| rm | 删除文件或目录 | +| mv | 将文件移动位置或改名 | +| echo | 将指定内容写入指定文件,当文件存在时,就写入该文件,当文件不存在时就新创建一个文件并写入 | +| cat | 展示文件的内容 | +| pwd | 打印出当前目录地址 | +| mkdir | 创建文件夹 | + +## 如何使用 + +如下是应用层使用 DFS 虚拟文件系统的 API 对 tmpfs 进行访问的序列图: + +- 文件系统自动初始化:开启自动初始化之后,虚拟文件系统和临时文件系统都将自动初始化,无需用户执行。 +- 在应用层使用 dfs_mount() 挂载 tmpfs 文件系统。 +- 在应用层使用 DFS 虚拟文件系统的 API 对 tmpfs 进行访问,更多 API 接口详见 [DFS 虚拟文件系统](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/filesystem/filesystem)。 + +![image-20221102174841105](figures/uml-1.png) + +## 使用示例 + +使用 QEMU 演示 tmpfs 的使用,以挂载在 "/mnt/tmp" 目录为例进行演示。 + +在 rt-thread 源码的 rt-smart 分支上,打开 qemu-vexpress-a9 BSP,使用 menuconfig 在组件中配置 tmpfs,位于 "RT-Thread Components → Device virtual file system",退出保存。 + +![image-20221101155404497](figures/menuconfig.png) + +注意:若同一个系统中使用多个文件系统,注意在同一界面修可挂载文件系统数量值与文件系统类型个数的值,使其支持多文件系统。 + +![image-20221103101448013](figures/dfs-config.png) + +在 mnt.c 中使用 dfs_mount 挂载文件系统的代码如下所示: + +```c + /* romfs 挂载在 / 下 */ + /* fatfs 挂载在 /mnt 下 */ + /* tmpfs 挂载在 /mnt/tmp 下 */ + if (dfs_mount(RT_NULL, "/mnt/tmp", "tmp", 0, NULL) != 0) + { + rt_kprintf("Dir /tmp mount failed!\n"); + return -1; + } +``` + +使用命令 `scons` 编译后,输入 `qemu.bat` 运行 qemu,切换到 mnt 目录下创建 tmp 目录(若是第一次使用 fatfs,则需要先使用 mkfs 格式化) + +```shell +msh />cd mnt # 使用 cd 命令切换目录 +msh /mnt>mkdir tmp # 使用 mkdir 创建新目录 +msh /mnt>ls # 使用 ls 命令查看当前目录信息 +Directory /mnt: +tmp +``` + +执行 "ctrl+c" 退出 qemu 后,再次执行 `qemu.bat` 运行 qemu + +![image-20221101155816447](figures/qemu-run.png) + +使用文件系统的 MSH 命令在 tmpfs 文件系统中操作文件: + +```shell +msh /mnt/tmp>echo "RT-Thread" # 将字符串输出到标准输出 +RT-Thread + +msh /mnt/tmp>mkdir test # 创建 test 目录 +msh /mnt/tmp>echo "rtt" tmpfile.txt # 使用 echo 命令将输入的字符串输出到指定输出位置 +msh /mnt/tmp>ls # 使用 ls 命令查看当前目录信息 +Directory /mnt/tmp: +tmpfile.txt 3 +test + +msh /mnt/tmp>cat tmpfile.txt # 使用 cat 命令查看文件内容 +rtt +``` + diff --git a/rt-thread-version/rt-thread-standard/programming-manual/ulog/ulog.md b/rt-thread-version/rt-thread-standard/programming-manual/ulog/ulog.md index 4eacbbc33d08b1f1768f085b2d2588aef9b1489c..08df9c734302dbc2187cc466b485f747d15491da 100644 --- a/rt-thread-version/rt-thread-standard/programming-manual/ulog/ulog.md +++ b/rt-thread-version/rt-thread-standard/programming-manual/ulog/ulog.md @@ -57,19 +57,21 @@ ENV 工具中使用 menuconfig 配置 ulog 的路径如下所示: [ ] Enable async output mode. /* 使能异步日志输出模式。开启这个模式后,日志不会立刻输出到后端,而是先缓存起来,然后交给日志输出线程(例如:idle 线程)去输出 */ log format ---> /* 配置日志的格式,例如:时间信息,颜色信息,线程信息,是否支持浮点等等 */ [*] Enable console backend. /* 使能控制台作为后端。使能后日志可以输出到控制台串口上。建议保持开启。 */ +[ ] Enable file backend. /* ulog 的文件后端 */ [ ] Enable runtime log filter. /* 使能运行时的日志过滤器,即动态过滤。使能后,日志将支持按标签、关键词等方式,在系统运行时进行动态过滤。 */ +[ ] Enable syslog format log and API. /* 启用 syslog 格式日志和 API */ ``` **配置日志的格式(log format)选项描述如下所示:** ```c [ ] Enable float number support. It will using more thread stack. /* 浮点型数字的支持(传统的 rtdbg/rt_kprintf 均不支持浮点数日志) */ - [*] Enable color log. /* 带颜色的日志 */ - [*] Enable time information. /* 时间信息 */ - [ ] Enable timestamp format for time. /* 包括时间戳 */ - [*] Enable level information. /* 级别信息 */ - [*] Enable tag information. /* 标签信息 */ - [ ] Enable thread information. /* 线程信息 */ +[*] Enable color log. /* 带颜色的日志 */ +[*] Enable time information. /* 时间信息 */ +[ ] Enable timestamp format for time. /* 包括时间戳 */ +[*] Enable level information. /* 级别信息 */ +[*] Enable tag information. /* 标签信息 */ +[ ] Enable thread information. /* 线程信息 */ ``` ### 日志级别 @@ -259,8 +261,9 @@ void Timer2_Handler(void) 这里说明下中断日志在 ulog 处于同步模式与异步模式下的不同策略: --**同步模式下**:如果线程此时正在输出日志时来了中断,此时如果中断里也有日志要输出,会直接输出到控制台上,不支持输出到其他后端; --**异步模式下**:如果发生上面的情况,中断里的日志会先放入缓冲区中,最终和线程日志一起交给日志输出线程来处理。 +**同步模式下**:如果线程此时正在输出日志时来了中断,此时如果中断里也有日志要输出,会直接输出到控制台上,不支持输出到其他后端; + +**异步模式下**:如果发生上面的情况,中断里的日志会先放入缓冲区中,最终和线程日志一起交给日志输出线程来处理。 ### 设置日志格式 @@ -399,6 +402,110 @@ struct ulog_backend * `flush` 也是可选择性实现,一些内部输出带缓存的后端需要必须实现该接口 。比如一些带RAM 缓存的文件系统。后端的 flush 一般会在断言、hardfault 等异常情况下由 `ulog_flush` 完成调用。 +##### 文件后端注册示例 + +如下代码将实现一个文件后端的实现示例,将输出日志保存至文件系统路径`/flash/log`中. +详细介绍 +> https://club.rt-thread.org/ask/article/73cedec4f1707abf.html + +```c +#include + +/* +* 后端注册表 +*/ +struct _log_file +{ + const char *name; //文件名 + ulog_backend_t backend; + struct ulog_file_be *file_be; + const char *dir_path; //保存路径 + rt_size_t max_num; //保存最大文件数量 + rt_size_t max_size; //保存最大文件大小 + rt_size_t buf_size; //文件保存缓存大小 +}; +/* +* 文件后端标识 +*/ +typedef enum +{ + console_id, + sys_id, + motion_id, +}ulog_file_be_name; + +#define ROOT_PATH "/flash/log" //设置保存路径 +#define FILE_SIZE 512 * 1024 //设置单个文件大小 +#define BUFF_SIZE 512 //设备缓存区大小 + +static struct ulog_backend sys_log_backend; +static struct ulog_file_be sys_log_file; + +static struct _log_file table[] = +{ + {"sys" ,&sys_log_backend,&sys_log_file,ROOT_PATH,10,FILE_SIZE,BUFF_SIZE}, +}; +/* Private function prototypes -----------------------------------------------*/ +/** + * @brief 系统日志文件后端初始化. + * @param None. + * @retval None. + * @note None. +*/ +void sys_log_file_backend_init(void) +{ + struct ulog_file_be *file_be = &sys_log_file; + uint8_t id = sys_id; + file_be->parent = sys_log_backend; + + ulog_file_backend_init( file_be, + table[id].name, + table[id].dir_path, + table[id].max_num, + table[id].max_size, + table[id].buf_size); + + ulog_file_backend_enable(file_be); //必须使能才能有效 +} +``` + +添加如下代码实现文件后端滤波功能. + +```c +/** + * @brief 系统日志文件后端滤波器设置. + * @param None. + * @retval The filter will be call before output. It will return TRUE when the filter condition is math. + * @note None. +*/ +static rt_bool_t sys_log_file_backend_filter(struct ulog_backend *backend, rt_uint32_t level, const char *tag, rt_bool_t is_raw, + const char *log, rt_size_t len) +{ + //设置滤波规则,可以自己编写代码实现不同滤波规则 + if (rt_strncmp(tag,"MOVE", sizeof(MOTION_TAG)) == 0)//排除带有"MOVE"标签输出 + return RT_FALSE; + else + return RT_TRUE; + + //if (rt_strncmp(tag,"MOVE", sizeof(MOTION_TAG)) == 0)//带有"MOVE"标签输出 + // return RT_TRUE; + //else + // return RT_FALSE; +} + +void sys_log_file_backend_init(void) +{ + //新增代码 + ulog_backend_filter_t filter = sys_log_file_backend_filter; + + ... + + ulog_file_backend_enable(file_be); + //新增代码 + ulog_backend_set_filter(&file_be->parent,filter); +} +``` + ### 异步日志 在 ulog 中,默认的输出模式是同步模式,在很多场景下用户可能还需要异步模式。用户在调用日志输出 API 时,会将日志缓存到缓冲区中,会有专门负责日志输出的线程取出日志,然后输出到后端。 @@ -480,15 +587,15 @@ int ulog_tag_lvl_filter_set(const char *tag, rt_uint32_t level) 参数 level 日志级别可取如下值: -|**级别** |**名称** | -| --------------------- | ---------------- | -| LOG_LVL_ASSERT | 断言 | -| LOG_LVL_ERROR | 错误 | -| LOG_LVL_WARNING | 警告 | -| LOG_LVL_INFO | 信息 | -| LOG_LVL_DBG | 调试 | -| LOG_FILTER_LVL_SILENT | 静默(停止输出) | -| LOG_FILTER_LVL_ALL | 全部 | +|**级别** |**名称** | **取值**| +| --------------------- | ---------------- |-| +| LOG_LVL_ASSERT | 断言 |0| +| LOG_LVL_ERROR | 错误 |3| +| LOG_LVL_WARNING | 警告 |4| +| LOG_LVL_INFO | 信息 |6| +| LOG_LVL_DBG | 调试 |7| +| LOG_FILTER_LVL_SILENT | 静默(停止输出) |0| +| LOG_FILTER_LVL_ALL | 全部 |7| 函数调用与命令示例如下所示: @@ -767,32 +874,32 @@ ulog 提供了多种维度的日志开关、过滤的功能,完全能够做到 ## 常见问题 -### Q: 日志代码已执行,但是无输出。 +**Q:** 日志代码已执行,但是无输出。 - **A:** 参考日志级别小节,了解日志级别分类,并检查日志过滤参数。还有种可能是不小心将控制台后端给关闭了,重新开启 `Enable console backend` 即可。 +**A:** 参考日志级别小节,了解日志级别分类,并检查日志过滤参数。还有种可能是不小心将控制台后端给关闭了,重新开启 `Enable console backend` 即可。 -### Q: 开启 ulog 后,系统运行崩溃,例如:线程堆栈溢出。 +**Q:** 开启 ulog 后,系统运行崩溃,例如:线程堆栈溢出。 - **A:** ulog 比起以前用的 rtdbg 或者 `rt_kprintf` 打印输出函数会多占一部分线程堆栈空间,如果是开启了浮点数打印支持,由于其内部使用了 libc 里资源占用加大的 `vsnprintf`,所以堆栈建议多预留 250 字节。如果开启了时间戳功能,堆栈建议多预留 100 字节。 +**A:** ulog 比起以前用的 rtdbg 或者 `rt_kprintf` 打印输出函数会多占一部分线程堆栈空间,如果是开启了浮点数打印支持,由于其内部使用了 libc 里资源占用加大的 `vsnprintf`,所以堆栈建议多预留 250 字节。如果开启了时间戳功能,堆栈建议多预留 100 字节。 -### Q: 日志内容的末尾缺失。 +**Q:** 日志内容的末尾缺失。 - **A:** 这是由于日志内容超出设定的日志的最大宽度。检查 `The log's max width` 选项,并增大其至合适的大小。 +**A:** 这是由于日志内容超出设定的日志的最大宽度。检查 `The log's max width` 选项,并增大其至合适的大小。 -### Q: 开启时间戳以后,为什么看不到毫秒级时间。 +**Q:** 开启时间戳以后,为什么看不到毫秒级时间。 - **A:** 这是因为 ulog 目前只支持在开启软件模拟 RTC 状态下,显示毫秒级时间戳。如需显示,只要开启 RT-Thread 软件模拟 RTC 功能即可。 +**A:** 这是因为 ulog 目前只支持在开启软件模拟 RTC 状态下,显示毫秒级时间戳。如需显示,只要开启 RT-Thread 软件模拟 RTC 功能即可。 -### Q: 每次 include ulog 头文件前,都要定义 LOG_TAG 及 LOG_LVL ,可否简化。 +**Q:** 每次 include ulog 头文件前,都要定义 LOG_TAG 及 LOG_LVL ,可否简化。 **A:** `LOG_TAG` 如果不定义,默认会使用 `NO_TAG` 标签,这样输出的日志会容易产生误解,所以标签的宏不建议省略。 `LOG_LVL` 如果不定义,默认会使用调试级别,如果该模块处于开发阶段这个过程可以省略,但是模块代码如果已经稳定,建议定义该宏,并修改级别为信息级别。 -### Q: 运行出现警告提示:Warning: There is no enough buffer for saving async log, please increase the ULOG_ASYNC_OUTPUT_BUF_SIZE option。 +**Q:** 运行出现警告提示:Warning: There is no enough buffer for saving async log, please increase the ULOG_ASYNC_OUTPUT_BUF_SIZE option。 **A:** 当遇到该提示时,说明了在异步模式下的缓冲区出现了溢出的情况,这会导致一部分日志丢失,增大 ULOG_ASYNC_OUTPUT_BUF_SIZE 选项可以解决该问题。 -### Q: 编译时提示:The idle thread stack size must more than 384 when using async output by idle (ULOG_ASYNC_OUTPUT_BY_IDLE)。 +**Q:** 编译时提示:The idle thread stack size must more than 384 when using async output by idle (ULOG_ASYNC_OUTPUT_BY_IDLE)。 **A:** 在使用 idle 线程作为输出线程时,idle 线程的堆栈大小需要提高,这也取决于具体的后端设备,例如:控制台后端时,idle 线程至少得 384 字节。 diff --git "a/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" "b/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" index ffc0615de1dc7deae7b405187edb666a75b0ffe2..4bb76a20aedf2429e2c0de97fd47121abbc75f24 100644 --- "a/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" +++ "b/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" @@ -41,7 +41,7 @@ BSP 框架结构如下图所示: 在 RT-Thread 系统中,应用程序通过设备驱动框架来操作硬件,因此了解设备驱动框架,对添加 BSP 驱动是很重要的。 -- 了解 [Kconfig](https://www.rt-thread.org/document/site/#/development-tools/kconfig/kconfig) 语法 +- 了解 [Kconfig](https://www.rt-thread.org/document/site/#/development-tools/build-config-system/Kconfig) 语法 RT-Thread 系统通过 menuconfig 的方式进行配置,而 menuconfig 中的选项是由 Kconfig 文件决定的,因此想要对 RT-Thread 系统进行配置,需要对 kconfig 语法有一定了解。 diff --git "a/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA\347\263\273\345\210\227BSP\345\244\226\350\256\276\351\251\261\345\212\250\344\275\277\347\224\250\346\225\231\347\250\213.md" "b/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA\347\263\273\345\210\227BSP\345\244\226\350\256\276\351\251\261\345\212\250\344\275\277\347\224\250\346\225\231\347\250\213.md" index 35f218a8624caae0b833bff0c08c01e931125f9a..e977e2eef00f328201499601d4dfe2991fe1fa21 100644 --- "a/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA\347\263\273\345\210\227BSP\345\244\226\350\256\276\351\251\261\345\212\250\344\275\277\347\224\250\346\225\231\347\250\213.md" +++ "b/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA\347\263\273\345\210\227BSP\345\244\226\350\256\276\351\251\261\345\212\250\344\275\277\347\224\250\346\225\231\347\250\213.md" @@ -12,7 +12,7 @@ ## 2. 前提要求 -- 学会如何使用 ENV 工具,参考:[RT-Thread env 工具用户手册](https://www.rt-thread.org/document/site/programming-manual/env/env/) +- 学会如何使用 ENV 工具,参考:[RT-Thread env 工具用户手册](https://www.rt-thread.org/document/site/#/development-tools/env/env) - 熟悉 [FSP](https://www2.renesas.cn/jp/zh/software-tool/flexible-software-package-fsp) 配置工具的使用 ## 3. 如何使用更多的外设资源 diff --git "a/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA\347\263\273\345\210\227\345\244\226\350\256\276\351\251\261\345\212\250\346\267\273\345\212\240\346\214\207\345\215\227.md" "b/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA\347\263\273\345\210\227\345\244\226\350\256\276\351\251\261\345\212\250\346\267\273\345\212\240\346\214\207\345\215\227.md" index b5fb0da7163317135b4cbeb371d005f6e8ec6c5f..522193e57d92646eba2839a4c5590688c546e830 100644 --- "a/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA\347\263\273\345\210\227\345\244\226\350\256\276\351\251\261\345\212\250\346\267\273\345\212\240\346\214\207\345\215\227.md" +++ "b/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA\347\263\273\345\210\227\345\244\226\350\256\276\351\251\261\345\212\250\346\267\273\345\212\240\346\214\207\345\215\227.md" @@ -6,8 +6,8 @@ ## 2. 前提要求 -- 熟练使用 ENV 工具,参考:[RT-Thread env 工具用户手册](https://www.rt-thread.org/document/site/rtthread-development-guide/rtthread-tool-manual/env/env-user-manual/) -- 熟悉 [Kconfig](https://www.rt-thread.org/document/site/#/development-tools/kconfig/kconfig) 语法 +- 熟练使用 ENV 工具,参考:[RT-Thread env 工具用户手册](https://www.rt-thread.org/document/site/#/development-tools/env/env) +- 熟悉 [Kconfig](https://www.rt-thread.org/document/site/#/development-tools/build-config-system/Kconfig) 语法 - 熟悉 [FSP](https://www2.renesas.cn/jp/zh/software-tool/flexible-software-package-fsp) 工具 - 了解 RT-Thread [设备驱动框架](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/device) diff --git "a/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA\347\263\273\345\210\227\351\251\261\345\212\250\344\273\213\347\273\215.md" "b/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA\347\263\273\345\210\227\351\251\261\345\212\250\344\273\213\347\273\215.md" index b125bf0c947140edb3675578ebce28a9709f66fe..5c1b7c4d3b4e9dc892ffbc57663768a5b394146e 100644 --- "a/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA\347\263\273\345\210\227\351\251\261\345\212\250\344\273\213\347\273\215.md" +++ "b/rt-thread-version/rt-thread-standard/tutorial/make-bsp/renesas-ra/RA\347\263\273\345\210\227\351\251\261\345\212\250\344\273\213\347\273\215.md" @@ -30,17 +30,17 @@ | 驱动 | 简介 | | ------------------------------------------------------------ | ------------------------------------------------ | -| [GPIO](https://www.rt-thread.org/document/site/programming-manual/device/pin/pin/) | 操作 GPIO 管脚 | -| [UART](https://www.rt-thread.org/document/site/programming-manual/device/uart/uart/) | 通过串口收发数据 | -| [I2C](https://www.rt-thread.org/document/site/programming-manual/device/i2c/i2c/) | 通过软件 I2C 收发数据 | -| [SPI](https://www.rt-thread.org/document/site/programming-manual/device/spi/spi/) | 通过 SPI 收发数据 | -| [ADC](https://www.rt-thread.org/document/site/programming-manual/device/adc/adc/) | 测量管脚上的模拟量 | +| [GPIO](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/pin/pin) | 操作 GPIO 管脚 | +| [UART](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/uart/uart_v1/uart) | 通过串口收发数据 | +| [I2C](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/i2c/i2c) | 通过软件 I2C 收发数据 | +| [SPI](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/spi/spi) | 通过 SPI 收发数据 | +| [ADC](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/adc/adc) | 测量管脚上的模拟量 | | SDIO | 通过 SDIO 读写数据 | -| [TIMER](https://www.rt-thread.org/document/site/programming-manual/device/hwtimer/hwtimer/) | 使用硬件定时器实现测量时间和定时执行回调函数功能 | -| [PWM](https://www.rt-thread.org/document/site/programming-manual/device/pwm/pwm/) | 在特定的管脚输出 PWM 波形 | -| [RTC](https://www.rt-thread.org/document/site/programming-manual/device/rtc/rtc/) | 设置和读取时间 | -| [WDT](https://www.rt-thread.org/document/site/programming-manual/device/watchdog/watchdog/) | 看门狗驱动 | -| [QSPI](https://www.rt-thread.org/document/site/programming-manual/device/spi/spi/#qspi_1) | 通过 SPI(1、2、4线) 收发数据 | +| [TIMER](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/hwtimer/hwtimer) | 使用硬件定时器实现测量时间和定时执行回调函数功能 | +| [PWM](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/pwm/pwm) | 在特定的管脚输出 PWM 波形 | +| [RTC](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/rtc/rtc) | 设置和读取时间 | +| [WDT](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/watchdog/watchdog) | 看门狗驱动 | +| [QSPI](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/spi/spi?id=配置-qspi-设备) | 通过 SPI(1、2、4线) 收发数据 | ### 2.2 板载外设 diff --git "a/rt-thread-version/rt-thread-standard/tutorial/make-bsp/stm32-bsp/STM32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" "b/rt-thread-version/rt-thread-standard/tutorial/make-bsp/stm32-bsp/STM32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" index 91eca7e3a07e98e11d47c51e23c4abbdae761cac..50ab9f1ed01ac57300b08b27a67b429d741cc883 100644 --- "a/rt-thread-version/rt-thread-standard/tutorial/make-bsp/stm32-bsp/STM32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" +++ "b/rt-thread-version/rt-thread-standard/tutorial/make-bsp/stm32-bsp/STM32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" @@ -32,7 +32,7 @@ BSP 框架结构如下图所示: - 掌握 STM32 系列 BSP 的使用方法 - 了解 BSP 的使用方法,可以阅读 [BSP 说明文档](../README.md) 中使用教程表格内的文档。了解外设驱动的添加方法可以参考《外设驱动添加指南》。 + 了解 BSP 的使用方法,可以阅读 [BSP说明文档](https://gitee.com/rtthread/rt-thread/blob/master/bsp/stm32/README.md)中使用教程表格内的文档。了解外设驱动的添加方法可以参考《外设驱动添加指南》。 - 了解 Scons 工程构建方法 @@ -129,7 +129,7 @@ BSP 的制作过程分为如下五个步骤: 在 **board.c** 文件中存放了函数 `SystemClock_Config()` ,该函数负责初始化系统时钟。当使用 CubeMX 工具对系统时钟重新配置的时候,需要更新这个函数。 -该函数由 CubeMX 工具生成,默认存放在`board/CubeMX_Config/Src/main.c` 文件中。但是该文件并没有被包含到我们的工程中,因此需要将这个函数从 main.c 中拷贝到 board.c 文件中。在整个 BSP 的制作过程中,这个函数是唯一要要拷贝的函数,该函数内容如下所示: +该函数由 CubeMX 工具生成,默认存放在`board/CubeMX_Config/Src/main.c` 文件中。但是该文件并没有被包含到我们的工程中,因此需要将这个函数从 main.c 中拷贝到 board.c 文件中。在整个 BSP 的制作过程中,这个函数是唯一要拷贝的函数,该函数内容如下所示: ![board_1](./figures/board_1.png) @@ -177,7 +177,7 @@ BSP 的制作过程分为如下五个步骤: 本次制作 BSP 使用的芯片为 STM32F103RB,FLASH 为 128k,因此修改 LR_IROM1 和 ER_IROM1 的参数为 0x00020000。RAM 的大小为20k, 因此修改 RW_IRAM1 的参数为 0x00005000。这样的修改方式在一般的应用下就够用了,后续如果有特殊要求,则需要按照链接脚本的语法来根据需求修改。修改链接脚本时,可以参考 [**3.2.3 堆内存配置讲解**](# 3.2.3 堆内存配置讲解) 章节来确定 BSP 的内存分配。 -其他两个链接脚本的文件分别为 iar 使用的 link.icf 和 gcc 编译器使用的 link.lds,修改的方式也是类似的,如下图所示: +其他两个链接脚本的文件分别为 IAR 使用的 link.icf 和 gcc 编译器使用的 link.lds,修改的方式也是类似的,如下图所示: - link.icf 修改内容 diff --git "a/rt-thread-version/rt-thread-standard/tutorial/make-bsp/stm32-bsp/STM32\347\263\273\345\210\227BSP\345\244\226\350\256\276\351\251\261\345\212\250\344\275\277\347\224\250\346\225\231\347\250\213.md" "b/rt-thread-version/rt-thread-standard/tutorial/make-bsp/stm32-bsp/STM32\347\263\273\345\210\227BSP\345\244\226\350\256\276\351\251\261\345\212\250\344\275\277\347\224\250\346\225\231\347\250\213.md" index ad0e7b2ece0d1baee879c5321ae8b81ab400a295..a04fb57e8772cd164904374882520b466e6c1a54 100644 --- "a/rt-thread-version/rt-thread-standard/tutorial/make-bsp/stm32-bsp/STM32\347\263\273\345\210\227BSP\345\244\226\350\256\276\351\251\261\345\212\250\344\275\277\347\224\250\346\225\231\347\250\213.md" +++ "b/rt-thread-version/rt-thread-standard/tutorial/make-bsp/stm32-bsp/STM32\347\263\273\345\210\227BSP\345\244\226\350\256\276\351\251\261\345\212\250\344\275\277\347\224\250\346\225\231\347\250\213.md" @@ -12,7 +12,7 @@ ## 前提要求 -- 学会如何使用 ENV 工具,参考:[RT-Thread env 工具用户手册](https://www.rt-thread.org/document/site/programming-manual/env/env/) +- 学会如何使用 ENV 工具,参考:[RT-Thread env 工具用户手册](https://www.rt-thread.org/document/site/#/development-tools/env/env) ## 如何使用更多的板载资源 diff --git "a/rt-thread-version/rt-thread-standard/tutorial/make-bsp/stm32-bsp/STM32\347\263\273\345\210\227\345\244\226\350\256\276\351\251\261\345\212\250\346\267\273\345\212\240\346\214\207\345\215\227.md" "b/rt-thread-version/rt-thread-standard/tutorial/make-bsp/stm32-bsp/STM32\347\263\273\345\210\227\345\244\226\350\256\276\351\251\261\345\212\250\346\267\273\345\212\240\346\214\207\345\215\227.md" index d96d81f2302e530c727cd01a346f7d154029383f..f5aa960e0573182c2d1d1fbf84b167d47a5fe384 100644 --- "a/rt-thread-version/rt-thread-standard/tutorial/make-bsp/stm32-bsp/STM32\347\263\273\345\210\227\345\244\226\350\256\276\351\251\261\345\212\250\346\267\273\345\212\240\346\214\207\345\215\227.md" +++ "b/rt-thread-version/rt-thread-standard/tutorial/make-bsp/stm32-bsp/STM32\347\263\273\345\210\227\345\244\226\350\256\276\351\251\261\345\212\250\346\267\273\345\212\240\346\214\207\345\215\227.md" @@ -69,7 +69,7 @@ - 部分驱动如果没有适配 BSP 所属的 STM32 系列,请等待 RT-Thread 团队更新。 - 驱动文件对 STM32 系列的支持情况可以查看 [STM32系列驱动介绍文档](STM32系列驱动介绍文档.md)。 - 对于驱动文件或文档说明,有任何建议或者意见,欢迎反馈到 [RT_Thread GitHub](https://github.com/RT-Thread/rt-thread) 网站或 [RT-Thread 官方论坛](https://www.rt-thread.org/qa/forum.php)。 -- 在生成代码时,不要勾选以下选项(即:不让其生成单独的 .c/.h 驱动文件,直接全部更新到 rt-thread 要使用的 stm32xxx_hal_msp.c 文件中) +- 在生成代码时,不要勾选以下选项(即:不让其生成单独的 .c/.h 驱动文件,直接全部更新到 RT-Thread 要使用的 stm32xxx_hal_msp.c 文件中) ![generate-code](figures/generate-code.png) @@ -77,9 +77,9 @@ ### 5.1 CubeMX配置说明 -本小节介绍 stm32 系列的 BSP 是如何利用 CubeMX 工具对 BSP 进行配置的。 +本小节介绍 STM32 系列的 BSP 是如何利用 CubeMX 工具对 BSP 进行配置的。 -就像文档中提到的那样,stm32 系列的 BSP 只利用了 CubeMX 工具生成的 `stm32XXxx_hal_conf.h` 和 `stm32XXxx_hal_msp.c` 文件。在 HAL 库中, `stm32XXxx_hal_conf.h` 文件里提供的宏开关会决定 HAL 库将哪些外设驱动添加到工程中。 而`stm32XXxx_hal_msp.c` 文件中则存放了在 CubeMX 工具中开启的外设驱动的配置代码。 +就像文档中提到的那样,STM32 系列的 BSP 只利用了 CubeMX 工具生成的 `stm32XXxx_hal_conf.h` 和 `stm32XXxx_hal_msp.c` 文件。在 HAL 库中, `stm32XXxx_hal_conf.h` 文件里提供的宏开关会决定 HAL 库将哪些外设驱动添加到工程中。 而 `stm32XXxx_hal_msp.c` 文件中则存放了在 CubeMX 工具中开启的外设驱动的配置代码。 ### 5.2 外设配置总结 diff --git "a/rt-thread-version/rt-thread-standard/tutorial/make-bsp/stm32-bsp/STM32\347\263\273\345\210\227\351\251\261\345\212\250\344\273\213\347\273\215.md" "b/rt-thread-version/rt-thread-standard/tutorial/make-bsp/stm32-bsp/STM32\347\263\273\345\210\227\351\251\261\345\212\250\344\273\213\347\273\215.md" index 45c9ec391fef57073e80390e00e36859b18fa999..cf1e073cce8d68cf7534ac4eeff5e2334425adbd 100644 --- "a/rt-thread-version/rt-thread-standard/tutorial/make-bsp/stm32-bsp/STM32\347\263\273\345\210\227\351\251\261\345\212\250\344\273\213\347\273\215.md" +++ "b/rt-thread-version/rt-thread-standard/tutorial/make-bsp/stm32-bsp/STM32\347\263\273\345\210\227\351\251\261\345\212\250\344\273\213\347\273\215.md" @@ -30,17 +30,17 @@ | 序号 | 驱动 | 简介 | | ---- | ------------------------------------------------------------ | ------------------------------------------------ | -| 1 | [GPIO](https://www.rt-thread.org/document/site/programming-manual/device/pin/pin/) | 操作 GPIO 管脚 | -| 2 | [UART](https://www.rt-thread.org/document/site/programming-manual/device/uart/uart/) | 通过串口收发数据 | -| 3 | [soft I2C](https://www.rt-thread.org/document/site/programming-manual/device/i2c/i2c/) | 通过软件 I2C 收发数据 | -| 4 | [SPI](https://www.rt-thread.org/document/site/programming-manual/device/spi/spi/) | 通过 SPI 收发数据 | -| 5 | [ADC](https://www.rt-thread.org/document/site/programming-manual/device/adc/adc/) | 测量管脚上的模拟量 | +| 1 | [GPIO](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/pin/pin) | 操作 GPIO 管脚 | +| 2 | [UART](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/uart/uart_v1/uart) | 通过串口收发数据 | +| 3 | [soft I2C](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/i2c/i2c) | 通过软件 I2C 收发数据 | +| 4 | [SPI](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/spi/spi) | 通过 SPI 收发数据 | +| 5 | [ADC](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/adc/adc) | 测量管脚上的模拟量 | | 6 | SDIO | 通过 SDIO 读写数据 | -| 7 | [TIMER](https://www.rt-thread.org/document/site/programming-manual/device/hwtimer/hwtimer/) | 使用硬件定时器实现测量时间和定时执行回调函数功能 | -| 8 | [PWM](https://www.rt-thread.org/document/site/programming-manual/device/pwm/pwm/) | 在特定的管脚输出 PWM 波形 | -| 9 | [RTC](https://www.rt-thread.org/document/site/programming-manual/device/rtc/rtc/) | 设置和读取时间 | -| 10 | [WDT](https://www.rt-thread.org/document/site/programming-manual/device/watchdog/watchdog/) | 看门狗驱动 | -| 11 | [QSPI](https://www.rt-thread.org/document/site/programming-manual/device/spi/spi/#qspi_1) | 通过 SPI(1、2、4线) 收发数据 | +| 7 | [TIMER](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/hwtimer/hwtimer) | 使用硬件定时器实现测量时间和定时执行回调函数功能 | +| 8 | [PWM](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/pwm/pwm) | 在特定的管脚输出 PWM 波形 | +| 9 | [RTC](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/rtc/rtc) | 设置和读取时间 | +| 10 | [WDT](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/watchdog/watchdog) | 看门狗驱动 | +| 11 | [QSPI](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/spi/spi?id=配置-qspi-设备) | 通过 SPI(1、2、4线) 收发数据 | ### 2.2 板载外设 diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/Infineon/Infineon-gateway-demo.md b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/Infineon/Infineon-gateway-demo.md new file mode 100644 index 0000000000000000000000000000000000000000..a2433e20a90d3006ac72c3bf83553823600f4211 --- /dev/null +++ b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/Infineon/Infineon-gateway-demo.md @@ -0,0 +1,126 @@ +# Infineon + RT-Thread 物联网 DEMO + +## 简介 + +这是一个基于 `CY8CPROTO-062-4343W` 开发板 + `RT-Thread` 实现的物联网 DEMO。 + +本文将介绍如何一步步从零搭建一个物联网 demo。 + +下图是整体的设计框图,使用 `RW007` 用于网络通信,使用 `MQTT` 协议连接 One-Net 物联网平台。在主控芯片中添加所需要的软件包、组件等中间件来快速搭建起一个设备上云 Demo。 + +## 实际运行效果 + +1、在 msh 中输入`onenet_mqtt_demo_start 【WI-Fi 名称】 【WI-Fi 密码】` 命令创建并启动 demo 线程 + +![](../figures/demo.png) + +![](../figures/wifi_info.png) + +2、在云平台的设备调试页面查看实时刷新的数据。 + +![](../figures/onenet01.png) + +3、进入[可视化网站](https://open.iot.10086.cn/iotbox/appsquare/appview?openid=edfdb062942604d9b1de5674d7433497),进行查看/下发数据的上行和下行 + +![](../figures/onenet-demo.png) + +## 准备工作 + +- [RT-Thread studio v2.2.5](https://download-sh-cmcc.rt-thread.org:9151/www/studio/download/RT-Thread%20Studio-v2.2.5-setup-x86_64_202208011830.exe) + +- OneNET:[中国移动物联网开放平台](https://open.iot.10086.cn) +- [CY8CPROTO-062-4343W 开发板](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/quick-start) +- USB-TTL:连接 UART5 (TX:P5_1; RX:P5_0)**波特率 115200** +- WiFi 网络模块:[RW007](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/application-note/packages/rw007_module_using/an0034-rw007-module-using?id=rw007) + +![物理连接](../figures/rw007.png) + +各 IO 接口与功能之间的对应关系表: + +| CY8CPROTO-062-4343W 引脚名 | 功能 | +| :------------------------: | :-------: | +| P6_2 | BOOT0/CLK | +| P6_1 | MISO | +| P6_0 | MOSI | +| P12_0 | BOOT1/CS | +| P5_7 | INT/BUSY | +| P6_5 | RESET | + +## 实现过程 + +1. 打开 RT-Thread studio,导入开发板示例工程:点击 Studio 左上角 `文件—>导入—>RT-Thread Studio项目到工作空间中 ` + +![](../figures/studio1.png) + +2. 选择本示例工程的根目录进行导入 + +![](../figures/studio2.png) + +3. 进入 `RT-Studio ` 的SDK管理器中,下载英飞凌的 `OpenOCD` 资源包。 + + ![](../figures/openocd01.png) + +4. 鼠标右键工程,点击 `同步 scons 配置至项目` + + ![](../figures/sync_proj.png) + +5. 编译、下载,验证运行结果 + +* 点击 IDE 左上角的构建选项进行工程的编译。 + +![](../figures/studio3-build.png) + +* 当编译无错误警告时,点击 `Debug` 或 `Download` 选项进行调试/下载。 + + 注:若点击下载并下载成功后串口终端无显示信息,请手动按下复位按键进行重启运行。 + + ![](../figures/studio4-download.png) + +- 查看系统运行情况 + +> 在串口终端输入命令 `help`、`ps`、`free`、`list_device` 等命令查看系统运行状态 + +6. 连云配置 + +- 在[云平台](https://open.iot.10086.cn)创建项目,创建完成后点击控制台进入配置 + +* 点击 `全部产品服务—>多协议接入` 进入配置界面 + +![](../figures/onenet03.png) + +* 添加产品 + +![](../figures/onenet04.png) + +* 输入产品信息 + +![](../figures/onenet05.png) + +* 添加设备 + +![](../figures/onenet06.png) + +* 输入设备信息 + +![](../figures/onenet07.png) + +* 进入 `RT-Thread Studio`,双击本工程下的 `RT-Thread Settings` ,进入工程配置界面 + +![](../figures/studio4.png) + +* 对照 `OneNet` 的信息,填写至配置选项中 + +![](../figures/onenet08.png) + +![](../figures/onenet09.png) + +![](../figures/studio5.png) + +* 编译、下载,验证IOT网关数据上报和下发功能。 + +## 更多资料 + +- [开发板官网主页](https://www.infineon.com/cms/en/product/evaluation-boards/cy8cproto-062-4343w/) +- [开发板原理图](https://www.infineon.com/dgdl/Infineon-CY8CPROTO-062-4343W_Schematic-PCBDesignData-v01_00-EN.pdf?fileId=8ac78c8c7d0d8da4017d0f010c6d183a&utm_source=cypress&utm_medium=referral&utm_campaign=202110_globe_en_all_integration-files) +- [英飞凌快速上手指南](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/quick-start) +- [CY8CPROTO-062-4343W_datasheet](https://www.infineon.com/dgdl/Infineon-PSOC_6_MCU_CY8C62X8_CY8C62XA-DataSheet-v17_00-EN.pdf?fileId=8ac78c8c7d0d8da4017d0ee7d03a70b1) diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/demo.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/demo.png new file mode 100644 index 0000000000000000000000000000000000000000..006e8711c6129d0aa7a4c96a627a38067cc4d9e5 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/demo.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet-demo.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet-demo.png new file mode 100644 index 0000000000000000000000000000000000000000..e6058b5f5e83f44ea91cd18022fb15a3550ec97e Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet-demo.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet01.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet01.png new file mode 100644 index 0000000000000000000000000000000000000000..52d0b7bec48402a247a0dfe6a761d0eeabbd95e3 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet01.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet03.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet03.png new file mode 100644 index 0000000000000000000000000000000000000000..d6636bf11e89f5f1ecc0d3f8497c19b926bc32de Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet03.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet04.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet04.png new file mode 100644 index 0000000000000000000000000000000000000000..b1e4560cb8809d5b96b99501d893300743d99e2c Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet04.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet05.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet05.png new file mode 100644 index 0000000000000000000000000000000000000000..5074f44933a9916478275cc016b36f253ffff6ca Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet05.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet06.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet06.png new file mode 100644 index 0000000000000000000000000000000000000000..08d29a99c2459c3be89327c0ad2026e8375acce2 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet06.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet07.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet07.png new file mode 100644 index 0000000000000000000000000000000000000000..669020e34df96a196f2847840ce99894c74e2a71 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet07.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet08.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet08.png new file mode 100644 index 0000000000000000000000000000000000000000..0a534ded72997c91c58d638f801654b7ecb234af Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet08.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet09.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet09.png new file mode 100644 index 0000000000000000000000000000000000000000..b723b41e15b804bd3897d947b8f6fffe90fc077e Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/onenet09.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/openocd01.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/openocd01.png new file mode 100644 index 0000000000000000000000000000000000000000..415a6438d72d338716a7676c36d85ed62aae2450 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/openocd01.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/openocd02.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/openocd02.png new file mode 100644 index 0000000000000000000000000000000000000000..1b24662f88bb44de065bbc637d87ffec60e32c7d Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/openocd02.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/rw007.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/rw007.png new file mode 100644 index 0000000000000000000000000000000000000000..18b6dd4f48dce9e654e9a9256ba4ef36c3514c28 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/rw007.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/studio1.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio1.png similarity index 100% rename from rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/studio1.png rename to rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio1.png diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio2.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio2.png new file mode 100644 index 0000000000000000000000000000000000000000..b2020c8af5822c73e787e74ea302d1650fe1ec2f Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio2.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio3-build.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio3-build.png new file mode 100644 index 0000000000000000000000000000000000000000..5019c1d219392828e3ecfcdb735cf36ef820be5d Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio3-build.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio3.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio3.png new file mode 100644 index 0000000000000000000000000000000000000000..ef26f6436b17327b7c36863940cd2a75512db295 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio3.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio4-download.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio4-download.png new file mode 100644 index 0000000000000000000000000000000000000000..526e134dc7493367616e110546b36d5a24b2e07a Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio4-download.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio4.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio4.png new file mode 100644 index 0000000000000000000000000000000000000000..0a4d4e8d53ec8ac77813c8fdc651107485e308eb Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio4.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio5.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio5.png new file mode 100644 index 0000000000000000000000000000000000000000..8511c70df4b51bf039b5ecf145d311d2698e1ff3 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/studio5.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/sync_proj.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/sync_proj.png new file mode 100644 index 0000000000000000000000000000000000000000..b7f94fceecc564f980ad26707a9dcb75e1bab99b Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/sync_proj.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/wifi_info.png b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/wifi_info.png new file mode 100644 index 0000000000000000000000000000000000000000..20852cddf473653589b6b4062145309dfe97c388 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/open-projects-design/figures/wifi_info.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/board.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/board.png similarity index 100% rename from rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/board.png rename to rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/board.png diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/compile_first_example.jpg b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/compile_first_example.jpg new file mode 100644 index 0000000000000000000000000000000000000000..44ae8fda2c9622d308b3a8823d793bccaba01bcb Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/compile_first_example.jpg differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/mdk_package.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/mdk_package.png similarity index 100% rename from rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/mdk_package.png rename to rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/mdk_package.png diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/studio1.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/studio1.png new file mode 100644 index 0000000000000000000000000000000000000000..85c4bdc662b91321f3ad24b39fd96165e302667d Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/studio1.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/studio2.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/studio2.png new file mode 100644 index 0000000000000000000000000000000000000000..0511a98f041ecf32c5fae570f2bffaaeab5fa4dd Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/studio2.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/studio3-build.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/studio3-build.png new file mode 100644 index 0000000000000000000000000000000000000000..5019c1d219392828e3ecfcdb735cf36ef820be5d Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/studio3-build.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/studio4-download.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/studio4-download.png new file mode 100644 index 0000000000000000000000000000000000000000..526e134dc7493367616e110546b36d5a24b2e07a Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/studio4-download.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/usb_pc.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/usb_pc.png similarity index 100% rename from rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/usb_pc.png rename to rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/figures/usb_pc.png diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/quick-start.md b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/quick-start.md similarity index 60% rename from rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/quick-start.md rename to rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/quick-start.md index daee077a94655a6831a10d7aa145a63ceff83804..848443081fa4b7bdf20521055de3c3dbe7083530 100644 --- a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/quick-start.md +++ b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CKIT-062S2-43012/quick-start.md @@ -2,20 +2,20 @@ ## 简介 -`PSoC6 CY8CKIT-062S2-43012` 是赛普拉斯推出的一款32位双核CPU子系统( ARM Cortex-M4 和 ARM Cortex-M0)的开发板,具有单周期乘法的150-MHz Arm Cortex-M4F CPU (浮点和存储器保护单元),100-MHz Cortex M0+ CPU,带单周期乘法和内存保护单元 MPU,可以充分发挥 PSoC6 双核芯片性能。 +`PSoC6-CY8CKIT-062S2-43012` 是英飞凌推出的一款32位双核CPU子系统( ARM Cortex-M4 和 ARM Cortex-M0)的开发板,具有单周期乘法的150-MHz Arm Cortex-M4F CPU (浮点和存储器保护单元),100-MHz Cortex M0+ CPU,带单周期乘法和内存保护单元 MPU,可以充分发挥 PSoC6 双核芯片性能。 -开发板外观详细信息:[CY8CPROTO-062-4343W - Infineon Technologies](https://www.infineon.com/cms/en/product/evaluation-boards/cy8cproto-062-4343w/) +开发板外观详细信息:[CY8CKIT-062S2-43012 - Infineon Technologies](https://www.infineon.com/cms/en/product/evaluation-boards/cy8cproto-062-4343w/) 该开发板核心 **板载资源** 如下: - MCU:CY8C624ABZI-S2D44,Cortex-M4主频 150MHz,Cortex-M0主频 100MHz,2MB Flash 和 1MB SRAM - MCU手册更多详细信息请参考文档 [PSoC 6 MCU: CY8C62x8, CY8C62xA Datasheet](https://www.infineon.com/dgdl/Infineon-PSOC_6_MCU_CY8C62X8_CY8C62XA-DataSheet-v17_00-EN.pdf?fileId=8ac78c8c7d0d8da4017d0ee7d03a70b1) +- MCU手册更多详细信息请参考文档 [PSoC 6 MCU: CY8C62x8, CY8C62xA Datasheet](https://www.infineon.com/dgdl/Infineon-PSOC_6_MCU_CY8C62X8_CY8C62XA-DataSheet-v17_00-EN.pdf?fileId=8ac78c8c7d0d8da4017d0ee7d03a70b1) - 板载资源:microSD card , 64-Mb Quad-SPI NOR flash, CYW43012 Wi-Fi + Bluetooth Combo Chip - 仿真器:板载 Psoc5 Dap-link 仿真调试器 - 开发环境:ModusToolbox 2.0/MDK V5 - PSoC® Creator™ 下载链接 [ModusToolbox™ Software - Infineon Technologies](https://www.infineon.com/cms/en/design-support/tools/sdk/modustoolbox-software/) +- PSoC® Creator™ 下载链接 [ModusToolbox™ Software - Infineon Technologies](https://www.infineon.com/cms/en/design-support/tools/sdk/modustoolbox-software/) - 开发板:CY8CKIT-062S2-43012 - 开发板更多详细信息请参考文档 [002-25010_REV A_WEB PDF V1 Final](https://www.infineon.com/dgdl/Infineon-CY8CPROTO-062-4343W_PSoC_6_Wi-Fi_BT_Prototyping_Kit_Quick_Start_Guide-UserManual-v01_00-EN.pdf?fileId=8ac78c8c7d0d8da4017d0f0106871835) +- 开发板更多详细信息请参考文档 [002-25010_REV A_WEB PDF V1 Final](https://www.infineon.com/dgdl/Infineon-CY8CPROTO-062-4343W_PSoC_6_Wi-Fi_BT_Prototyping_Kit_Quick_Start_Guide-UserManual-v01_00-EN.pdf?fileId=8ac78c8c7d0d8da4017d0f0106871835) 开发板外观如下图所示: @@ -23,7 +23,7 @@ ## 准备工作 -号令者 I.MX RT1052 板级支持包提供 MDK5 和 RT-Studio 工程,并且支持 GCC、ArmClang 开发环境,下面介绍如何将示例程序运行起来。运行示例程序前需要做如下准备工作: +**psoc6-cy8ckit-062S2-43012** 板级支持包提供 MDK5 和 RT-Studio 工程,并且支持 GCC、ArmClang 开发环境,下面介绍如何将示例程序运行起来。运行示例程序前需要做如下准备工作: 1. MDK 开发环境 @@ -40,7 +40,7 @@ ![导入工程](figures/studio1.png) - 4. 接着选择 `PSoC6 CY8CKIT-062S2-43012` 开发板支持包的目录,进行导入 + 4. 接着选择 `PSoC6-CY8CKIT-062S2-43012` 开发板支持包的目录,进行导入 ![导入工程](figures/studio2.png) @@ -52,7 +52,7 @@ 1. MDK 环境运行: -进入到 `bsp\cypress\psoc6-cy8cproto-4343w` 文件夹中,双击 project.uvprojx 文件,打开 MDK5 工程,执行编译。编译完成后,点击下载按钮将固件下载至开发板,观察程序运行状况。 +进入到 `bsp\cypress\psoc6-cy8ckit-062S2-43012` 文件夹中,双击 project.uvprojx 文件,打开 MDK5 工程,执行编译。编译完成后,点击下载按钮将固件下载至开发板,观察程序运行状况。 ![编译第一个示例程序](figures/compile_first_example.jpg) diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/compile_first_example.jpg b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/compile_first_example.jpg deleted file mode 100644 index c0075bd56322d1628dc190c16b8593e21deff8c5..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/compile_first_example.jpg and /dev/null differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/studio2.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/studio2.png deleted file mode 100644 index 1ce0690138b4231618d1bff0c0e70b983d1eca80..0000000000000000000000000000000000000000 Binary files a/rt-thread-version/rt-thread-standard/tutorial/quick-start/CY8CPROTO-062-4343W/figures/studio2.png and /dev/null differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/more.md b/rt-thread-version/rt-thread-standard/tutorial/quick-start/more.md index f6d5a3f468019721b26a70812a384202d6ef3847..4f50b10d37f9e139d23bcce71ba17a0b54e296c1 100644 --- a/rt-thread-version/rt-thread-standard/tutorial/quick-start/more.md +++ b/rt-thread-version/rt-thread-standard/tutorial/quick-start/more.md @@ -19,6 +19,7 @@ | | 【推荐】[Nuvoton NK-RTU980](../quick-start/nk-rtu980/quick-start.md) | | | 【推荐】[Nuvoton NK-N9H30](../quick-start/nk-n9h30/quick-start.md) | | | 【推荐】[Nuvoton NuMaker-M032KI](../quick-start/numaker-m032ki/quick-start.md) | +| | 【推荐】[Nuvoton NuMaker-M467HJ](../quick-start/numaker-m467hj/quick-start.md) | ## 其他开发板及其 BSP @@ -40,7 +41,7 @@ RT-Thread 支持的全部 BSP 均在 github 的 `rt-thread` 源码中,位于 ` | | [SWDM-QFP100-34SVEA1(https://github.com/RT-Thread/rt-thread/tree/master/bsp/synwit/swm341) ]| | Nordic | [nRF52840-PCA10056](https://github.com/RT-Thread/rt-thread/tree/master/bsp/nrf5x/nrf52840) | | | [nRF52832-PCA10040](https://github.com/RT-Thread/rt-thread/tree/master/bsp/nrf5x/nrf52832) | -| 英飞凌 | [CY8CPROTO-062-4343WI](../quick-start/CY8CPROTO-062-4343W/quick-start.md) | +| 英飞凌 | [CY8CKIT-062S2-43012](../quick-start/CY8CKIT-062S2-43012/quick-start.md) | ## STM32 系列 BSP 制作 diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/nordic-nrf5x/quick-start.md b/rt-thread-version/rt-thread-standard/tutorial/quick-start/nordic-nrf5x/quick-start.md index f074370a05caed1f915d10263cb819e39e254106..88f2d23863008dcf13dcee0d92d02153e16d0551 100644 --- a/rt-thread-version/rt-thread-standard/tutorial/quick-start/nordic-nrf5x/quick-start.md +++ b/rt-thread-version/rt-thread-standard/tutorial/quick-start/nordic-nrf5x/quick-start.md @@ -17,7 +17,7 @@ Nordic nRF5x 系列 BSP 目前支持情况如下: | nRF51822 | [Micro:bitV1.5](https://tech.microbit.org/hardware/1-5-revision/) | [nrf51822](https://github.com/RT-Thread/rt-thread/tree/master/bsp/nrf5x/nrf51822) | | | nrf52832 | [pca10040](https://www.nordicsemi.com/Products/Development-hardware/nRF52-DK) | [nrf52832](https://github.com/RT-Thread/rt-thread/tree/master/bsp/nrf5x/nrf52832) | | | nrf52840 | [PCA10056](https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF52840-DK) | [nrf52840](https://github.com/RT-Thread/rt-thread/tree/master/bsp/nrf5x/nrf52840) | | -| nrf52840 | [ARDUINO NANO 33 BLE](https://store.arduino.cc/usa/nano-33-ble-sense-with-headers) | [nrf52840](https://github.com/RT-Thread/rt-thread/tree/master/bsp/nrf5x/nrf52840) | menuconfig 中选择对应的 board | +| nrf52840 | [ARDUINO NANO 33 BLE](https://store-usa.arduino.cc/products/arduino-nano-33-ble-sense-with-headers) | [nrf52840](https://github.com/RT-Thread/rt-thread/tree/master/bsp/nrf5x/nrf52840) | menuconfig 中选择对应的 board | ### 主要支持功能 diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-iot-m487/quick-start.md b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-iot-m487/quick-start.md index 6d384f899f62e7afec76a143eb7cce46fed7f702..f2f39d25c7ca25688fc009e8dfef98e39d3fc380 100644 --- a/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-iot-m487/quick-start.md +++ b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-iot-m487/quick-start.md @@ -43,102 +43,115 @@ NuMaker-IoT-M487 提供多元连网方式与多种接口,并提供影像感测 NuMaker-IoT-M487 板级支持包提供 MDK5 和 IAR 工程,并且支持 GCC 开发环境,介绍如何将示例程序运行起来。运行示例程序前需要做如下准备工作: - 1. 源码获取 -在 env 窗口内运行 git clone 将程序拷贝到本地端。[源码目录说明](../src_code_introduction/rtthread_dir.md) +1. 源码获取 -```bash -git clone https://github.com/RT-Thread/rt-thread -``` + 在 env 窗口内运行 git clone 将程序拷贝到本地端。[源码目录说明](../src_code_introduction/rtthread_dir.md) - 2. 开发环境 -支持 GCC, MDK5, IAR 开发环境. + ```bash + git clone https://github.com/RT-Thread/rt-thread + ``` -| IDE/Compiler | Tested version | -| ---------- | ---------------------------- | -| MDK5 | 5.26.2 | -| IAR | 8.2 | -| GCC | GCC 5.4.1 20160919 (release) | +2. 开发环境 -注意: 开发前,请先安装 [Nu-Link_Keil](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180521) 或是 [Nu-Link_IAR](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180914) 驱动。 + 支持 GCC, MDK5, IAR 开发环境. - 3. 使用 USB 线连接开发板的 USB ICE Connector 到 PC 机。 + | IDE/Compiler | Tested version | + | ---------- | ---------------------------- | + | MDK5 | 5.26.2 | + | IAR | 8.2 | + | GCC | GCC 5.4.1 20160919 (release) | + + 注意: 开发前,请先安装 [Nu-Link_Keil](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180521) 或是 [Nu-Link_IAR](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180914) 驱动。 + +3. 使用 USB 线连接开发板的 USB ICE Connector 到 PC 机。 ## 运行板载功能演示 - 下载项目相关套件 -执行下列命令下载项目相关文件。 - -```bash -# cd rt-thread -# cd bsp/nuvoton/numaker-iot-m487 -# menuconfig --generate -# pkgs --update -Cloning into 'C:\rt-thread\bsp\nuvoton\numaker-iot-m487\packages\netutils-latest'... -remote: Enumerating objects: 442, done. -remote: Total 442 (delta 0), reused 0 (delta 0), pack-reused 442R -Receiving objects: 100% (442/442), 8.15 MiB | 36.00 KiB/s, done. -Resolving deltas: 100% (237/237), done. -==============================> FAL v0.4.0 is downloaded successfully. -==============================> netutils update done -Operation completed successfully. -``` + 执行下列命令下载项目相关文件。 + + ```bash + # cd rt-thread + # cd bsp/nuvoton/numaker-iot-m487 + # menuconfig --generate + # pkgs --update + Cloning into 'C:\rt-thread\bsp\nuvoton\numaker-iot-m487\packages\netutils-latest'... + remote: Enumerating objects: 442, done. + remote: Total 442 (delta 0), reused 0 (delta 0), pack-reused 442R + Receiving objects: 100% (442/442), 8.15 MiB | 36.00 KiB/s, done. + Resolving deltas: 100% (237/237), done. + ==============================> FAL v0.4.0 is downloaded successfully. + ==============================> netutils update done + Operation completed successfully. + ``` - GCC 编译项目 -执行下列指令进行 gcc 编译工程,生成的文件为 rtthread.bin。 - -```bash -# cd rt-thread -# cd bsp/nuvoton/numaker-iot-m487 -# scons -… -… -LINK rtthread.elf -arm-none-eabi-objcopy -O binary rtthread.elf rtthread.bin -arm-none-eabi-size rtthread.elf - text data bss dec hex filename - 245020 4556 10260 259836 3f6fc rtthread.elf -scons: done building targets. - -\bsp\nuvoton\numaker-iot-m487\rtthread.bin -``` + + 执行下列指令进行 gcc 编译工程,生成的文件为 rtthread.bin。 + + ```bash + # cd rt-thread + # cd bsp/nuvoton/numaker-iot-m487 + # scons + … + … + LINK rtthread.elf + arm-none-eabi-objcopy -O binary rtthread.elf rtthread.bin + arm-none-eabi-size rtthread.elf + text data bss dec hex filename + 245020 4556 10260 259836 3f6fc rtthread.elf + scons: done building targets. + + \bsp\nuvoton\numaker-iot-m487\rtthread.bin + ``` - MDK5 编译项目 -通过下列指令选译生成 MDK5 项目工程文件。MDK 项目工程产生在这个目录内,文件名为 project.uvprojx。 -```bash -# cd rt-thread -# cd bsp/nuvoton/numaker-iot-m487 -# scons --target=mdk5 –s + 通过下列指令选译生成 MDK5 项目工程文件。MDK 项目工程产生在这个目录内,文件名为 project.uvprojx。 + + ```bash + # cd rt-thread + # cd bsp/nuvoton/numaker-iot-m487 + # scons --target=mdk5 –s -\bsp\nuvoton\numaker-iot-m487\project.uvprojx -``` + \bsp\nuvoton\numaker-iot-m487\project.uvprojx + ``` - IAR 编译项目 -可以通过下列指令生成 IAR 项目工程文件。IAR 项目工程产生在这个目录内,文件名为 project.ewp 和 project.eww。(注意: 编译 IAR 项目工程需使用 8.2 以上的版本。) -```bash -# cd rt-thread -# cd bsp/nuvoton/numaker-iot-m487 -# scons --target=iar –s + 可以通过下列指令生成 IAR 项目工程文件。IAR 项目工程产生在这个目录内,文件名为 project.ewp 和 project.eww。(注意: 编译 IAR 项目工程需使用 8.2 以上的版本。) -\bsp\nuvoton\numaker-iot-m487\project.eww -\bsp\nuvoton\numaker-iot-m487\project.ewp -``` + ```bash + # cd rt-thread + # cd bsp/nuvoton/numaker-iot-m487 + # scons --target=iar –s + + \bsp\nuvoton\numaker-iot-m487\project.eww + \bsp\nuvoton\numaker-iot-m487\project.ewp + ``` - 固件下载 -简易的下载方法: 通过拖拉文档到 NuMicro MCU 虚拟磁盘或是使用传送到 NuMicro MCU 虚拟磁盘的方式,即可完成固件下载。 -![numicro_mcu](figures/numicro_mcu.png) -首先,配置 NuMaker-IoT-M487 上的 ISW1,将四个开关拨到 ‘ON’ 的位置。 -![isw](figures/nulinkme_isw.png) -配置完成后,将开发板使用 Micro USB 连接线连接计算机,我的计算机将出现一个 NuMicro MCU 虚拟磁盘。接下来,我们将使用这个虚拟磁盘来进行固件下载。(注意:若需要进行 IAR/MDK 源码除错功能,需要将第 4 个指拨开关切换回到 OFF 的位置。) + + 简易的下载方法: 通过拖拉文档到 NuMicro MCU 虚拟磁盘或是使用传送到 NuMicro MCU 虚拟磁盘的方式,即可完成固件下载。 + + ![numicro_mcu](figures/numicro_mcu.png) + + 首先,配置 NuMaker-IoT-M487 上的 ISW1,将四个开关拨到 ‘ON’ 的位置。 + + ![isw](figures/nulinkme_isw.png) + + 配置完成后,将开发板使用 Micro USB 连接线连接计算机,我的计算机将出现一个 NuMicro MCU 虚拟磁盘。接下来,我们将使用这个虚拟磁盘来进行固件下载。(注意:若需要进行 IAR/MDK 源码除错功能,需要将第 4 个指拨开关切换回到 OFF 的位置。) - 运行 -使用 Tera Term 终端软件操作 rt-thread finsh/msh 命令行功能。串口的配置如图所示。(注意: Nuvoton Virtual Com Port 对应的串口编号可在设备管理器内找到。例如: 串口编号为 COM30, 115200N81。) -![console](figures/console.png) -在 console 操作 ifconfig 指令打印取得的 IP 地址, 并使用 ping 指令,进行测试网关连接。 -![run](figures/run.gif) + + 使用 Tera Term 终端软件操作 rt-thread finsh/msh 命令行功能。串口的配置如图所示。(注意: Nuvoton Virtual Com Port 对应的串口编号可在设备管理器内找到。例如: 串口编号为 COM30, 115200N81。) + + ![console](figures/console.png) + + 在 console 操作 ifconfig 指令打印取得的 IP 地址, 并使用 ping 指令,进行测试网关连接。 + + ![run](figures/run.gif) ## 继续学习 已完成 RT-Thread 快速上手!点击这里进行 [内核学习](../../kernel/kernel-video.md) 。 - diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m032ki/quick-start.md b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m032ki/quick-start.md index 3b0290c79f97303009adbbf728793d28ec3e4019..c6200f78469b4d8400730845aa492e219a094b9d 100644 --- a/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m032ki/quick-start.md +++ b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m032ki/quick-start.md @@ -43,95 +43,103 @@ Nu-Link2-Me 刻录与除错器可透过SWD接口进行刻录与除错,还带 NuMaker-M032KI 板级支持包提供 MDK5 和 IAR 工程,并且支持 GCC 开发环境,介绍如何将示例程序运行起来。运行示例程序前需要做如下准备工作: - 1. 源码获取 +1. 源码获取 -在 env 窗口内运行 git clone 将程序拷贝到本地端。[源码目录说明](../src_code_introduction/rtthread_dir.md) + 在 env 窗口内运行 git clone 将程序拷贝到本地端。[源码目录说明](../src_code_introduction/rtthread_dir.md) -```bash -git clone https://github.com/RT-Thread/rt-thread -``` + ```bash + git clone https://github.com/RT-Thread/rt-thread + ``` - 2. 开发环境 -支持 GCC, MDK5, IAR 开发环境. +2. 开发环境 -| IDE/Compiler | Tested version | -| ---------- | ---------------------------- | -| MDK5 | 5.28 | -| IAR | 8.32 | -| GCC | GCC 6.3.1 20170620 (Need update env) | + 支持 GCC, MDK5, IAR 开发环境. -注意: 开发前,请先安装 [Nu-Link_Keil](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180521) 或是 [Nu-Link_IAR](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180914) 驱动。 + | IDE/Compiler | Tested version | + | ---------- | ---------------------------- | + | MDK5 | 5.28 | + | IAR | 8.32 | + | GCC | GCC 6.3.1 20170620 (Need update env) | - 3. 使用 USB 线连接开发板的 USB ICE Connector 到 PC 机。 + 注意: 开发前,请先安装 [Nu-Link_Keil](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180521) 或是 [Nu-Link_IAR](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180914) 驱动。 + +3. 使用 USB 线连接开发板的 USB ICE Connector 到 PC 机。 ## 运行板载功能演示 - 下载项目相应套件 执行下列命令下载项目相关文件。 - -```bash -# cd rt-thread -# cd bsp/nuvoton/numaker-m032ki -# menuconfig --generate -``` + ```bash + # cd rt-thread + # cd bsp/nuvoton/numaker-m032ki + # menuconfig --generate + ``` - GCC 编译项目 -执行下列指令进行 gcc 编译工程,生成的文件为 rtthread.bin。 - -```bash -# cd rt-thread -# cd bsp/nuvoton/numaker-m032ki -# scons -… -… -LINK rtthread.elf -arm-none-eabi-objcopy -O binary rtthread.elf rtthread.bin -arm-none-eabi-size rtthread.elf - text data bss dec hex filename - 176328 3696 22840 202864 31870 rtthread.elf -scons: done building targets. - -\bsp\nuvoton\numaker-m032ki\rtthread.bin -``` + + 执行下列指令进行 gcc 编译工程,生成的文件为 rtthread.bin。 + + ```bash + # cd rt-thread + # cd bsp/nuvoton/numaker-m032ki + # scons + … + … + LINK rtthread.elf + arm-none-eabi-objcopy -O binary rtthread.elf rtthread.bin + arm-none-eabi-size rtthread.elf + text data bss dec hex filename + 176328 3696 22840 202864 31870 rtthread.elf + scons: done building targets. + + \bsp\nuvoton\numaker-m032ki\rtthread.bin + ``` - MDK5 编译项目 -通过下列指令选译生成 MDK5 项目工程文件。MDK 项目工程产生在这个目录内,文件名为 project.uvprojx。 + 通过下列指令选译生成 MDK5 项目工程文件。MDK 项目工程产生在这个目录内,文件名为 project.uvprojx。 -```bash -# cd rt-thread -# cd bsp/nuvoton/numaker-m032ki -# scons --target=mdk5 –s + ```bash + # cd rt-thread + # cd bsp/nuvoton/numaker-m032ki + # scons --target=mdk5 –s -\bsp\nuvoton\numaker-m032ki\project.uvprojx -``` + \bsp\nuvoton\numaker-m032ki\project.uvprojx + ``` - IAR 编译项目 -可以通过下列指令生成 IAR 项目工程文件。IAR 项目工程产生在这个目录内,文件名为 project.ewp 和 project.eww。(注意: 编译 IAR 项目工程需使用 8.3 以上的版本。) -```bash -# cd rt-thread -# cd bsp/nuvoton/numaker-m032ki -# scons --target=iar –s + 可以通过下列指令生成 IAR 项目工程文件。IAR 项目工程产生在这个目录内,文件名为 project.ewp 和 project.eww。(注意: 编译 IAR 项目工程需使用 8.3 以上的版本。) + + ```bash + # cd rt-thread + # cd bsp/nuvoton/numaker-m032ki + # scons --target=iar –s -\bsp\nuvoton\numaker-m032ki\project.eww -\bsp\nuvoton\numaker-m032ki\project.ewp -``` + \bsp\nuvoton\numaker-m032ki\project.eww + \bsp\nuvoton\numaker-m032ki\project.ewp + ``` - 固件下载 -简易的下载方法: 通过拖拉文档到 NuMicro MCU 虚拟磁盘或是使用传送到 NuMicro MCU 虚拟磁盘的方式,即可完成固件下载。 -![numicro_mcu](figures/numicro_mcu.png) -首先,配置 Nu-Link2-Me 上的指拨开关,将四个开关拨到 ‘ON’ 的位置。 -![isw](figures/nulinkme_isw.png) -配置完成后,将开发板使用 Micro USB 连接线连接计算机,我的计算机将出现一个 NuMicro MCU 虚拟磁盘。接下来,我们将使用这个虚拟磁盘来进行固件下载。 + 简易的下载方法: 通过拖拉文档到 NuMicro MCU 虚拟磁盘或是使用传送到 NuMicro MCU 虚拟磁盘的方式,即可完成固件下载。 + + ![numicro_mcu](figures/numicro_mcu.png) + + 首先,配置 Nu-Link2-Me 上的指拨开关,将四个开关拨到 ‘ON’ 的位置。 + + ![isw](figures/nulinkme_isw.png) + + 配置完成后,将开发板使用 Micro USB 连接线连接计算机,我的计算机将出现一个 NuMicro MCU 虚拟磁盘。接下来,我们将使用这个虚拟磁盘来进行固件下载。 - 运行 -使用 Tera Term 终端软件操作 rt-thread finsh/msh 命令行功能。串口的配置如图所示。(注意: Nuvoton Virtual Com Port 对应的串口编号可在设备管理器内找到。例如: 串口编号为 COM30, 115200N81。) -![console](figures/console.png) -![run](figures/run.gif) + + 使用 Tera Term 终端软件操作 rt-thread finsh/msh 命令行功能。串口的配置如图所示。(注意: Nuvoton Virtual Com Port 对应的串口编号可在设备管理器内找到。例如: 串口编号为 COM30, 115200N81。) + + ![console](figures/console.png) + + ![run](figures/run.gif) ## 继续学习 已完成 RT-Thread 快速上手!点击这里进行 [内核学习](../../kernel/kernel-video.md) 。 - diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m2354/quick-start.md b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m2354/quick-start.md index c7c334835bdd71c6a4db44967490d6e17c9751ff..acc8c1bf3524e8ad20a4c0e38b339e4ad7f753cc 100644 --- a/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m2354/quick-start.md +++ b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m2354/quick-start.md @@ -44,98 +44,112 @@ NuMaker-M2354 的另一部分为 Nu-Link2-Me 除错烧录器。Nu-Link2-Me 可 NuMaker-M2354 板级支持包提供 MDK5 和 IAR 工程,并且支持 GCC 开发环境,介绍如何将示例程序运行起来。运行示例程序前需要做如下准备工作: 1. 源码获取 -在 env 窗口内运行 git clone 将程序拷贝到本地端。[源码目录说明](../src_code_introduction/rtthread_dir.md) -```bash -git clone https://github.com/RT-Thread/rt-thread -``` + + 在 env 窗口内运行 git clone 将程序拷贝到本地端。[源码目录说明](../src_code_introduction/rtthread_dir.md) + ```bash + git clone https://github.com/RT-Thread/rt-thread + ``` 2. 开发环境 -支持 GCC, MDK5, IAR 开发环境. -| IDE/Compiler | Tested version | -| ---------- | ---------------------------- | -| MDK5 | 5.26.2 | -| IAR | 8.32 | -| GCC | GCC 6.3.1 20170620 (Need update env) | -注意: 开发前,请先安装 [Nu-Link_Keil](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180521) 或是 [Nu-Link_IAR](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180914) 驱动。 + 支持 GCC, MDK5, IAR 开发环境. + | IDE/Compiler | Tested version | + | ---------- | ---------------------------- | + | MDK5 | 5.26.2 | + | IAR | 8.32 | + | GCC | GCC 6.3.1 20170620 (Need update env) | + + 注意: 开发前,请先安装 [Nu-Link_Keil](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180521) 或是 [Nu-Link_IAR](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180914) 驱动。 3. 使用 USB 线连接开发板的 USB ICE Connector 到 PC 机。 ## 运行板载功能演示 + - 下载项目相应套件 -执行下列命令下载项目相关文件。 - -```bash -# cd rt-thread -# cd bsp/nuvoton/numaker-m2354 -# menuconfig --generate -# pkgs --update -Cloning into 'C:\rt-thread\bsp\nuvoton\numaker-m2354\packages\netutils-latest'... -remote: Enumerating objects: 442, done. -remote: Total 442 (delta 0), reused 0 (delta 0), pack-reused 442R -Receiving objects: 100% (442/442), 8.15 MiB | 36.00 KiB/s, done. -Resolving deltas: 100% (237/237), done. -==============================> FAL v0.4.0 is downloaded successfully. -==============================> netutils update done -Operation completed successfully. -``` + + 执行下列命令下载项目相关文件。 + + ```bash + # cd rt-thread + # cd bsp/nuvoton/numaker-m2354 + # menuconfig --generate + # pkgs --update + Cloning into 'C:\rt-thread\bsp\nuvoton\numaker-m2354\packages\netutils-latest'... + remote: Enumerating objects: 442, done. + remote: Total 442 (delta 0), reused 0 (delta 0), pack-reused 442R + Receiving objects: 100% (442/442), 8.15 MiB | 36.00 KiB/s, done. + Resolving deltas: 100% (237/237), done. + ==============================> FAL v0.4.0 is downloaded successfully. + ==============================> netutils update done + Operation completed successfully. + ``` - GCC 编译项目 -执行下列指令进行 gcc 编译工程,生成的文件为 rtthread.bin。 - -```bash -# cd rt-thread -# cd bsp/nuvoton/numaker-m2354 -# scons -… -… -LINK rtthread.elf -arm-none-eabi-objcopy -O binary rtthread.elf rtthread.bin -arm-none-eabi-size rtthread.elf - text data bss dec hex filename - 245020 4556 10260 259836 3f6fc rtthread.elf -scons: done building targets. - -\bsp\nuvoton\numaker-m2354\rtthread.bin -``` + + 执行下列指令进行 gcc 编译工程,生成的文件为 rtthread.bin。 + + ```bash + # cd rt-thread + # cd bsp/nuvoton/numaker-m2354 + # scons + … + … + LINK rtthread.elf + arm-none-eabi-objcopy -O binary rtthread.elf rtthread.bin + arm-none-eabi-size rtthread.elf + text data bss dec hex filename + 245020 4556 10260 259836 3f6fc rtthread.elf + scons: done building targets. + + \bsp\nuvoton\numaker-m2354\rtthread.bin + ``` - MDK5 编译项目 -通过下列指令选译生成 MDK5 项目工程文件。MDK 项目工程产生在这个目录内,文件名为 project.uvprojx。 -```bash -# cd rt-thread -# cd bsp/nuvoton/numaker-m2354 -# scons --target=mdk5 –s + 通过下列指令选译生成 MDK5 项目工程文件。MDK 项目工程产生在这个目录内,文件名为 project.uvprojx。 -\bsp\nuvoton\numaker-m2354\project.uvprojx -``` + ```bash + # cd rt-thread + # cd bsp/nuvoton/numaker-m2354 + # scons --target=mdk5 –s + + \bsp\nuvoton\numaker-m2354\project.uvprojx + ``` - IAR 编译项目 -可以通过下列指令生成 IAR 项目工程文件。IAR 项目工程产生在这个目录内,文件名为 project.ewp 和 project.eww。(注意: 编译 IAR 项目工程需使用 8.3 以上的版本。) + 可以通过下列指令生成 IAR 项目工程文件。IAR 项目工程产生在这个目录内,文件名为 project.ewp 和 project.eww。(注意: 编译 IAR 项目工程需使用 8.3 以上的版本。) -```bash -# cd rt-thread -# cd bsp/nuvoton/numaker-m2354 -# scons --target=iar –s + ```bash + # cd rt-thread + # cd bsp/nuvoton/numaker-m2354 + # scons --target=iar –s -\bsp\nuvoton\numaker-m2354\project.eww -\bsp\nuvoton\numaker-m2354\project.ewp -``` + \bsp\nuvoton\numaker-m2354\project.eww + \bsp\nuvoton\numaker-m2354\project.ewp + ``` - 固件下载 -简易的下载方法: 通过拖拉文档到 NuMicro MCU 虚拟磁盘或是使用传送到 NuMicro MCU 虚拟磁盘的方式,即可完成固件下载。 -![numicro_mcu](figures/numicro_mcu.png) -首先,配置 Nu-Link2-Me 上的指拨开关,将四个开关拨到 ‘ON’ 的位置。 -![isw](figures/nulinkme_isw.png) -配置完成后,将开发板使用 Micro USB 连接线连接计算机,我的计算机将出现一个 NuMicro MCU 虚拟磁盘。接下来,我们将使用这个虚拟磁盘来进行固件下载。 + + 简易的下载方法: 通过拖拉文档到 NuMicro MCU 虚拟磁盘或是使用传送到 NuMicro MCU 虚拟磁盘的方式,即可完成固件下载。 + + ![numicro_mcu](figures/numicro_mcu.png) + + 首先,配置 Nu-Link2-Me 上的指拨开关,将四个开关拨到 ‘ON’ 的位置。 + + ![isw](figures/nulinkme_isw.png) + + 配置完成后,将开发板使用 Micro USB 连接线连接计算机,我的计算机将出现一个 NuMicro MCU 虚拟磁盘。接下来,我们将使用这个虚拟磁盘来进行固件下载。 - 运行 -使用 Tera Term 终端软件操作 rt-thread finsh/msh 命令行功能。串口的配置如图所示。(注意: Nuvoton Virtual Com Port 对应的串口编号可在设备管理器内找到。例如: 串口编号为 COM30, 115200N81。) -![console](figures/console.png) -在 console 操作 ifconfig 指令打印取得的 IP 地址, 并使用 ping 指令,进行测试网关连接。 -![run](figures/run.gif) + + 使用 Tera Term 终端软件操作 rt-thread finsh/msh 命令行功能。串口的配置如图所示。(注意: Nuvoton Virtual Com Port 对应的串口编号可在设备管理器内找到。例如: 串口编号为 COM30, 115200N81。) + + ![console](figures/console.png) + + 在 console 操作 ifconfig 指令打印取得的 IP 地址, 并使用 ping 指令,进行测试网关连接。 + + ![run](figures/run.gif) ## 继续学习 已完成 RT-Thread 快速上手!点击这里进行 [内核学习](../../kernel/kernel-video.md) 。 - diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/NuLinkMe_SwitchSetting.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/NuLinkMe_SwitchSetting.png new file mode 100644 index 0000000000000000000000000000000000000000..2a1822fbd43faed99552404d1274a9dc84d3dc0c Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/NuLinkMe_SwitchSetting.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/SerialSetting.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/SerialSetting.png new file mode 100644 index 0000000000000000000000000000000000000000..7ab04331be0ebb2af5c8a16772e6c293a9f934a5 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/SerialSetting.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/board.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/board.png new file mode 100644 index 0000000000000000000000000000000000000000..92c58822eb4d244069d2df3e8ad216276690a294 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/board.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/console.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/console.png new file mode 100644 index 0000000000000000000000000000000000000000..7ab04331be0ebb2af5c8a16772e6c293a9f934a5 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/console.png differ diff --git a/rt-thread-version/rt-thread-smart/rt-smart-quickstart/figures/Rapi4.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/image_grabber.gif similarity index 31% rename from rt-thread-version/rt-thread-smart/rt-smart-quickstart/figures/Rapi4.png rename to rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/image_grabber.gif index d355c00146bcdf092b5e02fca0c6412649208381..a9b5eb575855d0cb524fc43326beae91b8c779a3 100644 Binary files a/rt-thread-version/rt-thread-smart/rt-smart-quickstart/figures/Rapi4.png and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/image_grabber.gif differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/numicro_mcu.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/numicro_mcu.png new file mode 100644 index 0000000000000000000000000000000000000000..301fe5d2dc37e01279b5fa0835ffdb29451fab5a Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/numicro_mcu.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/run.gif b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/run.gif new file mode 100644 index 0000000000000000000000000000000000000000..83689847006564776195e0345bb0ecc55fac66e0 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/run.gif differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/sendto.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/sendto.png new file mode 100644 index 0000000000000000000000000000000000000000..dac6dd29b1dfa6fcd3633c9aa55a3ab6e67bf6ec Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/figures/sendto.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/quick-start.md b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/quick-start.md new file mode 100644 index 0000000000000000000000000000000000000000..a90149cc8bf9419540a096ab147813d6a5bd1cbc --- /dev/null +++ b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-m467hj/quick-start.md @@ -0,0 +1,192 @@ +# NuMaker-M467HJ 上手指南 + +**此文档也适用 NuMaker-HMI-M467 型号开发板** + +## 简介 + +NuMaker-M467HJ 目标板带有 NuMicro M467HJHAN 微控制器。NuMaker-M467HJ 目标板提供 M467HJHAN 的脚位扩展接口,与兼容于 Arduino UNO 的接口,方便搭配各式接口设备或 Arduino 模块,并有多种的电源供应设计,让项目的开发更加灵活。NuMaker-M467HJ 目标板还带有电流量测接口可以随时监控功耗,协助项目开发与评估。 + +NuMaker-M467HJ 的另一部分为 Nu-Link2-Me 除错烧录器。Nu-Link2-Me 可透过 SWD 接口对新唐微控制器进行在线 ICP 烧录与除错,也可以进行脱机 ICP 烧录,烧录的状态会显示在状态 LED 上。Nu-Link2-Me 也支持虚拟串口(VCOM)功能,可输出讯息至终端机窗口。Nu-Link2-Me 还可以与开发板分离,成为独立的批次生产烧录器。 + +开发板外观如下图所示: + +![board](figures/board.png) + +该开发板常用 **板载资源** 如下: + +- MCU + - M467HJHAN,主频 200MHz,1MB FLASH ,512KB RAM +- 板载装置 + - SPI NOR FLASH: W25Q32(SPI,4MB) + - HYPERRAM: W956A8MBYA5I(HBI,8MB) + - Audio Codec: NAU8822 Audio Codec + - Thermal sensor: NCT7717U + - 以太网: RTL8201F +- 常用外设 + - LED:3 个 + - 按键:3 个 +- 常用接口: + - Arduino UNO 相容扩充 + - RJ-45 + - USB 1.1/2.0 OTG + - SD 卡 + - 3.5mm 音源 + - CAN FD 通讯 + - LCD 屏(EBI) + - CMOS 影像 + - USB 转串口 +- 调试接口 + - 板载的 NuLinkMe 下载 +- 扩充板: + - HM1055 摄像头模块 + - NuMaker-M467HJ 适用屏幕模块 ([直接选择 NuMaker-HMI-M467 开发板](https://direct.nuvoton.com/zh/numaker-hmi-m467)) + +开发板更多详细信息请参考 [NuMaker-M467HJ](https://www.nuvoton.com/board/numaker-m467hj) + +## 软硬件需求 + +### 软件需求 + +- Window 10 操作系统。 +- Env RT-Thread 开发辅助工具。 +- IAR-8.2 以上版本或是 Arm MDK v5(或是 v4) – 工程编译软件。(Optional) +- Nu-Link Driver for Keil MDK。(Optional) +- Nu-Link Driver for IAR。(Optional) +- 终端联机工具,如 Tera Term。 +- RT-Thread 源码。 + +### 硬件需求 + +- NuMaker-M467HJ 开发板。 +- USB Micro 数据传输线 1 条。 + +## 准备工作 + +NuMaker-M467HJ 板级支持包提供 MDK5 和 IAR 工程,并且支持 GCC 开发环境,介绍如何将示例程序运行起来。运行示例程序前需要做如下准备工作: + + 1. 源码获取 +在 env 窗口内运行 git clone 将程序拷贝到本地端。[源码目录说明](../src_code_introduction/rtthread_dir.md) + +```bash +git clone https://github.com/RT-Thread/rt-thread +``` + + 2. 开发环境 +支持 GCC, MDK5, IAR 开发环境. + +| IDE/Compiler | Tested version | +| ---------- | ---------------------------- | +| MDK5 | 5.26.2 | +| IAR | 8.2 | +| GCC | GCC 5.4.1 20160919 (release) | + +注意: 开发前,请先安装 [Nu-Link_Keil](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180521) 或是 [Nu-Link_IAR](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180914) 驱动。 + + 3. 使用 USB 线连接开发板的 USB ICE Connector 到 PC 机。 + +## 运行板载功能演示 + +- 下载项目相关套件 + +执行下列命令下载项目相关文件。 + +```bash +# cd rt-thread +# cd bsp/nuvoton/numaker-m467hj +# menuconfig --generate +# pkgs --update +Cloning into +Cloning into '\bsp\nuvoton\numaker-m467hj\packages\wavplayer-latest'... +remote: Enumerating objects: 98, done. +remote: Counting objects: 100% (40/40), done. +remote: Compressing objects: 100% (40/40), done. +remote: Total 98 (delta 14), reused 0 (delta 0), pack-reused 58 +Unpacking objects: 100% (98/98), 1.64 MiB | 1.24 MiB/s, done. +... +==============================> OPTPARSE latest is downloaded successfully. +==============================> wavplayer update done +==============================> ramdisk update done +==============================> optparse update done +Operation completed successfully. +``` + +- GCC 编译项目 +执行下列指令进行 gcc 编译工程,生成的文件为 rtthread.bin。 + +```bash +# cd rt-thread +# cd bsp/nuvoton/numaker-m467hj +# scons +… +… +LINK rtthread.elf +arm-none-eabi-objcopy -O binary rtthread.elf rtthread.bin +arm-none-eabi-size rtthread.elf + text data bss dec hex filename + 381200 4964 176828 562992 89730 rtthread.elf +scons: done building targets. + +\bsp\nuvoton\numaker-m467hj\rtthread.bin +``` + +- MDK5 编译项目 +通过下列指令选译生成 MDK5 项目工程文件。MDK 项目工程产生在这个目录内,文件名为 project.uvprojx。 + +```bash +# cd rt-thread +# cd bsp/nuvoton/numaker-m467hj +# scons --target=mdk5 –s + +\bsp\nuvoton\numaker-m467hj\project.uvprojx +``` + +- IAR 编译项目 +可以通过下列指令生成 IAR 项目工程文件。IAR 项目工程产生在这个目录内,文件名为 project.ewp 和 project.eww。(注意: 编译 IAR 项目工程需使用 8.2 以上的版本。) + +```bash +# cd rt-thread +# cd bsp/nuvoton/numaker-m467hj +# scons --target=iar –s + +\bsp\nuvoton\numaker-m467hj\project.eww +\bsp\nuvoton\numaker-m467hj\project.ewp +``` + +- 固件下载 +简易的下载方法: 通过拖拉文档到 NuMicro MCU 虚拟磁盘或是使用传送到 NuMicro MCU 虚拟磁盘的方式,即可完成固件下载。 + +![numicro_mcu](figures/numicro_mcu.png) + +![numicro_mcu](figures/sendto.png) + +首先,配置 NuMaker-M467 上的 ICESW2,将 1 與 2 开关拨到 ‘ON’ 的位置。 + +![isw](figures/NuLinkMe_SwitchSetting.png) + +配置完成后,将开发板使用 Micro USB 连接线连接计算机,我的计算机将出现一个 NuMicro MCU 虚拟磁盘。接下来,我们将使用这个虚拟磁盘来进行固件下载。 + +- 运行 +使用 Tera Term 终端软件操作 rt-thread finsh/msh 命令行功能。串口的配置如图所示。(注意: Nuvoton Virtual Com Port 对应的串口编号可在设备管理器内找到。例如: 串口编号为 COM30, 115200N81。) + +![console](figures/console.png) + +- 操作 ifconfig 指令打印取得的 IP 地址, 并使用 ping 指令,进行测试网关连接。 +- 读取 NCT7717U 温度传感器。 +- 显示 8MB HYPERRAM as RAMDISK 档案列表。 +- 显示 SD Card 档案列表。 + +![run](figures/run.gif) + +### 其它外围功能演示 + +操作搭配专属屏幕与影像摄像头。 + +![run](figures/image_grabber.gif) + +## 更多开发板信息 + - [NuMaker-M467HJ](https://www.nuvoton.com/board/numaker-m467hj) + - [NuMaker-HMI-M467](https://www.nuvoton.com/products/gui-solution/gui-platform/numaker-hmi-m467/) + +## 继续学习 + +已完成 RT-Thread 快速上手!点击这里进行 [内核学习](../../kernel/kernel-video.md) 。 diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-pfm-m487/quick-start.md b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-pfm-m487/quick-start.md index 90db00c8cd7fda2a29a68e400d77abb92724dd74..943d27dabf75540314cc5ec0f73385c40c4986eb 100644 --- a/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-pfm-m487/quick-start.md +++ b/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-pfm-m487/quick-start.md @@ -38,105 +38,115 @@ NuMaker-PFM-M487 的主控板采用通用接口设计,提供兼容于 Arduino NuMaker-PFM-M487 板级支持包提供 MDK5 和 IAR 工程,并且支持 GCC 开发环境,介绍如何将示例程序运行起来。运行示例程序前需要做如下准备工作: - 1. 源码获取 +1. 源码获取 -在 env 窗口内运行 git clone 将程序拷贝到本地端。[源码目录说明](../src_code_introduction/rtthread_dir.md) + 在 env 窗口内运行 git clone 将程序拷贝到本地端。[源码目录说明](../src_code_introduction/rtthread_dir.md) -```bash -git clone https://github.com/RT-Thread/rt-thread -``` + ```bash + git clone https://github.com/RT-Thread/rt-thread + ``` - 2. 开发环境 +2. 开发环境 -支持 GCC, MDK5, IAR 开发环境. + 支持 GCC, MDK5, IAR 开发环境. -| IDE/Compiler | Tested version | -| ---------- | ---------------------------- | -| MDK5 | 5.26.2 | -| IAR | 8.2 | -| GCC | GCC 5.4.1 20160919 (release) | + | IDE/Compiler | Tested version | + | ---------- | ---------------------------- | + | MDK5 | 5.26.2 | + | IAR | 8.2 | + | GCC | GCC 5.4.1 20160919 (release) | -注意: 开发前,请先安装 [Nu-Link_Keil](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180521) 或是 [Nu-Link_IAR](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180914) 驱动。 + 注意: 开发前,请先安装 [Nu-Link_Keil](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180521) 或是 [Nu-Link_IAR](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180914) 驱动。 - 3. 使用 USB 线连接开发板的 USB ICE Connector 到 PC 机。 +3. 使用 USB 线连接开发板的 USB ICE Connector 到 PC 机。 ## 运行板载功能演示 - 下载项目相应套件 -执行下列命令下载项目相关文件。 - -```bash -# cd rt-thread -# cd bsp/nuvoton/numaker-pfm-m487 -# menuconfig --generate -# pkgs --update -Cloning into 'C:\rt-thread\bsp\nuvoton\numaker-pfm-m487\packages\netutils-latest'... -remote: Enumerating objects: 442, done. -remote: Total 442 (delta 0), reused 0 (delta 0), pack-reused 442R -Receiving objects: 100% (442/442), 8.15 MiB | 36.00 KiB/s, done. -Resolving deltas: 100% (237/237), done. -==============================> FAL v0.4.0 is downloaded successfully. -==============================> netutils update done -Operation completed successfully. -``` + 执行下列命令下载项目相关文件。 + + ```bash + # cd rt-thread + # cd bsp/nuvoton/numaker-pfm-m487 + # menuconfig --generate + # pkgs --update + Cloning into 'C:\rt-thread\bsp\nuvoton\numaker-pfm-m487\packages\netutils-latest'... + remote: Enumerating objects: 442, done. + remote: Total 442 (delta 0), reused 0 (delta 0), pack-reused 442R + Receiving objects: 100% (442/442), 8.15 MiB | 36.00 KiB/s, done. + Resolving deltas: 100% (237/237), done. + ==============================> FAL v0.4.0 is downloaded successfully. + ==============================> netutils update done + Operation completed successfully. + ``` - GCC 编译项目 -执行下列指令进行 gcc 编译工程,生成的文件为 rtthread.bin。 + 执行下列指令进行 gcc 编译工程,生成的文件为 rtthread.bin。 -```bash -# cd rt-thread -# cd bsp/nuvoton/numaker-pfm-m487 -# scons -… -… -LINK rtthread.elf -arm-none-eabi-objcopy -O binary rtthread.elf rtthread.bin -arm-none-eabi-size rtthread.elf - text data bss dec hex filename - 245020 4556 10260 259836 3f6fc rtthread.elf -scons: done building targets. + ```bash + # cd rt-thread + # cd bsp/nuvoton/numaker-pfm-m487 + # scons + … + … + LINK rtthread.elf + arm-none-eabi-objcopy -O binary rtthread.elf rtthread.bin + arm-none-eabi-size rtthread.elf + text data bss dec hex filename + 245020 4556 10260 259836 3f6fc rtthread.elf + scons: done building targets. -\bsp\nuvoton\numaker-pfm-m487\rtthread.bin -``` + \bsp\nuvoton\numaker-pfm-m487\rtthread.bin + ``` - MDK5 编译项目 -通过下列指令选译生成 MDK4 或是 MDK5 项目工程文件。MDK 项目工程产生在这个目录内,文件名为 project.uvprojx。 + 通过下列指令选译生成 MDK4 或是 MDK5 项目工程文件。MDK 项目工程产生在这个目录内,文件名为 project.uvprojx。 -```bash -# cd rt-thread -# cd bsp/nuvoton/numaker-pfm-m487 -# scons --target=mdk5 –s + ```bash + # cd rt-thread + # cd bsp/nuvoton/numaker-pfm-m487 + # scons --target=mdk5 –s -\bsp\nuvoton\numaker-pfm-m487\project.uvprojx -``` + \bsp\nuvoton\numaker-pfm-m487\project.uvprojx + ``` - IAR 编译项目 -可以通过下列指令生成 IAR 项目工程文件。IAR 项目工程产生在这个目录内,文件名为 project.ewp 和 project.eww。(注意: 编译 IAR 项目工程需使用 8.2 以上的版本。) + 可以通过下列指令生成 IAR 项目工程文件。IAR 项目工程产生在这个目录内,文件名为 project.ewp 和 project.eww。(注意: 编译 IAR 项目工程需使用 8.2 以上的版本。) -```bash -# cd rt-thread -# cd bsp/nuvoton/numaker-pfm-m487 -# scons --target=iar –s + ```bash + # cd rt-thread + # cd bsp/nuvoton/numaker-pfm-m487 + # scons --target=iar –s -\bsp\nuvoton\numaker-pfm-m487\project.eww -\bsp\nuvoton\numaker-pfm-m487\project.ewp -``` + \bsp\nuvoton\numaker-pfm-m487\project.eww + \bsp\nuvoton\numaker-pfm-m487\project.ewp + ``` - 固件下载 -简易的下载方法: 通过拖拉文档到 NuMicro MCU 虚拟磁盘或是使用传送到 NuMicro MCU 虚拟磁盘的方式,即可完成固件下载。 -![numicro_mcu](figures/numicro_mcu.png) -首先,配置 NuMaker-PFM-M487 上的 ISW1,将四个开关拨到 ‘ON’ 的位置。 -![isw](figures/nulinkme_isw.png) -配置完成后,将开发板使用 Micro USB 连接线连接计算机,我的计算机将出现一个 NuMicro MCU 虚拟磁盘。接下来,我们将使用这个虚拟磁盘来进行固件下载。(注意:若需要进行 IAR/MDK 源码除错功能,需要将第 4 个指拨开关切换回到 OFF 的位置。) + + 简易的下载方法: 通过拖拉文档到 NuMicro MCU 虚拟磁盘或是使用传送到 NuMicro MCU 虚拟磁盘的方式,即可完成固件下载。 + + ![numicro_mcu](figures/numicro_mcu.png) + + 首先,配置 NuMaker-PFM-M487 上的 ISW1,将四个开关拨到 ‘ON’ 的位置。 + + ![isw](figures/nulinkme_isw.png) + + 配置完成后,将开发板使用 Micro USB 连接线连接计算机,我的计算机将出现一个 NuMicro MCU 虚拟磁盘。接下来,我们将使用这个虚拟磁盘来进行固件下载。(注意:若需要进行 IAR/MDK 源码除错功能,需要将第 4 个指拨开关切换回到 OFF 的位置。) + - 运行 -使用 Tera Term 终端软件操作 rt-thread finsh/msh 命令行功能。串口的配置如图所示。(注意: Nuvoton Virtual Com Port 对应的串口编号可在设备管理器内找到。例如: 串口编号为 COM30, 115200N81。) -![console](figures/console.png) -在 console 操作 ifconfig 指令打印取得的 IP 地址, 并使用 ping 指令,进行测试网关连接。 -![run](figures/run.gif) + + 使用 Tera Term 终端软件操作 rt-thread finsh/msh 命令行功能。串口的配置如图所示。(注意: Nuvoton Virtual Com Port 对应的串口编号可在设备管理器内找到。例如: 串口编号为 COM30, 115200N81。) + + ![console](figures/console.png) + + 在 console 操作 ifconfig 指令打印取得的 IP 地址, 并使用 ping 指令,进行测试网关连接。 + + ![run](figures/run.gif) ## 更多 - [Nuvoton NuMaker-IoT-M487 快速上手](../numaker-iot-m487/quick-start.md) @@ -147,4 +157,3 @@ scons: done building targets. ## 继续学习 已完成 RT-Thread 快速上手!点击这里进行 [内核学习](../../kernel/kernel-video.md) 。 - diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/CORE-V-MCU_Block_Diagram.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/CORE-V-MCU_Block_Diagram.png new file mode 100644 index 0000000000000000000000000000000000000000..63ec66b7d8a99e7e1afb27da0008227c6fb4d220 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/CORE-V-MCU_Block_Diagram.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/IDE_MAKE.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/IDE_MAKE.png new file mode 100644 index 0000000000000000000000000000000000000000..e98217b248ee20f949d04e5b86b1afa2b931e301 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/IDE_MAKE.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/Properites.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/Properites.png new file mode 100644 index 0000000000000000000000000000000000000000..7a1dc843b5ffe7bd64cbef12efea58ac2340d9d8 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/Properites.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/debug.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/debug.png new file mode 100644 index 0000000000000000000000000000000000000000..b92ffbb9ce5f728f338fdae2d84f4719775518ca Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/debug.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/debug2.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/debug2.png new file mode 100644 index 0000000000000000000000000000000000000000..a6195aa82061d7edfac588e30dbfb9ca7121d193 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/debug2.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/import_2.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/import_2.png new file mode 100644 index 0000000000000000000000000000000000000000..8cea991e974449e161912b289d584366084247da Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/import_2.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/make.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/make.png new file mode 100644 index 0000000000000000000000000000000000000000..80c64b9cc906fa4e1ff432da43335ce62ab8d2a7 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/make.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/makefile_project.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/makefile_project.png new file mode 100644 index 0000000000000000000000000000000000000000..578186aa5e9e42de8e52c27ffbc3c44efa9d3ea9 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/makefile_project.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/openocd.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/openocd.png new file mode 100644 index 0000000000000000000000000000000000000000..0091126337ef941eaa8f714ab6c5396ab1cd4bfe Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/openocd.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/register_file.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/register_file.png new file mode 100644 index 0000000000000000000000000000000000000000..4753066c3bda0c6366a110cacfded412f574250a Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/register_file.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/remove_ifdef.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/remove_ifdef.png new file mode 100644 index 0000000000000000000000000000000000000000..36866d176570d018126d3a9866506376282d9d55 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/remove_ifdef.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/result0.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/result0.png new file mode 100644 index 0000000000000000000000000000000000000000..eeda881a62944c110ccd9ab0c03f64749de59d07 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/result0.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/run.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/run.png new file mode 100644 index 0000000000000000000000000000000000000000..719ced7cf69e7b1c2827886fbd6a74184a333cfb Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/run.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/settings.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/settings.png new file mode 100644 index 0000000000000000000000000000000000000000..4bacec3a64eba06632c20e24a9f5b64ccfb6c4de Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/settings.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/svd.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/svd.png new file mode 100644 index 0000000000000000000000000000000000000000..e0aa493badeb161262660b79e99c97c97028e828 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/svd.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/test_result1.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/test_result1.png new file mode 100644 index 0000000000000000000000000000000000000000..5588e848428a816b859c37d31fbf691b81a525a1 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/test_result1.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/test_result2.png b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/test_result2.png new file mode 100644 index 0000000000000000000000000000000000000000..cb7e905a8d358cd4f6d2666a18bc7349fbaff613 Binary files /dev/null and b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/figures/test_result2.png differ diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/quick-start.md b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/quick-start.md new file mode 100644 index 0000000000000000000000000000000000000000..8f23c032e936210f0a48fcdce64ae081ac741cc1 --- /dev/null +++ b/rt-thread-version/rt-thread-standard/tutorial/quick-start/openhw-core-v-mcu/quick-start.md @@ -0,0 +1,206 @@ +# core-v-mcu 上手指南 + +## 1 MCU 简介 + +core-v-mcu 的目的是展示 cv32e40p,这是 Open Hardware Group(OpenHW) 提供的经过充分验证的 RISC-V 内核。cv32e40p 核心连接到一组具有代表性的外围设备。 + +![CORE-V-MCU_Block_Diagram](figures/CORE-V-MCU_Block_Diagram.png) + +**core-v-mcu 资源:** + +- 2xUART +- 2xI2C master +- 1xI2C slave +- 2xQSPI master +- 1xCAMERA +- 1xSDIO +- 4xPWM +- eFPGA with 4 math units + +更多信息请访问 [core-v-mcu 介绍](https://docs.openhwgroup.org/projects/core-v-mcu/doc-src/overview.html),更多资源详见 [OpenHW 官网](https://www.openhwgroup.org/)。 + +## 2 编译说明 + +板级包支持 RISC-V GCC 开发环境,以下是具体版本信息: + +| IDE / 编译器 | 已测试版本 | +| ---------- | ----------------------- | +| GCC | riscv32-unknown-elf-gcc | + +## 3 使用说明 + +> 本章节是为在 core-v-mcu 上使用 RT-Thread 的用户提供,core-v-mcu 目前没有实际的硬件,采用 QEMU 的方式实现模拟, 本文使用的 qemu 为 ubuntu18.04 环境下编译 qemu。 + +### 3.1 使用 Env 编译 BSP + +本节讲解如何使用 Env 工具来编译 BSP 工程。 + +#### 3.1.1 编译 BSP + +1. 准备工作 1:[下载 Linux 环境下 GCC 编译工具链](https://github.com/Yaochenger/openhw-/tree/master/toolchain),将下载的工具链放在自己的 Linux 环境下。 + +2. 准备工作 2:在 Linux 环境下安装 Env,在控制台运行以下命令。 + + ```shell + wget https://gitee.com/RT-Thread-Mirror/env/raw/master/install_ubuntu.sh + chmod 777 install_ubuntu.sh + ./install_ubuntu.sh --gitee + ``` + +3. 准备工作 3:在 Linux 环境下编译 PLCT 实验室提供的 [qemu](https://github.com/plctlab/plct-qemu), 参考 README.rst 中给出的编译方法编译 Linux 环境下的 qemu,或使用笔者编译好的 [qemu](https://github.com/Yaochenger/openhw-/releases/tag/qemu-linux)。 + +4. Windows 环境下载 [RT-Thread最新源码](https://github.com/RT-Thread/rt-thread/archive/refs/heads/master.zip),此步骤同样可以在 Linux 环境下完成。 + +5. Windows 环境下载当前 BSP 根目录下打开 Env 工具并执行以下命令编译,`scons --exec-path=xxx`,`xxx` 为工具链路径,Windows 下的工具链可以直接使用 RT-Studio 下载,工具链的路径依据用户的具体环境进行配置,此步骤同样可以在 Linux 环境下完成,示例命令如下: + + ```shell + scons --exec-path=D:\RT-ThreadStudio\repo\Extract\ToolChain_Support_Packages + \RISC-V\RISC-V-GCC-RV32\2022-04-12\bin + ``` + + 在指定工具链位置的同时直接编译,编译后生成 rtthread.elf 文件,编译结果如下: + + ![](figures/result0.png) + +6. 试运行 rtthread.elf,将上步生成的 rtthread.elf 拷贝到编到编译的 qemu 工具的 bin 文件目录下,执行以下命令 + + ```shell + ./qemu-system-riscv32 -M core_v_mcu -bios none -kernel rtthread.elf -nographic -monitor none -serial stdio + ``` + + 运行结果如下: + + ![](figures/test_result1.png) + +7. 运行以下命令生成完整可拷贝的工程 + + ```shell + scons --dist + ``` + + 将生成的独立工程拷贝到 Linux 环境下。 + +### 3.2Liunx 环境下编译运行工程 + +#### 3.2.1 配置工程 + +1. 在上文拷贝的完整的工程根目录下找到 **rtconfig.h**, 去掉该文件中的预编译命令, 一定要执行这步操作,否则会编译报错, 需要去掉的内容如下: + + ```c + #ifndef RT_CONFIG_H__ + #define RT_CONFIG_H__ + ... + #endif + ``` + + 去掉后的内容如下: + + ![remove ifdef](figures/remove_ifdef.png) + +2. 执行以下命令生成 makefile 工程 + + ```shell + scons --target=makefile + ``` + +3. 在命令行输入 **make** 编译工程 + +4. 运行以下命令,启动 qemu 运行编译出 rtthread.elf,`/home/wangshun/bin/qemu-riscv/bin/qemu-system-riscv32` 为 Linux 环境的工具链路径,这里设置为用户的工具链路径。 + + ```shell + /home/wangshun/bin/qemu-riscv/bin/qemu-system-riscv32 -M core_v_mcu -bios none -kernel rtthread.elf -nographic -monitor none -serial stdio + ``` + + BSP 支持 RT-Thread 的 Finsh 组件,输入 version 可以查看 rt-thread 的版本信息,Tab 键可以查看支持的命令,运行结果如下: + + ![test-result2](figures/test_result2.png) + + 至此,基于 core-v-mcu 的 RT-Thread 工程的配置与运行测试完成。 + +### 3.3 将 RT-Thread 工程导入 OpenHW 的 Core-V-IDE + +1. 下载安装 [core-v-sdk](https://github.com/openhwgroup/core-v-sdk), 按照[README.md](https://github.com/openhwgroup/core-v-sdk#readme) 中的步骤安装 Linux 环境下的 IDE。 + +2. 在主目录下创建 workspace 文件夹,打开 IDE 将 workspace 文件夹作为工作路径。 + +3. 选择 `Import projects` 选项 。 + + ![import_2](figures/import_2.png) + +4. 选择 `Existing Code as Makefile Project` 选项。 + + ![makefile project](figures/makefile_project.png) + +5. 设置如下 + + ![settings](figures/settings.png) + +6. 工程配置设置 + + ![Properites](figures/Properites.png) + +7. 修改编译命令 + + ![make](figures/make.png) + +8. 清空工程编译出的文件,重新编译工程 + + ![IDE-MAKE](figures/IDE_MAKE.png) + +9. 在使用 IDE 编译的工程的根目录下运行以下命令,结果和 **3.2.1** 运行的结果一致 IDE 下的工程便配置完成,至此,IDE 导入 core-v-mcu 的 RT-Thread 工程的导入与运行测试完成。 + + ```shell + /home/wangshun/bin/qemu-riscv/bin/qemu-system-riscv32 -M core_v_mcu -bios none -kernel rtthread.elf -nographic -monitor none -serial stdio + ``` + +### 3.4 调试配置 + +1. Debug Configurations 配置 + + ![debug](figures/debug.png) + +2. 双击 `GDB OpenOCD Debugging`,生成调试配置选项 + + ![openocd](figures/openocd.png) + +3. 导入内核寄存器文件 + + 文件路径 `OpenHW/CORE-V-SDKv0.0.0.4/registers/csr`, 具体路径根据用户安装的 SDK 路径配置。 + + ![register file](figures/register_file.png) + +4. 导入片上外设寄存器文件 + + 文件路径 `/home/wangshun/OpenHW/CORE-V-SDKv0.0.0.4/registers/peripheral`, 具体路径根据用户安装的 SDK 路径配置。 + + ![svd](figures/svd.png) + +5. 配置 qemu 运行环境 + + 取消 `Start OpenOCD locally` 的勾选,配置参数如下 + + ![debug2](figures/debug2.png) + +6. 运行下述指令 + + ```shell + /home/wangshun/bin/qemu-riscv/bin/qemu-system-riscv32 -M core_v_mcu -bios none -kernel rtthread.elf -nographic -monitor none -serial stdio -s -S + ``` + +7. 点击 debug 开始调试 + + ![run](figures/run.png) + +### 4.CLI 组件 + +​OPENHW 提供的 FreeRTOS 工程支持一个 CLI 组件用于测试,在使用 RT-Thread 时为了兼容原有的 CLI,所以将原来的 CLI 做成了独立的软件包,同时该软件包自动开启 FreeRTOS 兼容层,所以该软件包既可以支持原有的 CLI 组件,同时用户可以自行选择使用 FreeRTOS 的 API 或者 RT-Thread 的 API。 + +#### 4.1 使用方法 + +​在 Env 工具中使用 menuconfig 配置开启 CorevMCU_CLI 软件包,将 example.c 中的示例代码放到 main.c 提示的地方。使用 menuconfig 配置的步骤如下: + +```c +RT-Thread online packages + miscellaneous packages ---> + [*] CorevMCU_CLI +``` diff --git a/rt-thread-version/rt-thread-standard/tutorial/quick-start/qemu-vexpress-a9/quick-start.md b/rt-thread-version/rt-thread-standard/tutorial/quick-start/qemu-vexpress-a9/quick-start.md index e0999afd508faae5c326c72a2db87ded55ca58ae..cd189bc267794a25fffc7dc563ce1e35445fb109 100644 --- a/rt-thread-version/rt-thread-standard/tutorial/quick-start/qemu-vexpress-a9/quick-start.md +++ b/rt-thread-version/rt-thread-standard/tutorial/quick-start/qemu-vexpress-a9/quick-start.md @@ -8,7 +8,7 @@ 1. 获取 ENV 工具 - [官网下载](https://www.rt-thread.org/page/download.html),下载完成后,按照 Add_Env_To_Right-click_Menu 图片中的步骤将 Env 添加到右键启动菜单 + [官网下载](https://www.rt-thread.org/download.html),下载完成后,按照 Add_Env_To_Right-click_Menu 图片中的步骤将 Env 添加到右键启动菜单 2. 源码获取 diff --git a/rt-thread-version/rt-thread-standard/tutorial/smart-car/darknet-yolov2/darknet-yolov2.md b/rt-thread-version/rt-thread-standard/tutorial/smart-car/darknet-yolov2/darknet-yolov2.md index 6737e0412f50bb1b4fef67efb493ce0f209b00b0..a0624fe69b3ecd083499c7cb8dfc08f16a0683fe 100644 --- a/rt-thread-version/rt-thread-standard/tutorial/smart-car/darknet-yolov2/darknet-yolov2.md +++ b/rt-thread-version/rt-thread-standard/tutorial/smart-car/darknet-yolov2/darknet-yolov2.md @@ -33,7 +33,7 @@ darknet 是用 C 语言实现的,在 github 上也能找到开源的 [**源码 ### 参考文献 - [darknet](https://pjreddie.com/darknet/) -- [目标检测]() +- [目标检测](http://machinethink.net/blog/object-detection/) ## 1 准备训练集 diff --git a/rt-thread-version/rt-thread-standard/tutorial/smart-car/ros-connect/ros-connect.md b/rt-thread-version/rt-thread-standard/tutorial/smart-car/ros-connect/ros-connect.md index a023c393d02b01a5716d2b6ac8ec3244f95b928b..7cf0a3744cc284e042fdfc554066f6b49f66a6ed 100644 --- a/rt-thread-version/rt-thread-standard/tutorial/smart-car/ros-connect/ros-connect.md +++ b/rt-thread-version/rt-thread-standard/tutorial/smart-car/ros-connect/ros-connect.md @@ -611,7 +611,7 @@ $ rosrun rosserial_python serial_node.py tcp ### 3.3 参考文献 -- [RT-Thread 使用 ESP8266 上网](https://www.rt-thread.org/document/site/application-note/components/at/an0014-at-client/) +- [RT-Thread 使用 ESP8266 上网](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/application-note/components/at/an0014-at-client) ## 4 总结 diff --git a/rt-thread-version/rt-thread-standard/tutorial/smart-car/rplidar-connect/rplidar-connect.md b/rt-thread-version/rt-thread-standard/tutorial/smart-car/rplidar-connect/rplidar-connect.md index 59e1703ddef33f9fa61fa415b3e6c9329c73320a..4baedb2cad479368c6be815ca5fde4aada80d72c 100644 --- a/rt-thread-version/rt-thread-standard/tutorial/smart-car/rplidar-connect/rplidar-connect.md +++ b/rt-thread-version/rt-thread-standard/tutorial/smart-car/rplidar-connect/rplidar-connect.md @@ -14,7 +14,7 @@ 在开始介绍之前,需要准备好这些东西: -- 搭建好 RT-Thread 的环境 ([Git](https://git-scm.com/), [Env 工具](https://www.rt-thread.org/page/download.html), [RT-Thread 源码](https://www.rt-thread.org/page/download.html)) +- 搭建好 RT-Thread 的环境 ([Git](https://git-scm.com/), [Env 工具](https://www.rt-thread.org/download.html), [RT-Thread 源码](https://www.rt-thread.org/download.html)) - RPLidar A1 (或者其他A系列也可以) - STM32 (或者其他可以运行 RT-Thread 的开发板,需要有2个串口) diff --git a/rt-thread-version/rt-thread-standard/tutorial/temperature-system/ipc.md b/rt-thread-version/rt-thread-standard/tutorial/temperature-system/ipc.md index 9f6efaa15a250e83f10b5c84336431de6b6bc0f5..778190d05c41f5c06bb882ccf258550d98680438 100644 --- a/rt-thread-version/rt-thread-standard/tutorial/temperature-system/ipc.md +++ b/rt-thread-version/rt-thread-standard/tutorial/temperature-system/ipc.md @@ -14,7 +14,7 @@ ## 软件包的获取 -软件包可以通过 env 工具十分方便的获取到,并且加载到工程里面去,env 工具的下载链接可以在官网找到,[点击此处跳转](https://www.rt-thread.org/page/download.html)。env 的使用方法可以查看其教程进行学习,[点击此处跳转](https://www.rt-thread.org/document/site/tutorial/env-video/)。 +软件包可以通过 env 工具十分方便的获取到,并且加载到工程里面去,env 工具的下载链接可以在官网找到,[点击此处跳转](https://www.rt-thread.org/download.html)。env 的使用方法可以查看其教程进行学习,[点击此处跳转](https://www.rt-thread.org/document/site/#/development-tools/env/env)。 ![board](figures/env_download1.jpg) @@ -81,7 +81,7 @@ int main(void) ### 邮箱工作原理举例介绍 -RT-Thread 的文档中心已经有对邮箱和内存池原理上的详细讲解,[点击此处跳转](https://www.rt-thread.org/document/site/programming-manual/ipc2/ipc2/)至邮箱,[点击此处跳转](https://www.rt-thread.org/document/site/programming-manual/memory/memory/)至内存池。这里不在赘述。这里通过举一个生活中的例子,去帮助大家理解邮箱和内存池。 +RT-Thread 的文档中心已经有对邮箱和内存池原理上的详细讲解,[点击此处跳转](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/ipc2/ipc2?id=%e9%82%ae%e7%ae%b1)至邮箱,[点击此处跳转](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/memory/memory?id=%e5%86%85%e5%ad%98%e6%b1%a0)至内存池。这里不在赘述。这里通过举一个生活中的例子,去帮助大家理解邮箱和内存池。 如今,很多人购物都是通过电商平台购买,那避免不了是要收快递的。 @@ -307,7 +307,7 @@ msg = RT_NULL; 类比生活中的例子,存钱罐,发工资了(纸币),把一张张的钱放到存钱罐里去,你自己或者你对象需要花钱了,就从存钱罐里面取钱出来用。 -更多对消息队列的讲解,请查看 RT-Thread 文档中心,[点击此处跳转](https://www.rt-thread.org/document/site/programming-manual/ipc2/ipc2/#_13)。 +更多对消息队列的讲解,请查看 RT-Thread 文档中心,[点击此处跳转](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/ipc2/ipc2?id=%e6%b6%88%e6%81%af%e9%98%9f%e5%88%97)。 ### 在项目中运用消息队列 diff --git a/rt-thread-version/rt-thread-standard/tutorial/temperature-system/onenet.md b/rt-thread-version/rt-thread-standard/tutorial/temperature-system/onenet.md index d48112140f08794b25727a345f4f26147dc10e13..46fc72cc03ef484bcd4ed46097bf9e20ffd9be31 100644 --- a/rt-thread-version/rt-thread-standard/tutorial/temperature-system/onenet.md +++ b/rt-thread-version/rt-thread-standard/tutorial/temperature-system/onenet.md @@ -16,13 +16,13 @@ DIY 活动已经来到了尾声,本次的任务是整个项目中最有趣也 请务必先学习以下内容,再继续看本篇文章: -- OneNet 的产品创建与设备接入视频教程:[点击此处跳转](https://www.rt-thread.org/document/site/tutorial/qemu-network/onenet/onenet/) +- OneNet 的产品创建与设备接入视频教程:[点击此处跳转](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/tutorial/qemu-network/onenet/onenet) - OneNet 软件包简介与使用说明:[点击此处跳转](https://github.com/RT-Thread-packages/onenet) - AT Device 软件包简介与使用说明:[点击此处跳转](https://github.com/RT-Thread-packages/at_device) -- 《RT-Thread 编程指南》中 AT 组件的章节 :[点击此处跳转](https://www.rt-thread.org/document/site/programming-manual/at/at/) +- 《RT-Thread 编程指南》中 AT 组件的章节 :[点击此处跳转](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/at/at) - Paho MQTT 软件包简介与使用说明:[点击此处跳转](https://github.com/RT-Thread-packages/paho-mqtt) @@ -45,7 +45,7 @@ RT-Thread online packages ---> (512) The maximum length of receive line buffer ``` -开启 OneNet,完成相关参数配置,其中 `device id`、`auth info`、`api key`、`product id`、`master/product apikey` 这些参数如何配置请查看 OneNet 的产品创建与设备接入视频教程:[点此处跳转](https://www.rt-thread.org/document/site/tutorial/qemu-network/onenet/onenet/) +开启 OneNet,完成相关参数配置,其中 `device id`、`auth info`、`api key`、`product id`、`master/product apikey` 这些参数如何配置请查看 OneNet 的产品创建与设备接入视频教程:[点此处跳转](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/tutorial/qemu-network/onenet/onenet) ``` RT-Thread online packages ---> @@ -225,7 +225,7 @@ onenet_mqtt_upload_digit("temperature_p1", buf_mp->temperature_p1); ![board](figures/makeapp.png) -由于文章篇幅有限,这里就不详细展示如何制作应用了,更多内容,请查看 OneNet 的产品创建与设备接入视频教程:[点击此处跳转](https://www.rt-thread.org/document/site/tutorial/qemu-network/onenet/onenet/)。 +由于文章篇幅有限,这里就不详细展示如何制作应用了,更多内容,请查看 OneNet 的产品创建与设备接入视频教程:[点击此处跳转](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/tutorial/qemu-network/onenet/onenet)。 ## 6. 开源代码 diff --git a/rt-thread-version/rt-thread-standard/tutorial/temperature-system/sensor.md b/rt-thread-version/rt-thread-standard/tutorial/temperature-system/sensor.md index 36d7c92b7e0e8db7d2cf5e16c31d01ac7c924b42..77d3869da1f6a14379ce28a234538d10a9f75613 100644 --- a/rt-thread-version/rt-thread-standard/tutorial/temperature-system/sensor.md +++ b/rt-thread-version/rt-thread-standard/tutorial/temperature-system/sensor.md @@ -211,7 +211,7 @@ rt_hw_sensor_register(sensor_temp, name, RT_DEVICE_FLAG_RDONLY, RT_NULL); 哇!成功将 ds18b20 注册成传感器设备了,可喜可贺!!! -传感器驱动对接 Sensor 框架的操作中的更多细节,请在 RT-Thread 的文档中心中查看,[点击此处跳转](https://www.rt-thread.org/document/site/development-guide/sensor/sensor_driver_development/)。 +传感器驱动对接 Sensor 框架的操作中的更多细节,请在 RT-Thread 的文档中心中查看,[点击此处跳转](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/development-guide/sensor/sensor_driver_development)。 ## 在线程中读取温度数据