Skip to content

Commit 6e0d71f

Browse files
committed
* [maixcam2] add gen_sd_os.sh
* bind maixpy version to 4.12.5
1 parent e7d7236 commit 6e0d71f

File tree

5 files changed

+565
-9
lines changed

5 files changed

+565
-9
lines changed

maix/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
version_major = 4
55
version_minor = 12
6-
version_patch = 4
6+
version_patch = 5
77

88
__version__ = "{}.{}.{}".format(version_major, version_minor, version_patch)

tools/os/maixcam2/axp-tools/axp_tools/axp2img.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ def compress_to_xz_auto(src_path, dst_path, threads=0):
123123
with open(src_path, 'rb') as src, lzma.open(dst_path, 'wb') as dst:
124124
shutil.copyfileobj(src, dst)
125125

126+
def compress_to_7z_auto(src_path, dst_path, threads=0):
127+
if shutil.which("7z"):
128+
print("Compress with system's 7z command")
129+
cmd = ["7z", "a", "-v2g", "-mx9", f"-mmt{threads}", dst_path, src_path]
130+
subprocess.run(cmd, check=True)
131+
else:
132+
print("7z command not found")
133+
126134
def check_env():
127135
if not shutil.which("simg2img"):
128136
print("[ERROR] simg2img command not found, please install first")
@@ -135,7 +143,10 @@ def axp2img(arg_input, arg_output):
135143
if not check_env():
136144
return -1
137145

138-
file_name = os.path.splitext(os.path.basename(arg_input))[0]
146+
file_name = os.path.splitext(os.path.basename(arg_output))[0]
147+
while file_name.endswith(".img"):
148+
file_name = os.path.splitext(file_name)[0]
149+
139150
if os.path.isfile(arg_input):
140151
input_dir = os.path.abspath(os.path.dirname(arg_input))
141152
temp_dir = os.path.join(input_dir, "temp")
@@ -153,7 +164,7 @@ def axp2img(arg_input, arg_output):
153164
if not arg_output:
154165
arg_output = os.path.join(out_dir, f"{file_name}.img.xz")
155166

156-
supported_format = [".xz", ".img"]
167+
supported_format = [".xz", ".img", ".7z"]
157168
format = os.path.splitext(arg_output)[1]
158169
if format not in supported_format:
159170
print(f"Not support output format {format}, supported: {supported_format}")
@@ -251,7 +262,14 @@ def axp2img(arg_input, arg_output):
251262
print("xz compress complete, remove img file")
252263
os.remove(out_img_path)
253264
print("xz file saved to", arg_output)
254-
265+
elif arg_output.endswith(".7z"):
266+
print("\nCompress to 7z format:")
267+
print(" from:", out_img_path)
268+
print(" to:", arg_output)
269+
compress_to_7z_auto(out_img_path, arg_output)
270+
print("7z compress complete, remove img file")
271+
os.remove(out_img_path)
272+
print("7z file saved to", arg_output)
255273
if temp_dir:
256274
shutil.rmtree(temp_dir)
257275

tools/os/maixcam2/gen_os.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ builtin_files_dir_path=$3
5353
skip_build_apps=0
5454
board_name=maixcam
5555
generate_axp_full=0
56+
package_method="7z"
5657

5758
# 如果提供了第五个参数且不为空,则将 skip_build_apps 设置为 1
5859
if [ -n "$4" ]; then
@@ -73,7 +74,7 @@ if [ -n "$5" ]; then
7374
fi
7475
fi
7576

76-
check_axp2img_command
77+
# check_axp2img_command
7778

7879
if [ -n "$6" ]; then
7980
if [ "x$6" == "x1" ]; then
@@ -229,14 +230,15 @@ echo "Now update system image, need sudo permition to mount rootfs:"
229230
sudo ./update_img.sh $base_os_path tmp/sys_builtin_files $delete_first_files
230231
echo "Complete: os dir: tmp2/axp"
231232

233+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
232234
mkdir -p images
233-
echo "Now convert to binary img file: images/${os_version_str}.img.xz"
234-
# need install simg2img and xz tool first
235+
echo "Now convert to binary img file: images/${os_version_str}.img.${package_method}"
235236
sudo chmod 777 tmp2/axp
236-
axp2img -i tmp2/axp -o images/${os_version_str}.img.xz
237+
# axp2img
238+
python ${SCRIPT_DIR}/axp-tools/axp_tools/axp2img.py -i tmp2/axp -o images/${os_version_str}.img.${package_method}
237239
rm -rf tmp2/axp/out tmp2/axp/temp
238240
sync
239-
echo "Complete convert to binary img file: images/${os_version_str}.img.xz"
241+
echo "Complete convert to binary img file: images/${os_version_str}.img.${package_method}"
240242

241243
echo "Now zip boot_parts axp file"
242244
mkdir -p tmp2/axp2

0 commit comments

Comments
 (0)