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 index 1c01c8346eb57febc78f91a1cead07b0c13525d2..dc3cf1f68cd297bd5ee08a7ddad2a4b86b9aab11 100644 Binary files a/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/figures/prebuilt-file.png 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/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/quickstart.md b/rt-thread-version/rt-thread-smart/quick-start/qemu-linux/quickstart.md index f44be84510fd3ff319e72b674d85681cdcfea39b..1d95acf42beee61ccf23651394df3db809c89821 100644 --- 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 @@ -1,6 +1,8 @@ # QEMU 快速上手 (Linux) -本教程在 Ubuntu 平台上使用 QEMU 快速上手 RT-Smart,运行 RT-Smart 用户态应用,内核基于 qemu-vexpress-a9。 +本教程在 Ubuntu 平台上使用 QEMU 快速上手 RT-Smart,运行 RT-Smart 用户态应用,内核基于 qemu-vexpress-a9 ,其他内核可以用同样的方式运行。 + +> 注意:运行环境的 QEMU 版本太低会导致执行脚本后终端无输出。 ## 如何构建用户态应用 @@ -39,7 +41,7 @@ git clone https://github.com/RT-Thread/userapps.git python get_toolchain.py arm ``` -在 userapps 目录下, 运行 smart-env.sh 配置工具链路径,配置完会显示配置好的工具链路径。 +在 userapps 目录下, 运行 smart-env.sh 配置工具链路径,配置完会显示配置好的工具链路径。(这一步包括后面步骤编译内核都需要保留的工具链路径,重开一个终端都要重新source一次) ``` source smart-env.sh arm @@ -55,50 +57,10 @@ source smart-env.sh arm ![image-20221021145335403](figures/build_app-res.png) -## 运行用户态应用 - -在本仓库的 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`。 - -![image-20221024180626302](figures/qemu_run.png) - -Smart 运行起来后输入 ls 可以看到我们存储到 QEMU SD 卡里的文件和文件夹了。 - -![image-20221024180816610](figures/qemu_run2.png) - -在最后执行了 hello 示例,输出 "hello world!"。 - -执行 ctrl a,x 可退出 QEMU。 ## 构建内核镜像 -当需要更新内核镜像文件时,查看本节内容。 +rt-thread 中默认的镜像并非 Smart 需要先编译替换 下载 rt-thread 源码(如有则跳过),之后切换到 rt-smart 分支并从远端同步更新。(RT-Thread 版本大于等于 5.0.0 时,直接查看下面的注意事项) @@ -124,18 +86,21 @@ git pull origin rt-smart > > ``` > 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. 首先是使能 Smart 内核 +> 1. 选择 RT-Thread Kernel 选项 +> +> ![img](figures/smart-cfg-first-stages.png) > -> ![img](figures/samrt-cfg.png) > -> 2. 打开 Isolated user space 选项,之后退出并保存 +> 2. 使能 Smart 内核 +> +> ![img](figures/samrt-cfg.png) > -> ![img](figures/usr-space-cfg.png) > > 3. 然后在该目录下执行 scons 编译 > @@ -143,7 +108,60 @@ git pull origin rt-smart > > ![image-20221021153136199](figures/build_kernel2.png) > -> 将生成的内核镜像 rtthread.bin 更新到 userapps\prebuilt\ qemu-vexpress-a9 目录即可。 +> 将生成的内核镜像 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。