Skip to content

Commit ccc41f5

Browse files
committed
✨ feat(tools): add cromfs support
1 parent abc5ff6 commit ccc41f5

5 files changed

Lines changed: 39 additions & 11 deletions

File tree

.gitattributes

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
*.xmind binary
1212
*.bmp binary
1313
*.exe binary
14-
fatdisk-x86 binary
15-
udb binary
1614
*.lzma binary
1715
*.zip binary
1816
*.Z binary
@@ -21,11 +19,15 @@ udb binary
2119
*.mo binary
2220
*.pb binary
2321
*.tga binary
24-
xfel binary
25-
make_ext4fs* binary
2622
*.deb binary
2723
*.bin binary
2824
*.img binary
2925

26+
cromfs-tool-* binary
27+
xfel binary
28+
make_ext4fs-* binary
29+
fatdisk-* binary
30+
udb binary
31+
3032
# These should also not be modified by git.
3133
*.svg -text

tools/cromfs/cromfs-tool-x86

721 KB
Binary file not shown.

tools/cromfs/cromfs-tool.exe

77 KB
Binary file not shown.

tools/scripts/tasks.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ do
3232
options = {
3333
{"f", "format", "kv", "ext4", "image format",
3434
" - ext4",
35-
" - fat"},
35+
" - fat",
36+
" - cromfs"},
3637
{"s", "size", "kv", "256M", "image size"},
3738
{"o", "output", "kv", nil, "output image dir"},
3839
{"r", "rootfs", "kv", nil, "rootfs dir"},

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

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
--
1313
-- Copyright (C) 2023-2023 RT-Thread Development Team
1414
--
15-
-- @author xqyjlj
15+
-- @author xqyjlj
1616
-- @file on_run.lua
1717
--
1818
-- Change Logs:
@@ -50,17 +50,40 @@ function make_fat(size, output, rootfs)
5050
local fatdisk_exec
5151
local fatdisk_dir = path.absolute("../../../fatdisk", os.scriptdir())
5252

53-
if not os.host() == "linux" then
53+
if os.host() == "windows" then
54+
fatdisk_exec = path.join(fatdisk_dir, "fatdisk.exe")
55+
elseif os.host() == "linux" then
56+
if os.is_arch("x86_64", "x86", "x64") then
57+
fatdisk_exec = path.join(fatdisk_dir, "fatdisk-x86")
58+
else
59+
os.raise("not support arch '%s'", os.arch())
60+
end
61+
else
5462
os.raise("not support host '%s'", os.host())
5563
end
5664

57-
if os.arch() == "x86_64" then
58-
fatdisk_exec = path.join(fatdisk_dir, "fatdisk-x86")
65+
os.vrunv(fatdisk_exec, {"--disk_size=" .. size, "--output=" .. output, "--input=" .. rootfs})
66+
end
67+
68+
function make_cromfs(output, rootfs)
69+
local target
70+
local rootfs_dir
71+
local cromfs_exec
72+
local cromfs_dir = path.absolute("../../../cromfs", os.scriptdir())
73+
74+
if os.host() == "windows" then
75+
cromfs_exec = path.join(cromfs_dir, "cromfs-tool.exe")
76+
elseif os.host() == "linux" then
77+
if os.is_arch("x86_64", "x86", "x64") then
78+
cromfs_exec = path.join(cromfs_dir, "cromfs-tool-x86")
79+
else
80+
os.raise("not support arch '%s'", os.arch())
81+
end
5982
else
60-
os.raise("not support arch '%s'", os.arch())
83+
os.raise("not support host '%s'", os.host())
6184
end
6285

63-
os.vrunv(fatdisk_exec, {"--disk_size=" .. size, "--output=" .. output, "--input=" .. rootfs})
86+
os.vrunv(cromfs_exec, {rootfs, output})
6487
end
6588

6689
function main()
@@ -93,6 +116,8 @@ function main()
93116
make_ext4(size, output, rootfs)
94117
elseif format == "fat" then
95118
make_fat(size, output, rootfs)
119+
elseif format == "cromfs" then
120+
make_cromfs(output, rootfs)
96121
else
97122
os.raise("unsupport format '%s'", format)
98123
end

0 commit comments

Comments
 (0)