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
This commit is contained in:
Oleg 2022-10-25 12:28:23 +03:00 committed by GitHub
parent ab7cb8df10
commit d41125a5fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 116 additions and 120 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -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/" \

BIN
packages/blobs/jetson/boot.scr Executable file

Binary file not shown.