rt-smart

说明

整理流程很像 linux, 先 load 内核,再加载 rootfs

配置

以 qemu-virt64-aarch64 为例

用户态

工具链需要通过编译用户态程序才能导出,有点奇怪

1
2
3
git clone --depth 1 https://github.com/RT-Thread/userapps.git
cd userapps; source env.sh
cd apps

下载工具链

1
xmake config --arch=aarch64 -y

导出 toolchain 需要先编译

每次修改完应用程序,都需要 xmake 一下

1
xmake

toolchain 在 apps/build/packages

sdk 在apps/build/sdk

1
xmake smart-rootfs --export=all

生成 rootfs,执行以后,在 apps/build/

如果需要把 zig 编译的程序放进去,可以放在这个里面, 实际测试,运行会崩溃

1
xmake smart-rootfs

生成磁盘镜像

1
xmake smart-image -f ext4

内核

toolchain 在 userapps/apps/build/packages 里面,复制出来

1
2
3
4
export RTT_CC="gcc"
export RTT_EXEC_PATH="./toolchain/bin/"
export RTT_CC_PREFIX="aarch64-linux-musleabi-"
export PATH="$RTT_EXEC_PATH:$PATH"

编译内核

1
2
3
git clone --depth 1 https://github.com/RT-Thread/rt-thread
cd rt-thread/bsp/qemu-virt64-aarch64/
scons --menuconfig
1
2
3
4
5
6
RT-Thread Kernel --->
[*] Enable RT-Thread Smart (microkernel on kernel/userland)

RT-Thread online packages --->
system packages --->
[*] lwext4: an excellent choice of ext2/3/4 filesystem for microcontrol
1
2
3
4
5
source ~/.env/env.sh
pkgs --update

scons -c; scons
# scons --dist

运行

1
cp ext4.img ../../../rt-thread/bsp/qemu-virt64-aarch64/

修改 qemu.sh 里面的 sd.bin 为 ext4.img

参考这里最后生成 prebuilt 的部分里面的 run.sh