Skip to content

Commit 9cbcd7a

Browse files
authored
Merge pull request #8 from Guohezu001/main
Add:"ci" and Optimized sd.image packing scripts
2 parents a92c434 + e4f10ce commit 9cbcd7a

File tree

4 files changed

+73
-10
lines changed

4 files changed

+73
-10
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
sudo add-apt-repository ppa:xmake-io/xmake -y
2020
sudo apt update
2121
sudo apt install -y nim
22-
sudo apt install -y xmake python3-pip
22+
sudo apt install -y xmake python3-pip qemu-system-aarch64
2323
pip install --upgrade pip
2424
pip install kconfiglib scons requests tqdm psutil
2525
@@ -31,4 +31,24 @@ jobs:
3131
cd models
3232
xmake -vyD
3333
'
34-
shell: bash
34+
shell: bash
35+
36+
- name: Set file permissions
37+
run: |
38+
chmod +r ./models/rtthread.bin
39+
chmod +r ./models/build/ext4.img
40+
ls -lh ./models/build/
41+
42+
- name: Upload Build Artifacts
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: build-artifacts
46+
path: |
47+
./models/rtthread.bin
48+
./models/build/ext4.img
49+
retention-days: 7
50+
51+
- name: Run QEMU and Execute /bin/hello
52+
run: |
53+
chmod +x ./.github/workflows/run_qemu.sh
54+
./.github/workflows/run_qemu.sh

.github/workflows/run_qemu.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# 启动 QEMU 并运行 rtthread.bin 和 ext4.img
4+
qemu-system-aarch64 -M virt,gic-version=2 -cpu cortex-a53 -m 128M -smp 4 -kernel ./models/rtthread.bin -nographic \
5+
-drive if=none,file=./models/build/ext4.img,format=raw,id=blk0 \
6+
-device virtio-blk-device,drive=blk0,bus=virtio-mmio-bus.0 \
7+
-netdev user,id=net0 -device virtio-net-device,netdev=net0,bus=virtio-mmio-bus.1 \
8+
-device virtio-serial-device \
9+
-chardev socket,host=127.0.0.1,port=4321,server=on,wait=off,telnet=on,id=console0 \
10+
-device virtserialport,chardev=console0 \
11+
-nographic \
12+
-append "console=ttyAMA0" &
13+
14+
# 等待 10 秒钟,以便 QEMU 启动并执行 /bin/hello
15+
sleep 10
16+
17+
# 在 QEMU 虚拟机上执行 /bin/hello 任务
18+
echo "Running /bin/hello in QEMU..."
19+
telnet 127.0.0.1 4321 <<EOF
20+
/bin/hello
21+
EOF
22+
23+
# 等待 10 秒后杀死 QEMU 进程
24+
sleep 10
25+
echo "Terminating QEMU..."
26+
pkill -f "qemu-system-aarch64"

repo/packages/r/rt-thread/xmake.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ do
5656
return config_key
5757
end
5858

59-
local vendor = get_config_values(config_file, "CONFIG_VENDOR_", "CONFIG_CHIP_MODEL_", "CONFIG_BOARD_", "CONFIG_KERNEL_SOURCE_")
59+
local vendor = get_config_values(config_file, "CONFIG_VENDOR_")
6060
local model = get_config_values(config_file, "CONFIG_CHIP_MODEL_")
6161
local board = get_config_values(config_file, "CONFIG_BOARD_")
6262
local company = get_config_values(config_file, "CONFIG_COMPANY_")

tools/scripts/tasks/sdk-image/on_run.lua

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ local function get_other_files_from_curdir()
106106
return files
107107
end
108108

109-
function main()
110-
109+
-- rk3500的sd.image打包函数
110+
local function packages_rk3500()
111111
-- 获取文件路径
112112
local rtthread_bin = get_kernel_from_curdir() -- 获取内核文件
113113
local rootfs_img = get_rootfs_from_curdir() -- 获取根文件系统
@@ -117,10 +117,7 @@ function main()
117117
local uboot_img = other_files.uboot
118118
local fdt = other_files.fdt
119119
local idbloader_img = other_files.idbloader
120-
121-
-- 删除现有镜像文件
122-
os.iorun("rm sd.img -f")
123-
120+
124121
-- 确保文件存在
125122
check_required_param(rtthread_bin, "kernel")
126123
check_required_param(uboot_img, "uboot")
@@ -131,7 +128,7 @@ function main()
131128
-- 镜像文件名
132129
local imgname = "sd.img"
133130
local pwd = os.getenv("PWD")
134-
131+
135132
-- 创建空白的 sd.img 文件并初始化
136133
os.execv("dd", {"if=/dev/zero", "of="..pwd .. "/" .. imgname, "bs=1M", "count=1000"})
137134
os.execv("ls -al")
@@ -161,3 +158,23 @@ function main()
161158
-- 清理临时的 boot.img 文件
162159
os.iorun("rm boot.img")
163160
end
161+
162+
function main()
163+
-- 删除现有镜像文件
164+
os.iorun("rm sd.img -f")
165+
166+
local config_file = ".config"
167+
local file = io.open(config_file, "r")
168+
local content = file:read("*all")
169+
file:close()
170+
local vendor = content:match("CONFIG_VENDOR_" .. "([^%s=]*)=y")
171+
local model = content:match("CONFIG_CHIP_MODEL_" .. "([^%s=]*)=y")
172+
print("sdk_vendor:",vendor)
173+
if vendor == "QEMU" then
174+
end
175+
if vendor == "ROCKCHIP" then
176+
if model == "RK3568" then
177+
packages_rk3500()
178+
end
179+
end
180+
end

0 commit comments

Comments
 (0)