From e8ab9e73d09cf76348d48ac1d3c7715cf7702a93 Mon Sep 17 00:00:00 2001 From: hzy Date: Sun, 9 Oct 2022 01:22:26 +0800 Subject: [PATCH] Wrap `/lib/fel-load.sh` as function --- lib/{fel-load.sh => functions/extras/fel.sh} | 48 ++++++++++---------- lib/functions/main/rootfs-image.sh | 2 +- 2 files changed, 26 insertions(+), 24 deletions(-) rename lib/{fel-load.sh => functions/extras/fel.sh} (80%) diff --git a/lib/fel-load.sh b/lib/functions/extras/fel.sh similarity index 80% rename from lib/fel-load.sh rename to lib/functions/extras/fel.sh index 31dbefe535..1cf2dc823c 100644 --- a/lib/fel-load.sh +++ b/lib/functions/extras/fel.sh @@ -74,27 +74,29 @@ fel_load() { write 0x43100000 "${FEL_ROOTFS}"/boot/boot.scr } -if [[ -f $USERPATCHES_PATH/fel-hooks.sh ]]; then - display_alert "Using additional FEL hooks in" "userpatches/fel-hooks.sh" "info" - # shellcheck source=/dev/null - source "$USERPATCHES_PATH"/fel-hooks.sh -fi +function start_fel_boot() { + if [[ -f $USERPATCHES_PATH/fel-hooks.sh ]]; then + display_alert "Using additional FEL hooks in" "userpatches/fel-hooks.sh" "info" + # shellcheck source=/dev/null + source "$USERPATCHES_PATH"/fel-hooks.sh + fi -# basic sanity check -if [[ -n $FEL_ROOTFS ]]; then - fel_prepare_host - fel_prepare_target - [[ $(type -t fel_post_prepare) == function ]] && fel_post_prepare - RES=b - while [[ $RES != q ]]; do - if [[ $FEL_AUTO != yes ]]; then - display_alert "Connect device in FEL mode and press" "" "info" - read -r - fi - fel_load - display_alert "Press any key to boot again, to finish" "FEL" "info" - read -r -n 1 RES - echo - done - service nfs-kernel-server restart -fi + # basic sanity check + if [[ -n $FEL_ROOTFS ]]; then + fel_prepare_host + fel_prepare_target + [[ $(type -t fel_post_prepare) == function ]] && fel_post_prepare + RES=b + while [[ $RES != q ]]; do + if [[ $FEL_AUTO != yes ]]; then + display_alert "Connect device in FEL mode and press" "" "info" + read -r + fi + fel_load + display_alert "Press any key to boot again, to finish" "FEL" "info" + read -r -n 1 RES + echo + done + service nfs-kernel-server restart + fi +} diff --git a/lib/functions/main/rootfs-image.sh b/lib/functions/main/rootfs-image.sh index d20a93a418..9847350cef 100644 --- a/lib/functions/main/rootfs-image.sh +++ b/lib/functions/main/rootfs-image.sh @@ -100,7 +100,7 @@ PRE_INSTALL_DISTRIBUTION_SPECIFIC if [[ $ROOTFS_TYPE == fel ]]; then FEL_ROOTFS=$SDCARD/ display_alert "Starting FEL boot" "$BOARD" "info" - source $SRC/lib/fel-load.sh + start_fel_boot else prepare_partitions create_image