Merge pull request #246 from fbelavenuto/110-compatibility-hp-g7-n54l

Added function to boot directly to DSM from Grub
This commit is contained in:
Fabio Belavenuto 2022-10-13 13:45:34 -03:00 committed by GitHub
commit 5bdfb60f46
11 changed files with 39 additions and 16 deletions

View File

@ -18,6 +18,9 @@ printf "\033[1;44m%*s\033[0m\n" ${COLUMNS} ""
TITLE="BOOTING..."
printf "\033[1;33m%*s\033[0m\n" $(((${#TITLE}+${COLUMNS})/2)) "${TITLE}"
history -w
sync
# Check if DSM zImage changed, patch it if necessary
ZIMAGE_HASH="`readConfigKey "zimage-hash" "${USER_CONFIG_FILE}"`"
if [ "`sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print$1}'`" != "${ZIMAGE_HASH}" ]; then
@ -110,7 +113,7 @@ for KEY in ${!CMDLINE[@]}; do
done
# Escape special chars
CMDLINE_LINE=`echo ${CMDLINE_LINE} | sed 's/>/\\\\>/g'`
grub-editenv ${GRUB_PATH}/grubenv set dsm_cmdline="${CMDLINE_LINE}"
echo -e "Cmdline:\n\033[1;36m${CMDLINE_LINE}\033[0m"
# Wait for an IP
@ -130,11 +133,17 @@ while true; do
echo -n "."
done
DIRECT="`readConfigKey "directboot" "${USER_CONFIG_FILE}"`"
if [ "${DIRECT}" = "true" ]; then
echo -e "\033[1;33mReboot to boot directly in DSM\033[0m"
grub-editenv ${GRUB_PATH}/grubenv set next_entry="direct"
reboot
sleep 100
exit
fi
echo -e "\033[1;37mLoading DSM kernel...\033[0m"
# Executes DSM kernel via KEXEC
history -w
sync
if [ "${EFI_BUG}" = "yes" -a ${EFI} -eq 1 ]; then
echo -e "\033[1;33mWarning, running kexec with --noefi param, strange things will happen!!\033[0m"
kexec --noefi -l "${MOD_ZIMAGE_FILE}" --initrd "${MOD_RDGZ_FILE}" --command-line="${CMDLINE_LINE}" >"${LOG_FILE}" 2>&1 || dieLog

View File

@ -8,6 +8,7 @@ RAMDISK_PATH="${TMP_PATH}/ramdisk"
LOG_FILE="${TMP_PATH}/log.txt"
USER_CONFIG_FILE="${BOOTLOADER_PATH}/user-config.yml"
GRUB_PATH="${BOOTLOADER_PATH}/grub"
ORI_ZIMAGE_FILE="${SLPART_PATH}/zImage"
ORI_RDGZ_FILE="${SLPART_PATH}/rd.gz"

View File

@ -69,6 +69,7 @@ MACF=`echo ${MAC} | sed 's/://g'`
if [ ! -f "${USER_CONFIG_FILE}" ]; then
touch "${USER_CONFIG_FILE}"
writeConfigKey "lkm" "dev" "${USER_CONFIG_FILE}"
writeConfigKey "directboot" "false" "${USER_CONFIG_FILE}"
writeConfigKey "model" "" "${USER_CONFIG_FILE}"
writeConfigKey "build" "" "${USER_CONFIG_FILE}"
writeConfigKey "sn" "" "${USER_CONFIG_FILE}"

View File

@ -23,6 +23,7 @@ BUILD="`readConfigKey "build" "${USER_CONFIG_FILE}"`"
LAYOUT="`readConfigKey "layout" "${USER_CONFIG_FILE}"`"
KEYMAP="`readConfigKey "keymap" "${USER_CONFIG_FILE}"`"
LKM="`readConfigKey "lkm" "${USER_CONFIG_FILE}"`"
DIRECTBOOT="`readConfigKey "directboot" "${USER_CONFIG_FILE}"`"
SN="`readConfigKey "sn" "${USER_CONFIG_FILE}"`"
###############################################################################
@ -1049,7 +1050,10 @@ while true; do
echo "d \"Build the loader\"" >> "${TMP_PATH}/menu"
fi
fi
loaderIsConfigured && echo "b \"Boot the loader\" " >> "${TMP_PATH}/menu"
if loaderIsConfigured; then
echo "r \"Switch direct boot: \Z4${DIRECTBOOT}\Zn\"">> "${TMP_PATH}/menu"
echo "b \"Boot the loader\" " >> "${TMP_PATH}/menu"
fi
echo "u \"Edit user config file manually\"" >> "${TMP_PATH}/menu"
echo "k \"Choose a keymap\" " >> "${TMP_PATH}/menu"
[ ${RAMCACHE} -eq 0 -a -d "${CACHE_PATH}/dl" ] && echo "c \"Clean disk cache\"" >> "${TMP_PATH}/menu"
@ -1071,7 +1075,11 @@ while true; do
NEXT="o"
;;
o) selectModules; NEXT="d" ;;
d) make; NEXT="b" ;;
d) make; NEXT="r" ;;
r) [ "${DIRECTBOOT}" = "false" ] && DIRECTBOOT='true' || DIRECTBOOT='false'
writeConfigKey "directboot" "${DIRECTBOOT}" "${USER_CONFIG_FILE}"
NEXT="b"
;;
b) boot ;;
u) editUserConfig; NEXT="u" ;;
k) keymapMenu ;;

View File

@ -5,16 +5,18 @@ insmod test
terminal_input console
terminal_output console
set default="0"
set default="boot"
set timeout="5"
set timeout_style="menu"
insmod loadenv
if [ -s $prefix/grubenv ]; then
set have_grubenv=true
load_env
fi
if [ "${next_entry}" ] ; then
if [ "${default}" ]; then
set default="${default}"
fi
if [ "${next_entry}" ]; then
set default="${next_entry}"
set next_entry=
save_env next_entry
@ -36,14 +38,6 @@ else
insmod vga
fi
insmod font
if loadfont ${prefix}/fonts/unicode.pf2; then
insmod gfxterm
set gfxmode=auto
set gfxpayload=keep
terminal_output gfxterm
fi
insmod serial
if serial --unit=0 --speed=115200; then
terminal_input --append serial_com0
@ -53,6 +47,16 @@ fi
insmod search
search --set=root --label "ARPL3"
if [ -s /zImage-dsm -a -s /initrd-dsm ]; then
if [ "${default}" = "direct" ]; then
set timeout="1"
menuentry 'Boot DSM kernel directly' --id direct {
echo "Loading DSM kernel..."
linux /zImage-dsm ${dsm_cmdline}
echo "Loading DSM initramfs..."
initrd /initrd-dsm
echo "Booting..."
}
fi
menuentry 'Boot DSM' --id boot {
echo "Loading kernel..."
linux /bzImage-arpl console=ttyS0,115200n8 quiet net.ifnames=0 biosdevname=0