Skip to content

Commit

Permalink
Correct TEXT_OFFSET name
Browse files Browse the repository at this point in the history
  • Loading branch information
ophub committed Apr 15, 2022
1 parent 1142fcb commit 40c7e24
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 32 deletions.
9 changes: 4 additions & 5 deletions build-armbian/common-files/rootfs/usr/sbin/armbian-install
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# Copyright (C) 2021 https://github.com/ophub/amlogic-s9xxx-armbian
#
# Command: armbian-install
# Kernel version 5.10.y or newer is recommended to install mainline u-boot
# Command optional parameters: armbian-install <mainline_u-boot>
# The mainline u-boot is installed by default: armbian-install
# Don't write mainline u-boot command: armbian-install no
#==========================================================================
Expand Down Expand Up @@ -41,7 +41,8 @@ fi
DEV_EMMC="/dev/${install_emmc}"
echo "DEV_EMMC: ${DEV_EMMC}"

# Check the text_offset of zImage, For u-boot.ext and u-boot.emmc
# Get kernel TEXT_OFFSET, For u-boot.ext and u-boot.emmc
K510="1"
temp_script="$(mktemp)"
cat >${temp_script} <<EOF
use strict;
Expand All @@ -55,9 +56,7 @@ close(\$fh);
my \$str = unpack 'H*', \$buf;
print "\$str\n";
EOF
K510="1"
vmlinuz_text_offset="$(perl "${temp_script}" "/boot/zImage")"
[ "${vmlinuz_text_offset}" == "00000801" ] && K510="0"
[[ "$(perl "${temp_script}" "/boot/zImage")" == "00000801" ]] && K510="0"
rm -f ${temp_script} 2>/dev/null

# Generate New ROOTFS UUID
Expand Down
39 changes: 15 additions & 24 deletions build-armbian/common-files/rootfs/usr/sbin/armbian-update
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#
# Command: armbian-update
# Command optional parameters: armbian-update <kernel_version> <version_branch> <mainline_u-boot>
# The kernel above version 5.10 needs to install mainline u-boot
# The mainline u-boot is installed by default: armbian-update
# Don't write mainline u-boot command: armbian-update 5.4.170 stable no
#===================================================================================================
Expand All @@ -34,10 +33,18 @@ error_msg() {
exit 1
}

get_k510_from_vmlinuz() {
local vmlinuz="${1}"
local temp_script="$(mktemp)"
cat >$temp_script <<EOF
# Get kernel TEXT_OFFSET, For u-boot.ext and u-boot.emmc
get_textoffset_from_tgz() {
boot_tgz_file="${1}"
vmlinuz_name="${2}"
K510="1"
temp_dir="$(mktemp -d)"
(
cd ${temp_dir}
tar -xzf "${boot_tgz_file}" "${vmlinuz_name}"
)
temp_script="$(mktemp)"
cat >${temp_script} <<EOF
use strict;
my \$filename = \$ARGV[0];
open my \$fh, '<', \$filename or die;
Expand All @@ -49,24 +56,8 @@ close(\$fh);
my \$str = unpack 'H*', \$buf;
print "\$str\n";
EOF
local result="1"
local text_offset="$(perl "${temp_script}" "${vmlinuz}")"
[ "${text_offset}" == "00000801" ] && result="0"
rm -f $temp_script
echo "${result}"
}

get_k510_from_boot_tgz() {
local boot_tgz="${1}"
local vmlinuz="${2}"
local temp_dir="$(mktemp -d)"
(
cd ${temp_dir}
tar xzf "${boot_tgz}" "${vmlinuz}"
)
local result=$(get_k510_from_vmlinuz "${temp_dir}/${vmlinuz}")
rm -rf ${temp_dir} 2>/dev/null
echo "${result}"
[[ "$(perl "${temp_script}" "${temp_dir}/${vmlinuz_name}")" == "00000801" ]] && K510="0"
rm -rf ${temp_script} ${temp_dir} 2>/dev/null
}

# Check release file
Expand Down Expand Up @@ -214,7 +205,7 @@ if [ $(ls ${tmp_path}/*${inputs_kernel}*.tar.gz -l 2>/dev/null | grep "^-" | wc
KERNEL_VERSION=$(echo ${custom_kernel_name} | grep -oE '^[1-9].[0-9]{1,3}.[0-9]+')
echo -e "custom_kernel_name: ${custom_kernel_name}"

K510="$(get_k510_from_boot_tgz "${build_boot_abs}" "vmlinuz-${custom_kernel_name}")"
get_textoffset_from_tgz "${build_boot_abs}" "vmlinuz-${custom_kernel_name}"
echo -e "K510 [ ${K510} ]"
if [[ "${K510}" -eq "1" ]]; then
[[ -n "${UBOOT_OVERLOAD}" && -f "/boot/${UBOOT_OVERLOAD}" ]] || error_msg "The UBOOT_OVERLOAD file is missing and cannot be update."
Expand Down
5 changes: 2 additions & 3 deletions rebuild
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#
# error_msg : Output error message
# process_msg : Output process message
# get_textoffset : Get Kernel TextOffset
# get_textoffset : Get kernel TEXT_OFFSET
#
# init_var : Initialize all variables
# find_armbian : Find Armbian file (build/output/images/*.img)
Expand Down Expand Up @@ -112,8 +112,7 @@ close(\$fh);
my \$str = unpack 'H*', \$buf;
print "\$str\n";
EOF
vmlinuz_text_offset="$(perl "${temp_script}" "${vmlinuz_name}")"
[ "${vmlinuz_text_offset}" == "00000801" ] && K510="0"
[[ "$(perl "${temp_script}" "${vmlinuz_name}")" == "00000801" ]] && K510="0"
rm -f ${temp_script} 2>/dev/null
}

Expand Down

0 comments on commit 40c7e24

Please sign in to comment.