blob: 7365952b7498ac6ea577f02ea212e85f1b0cb15b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# RT-Thread for x86
## Intro
This x86 BSP support both newlib & picolib, with toolchain available
- **Newlib:** `i686-atxhua-newlib-elf-`
- **Picolibc:** `i686-atxhua-picolib-elf-`
## Install Toolchain
To install toolchain run the following command:
- **Newlib:** sudo ../../tools/ci/toolchain.sh i686-atxhua-newlib-elf-gcc
- **Picolibc:** sudo ../../tools/ci/toolchain.sh i686-atxhua-picolib-elf-gcc
## Configuration
Use `menuconfig` to select your preferred C library:
1. Run `scons --menuconfig`
2. Navigate to `X86 Features` -> `C Library type`
3. Select either `Newlib`(default) or `Picolibc`
## Building
After select the correct library in `menuconfig`, set the toolchain path and prefix:
### Newlib
```bash
export RTT_EXEC_PATH=/opt/i686-atxhua-newlib-elf-gcc/bin
export RTT_CC_PREFIX=i686-atxhua-newlib-elf-
scons
```
### Picolib
```bash
export RTT_EXEC_PATH=/opt/i686-atxhua-picolib-elf-gcc/bin
export RTT_CC_PREFIX=i686-atxhua-picolib-elf-
scons
```
## Result ELF
### Newlib
```
Memory region Used Size Region Size %age Used
i686-atxhua-newlib-elf-objcopy -O binary rtthread.elf rtthread.bin
i686-atxhua-newlib-elf-size rtthread.elf
text data bss dec hex filename
212900 3274 10844 227018 376ca rtthread.elf
scons: done building targets.
```
### Picolib
```
Memory region Used Size Region Size %age Used
i686-atxhua-picolib-elf-objcopy -O binary rtthread.elf rtthread.bin
i686-atxhua-picolib-elf-size rtthread.elf
text data bss dec hex filename
174122 2568 10528 187218 2db52 rtthread.elf
scons: done building targets.
```
这是一份基础的RT-Thread针对x86的版本、移植,主要是能够在qemu中执行。以下说明主要针对Linux的环境,如果是Windows环境,请使用Env工具,同时请自行处理生成iso的方法。
## 编译
编译RT-Thread for x86版本,还需要一份支持newlib的工具链,可以通过以下地址获得:
* [i386-unknown-elf_for_x86_64-pc-linux-gnu_latest.tar.bz2](http://117.143.63.254:9012/www/rt-smart/i386-unknown-elf_for_x86_64-pc-linux-gnu_latest.tar.bz2)
* [ GCC 15.2.0 w/ Newlib 4.6.0.20260123: https://github.com/atxhua/i686-atxhua-newlib-elf/releases/download/15.2.0/i686-atxhua-newlib-elf-linux.tar.gz ](https://github.com/atxhua/i686-atxhua-newlib-elf/releases/download/15.2.0/i686-atxhua-newlib-elf-linux.tar.gz)
* [ GCC 15.2.0 w/ Picolib 1.8.11: https://github.com/atxhua/i686-atxhua-picolib-elf/releases/download/15.2.0/i686-atxhua-picolib-elf-linux.tar.gz ](https://github.com/atxhua/i686-atxhua-picolib-elf/releases/download/15.2.0/i686-atxhua-picolib-elf-linux.tar.gz)
下载后解压,然后配置RTT_EXEC_PATH & RTT_CC_PREFIX 变量
```bash
export RTT_EXEC_PATH='/path/to/i686-atxhua-newlib-elf-linux/bin'
export RTT_CC_PREFIX='i686-atxhua-newlib-elf-'
```
rtconfig.py
```python
if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
EXEC_PATH = os.getenv('RTT_EXEC_PATH') or 'E:/Program Files/CodeSourcery/Sourcery_CodeBench_Lite_for_IA32_ELF/bin'
if PLATFORM == 'gcc':
# toolchains
PREFIX = os.getenv('RTT_CC_PREFIX') or 'i386-unknown-elf-'
```
然后在x86 bsp目录下执行scons命令来编译:
```bash
scons
```
### 配置
RT-Thread for x86的版本也支持menuconfig的配置方式,在Linux下可以使用`scons --menuconfig`的方式进行配置。
因为menuconfig是一份字符界面的配置(Kconfig),在ubuntu下需要安装ncurses5的库
```bash
sudo apt install libncurses5-dev
```
## 运行
在ubuntu下运行,请确保你安装了`qemu-system-i386`,`grub` 以及 `xorriso`软件包:
```bash
sudo apt install qemu-system-x86 grub-common xorriso
```
然后使用qemu来模拟执行
```bash
$ qemu-system-i386 -M pc -kernel rtthread.elf -nographic
SeaBIOS (version 1.16.3-debian-1.16.3-2)
iPXE (https://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+06FCAE00+06F0AE00 CA00
Booting from ROM..
\ | /
- RT - Thread Operating System
/ | \ 5.3.0 build May 10 2026 21:25:36
2006 - 2024 Copyright by RT-Thread team
Floppy Inc : NEC765B controller Floppy Type : 2.88MB
[I/DBG] root filesystem mounted.
hello!
msh />
```
在qemu下可以按Ctrl-A + X退出qemu。
|