-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[project]Optimize the arm2d project directory structure.
- Loading branch information
Showing
28 changed files
with
1,814 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
projects/arm2d/vision_board_mipi_2.0inch_arm2d/board/ports/arm2d/SConscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from building import * | ||
import os | ||
|
||
cwd = GetCurrentDir() | ||
group = [] | ||
src = Glob('*.c') | ||
CPPPATH = [cwd] | ||
|
||
group = group + DefineGroup('arm2d_app', src, depend = [''], CPPPATH = CPPPATH) | ||
Return('group') |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions
12
projects/arm2d/vision_board_mipi_2.0inch_arm2d/packages/SConscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import os | ||
from building import * | ||
|
||
objs = [] | ||
cwd = GetCurrentDir() | ||
list = os.listdir(cwd) | ||
|
||
for item in list: | ||
if os.path.isfile(os.path.join(cwd, item, 'SConscript')): | ||
objs = objs + SConscript(os.path.join(item, 'SConscript')) | ||
|
||
Return('objs') |
61 changes: 61 additions & 0 deletions
61
...m2d/vision_board_mipi_2.0inch_arm2d/packages/rt_vsnprintf_full-latest/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# rt_vsnprintf 完整功能版本 | ||
|
||
在RT-Thread的kservice.c源码中的这些函数的实现是为了满足RT-Thread内核的自持能力,即在不依赖标准C库的情况下,RT-Thread核心代码也可以正常运行,因此rt_kprintf、rt_sprintf、rt_snprintf、rt_vsnprintf这类打印函数(或者称之为rt_kprintf家族函数)仅仅满足内核的使用需求,不会实现完整的、和标准C库一致的功能,以减少ROM占用。但是,很多社区小伙伴希望rt_kprintf家族函数可以支持上更多的功能(例如打印浮点数据等等)。因此,本软件包实现了该功能。 | ||
|
||
本软件包实现了rt_kprintf家族函数的全功能版本,因为rt_kprintf家族函数的核心功能都是调用rt_vsnprintf函数,因此只需要重新实现rt_vsnprintf函数即可。本软件包基于开源项目[printf](https://github.com/eyalroz/printf)重新实现了rt_vsnprintf,在4.1.0以及以上的RT-Thread版本中,只需要安装本软件包即可。若RT-Thread低于4.1.0版本,需要手动将kservice.c内的rt_vsnprintf函数注释掉,再安装本软件包。 | ||
|
||
关于newlib下使用自带printf函数的问题可以参考这边帖子的评论区:https://club.rt-thread.org/ask/article/2b0a1d202135b205.html | ||
|
||
## 接管标准C库的printf家族函数(仅支持4.1.0及以上版本) | ||
本软件包有三个功能宏开关,是否允许本软件包接管printf、sprintf以及snprintf函数,默认为yes,即接管。 | ||
也就是说,安装本软件包后,即便没有使能libc(RT_USING_LIBC),你可以正常的使用printf、sprintf以及snprintf函数,当你调用这三个函数时,会自动被rt_kprintf、rt_sprintf、rt_snprintf函数接管。你可以正常使用printf家族函数的所有功能。 | ||
|
||
```c | ||
#include <stdio.h> | ||
|
||
printf("hello world\n"); | ||
``` | ||
## ROM占用 | ||
GCC下占用8.6KB, Keil下占用8KB。远小于开启标准C库的ROM占用。 | ||
## 如何添加该软件包 | ||
``` | ||
RT-Thread online packages | ||
system packages ---> | ||
enhanced kernel services ---> | ||
[*] rt_vsnprintf_full: fully functional version of rt_vsnprintf ---> | ||
Version (latest) ---> | ||
``` | ||
- 使用 `RT-Thread Studio` 打开 `RT-Thread Settings`, 点击添加软件包,输入关键字 `printf`, 添加 `rt_vsnprintf_full` 软件包,保存 | ||
![1](figures/1.png) | ||
- 软件包目录下多出了一个 `rt_vsnprintf_full-latest` 包 | ||
![2](figures/2.png) | ||
- 打开 rt_vsnprintf.c,发现其中也实现了 rt_vsnprintf | ||
```c | ||
rt_int32_t rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args) | ||
{ | ||
return __vsnprintf(out_buffer, buf, size, fmt, args); | ||
} | ||
``` | ||
|
||
- 注释掉 kservice.c 中的 rt_vsnprintf **(只针对4.1.0版本以下)** | ||
|
||
- 重新编译并运行 `rt_kprintf ` 和 `LOG_I`, 浮点数打印正常 | ||
![3](figures/3.png) | ||
|
||
|
||
|
||
## 维护 | ||
|
||
[Meco Man](https://github.com/mysterywolf) | ||
|
14 changes: 14 additions & 0 deletions
14
projects/arm2d/vision_board_mipi_2.0inch_arm2d/packages/rt_vsnprintf_full-latest/SConscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from building import * | ||
|
||
src = ['rt_vsnprintf.c'] | ||
CPPDEFINES = [] | ||
|
||
if GetDepend('RT_VSNPRINTF_FULL_REPLACING_SPRINTF'): | ||
CPPDEFINES += ['sprintf=rt_sprintf'] | ||
if GetDepend('RT_VSNPRINTF_FULL_REPLACING_SNPRINTF'): | ||
CPPDEFINES += ['snprintf=rt_snprintf'] | ||
if GetDepend('RT_VSNPRINTF_FULL_REPLACING_PRINTF'): | ||
CPPDEFINES += ['printf=rt_kprintf'] | ||
|
||
group = DefineGroup('rt_kprintf', src, depend = ['PKG_USING_RT_VSNPRINTF_FULL'], CPPDEFINES = CPPDEFINES) | ||
Return('group') |
Binary file added
BIN
+43.2 KB
...vision_board_mipi_2.0inch_arm2d/packages/rt_vsnprintf_full-latest/figures/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+36.8 KB
...vision_board_mipi_2.0inch_arm2d/packages/rt_vsnprintf_full-latest/figures/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.9 KB
...vision_board_mipi_2.0inch_arm2d/packages/rt_vsnprintf_full-latest/figures/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.