mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
Add hook to allow forcing uboot update
This commit is contained in:
@@ -9,3 +9,25 @@ KERNEL_TARGET="current,edge"
|
||||
KERNEL_TEST_TARGET="current"
|
||||
FULL_DESKTOP="yes"
|
||||
BOOT_SOC="rk3288"
|
||||
|
||||
function tinkerboard_uboot_postinst(){
|
||||
[[ $DEVICE == /dev/null ]] && exit 0
|
||||
if [[ -z $DEVICE ]]; then
|
||||
DEVICE="/dev/mmcblk0"
|
||||
# proceed to other options.
|
||||
[ ! -b $DEVICE ] && DEVICE="/dev/mmcblk1"
|
||||
[ ! -b $DEVICE ] && DEVICE="/dev/mmcblk2"
|
||||
fi
|
||||
[[ $(type -t setup_write_uboot_platform) == function ]] && setup_write_uboot_platform
|
||||
if [[ -b $DEVICE ]]; then
|
||||
echo "Updating u-boot on $DEVICE" >&2
|
||||
write_uboot_platform $DIR $DEVICE
|
||||
sync
|
||||
else
|
||||
echo "Device $DEVICE does not exist, skipping" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
function pre_package_uboot_image__tinkerboard_update_uboot_postinst_script(){
|
||||
postinst_functions+=('tinkerboard_uboot_postinst')
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ BOOTPATCHDIR="u-boot-meson-s4t7"
|
||||
BOOTENV_FILE='meson.txt'
|
||||
BOOTSCRIPT="boot-meson-s4t7.cmd:boot.cmd"
|
||||
FORCE_BOOTSCRIPT_UPDATE="yes"
|
||||
FORCE_UBOOT_UPDATE="yes"
|
||||
UBOOT_TARGET_MAP=";;fip/_tmp/u-boot.bin.sd.bin.signed:u-boot.bin.sd.bin.signed"
|
||||
|
||||
## funny enough, the uboot+fip blobs go in the same spot as normal meson64...
|
||||
|
||||
@@ -74,7 +74,7 @@ function artifact_uboot_prepare_version() {
|
||||
# Hash the extension hooks
|
||||
declare -a extension_hooks_to_hash=(
|
||||
"post_uboot_custom_postprocess" "fetch_custom_uboot" "build_custom_uboot"
|
||||
"pre_config_uboot_target" "post_config_uboot_target"
|
||||
"pre_config_uboot_target" "post_config_uboot_target" "pre_package_uboot_image"
|
||||
)
|
||||
declare -a extension_hooks_hashed=("$(dump_extension_method_sources_functions "${extension_hooks_to_hash[@]}")")
|
||||
declare hash_hooks="undetermined"
|
||||
|
||||
@@ -103,6 +103,7 @@ function compile_armbian-bsp-cli() {
|
||||
INITRD_ARCH=$INITRD_ARCH
|
||||
KERNEL_IMAGE_TYPE=$KERNEL_IMAGE_TYPE
|
||||
FORCE_BOOTSCRIPT_UPDATE=$FORCE_BOOTSCRIPT_UPDATE
|
||||
FORCE_UBOOT_UPDATE=$FORCE_UBOOT_UPDATE
|
||||
VENDOR="$VENDOR"
|
||||
VENDORDOCS="$VENDORDOCS"
|
||||
VENDORURL="$VENDORURL"
|
||||
|
||||
@@ -368,30 +368,18 @@ function compile_uboot() {
|
||||
|
||||
display_alert "Preparing u-boot general packaging" "${version} ${target_make}"
|
||||
|
||||
# set up postinstall script # @todo: extract into a tinkerboard extension
|
||||
if [[ $BOARD == tinkerboard ]]; then
|
||||
cat <<- EOF > "$uboottempdir/DEBIAN/postinst"
|
||||
#!/bin/bash
|
||||
source /usr/lib/u-boot/platform_install.sh
|
||||
[[ \$DEVICE == /dev/null ]] && exit 0
|
||||
if [[ -z \$DEVICE ]]; then
|
||||
DEVICE="/dev/mmcblk0"
|
||||
# proceed to other options.
|
||||
[ ! -b \$DEVICE ] && DEVICE="/dev/mmcblk1"
|
||||
[ ! -b \$DEVICE ] && DEVICE="/dev/mmcblk2"
|
||||
fi
|
||||
[[ \$(type -t setup_write_uboot_platform) == function ]] && setup_write_uboot_platform
|
||||
if [[ -b \$DEVICE ]]; then
|
||||
echo "Updating u-boot on \$DEVICE" >&2
|
||||
write_uboot_platform \$DIR \$DEVICE
|
||||
sync
|
||||
else
|
||||
echo "Device \$DEVICE does not exist, skipping" >&2
|
||||
fi
|
||||
exit 0
|
||||
EOF
|
||||
chmod 755 "$uboottempdir/DEBIAN/postinst"
|
||||
fi
|
||||
local -a postinst_functions=()
|
||||
local destination=$uboottempdir
|
||||
|
||||
call_extension_method "pre_package_uboot_image" <<- 'PRE_PACKAGE_UBOOT_IMAGE'
|
||||
*allow making some last minute changes before u-boot is packaged*
|
||||
This should be implemented by the config to tweak the uboot package, after the board or family has had the chance to.
|
||||
You can write to `$destination` here and it will be packaged.
|
||||
You can also append to the `postinst_functions` array, and the _content_ of those functions will be added to the postinst script.
|
||||
PRE_PACKAGE_UBOOT_IMAGE
|
||||
|
||||
artifact_package_hook_helper_board_side_functions "postinst" uboot_postinst_base "${postinst_functions[@]}"
|
||||
unset uboot_postinst_base postinst_functions destination
|
||||
|
||||
# declare -f on non-defined function does not do anything (but exits with errors, so ignore them with "|| true")
|
||||
cat <<- EOF > "$uboottempdir/usr/lib/u-boot/platform_install.sh"
|
||||
@@ -434,3 +422,21 @@ function compile_uboot() {
|
||||
display_alert "Built u-boot deb OK" "linux-u-boot-${BOARD}-${BRANCH} ${artifact_version}" "info"
|
||||
return 0 # success
|
||||
}
|
||||
|
||||
function uboot_postinst_base() {
|
||||
# Source the armbian-release information file
|
||||
[ -f /etc/armbian-release ] && . /etc/armbian-release
|
||||
source /usr/lib/u-boot/platform_install.sh
|
||||
|
||||
if [ "${FORCE_UBOOT_UPDATE:-no}" == "yes" ]; then
|
||||
#recognize_root
|
||||
root_uuid=$(sed -e 's/^.*root=//' -e 's/ .*$//' < /proc/cmdline)
|
||||
root_partition=$(blkid | tr -d '":' | grep "${root_uuid}" | awk '{print $1}')
|
||||
root_partition_name=$(echo $root_partition | sed 's/\/dev\///g')
|
||||
root_partition_device_name=$(lsblk -ndo pkname $root_partition)
|
||||
root_partition_device=/dev/$root_partition_device_name
|
||||
|
||||
write_uboot_platform "$DIR" "${root_partition_device}"
|
||||
sync
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user