Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
付燕斌
android-image-pack-tool
Commits
1df097a2
Commit
1df097a2
authored
Sep 06, 2024
by
fuyanbin
Browse files
test build rochip image
parent
a4b5f319
Changes
2
Hide whitespace changes
Inline
Side-by-side
pack-ci.sh
View file @
1df097a2
...
...
@@ -58,9 +58,11 @@ update_img_tmp_dir="$build_dir/img_dir"
super_img_tmp_dir
=
"
$build_dir
/img_dir/super"
ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME
=
"system_a"
ROCKCHIP_DEFAULT_SYSTEM_PARTITION_NAME
=
"system"
is_amlogic
=
0
is_allwinner
=
0
is_rockchip
=
0
outfile_path
=
""
...
...
@@ -137,6 +139,28 @@ resize_system_image() {
losetup
-d
"
$loopdev
"
}
__unpack_super_img
()
{
local
system_partition_name
=
"
$1
"
super_file
=
"
$update_img_tmp_dir
/update.img.dump/super.fex"
super_file_ext4
=
"
$update_img_tmp_dir
/update.img.dump/super.fex.ext4"
if
file
"
$super_file
"
|
grep
"Android sparse image"
then
simg2img
"
$super_file
"
"
$super_file_ext4
"
lpunpack
"
$super_file_ext4
"
"
$super_img_tmp_dir
"
else
lpunpack
"
$super_file
"
"
$super_img_tmp_dir
"
fi
systemfile
=
"
$super_img_tmp_dir
/
${
system_partition_name
}
.img"
systemfile_ext4
=
"
$super_img_tmp_dir
/
${
system_partition_name
}
.img.ext4"
if
file
"
$systemfile
"
|
grep
"Android sparse image"
then
resize_system_image
"
$systemfile_ext4
"
else
resize_system_image
"
$systemfile
"
fi
}
unpack_and_mount_image
()
{
local
img
=
"
$1
"
local
loopdev
...
...
@@ -159,34 +183,20 @@ unpack_and_mount_image() {
cp
"
$img
"
"
$update_img_tmp_dir
/update.img"
imgrepacker /skip
"
$update_img_tmp_dir
/update.img"
rm
-f
"
$update_img_tmp_dir
/update.img"
super_file
=
"
$update_img_tmp_dir
/update.img.dump/super.fex"
super_file_ext4
=
"
$update_img_tmp_dir
/update.img.dump/super.fex.ext4"
if
file
"
$super_file
"
|
grep
"Android sparse image"
then
simg2img
"
$super_file
"
"
$super_file_ext4
"
lpunpack
"
$super_file_ext4
"
"
$super_img_tmp_dir
"
else
lpunpack
"
$super_file
"
"
$super_img_tmp_dir
"
fi
systemfile
=
"
$super_img_tmp_dir
/
${
ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME
}
.img"
systemfile_ext4
=
"
$super_img_tmp_dir
/
${
ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME
}
.img.ext4"
if
file
"
$systemfile
"
|
grep
"Android sparse image"
then
resize_system_image
"
$systemfile_ext4
"
else
resize_system_image
"
$systemfile
"
fi
__unpack_super_img
"
$ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME
"
else
local
update_img
=
"
${
build_dir
}
/
$(
basename
"
$img
"
)
-update.img"
is_amlogic
=
0
img_unpack
"
$img
"
"
$update_img
"
# fix: afptool 只能用相对路径创建Image目录
pushd
"
$build_dir
"
afptool
-unpack
"
$update_img
"
"./img_dir"
popd
systemfile
=
"
$update_img_tmp_dir
/Image/system.img"
systemfile_ext4
=
"
$update_img_tmp_dir
/Image/system.img.ext4"
echo
"Rockchip Format Detected.."
is_rockchip
=
1
cp
"
$img
"
"
$update_img_tmp_dir
/update.img"
mkdir
-p
"
$update_img_tmp_dir
/update.img.dump"
rkImageMaker
-unpack
"
$update_img_tmp_dir
/update.img"
"
$update_img_tmp_dir
/update.img.dump"
afptool
-unpack
"
$update_img_tmp_dir
/update.img.dump/firmware.img"
"
$update_img_tmp_dir
/update.img.dump"
rm
-f
"
$update_img_tmp_dir
/update.img"
rm
-f
"
$update_img_tmp_dir
/update.img.dump/firmware.img"
rm
-f
"
$update_img_tmp_dir
/update.img.dump/boot.bin"
__unpack_super_img
"
$ROCKCHIP_DEFAULT_SYSTEM_PARTITION_NAME
"
fi
if
file
"
$systemfile
"
|
grep
"Android sparse image"
...
...
@@ -293,6 +303,99 @@ install_dianxin() {
pack_image
"
$img
"
}
__pack_super_img
()
{
local
system_partition_name
=
"
$1
"
local
c_super_file
if
[[
-f
"
$super_file_ext4
"
]]
then
c_super_file
=
"
$super_file_ext4
"
else
c_super_file
=
"
$super_file
"
fi
local
c_group_name
c_group_name
=
"
$(
get_group_name
"
$c_super_file
"
"
$system_partition_name
"
)
"
if
validate_partition_size_change
"
$c_super_file
"
"
$system_partition_name
"
then
lpadd
--readonly
\
--replace
\
"
$c_super_file
"
\
"
$system_partition_name
"
\
"
$c_group_name
"
\
"
$systemfile
"
if
[[
-f
"
$super_file_ext4
"
]]
then
img2simg
"
$super_file_ext4
"
"
$super_file
"
rm
-rf
"
$super_file_ext4
"
fi
else
repack.sh
"
$c_super_file
"
"
$c_group_name
"
"
$systemfile
"
"
$system_partition_name
"
mv
"
$(
dirname
"
$c_super_file
"
)
/super.new.img"
"
$c_super_file
"
fi
}
__get_chip_from_parameter
()
{
local
parameter_file
local
chip
local
arg
parameter_file
=
"
$1
"
chip
=
$(
grep
"MACHINE:"
"
$parameter_file
"
|
grep
-P
-o
"rk
\d
+"
)
chip
=
${
chip
^^
}
case
$chip
in
PX30
|
RK3358
)
parameter
=
"RKPX30"
;;
RK1808
|
RK3399PRO_NPU
)
parameter
=
"RK180A"
;;
RK3036
)
parameter
=
"RK303A"
;;
RK3126
|
RK3128
)
parameter
=
"RK312A"
;;
RK3128H
)
parameter
=
"RK312X"
;;
RK3229
)
parameter
=
"RK3229"
;;
RK3288
)
parameter
=
"RK320A"
;;
RK3308
)
parameter
=
"RK3308"
;;
RK3326
)
parameter
=
"RK3326"
;;
RK3328
)
parameter
=
"RK322H"
;;
RK3399
)
parameter
=
"RK330C"
;;
RK3568
)
parameter
=
"RK3568"
;;
RK3566
)
parameter
=
"RK3568"
;;
RK3562
)
parameter
=
"RK3562"
;;
RK3588
)
parameter
=
"RK3588"
;;
RV1126
)
parameter
=
"RK1126"
;;
*
)
echo
"Bad MACHINE_MODEL:
$chip
in parameter.txt"
esac
printf
"%s"
"
$parameter
"
}
pack_image
()
{
local
img
img
=
"
$1
"
...
...
@@ -316,42 +419,22 @@ pack_image() {
elif
[[
"
$is_allwinner
"
==
"1"
]]
then
echo
"Allwinner PhoenixSute Image Format Detected.."
local
c_super_file
=
if
[[
-f
"
$super_file_ext4
"
]]
then
c_super_file
=
"
$super_file_ext4
"
else
c_super_file
=
"
$super_file
"
fi
local
c_group_name
c_group_name
=
"
$(
get_group_name
"
$c_super_file
"
"
$ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME
"
)
"
if
validate_partition_size_change
"
$c_super_file
"
"
$ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME
"
then
lpadd
--readonly
\
--replace
\
"
$c_super_file
"
\
"
$ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME
"
\
"
$c_group_name
"
\
"
$systemfile
"
if
[[
-f
"
$super_file_ext4
"
]]
then
img2simg
"
$super_file_ext4
"
"
$super_file
"
rm
-rf
"
$super_file_ext4
"
fi
else
repack.sh
"
$c_super_file
"
"
$c_group_name
"
"
$systemfile
"
"
$ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME
"
mv
"
$(
dirname
"
$c_super_file
"
)
/super.new.img"
"
$c_super_file
"
fi
__pack_super_img
"
$ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME
"
sleep
5
imgrepacker
"
$update_img_tmp_dir
/update.img.dump"
mv
"
$update_img_tmp_dir
/update.img"
"
$outfile_path
"
else
local
update_img_tmp_dir
=
"
$build_dir
/img_dir"
find
"
$update_img_tmp_dir
/Image/"
-name
parameter.txt
-exec
cp
{}
"
$update_img_tmp_dir
/parameter"
\;
afptool
-pack
"
$update_img_tmp_dir
"
"
${
outfile_path
}
.tmp"
cp
"
$build_dir
/img_dir/Image/MiniLoaderAll.bin"
"
${
packge_dir
}
/MiniLoaderAll.bin"
img_maker
"
${
packge_dir
}
/MiniLoaderAll.bin"
"
${
outfile_path
}
.tmp"
"
$outfile_path
"
elif
[[
"
$is_rockchip
"
==
"1"
]]
then
echo
"Rockchip Image Format Detected.."
__pack_super_img
"
$ROCKCHIP_DEFAULT_SYSTEM_PARTITION_NAME
"
cp
-f
"
$update_img_tmp_dir
/update.img.dump/MiniLoaderAll.bin"
"
$update_img_tmp_dir
/update.img.dump/Image/MiniLoaderAll.bin"
cp
-f
"
$update_img_tmp_dir
/update.img.dump/parameter.txt"
"
$update_img_tmp_dir
/update.img.dump/Image/parameter.txt"
afptool
-pack
"
$update_img_tmp_dir
"
"
$update_img_tmp_dir
/update.img"
local
chip_parameter
chip_parameter
=
"
$(
__get_chip_from_parameter
"
${
update_img_tmp_dir
}
/parameter.txt"
)
"
# e.g. rkImageMaker -RK322H output/MiniLoaderAll.bin output/Image/update.img update.img -os_type:androidos
rkImageMaker
"-
${
chip_parameter
}
"
-os_type
:androidos
\
"
$update_img_tmp_dir
/MiniLoaderAll.bin"
"
$update_img_tmp_dir
/update.img"
"
$outfile_path
"
fi
rm
-rf
"
$build_dir
"
}
...
...
tools/rockchip_tool/rkImageMaker
0 → 100755
View file @
1df097a2
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment