From d41125a5fda2172ab2ece642b216d0eaa2eda380 Mon Sep 17 00:00:00 2001 From: Oleg Date: Tue, 25 Oct 2022 12:28:23 +0300 Subject: [PATCH] move Jetson Nano EFI\Grub (#4284) * move Jetson Nano EFI\Grub * fix dtb for efi * remove list module initrd curren\edge for Jetson Nano * rename to grub-sbc-media --- config/modules/jetson-nano-current | 50 -------------- config/modules/jetson-nano-edge | 53 --------------- config/sources/families/media.conf | 18 ++--- extensions/grub-sbc-media.sh | 101 ++++++++++++++++++++++++++++ lib/functions/host/prepare-host.sh | 2 +- lib/functions/image/partitioning.sh | 12 ++-- packages/blobs/jetson/boot.scr | Bin 0 -> 216 bytes 7 files changed, 116 insertions(+), 120 deletions(-) delete mode 100644 config/modules/jetson-nano-current delete mode 100644 config/modules/jetson-nano-edge create mode 100644 extensions/grub-sbc-media.sh create mode 100755 packages/blobs/jetson/boot.scr diff --git a/config/modules/jetson-nano-current b/config/modules/jetson-nano-current deleted file mode 100644 index d2139f899..000000000 --- a/config/modules/jetson-nano-current +++ /dev/null @@ -1,50 +0,0 @@ -tls -fuse -binfmt_misc -sch_fq_codel -zram -joydev -rfkill -l2tp_ppp -l2tp_netlink -l2tp_core -ip6_udp_tunnel -udp_tunnel -pppox -ppp_generic -slhc -xfrm_user -xfrm_algo -uas -snd_soc_tegra210_dmic -snd_soc_tegra210_admaif -tegra_video -snd_soc_tegra210_i2s -snd_soc_tegra_pcm -v4l2_dv_timings -videobuf2_dma_contig -videobuf2_memops -snd_soc_tegra210_ahub -videobuf2_v4l2 -videobuf2_common -tegra210_adma -videodev -mc -tegra_drm -snd_soc_tegra_audio_graph_card -crct10dif_ce -snd_soc_audio_graph_card -snd_soc_simple_card_utils -snd_hda_codec_hdmi -tegra_aconnect -pwm_fan -tegra_xudc -spi_tegra210_quad -snd_hda_tegra -snd_hda_codec -snd_hwdep -snd_hda_core -r8169 -at24 -realtek -host1x diff --git a/config/modules/jetson-nano-edge b/config/modules/jetson-nano-edge deleted file mode 100644 index e95bab1b3..000000000 --- a/config/modules/jetson-nano-edge +++ /dev/null @@ -1,53 +0,0 @@ -xfrm_user -xfrm_algo -l2tp_ppp -l2tp_netlink -l2tp_core -ip6_udp_tunnel -udp_tunnel -pppox -ppp_generic -slhc -rfkill -tegra_video -joydev -videobuf2_dma_contig -v4l2_dv_timings -videobuf2_memops -videobuf2_v4l2 -videobuf2_common -videodev -tegra_drm -snd_hda_codec_hdmi -mc -snd_hda_tegra -snd_soc_tegra210_mixer -snd_soc_tegra210_admaif -snd_soc_tegra210_adx -snd_soc_tegra210_amx -snd_soc_tegra210_dmic -snd_soc_tegra210_i2s -snd_soc_tegra210_sfc -snd_soc_tegra210_mvc -snd_soc_tegra_pcm -snd_hda_codec -snd_soc_tegra_audio_graph_card -crct10dif_ce -snd_soc_audio_graph_card -tegra_xudc -at24 -snd_hda_core -snd_soc_simple_card_utils -tegra210_adma -host1x -pwm_fan -snd_soc_tegra210_ahub -snd_hwdep -zram -sch_fq_codel -binfmt_misc -fuse -uas -spi_tegra210_quad -tegra_aconnect -r8169 diff --git a/config/sources/families/media.conf b/config/sources/families/media.conf index c5fe50852..882dfd84e 100644 --- a/config/sources/families/media.conf +++ b/config/sources/families/media.conf @@ -1,5 +1,9 @@ source "${BASH_SOURCE%/*}/include/rockchip64_common.inc" +if [[ $BOARD = jetson-nano ]]; then + enable_extension "grub-sbc-media" +fi + if [[ $BOARD == station-p2 || $BOARD == station-m2 || $BOARD == bananapir2pro ]]; then BOOTSOURCE='https://github.com/150balbes/u-boot-rk' BOOTBRANCH='branch:rk356x' @@ -78,10 +82,9 @@ case $BRANCH in else KERNELPATCHDIR='media-'$BRANCH LINUXFAMILY=media - - if [[ $BOARD == jetson-nano ]]; then - MODULES_INITRD="jetson-nano-current" - fi +# if [[ $BOARD == jetson-nano ]]; then +# MODULES_INITRD="jetson-nano-current" +# fi fi ;; @@ -90,10 +93,9 @@ case $BRANCH in KERNELPATCHDIR='media-'$BRANCH LINUXFAMILY=media LINUXCONFIG='linux-media-'$BRANCH - - if [[ $BOARD == jetson-nano ]]; then - MODULES_INITRD="jetson-nano-edge" - fi +# if [[ $BOARD == jetson-nano ]]; then +# MODULES_INITRD="jetson-nano-edge" +# fi ;; esac diff --git a/extensions/grub-sbc-media.sh b/extensions/grub-sbc-media.sh new file mode 100644 index 000000000..eefbf6bf0 --- /dev/null +++ b/extensions/grub-sbc-media.sh @@ -0,0 +1,101 @@ +# This runs *after* user_config. Don't change anything not coming from other variables or meant to be configured by the user. + function extension_prepare_config__prepare_grub-sbc-media() { + display_alert "Prepare config" "${EXTENSION}" "info" + # Extension configuration defaults. + export DISTRO_GENERIC_KERNEL=${DISTRO_GENERIC_KERNEL:-no} # if yes, does not build our own kernel, instead, uses generic one from distro + export UEFI_GRUB_DISABLE_OS_PROBER="${UEFI_GRUB_DISABLE_OS_PROBER:-}" # 'true' will disable os-probing, useful for SD cards. + export UEFI_GRUB_DISTRO_NAME="${UEFI_GRUB_DISTRO_NAME:-Armbian}" # Will be used on grub menu display + export UEFI_GRUB_TIMEOUT=${UEFI_GRUB_TIMEOUT:-5} # Small timeout by default + export GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT:-}" # Cmdline by default + export UEFI_ENABLE_BIOS_AMD64="${UEFI_ENABLE_BIOS_AMD64:-no}" # Enable BIOS too if target is amd64 + # User config overrides. + export IMAGE_PARTITION_TABLE="gpt" # GPT partition table is essential for many UEFI-like implementations, eg Apple+Intel stuff. + export UEFISIZE=256 # in MiB - grub EFI is tiny - but some EFI BIOSes ignore small too small EFI partitions + export BOOTSIZE=0 # No separate /boot when using UEFI. + export CLOUD_INIT_CONFIG_LOCATION="${CLOUD_INIT_CONFIG_LOCATION:-/boot/efi}" # use /boot/efi for cloud-init as default when using Grub. + export EXTRA_BSP_NAME="${EXTRA_BSP_NAME}-grub" # Unique bsp name. + export UEFI_GRUB_TARGET_BIOS="" # Target for BIOS GRUB install, set to i386-pc when UEFI_ENABLE_BIOS_AMD64=yes and target is amd64 + local uefi_packages="efibootmgr efivar" # Use growroot, add some efi-related packages + uefi_packages="os-prober grub-efi-${ARCH}-bin ${uefi_packages}" # This works for Ubuntu and Debian, by sheer luck; common for EFI and BIOS + + [[ "${ARCH}" == "arm64" ]] && export uefi_packages="${uefi_packages} grub-efi-${ARCH}" + [[ "${ARCH}" == "arm64" ]] && export UEFI_GRUB_TARGET="arm64-efi" # Default for arm64-efi + + DISTRO_KERNEL_PACKAGES="" + DISTRO_FIRMWARE_PACKAGES="" + + export PACKAGE_LIST_BOARD="${PACKAGE_LIST_BOARD} ${DISTRO_FIRMWARE_PACKAGES} ${DISTRO_KERNEL_PACKAGES} ${uefi_packages}" + +} + +pre_umount_final_image__install_grub() { + configure_grub + local chroot_target=$MOUNT + display_alert "Installing bootloader" "GRUB" "info" + + # getting rid of the dtb package, if installed, is hard. for now just zap it, otherwise update-grub goes bananas + mkdir -p "$MOUNT"/boot/efi/dtb + cp -r "$MOUNT"/boot/dtb/* "$MOUNT"/boot/efi/dtb/ + cp -r ${SRC}/packages/blobs/splash/grub.png "$MOUNT"/boot/grub + + # add config to disable os-prober, otherwise image will have the host's other OSes boot entries. + cat <<- grubCfgFragHostSide >> "${MOUNT}"/etc/default/grub.d/99-armbian-host-side.cfg + GRUB_DISABLE_OS_PROBER=true + grubCfgFragHostSide + + # copy Armbian GRUB wallpaper + mkdir -p "${MOUNT}"/usr/share/images/grub/ + cp "${SRC}"/packages/blobs/splash/grub.png "${MOUNT}"/usr/share/images/grub/wallpaper.png + + # Mount the chroot... + mount_chroot "$chroot_target/" # this already handles /boot/efi which is required for it to work. + + sed -i '/devicetree/c echo' "$MOUNT"/etc/grub.d/10_linux >>"${DEST}"/"${LOG_SUBPATH}"/grub-n.log 2>&1 + + local install_grub_cmdline="update-grub && grub-install --verbose --target=${UEFI_GRUB_TARGET} --no-nvram --removable" # nvram is global to the host, even across chroot. take care. + display_alert "Installing GRUB EFI..." "${UEFI_GRUB_TARGET}" "" + chroot "$chroot_target" /bin/bash -c "$install_grub_cmdline" >> "$DEST"/"${LOG_SUBPATH}"/install.log 2>&1 || { + exit_with_error "${install_grub_cmdline} failed!" + } + + # Remove host-side config. + rm -f "${MOUNT}"/etc/default/grub.d/99-armbian-host-side.cfg + + local root_uuid + root_uuid=$(blkid -s UUID -o value "${LOOP}p${uefipart}") # get the uuid of the root partition, this has been transposed + + if [[ $BOARD == jetson-nano ]]; then + cp -R $SRC/packages/blobs/jetson/boot.scr "${MOUNT}"/boot/efi/boot.scr + fi + + umount_chroot "$chroot_target/" + +} + +configure_grub() { + [[ -n "$SRC_CMDLINE" ]] && + GRUB_CMDLINE_LINUX_DEFAULT+=" ${SRC_CMDLINE}" + [[ -n "$MAIN_CMDLINE" ]] && + GRUB_CMDLINE_LINUX_DEFAULT+=" ${MAIN_CMDLINE}" + + display_alert "GRUB EFI kernel cmdline" "${GRUB_CMDLINE_LINUX_DEFAULT} distro=${UEFI_GRUB_DISTRO_NAME} timeout=${UEFI_GRUB_TIMEOUT}" "" + cat <<- grubCfgFrag >> "${MOUNT}"/etc/default/grub.d/98-armbian.cfg + GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT}" + GRUB_TIMEOUT_STYLE=menu # Show the menu with Kernel options (Armbian or -generic)... + GRUB_TIMEOUT=${UEFI_GRUB_TIMEOUT} # ... for ${UEFI_GRUB_TIMEOUT} seconds, then boot the Armbian default. + GRUB_DISTRIBUTOR="${UEFI_GRUB_DISTRO_NAME}" # On GRUB menu will show up as "Armbian GNU/Linux" (will show up in some UEFI BIOS boot menu (F8?) as "armbian", not on others) + GRUB_BACKGROUND="/boot/grub/grub.png" + grubCfgFrag + + if [[ "a${UEFI_GRUB_DISABLE_OS_PROBER}" != "a" ]]; then + cat <<- grubCfgFragHostSide >> "${MOUNT}"/etc/default/grub.d/98-armbian.cfg + GRUB_DISABLE_OS_PROBER=${UEFI_GRUB_DISABLE_OS_PROBER} + grubCfgFragHostSide + fi + + if [[ "a${UEFI_GRUB_TERMINAL}" != "a" ]]; then + cat <<- grubCfgFragTerminal >> "${MOUNT}"/etc/default/grub.d/98-armbian.cfg + GRUB_TERMINAL="${UEFI_GRUB_TERMINAL}" + grubCfgFragTerminal + fi +} diff --git a/lib/functions/host/prepare-host.sh b/lib/functions/host/prepare-host.sh index 6044a77ee..fb7102269 100644 --- a/lib/functions/host/prepare-host.sh +++ b/lib/functions/host/prepare-host.sh @@ -49,7 +49,7 @@ prepare_host() { elif [[ $(dpkg --print-architecture) == arm64 ]]; then - hostdeps+="gcc-arm-none-eabi libc6 libc6-amd64-cross qemu" + hostdeps+=" gcc-arm-none-eabi libc6 libc6-amd64-cross qemu" else diff --git a/lib/functions/image/partitioning.sh b/lib/functions/image/partitioning.sh index af7dd8983..bb1828894 100644 --- a/lib/functions/image/partitioning.sh +++ b/lib/functions/image/partitioning.sh @@ -80,13 +80,9 @@ PRE_PREPARE_PARTITIONS local next=1 # Check if we need UEFI partition if [[ $UEFISIZE -gt 0 ]]; then - if [[ "${IMAGE_PARTITION_TABLE}" == "gpt" ]]; then - local uefipart=15 - # Check if we need BIOS partition - [[ $BIOSSIZE -gt 0 ]] && local biospart=14 - else - local uefipart=$((next++)) - fi + # Check if we need BIOS partition + [[ $BIOSSIZE -gt 0 ]] && local biospart=$((next++)) + local uefipart=$((next++)) fi # Check if we need boot partition if [[ -n $BOOTFS_TYPE || $ROOTFS_TYPE != ext4 || $CRYPTROOT_ENABLE == yes ]]; then @@ -290,7 +286,7 @@ PREPARE_IMAGE_SIZE echo "rootdev=$rootfs" >> $SDCARD/boot/armbianEnv.txt fi echo "rootfstype=$ROOTFS_TYPE" >> $SDCARD/boot/armbianEnv.txt - elif [[ $rootpart != 1 ]]; then + elif [[ $rootpart != 1 ]] && [[ $SRC_EXTLINUX != yes ]]; then local bootscript_dst=${BOOTSCRIPT##*:} sed -i 's/mmcblk0p1/mmcblk0p2/' $SDCARD/boot/$bootscript_dst sed -i -e "s/rootfstype=ext4/rootfstype=$ROOTFS_TYPE/" \ diff --git a/packages/blobs/jetson/boot.scr b/packages/blobs/jetson/boot.scr new file mode 100755 index 0000000000000000000000000000000000000000..e22e72f911ec4faaa774293f5609e49f88355c7d GIT binary patch literal 216 zcmY#ql?-E+?){tW7rl>xfnf#^gTWjX=6F^nHW(KlJpm+{nw*iZpcGt^SX83mn3AH9 zQj(gK7S2M0=A#i=E!d1VTzX_@h9DJ5x{IjIUtKy~_gWtl0NiTWj}=|zb~h6cI? l#wMl)x&}a?2b5OgDk{xW$jMJki3jNfig3X!%P+ub7XX7nF;4&h literal 0 HcmV?d00001