Commit 1df097a2 authored by fuyanbin's avatar fuyanbin
Browse files

test build rochip image

parent a4b5f319
...@@ -58,9 +58,11 @@ update_img_tmp_dir="$build_dir/img_dir" ...@@ -58,9 +58,11 @@ update_img_tmp_dir="$build_dir/img_dir"
super_img_tmp_dir="$build_dir/img_dir/super" super_img_tmp_dir="$build_dir/img_dir/super"
ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME="system_a" ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME="system_a"
ROCKCHIP_DEFAULT_SYSTEM_PARTITION_NAME="system"
is_amlogic=0 is_amlogic=0
is_allwinner=0 is_allwinner=0
is_rockchip=0
outfile_path="" outfile_path=""
...@@ -137,6 +139,28 @@ resize_system_image() { ...@@ -137,6 +139,28 @@ resize_system_image() {
losetup -d "$loopdev" 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() { unpack_and_mount_image() {
local img="$1" local img="$1"
local loopdev local loopdev
...@@ -159,34 +183,20 @@ unpack_and_mount_image() { ...@@ -159,34 +183,20 @@ unpack_and_mount_image() {
cp "$img" "$update_img_tmp_dir/update.img" cp "$img" "$update_img_tmp_dir/update.img"
imgrepacker /skip "$update_img_tmp_dir/update.img" imgrepacker /skip "$update_img_tmp_dir/update.img"
rm -f "$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" __unpack_super_img "$ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME"
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
else else
local update_img="${build_dir}/$(basename "$img")-update.img" echo "Rockchip Format Detected.."
is_amlogic=0 is_rockchip=1
img_unpack "$img" "$update_img" cp "$img" "$update_img_tmp_dir/update.img"
# fix: afptool 只能用相对路径创建Image目录 mkdir -p "$update_img_tmp_dir/update.img.dump"
pushd "$build_dir" rkImageMaker -unpack "$update_img_tmp_dir/update.img" "$update_img_tmp_dir/update.img.dump"
afptool -unpack "$update_img" "./img_dir" afptool -unpack "$update_img_tmp_dir/update.img.dump/firmware.img" "$update_img_tmp_dir/update.img.dump"
popd rm -f "$update_img_tmp_dir/update.img"
systemfile="$update_img_tmp_dir/Image/system.img" rm -f "$update_img_tmp_dir/update.img.dump/firmware.img"
systemfile_ext4="$update_img_tmp_dir/Image/system.img.ext4" rm -f "$update_img_tmp_dir/update.img.dump/boot.bin"
__unpack_super_img "$ROCKCHIP_DEFAULT_SYSTEM_PARTITION_NAME"
fi fi
if file "$systemfile" | grep "Android sparse image" if file "$systemfile" | grep "Android sparse image"
...@@ -293,6 +303,99 @@ install_dianxin() { ...@@ -293,6 +303,99 @@ install_dianxin() {
pack_image "$img" 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() { pack_image() {
local img local img
img="$1" img="$1"
...@@ -316,42 +419,22 @@ pack_image() { ...@@ -316,42 +419,22 @@ pack_image() {
elif [[ "$is_allwinner" == "1" ]] elif [[ "$is_allwinner" == "1" ]]
then then
echo "Allwinner PhoenixSute Image Format Detected.." echo "Allwinner PhoenixSute Image Format Detected.."
local c_super_file= __pack_super_img "$ALLWINNER_DEFAULT_SYSTEM_PARTITION_NAME"
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
sleep 5 sleep 5
imgrepacker "$update_img_tmp_dir/update.img.dump" imgrepacker "$update_img_tmp_dir/update.img.dump"
mv "$update_img_tmp_dir/update.img" "$outfile_path" mv "$update_img_tmp_dir/update.img" "$outfile_path"
else elif [[ "$is_rockchip" == "1" ]]
local update_img_tmp_dir="$build_dir/img_dir" then
find "$update_img_tmp_dir/Image/" -name parameter.txt -exec cp {} "$update_img_tmp_dir/parameter" \; echo "Rockchip Image Format Detected.."
afptool -pack "$update_img_tmp_dir" "${outfile_path}.tmp" __pack_super_img "$ROCKCHIP_DEFAULT_SYSTEM_PARTITION_NAME"
cp "$build_dir/img_dir/Image/MiniLoaderAll.bin" "${packge_dir}/MiniLoaderAll.bin" cp -f "$update_img_tmp_dir/update.img.dump/MiniLoaderAll.bin" "$update_img_tmp_dir/update.img.dump/Image/MiniLoaderAll.bin"
img_maker "${packge_dir}/MiniLoaderAll.bin" "${outfile_path}.tmp" "$outfile_path" 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 fi
rm -rf "$build_dir" rm -rf "$build_dir"
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment