Skip to content

Commit b34fe81

Browse files
authored
Merge pull request #1 from Guohezu001/main
init_store: a tool similar to "Buildroot" that can automatically compile and generate an image for flashing onto an SD card.
2 parents 731c143 + 936eb51 commit b34fe81

File tree

295 files changed

+31112
-2
lines changed

Some content is hidden

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

295 files changed

+31112
-2
lines changed

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# 可执行文件
2+
*.exe
3+
*.dll
4+
*.so
5+
*.elf
6+
*.bin
7+
*.hex
8+
*.axf
9+
*.pdb
10+
11+
# 对象文件和库文件
12+
*.o
13+
*.obj
14+
*.lib
15+
*.a
16+
17+
# 编译相关的临时文件
18+
*.dep
19+
*.i
20+
*.d
21+
*.dfinish
22+
*.su
23+
*.bak
24+
*.old
25+
*.crf
26+
*.dblite
27+
28+
# xmake 相关
29+
build/
30+
.xmake/
31+
xmake.lua.bak
32+
xmake.lua~
33+
xmake_require_lock.lua
34+
xmake_requires.lua
35+
xmake_requires_lock.lua
36+
xmake_logs/

README.md

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,89 @@
1-
# smart-build
2-
build kernel/rootfs/bootloader for rt-smart
1+
# 介绍与快速入门
2+
3+
> 本文档环境为 `ubuntu 20.04`
4+
5+
## 介绍
6+
7+
### RT-Thread-Smart
8+
9+
RT-Thread Smart(以下简称 Smart) 是基于 RT-Thread 操作系统上的混合操作系统,简称为 rt-smart,它把应用从内核中独立出来,形成独立的用户态应用程序,并具备独立的地址空间(32 位系统上是 4G 的独立地址空间)。详细信息请见 [RT-Thread 文档中心](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-smart/introduction/rt-smart-intro/rt-smart-intro)
10+
11+
### Xmake
12+
13+
xmake 是一个基于 Lua 的轻量级跨平台构建工具,使用 xmake.lua 维护项目构建,相比 makefile/CMakeLists.txt,配置语法更加简洁直观,对新手非常友好,短时间内就能快速入门,能够让用户把更多的精力集中在实际的项目开发上。详细信息请见 [Xmake 文档中心](https://xmake.io/#/zh-cn/about/introduction)
14+
15+
## 快速入门
16+
17+
![image-20241211512457800](./assets/image-20241211512457800.png)
18+
19+
> 此次以 qemu-virt64-aarch64 为例讲解
20+
21+
1. **安装 xmake及kconfiglib库**
22+
23+
请根据 [xmake 官方文档](https://xmake.io/#/zh-cn/guide/installation?id=ubuntu) 进行安装。
24+
25+
以下为 ubuntu 安装方式
26+
27+
```shell
28+
sudo add-apt-repository ppa:xmake-io/xmake
29+
sudo apt update
30+
sudo apt install xmake
31+
pip install kconfiglib
32+
```
33+
34+
2. **克隆仓库**
35+
36+
将 Smart 的 userapps 仓库克隆下来, 假定我们的工作路径是 `$WS`
37+
38+
```shell
39+
cd $WS
40+
git clone https://github.com/RT-Thread/smart-build.git
41+
```
42+
43+
3. **选择我们想要编译的开发板及应用**
44+
45+
文件系统由多个应用程序组成,这些应用程序都放在 `apps` 目录下。由于 smart 采用 xmake 编译用户态环境,因此 smart 的编译方式非常简单。
46+
47+
首先进入 userapps 并运行 `env.sh` 添加一下环境变量。
48+
49+
```shell
50+
cd $WS/userapps
51+
source ./env.sh
52+
```
53+
54+
进入 models 目录进行选择
55+
56+
```shell
57+
cd models
58+
xmake menu #进入菜单选择界面
59+
```
60+
61+
![image-20241211173829621](./assets/image-20241211173829621.png)
62+
63+
目前支持的平台:arm、aarch64、riscv64gc。
64+
65+
![image-20230531173059551](./assets/image-20230531173059551.png)
66+
67+
68+
4. **制作镜像文件**
69+
70+
运行 `xmake` 制作image镜像,所谓制作文件系统,就是将上一步编译生成的用户程序按照文件系统的布局拷贝到 `$WS/userapps/models/build/rootfs` 路径下,并根据提前写好的on_run.lua脚本打包生成特定格式的 image 文件。
71+
72+
```shell
73+
xmake
74+
```
75+
76+
目前支持的镜像格式包括 ext4/fat/cromfs。
77+
78+
这里的例子会在 `$WS/userapps/models/build` 路径下生成 `ext4.img` 文件。
79+
80+
![image-20241211512457899.png](./assets/image-20241211512457899.png)
81+
82+
## prebuilt 的版本
83+
84+
会在每天凌晨生成 aarch64/riscv64 for qemu 的 prebuilt 版本,包括内核和 rootfs 文件系统:
85+
86+
- [aarch64](https://download-redirect.rt-thread.org/download/rt-smart/prebuilt/qemu-virt64-aarch64_latest.tar.gz)
87+
- [riscv64](https://download-redirect.rt-thread.org/download/rt-smart/prebuilt/qemu-virt64-riscv_latest.tar.gz)
88+
89+
可以使用 qemu 来运行起来。

apps/busybox/xmake.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
-- Licensed under the Apache License, Version 2.0 (the "License");
2+
-- You may not use this file except in compliance with the License.
3+
-- You may obtain a copy of the License at
4+
--
5+
-- http://www.apache.org/licenses/LICENSE-2.0
6+
--
7+
-- Unless required by applicable law or agreed to in writing, software
8+
-- distributed under the License is distributed on an "AS IS" BASIS,
9+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
-- See the License for the specific language governing permissions and
11+
-- limitations under the License.
12+
--
13+
-- Copyright (C) 2022-2023 RT-Thread Development Team
14+
--
15+
-- @author xqyjlj
16+
-- @file xmake.lua
17+
--
18+
-- Change Logs:
19+
-- Date Author Notes
20+
-- ------------ ---------- -----------------------------------------------
21+
-- 2023-06-21 xqyjlj initial version
22+
--
23+
24+
add_rules("mode.debug", "mode.release")
25+
26+
add_requires("busybox")
27+
28+
target("busybox")
29+
do
30+
set_kind("phony")
31+
add_packages("busybox")
32+
end
33+
target_end()

apps/cpp/main.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2006-2018, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: GPL-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2020-10-20 Bernard The first version
9+
*/
10+
11+
#include <iostream>
12+
using namespace std;
13+
14+
int main()
15+
{
16+
cout << "Hello, World!" << endl;
17+
return 0;
18+
}

apps/cpp/xmake.lua

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- Licensed under the Apache License, Version 2.0 (the "License");
2+
-- You may not use this file except in compliance with the License.
3+
-- You may obtain a copy of the License at
4+
--
5+
-- http://www.apache.org/licenses/LICENSE-2.0
6+
--
7+
-- Unless required by applicable law or agreed to in writing, software
8+
-- distributed under the License is distributed on an "AS IS" BASIS,
9+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
-- See the License for the specific language governing permissions and
11+
-- limitations under the License.
12+
--
13+
-- Copyright (C) 2022-2023 RT-Thread Development Team
14+
--
15+
-- @author xqyjlj
16+
-- @file xmake.lua
17+
--
18+
-- Change Logs:
19+
-- Date Author Notes
20+
-- ------------ ---------- -----------------------------------------------
21+
-- 2023-03-10 xqyjlj initial version
22+
--
23+
add_rules("mode.debug", "mode.release")
24+
25+
target("cpp_tc")
26+
do
27+
add_rules("rt.cpp")
28+
add_files("*.cpp")
29+
add_values("rt.rootfs.prefixdir", "/tc")
30+
end
31+
target_end()

apps/ffmpeg/xmake.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
-- Licensed under the Apache License, Version 2.0 (the "License");
2+
-- You may not use this file except in compliance with the License.
3+
-- You may obtain a copy of the License at
4+
--
5+
-- http://www.apache.org/licenses/LICENSE-2.0
6+
--
7+
-- Unless required by applicable law or agreed to in writing, software
8+
-- distributed under the License is distributed on an "AS IS" BASIS,
9+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
-- See the License for the specific language governing permissions and
11+
-- limitations under the License.
12+
--
13+
-- Copyright (C) 2022-2023 RT-Thread Development Team
14+
--
15+
-- @author zbtrs
16+
-- @file xmake.lua
17+
--
18+
-- Change Logs:
19+
-- Date Author Notes
20+
-- ------------ ---------- -----------------------------------------------
21+
-- 2023-08-09 zbtrs initial version
22+
--
23+
24+
add_rules("mode.debug", "mode.release")
25+
26+
add_requires("ffmpeg")
27+
28+
target("ffmpeg")
29+
do
30+
set_kind("phony")
31+
add_packages("ffmpeg")
32+
end
33+
target_end()

apps/hello/main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2006-2018, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: GPL-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2020-10-20 Bernard The first version
9+
*/
10+
11+
#include <stdio.h>
12+
13+
int main(int argc, char **argv)
14+
{
15+
printf("hello world!\n");
16+
17+
return 0;
18+
}

apps/hello/xmake.lua

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
-- Licensed under the Apache License, Version 2.0 (the "License");
2+
-- You may not use this file except in compliance with the License.
3+
-- You may obtain a copy of the License at
4+
--
5+
-- http://www.apache.org/licenses/LICENSE-2.0
6+
--
7+
-- Unless required by applicable law or agreed to in writing, software
8+
-- distributed under the License is distributed on an "AS IS" BASIS,
9+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
-- See the License for the specific language governing permissions and
11+
-- limitations under the License.
12+
--
13+
-- Copyright (C) 2022-2023 RT-Thread Development Team
14+
--
15+
-- @author xqyjlj
16+
-- @file xmake.lua
17+
--
18+
-- Change Logs:
19+
-- Date Author Notes
20+
-- ------------ ---------- -----------------------------------------------
21+
-- 2023-03-10 xqyjlj initial version
22+
--
23+
add_rules("mode.debug", "mode.release")
24+
25+
target("hello")
26+
do
27+
add_files("*.c")
28+
end
29+
target_end()

apps/micropython/xmake.lua

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
-- Licensed under the Apache License, Version 2.0 (the "License");
2+
-- You may not use this file except in compliance with the License.
3+
-- You may obtain a copy of the License at
4+
--
5+
-- http://www.apache.org/licenses/LICENSE-2.0
6+
--
7+
-- Unless required by applicable law or agreed to in writing, software
8+
-- distributed under the License is distributed on an "AS IS" BASIS,
9+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
-- See the License for the specific language governing permissions and
11+
-- limitations under the License.
12+
--
13+
-- Copyright (C) 2022-2023 RT-Thread Development Team
14+
--
15+
-- @author xqyjlj
16+
-- @file xmake.lua
17+
--
18+
-- Change Logs:
19+
-- Date Author Notes
20+
-- ------------ ---------- -----------------------------------------------
21+
-- 2023-06-21 xqyjlj initial version
22+
--
23+
add_rules("mode.debug", "mode.release")
24+
25+
add_requires("micropython")
26+
27+
target("micropython")
28+
do
29+
set_kind("phony")
30+
add_packages("micropython")
31+
end
32+
target_end()

0 commit comments

Comments
 (0)