diff options
author | Yongqin Liu <yongqin.liu@linaro.org> | 2024-04-24 10:48:05 +0800 |
---|---|---|
committer | Yongqin Liu <yongqin.liu@linaro.org> | 2024-04-24 10:48:05 +0800 |
commit | 8c4932c17a96b79e5bd56195f75a836fdffbd85e (patch) | |
tree | 4695213f06c318619acff0c11f1cdfd9581e2e40 | |
parent | 4b4ed43492d97ece06bef8e9bf67c5bd54176a8e (diff) |
android-tools: update the deploy scripts
to support network urls for deployments
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
-rwxr-xr-x | android-tools/db845c/db845c-deploy.sh | 52 | ||||
-rwxr-xr-x | android-tools/hikey/hikey-deploy.sh | 54 | ||||
-rwxr-xr-x | android-tools/hikey/hikey960-deploy.sh | 127 |
3 files changed, 193 insertions, 40 deletions
diff --git a/android-tools/db845c/db845c-deploy.sh b/android-tools/db845c/db845c-deploy.sh index 59ee8c0..4b6c9e9 100755 --- a/android-tools/db845c/db845c-deploy.sh +++ b/android-tools/db845c/db845c-deploy.sh @@ -42,9 +42,31 @@ fi # exit 1 #fi -function flash_image(){ - local partition=$1 - local file_img=$2 +##############common functions ############### + +function check_file_existence(){ + local target_file="${1}" + if echo "${target_file}"|grep -E "^http://|^https://"; then + is_xz_file=false + if wget --spider "${target_file}"; then + return 0 + elif wget --spider "${target_file}.xz"; then + return 0 + else + return 1 + fi + elif [ -f "${target_file}" ]; then + return 0 + elif [ -f "${target_file}.xz" ]; then + return 0 + fi + return 1 +} + +function fastboot_wrapper(){ + local fastboot_cmd="${1}" + local partition="${2}" + local file_img="${3}" if [ -z "${partition}" ] || [ -z "${file_img}" ]; then return fi @@ -93,17 +115,35 @@ function flash_image(){ echo "======= Flash ${partition} partition with file $file_img ==============" #/SATA3/nougat/out/host/linux-x86/bin/fastboot flash -w ${partition} ${file_img} - fastboot flash ${partition} ${file_img} - if [ $? -ne 0 ]; then + if [ "X${fastboot_cmd}" = "Xboot" ]; then + fastboot "${fastboot_cmd}" "${file_img}" + ret=$? + else + fastboot "${fastboot_cmd}" "${partition}" "${file_img}" + ret=$? + fi + if [ $ret -ne 0 ]; then echo "Failed to deploy ${file_img}" exit 1 elif ${temp_file}; then - rm ${file_img} + rm "${file_img}" fi # sleep 2 after flash sleep 2 } +function flash_image(){ + local partition="${1}" + local file_img="${2}" + fastboot_wrapper "flash" "${partition}" "${file_img}" +} + +function boot_image(){ + local file_img="${1}" + fastboot_wrapper "boot" "boot" "${file_img}" +} + +#### common functions ################### flash_image boot ${img_dir}/boot.img flash_image super ${img_dir}/super.img flash_image userdata ${img_dir}/userdata.img diff --git a/android-tools/hikey/hikey-deploy.sh b/android-tools/hikey/hikey-deploy.sh index 637d306..e99c7ff 100755 --- a/android-tools/hikey/hikey-deploy.sh +++ b/android-tools/hikey/hikey-deploy.sh @@ -42,9 +42,31 @@ fi # exit 1 #fi -function flash_image(){ - local partition=$1 - local file_img=$2 +##############common functions ############### + +function check_file_existence(){ + local target_file="${1}" + if echo "${target_file}"|grep -E "^http://|^https://"; then + is_xz_file=false + if wget --spider "${target_file}"; then + return 0 + elif wget --spider "${target_file}.xz"; then + return 0 + else + return 1 + fi + elif [ -f "${target_file}" ]; then + return 0 + elif [ -f "${target_file}.xz" ]; then + return 0 + fi + return 1 +} + +function fastboot_wrapper(){ + local fastboot_cmd="${1}" + local partition="${2}" + local file_img="${3}" if [ -z "${partition}" ] || [ -z "${file_img}" ]; then return fi @@ -93,17 +115,35 @@ function flash_image(){ echo "======= Flash ${partition} partition with file $file_img ==============" #/SATA3/nougat/out/host/linux-x86/bin/fastboot flash -w ${partition} ${file_img} - fastboot flash ${partition} ${file_img} - if [ $? -ne 0 ]; then + if [ "X${fastboot_cmd}" = "Xboot" ]; then + fastboot "${fastboot_cmd}" "${file_img}" + ret=$? + else + fastboot "${fastboot_cmd}" "${partition}" "${file_img}" + ret=$? + fi + if [ $ret -ne 0 ]; then echo "Failed to deploy ${file_img}" exit 1 elif ${temp_file}; then - rm ${file_img} + rm "${file_img}" fi # sleep 2 after flash sleep 2 } +function flash_image(){ + local partition="${1}" + local file_img="${2}" + fastboot_wrapper "flash" "${partition}" "${file_img}" +} + +function boot_image(){ + local file_img="${1}" + fastboot_wrapper "boot" "boot" "${file_img}" +} + +#### common functions ################### #flash_image fastboot "${FIRMWARE_DIR}"/fip.bin #flash_image boot ${img_dir}/boot_fat.uefi.img flash_image boot ${img_dir}/boot.img @@ -114,4 +154,4 @@ flash_image userdata ${img_dir}/userdata.img #fastboot flash -S 256M userdata ${img_dir}/userdata.img #fastboot reboot #fastboot continue -fastboot boot ${img_dir}/boot.img +boot_image ${img_dir}/boot.img diff --git a/android-tools/hikey/hikey960-deploy.sh b/android-tools/hikey/hikey960-deploy.sh index 6b998ba..4a5e391 100755 --- a/android-tools/hikey/hikey960-deploy.sh +++ b/android-tools/hikey/hikey960-deploy.sh @@ -1,7 +1,6 @@ -#!/bin/bash +#!/bin/bash -ex -#local_android_serial="616A34F301931D53" -local_android_serial="78B3BF5501937821" +local_android_serial="616A34F301931D53" local_android_product="hikey960" if adb devices|grep ${local_android_serial}; then @@ -38,48 +37,122 @@ else FIRMWARE_DIR="${img_dir}" fi -if ! [ -d ${img_dir} ]; then - echo "The specified path is not a directory:${img_dir}" - exit 1 -fi +#if ! [ -d ${img_dir} ]; then +# echo "The specified path is not a directory:${img_dir}" +# exit 1 +#fi -function flash_image(){ - local partition=$1 - local file_img=$2 +##############common functions ############### + +function check_file_existence(){ + local target_file="${1}" + if echo "${target_file}"|grep -E "^http://|^https://"; then + is_xz_file=false + if wget --spider "${target_file}"; then + return 0 + elif wget --spider "${target_file}.xz"; then + return 0 + else + return 1 + fi + elif [ -f "${target_file}" ]; then + return 0 + elif [ -f "${target_file}.xz" ]; then + return 0 + fi + return 1 +} + +function fastboot_wrapper(){ + local fastboot_cmd="${1}" + local partition="${2}" + local file_img="${3}" if [ -z "${partition}" ] || [ -z "${file_img}" ]; then return fi - if [ ! -e "${file_img}" ]; then - echo "${file_img} does not exist" + temp_file=false + if echo "${file_img}"|grep -E "^http://|^https://"; then + f_img_local=$(mktemp -u "/tmp/${partition}-XXX.img") + ## + wget -c http://192.168.1.14:8000/android/lkft/lkft-aosp-main-db845c/1662/images//cache.img --progress=dot:mega -O /tmp/cache-GNu.img + ## --2023-10-19 14:08:42-- http://192.168.1.14:8000/android/lkft/lkft-aosp-main-db845c/1662/images//cache.img + ## Connecting to 192.168.1.14:8000... connected. + ## HTTP request sent, awaiting response... 404 File not found + ## 2023-10-19 14:08:42 ERROR 404: File not found. + is_xz_file=false + if wget --spider "${file_img}"; then + cmd_wget="wget -c ${file_img} --progress=dot:giga -O ${f_img_local}" + elif wget --spider "${file_img}.xz"; then + cmd_wget="wget -c ${file_img}.xz --progress=dot:giga -O ${f_img_local}.xz" + is_xz_file=true + else + echo "Neither ${file_img} nor ${file_img}.xz exists" + return + fi + if ${cmd_wget}; then + ${is_xz_file} && xz -d "${f_img_local}.xz" + file_img="${f_img_local}" + temp_file=true + else + rm -f "${f_img_local}" + return + fi + fi + + if [ -f "${file_img}" ]; then + : + elif [ -f "${file_img}.xz" ]; then + f_img_local=$(mktemp -u "/tmp/${partition}-XXX.img") + if xz -c -d "${file_img}.xz" >"${f_img_local}"; then + temp_file=true + file_img="${f_img_local}" + else + return + fi + else + echo "Neither ${file_img} nor ${file_img}.xz exists" return fi echo "======= Flash ${partition} partition with file $file_img ==============" #/SATA3/nougat/out/host/linux-x86/bin/fastboot flash -w ${partition} ${file_img} - fastboot flash ${partition} ${file_img} - if [ $? -ne 0 ]; then + if [ "X${fastboot_cmd}" = "Xboot" ]; then + fastboot "${fastboot_cmd}" "${file_img}" + ret=$? + else + fastboot "${fastboot_cmd}" "${partition}" "${file_img}" + ret=$? + fi + if [ $ret -ne 0 ]; then echo "Failed to deploy ${file_img}" exit 1 + elif ${temp_file}; then + rm "${file_img}" fi # sleep 2 after flash sleep 2 } -if [ -f ${img_dir}/prm_ptable.img ]; then - flash_image ptable ${img_dir}/prm_ptable.img -elif [ -f ${img_dir}/super.img ]; then - flash_image ptable ${dir_parent}/prm_ptable-hikey960-super.img +function flash_image(){ + local partition="${1}" + local file_img="${2}" + fastboot_wrapper "flash" "${partition}" "${file_img}" +} + +function boot_image(){ + local file_img="${1}" + fastboot_wrapper "boot" "boot" "${file_img}" +} + +#### common functions ################### +if check_file_existence "${img_dir}/prm_ptable.img"; then + flash_image ptable "${img_dir}/prm_ptable.img" else - flash_image ptable ${dir_parent}/prm_ptable-hikey960-system.img + flash_image ptable ${dir_parent}/prm_ptable-hikey960-super.img fi flash_image boot ${img_dir}/boot.img -flash_image dts "${img_dir}"/dt.img -if [ -f ${img_dir}/super.img ]; then - flash_image super ${img_dir}/super.img -else - flash_image system ${img_dir}/system.img - flash_image vendor ${img_dir}/vendor.img -fi +#flash_image dts "${img_dir}"/dt.img +flash_image super ${img_dir}/super.img flash_image userdata ${img_dir}/userdata.img fastboot format cache -fastboot reboot +#fastboot reboot +boot_image ${img_dir}/boot.img |