Initial commit

This commit is contained in:
Nathan 2025-04-20 14:50:31 -05:00
commit 9e10604627
2 changed files with 290 additions and 0 deletions

40
README.md Normal file
View File

@ -0,0 +1,40 @@
# Chromebook Device Nyan NVIDIA Tegra K1 (T124) Linux for Tegra Userspace Package Builder (Ubuntu/Debian)
## This Git repository is the home of the 'build_linux_for_tegra_userspace.sh' package builder tool.
## Purpose
'build_linux_for_tegra_userspace.sh' allows for the simplified and automated packaging of Linux for Tegra (L4T) 21.8 userspace libraries for use with NVIDIA Tegra K1 (T124) SoC Chromebooks.
Note: The package builder does not support the NVIDIA Jetson TK1 development board.
## Using the Package Builder
At a minimum, the package builder requires the following flags to be appended:
--package-maintainer <name>
--package-maintainer-contact <email>
Triple buffering is enabled by default in the X11 configuration file and is required to avoid artifacting in some cases, such as if the system is using the Mate desktop environment with the Compiz compositor
To prevent triple buffering from being enabled in the X11 xserver configuration file, append the flag:
--triple-buffering-is-disabled
For debugging purposes and testing, the following flag allows the script to continue should there be any error:
--disable-exit-on-error
Note: It is not recommended for this flag to be appended for general use cases.
A URL to the Linux for Tegra 21.8 userspace archive can be specified with:
--linux-for-tegra-userspace-archive-url
However, if no URL is specified to the package builder, it will use the following URL:
https://developer.download.nvidia.com/embedded/L4T/r21_Release_v8.0/release_files/Tegra124_Linux_R21.8.0_armhf.tbz2
If the '.deb' package file has been built successfully, it will be in the 'l4t-userspace-package' folder.
Note: Each time the package builder is used, the folder 'l4t-userspace-package' (if it exists at runtime) and anything that was placed in the folder will be removed.
## X11 Server Compatibility
As of currently, the newest X11 server compatible with the Linux for Tegra (L4T) 21.8 graphics libraries is the 1.18 series. However, an upstream release of the X11 server with compatibility for the Linux for Tegra 21.8 graphics drivers.

View File

@ -0,0 +1,250 @@
#!/bin/bash
set -e
DEB_FILE_OUTPUT="nvidia-l4t-driver-21.8-nyan_armhf"
DEB_SOURCE_DIRECTORY="linux-for-tegra-userspace-deb-source"
LINUX_FOR_TEGRA_FOLDER="Linux_for_Tegra"
WORK_DIRECTORY="work-directory"
APPLY_BINARIES_SCRIPT_FILE="apply_binaries.sh"
LINUX_FOR_TEGRA_USERSPACE_PACKAGE_FILE_FOLDER="l4t-userspace-package"
information() {
echo "Flags: --disable-exit-on-error --package-maintainer <name> --package-maintainer-contact <email>"
echo "--linux-for-tegra-userspace-archive-url <url> --triple-buffering-is-disabled"
exit 1
}
if [ $# -eq 0 ]; then
information
fi
while [[ $# -gt 0 ]]; do
case "$1" in
--disable-exit-on-error)
if [ -n "$2" ] && [[ "$2" != "--"* ]]; then
echo "The build image utility will not exit regardless of reported errors"
set +e
shift 2
else
information
fi
;;
--package-maintainer)
if [ -n "$2" ] && [[ "$2" != "--"* ]]; then
PACKAGE_MAINTAINER="$2"
shift 2
else
information
fi
;;
--package-maintainer-contact)
if [ -n "$2" ] && [[ "$2" != "--"* ]]; then
PACKAGE_MAINTAINER_CONTACT="$2"
shift 2
else
information
fi
;;
--linux-for-tegra-userspace-archive-url)
if [ -n "$2" ] && [[ "$2" != "--"* ]]; then
LINUX_FOR_TEGRA_URL="$2"
shift 2
else
information
fi
;;
--triple-buffering-is-disabled)
TRIPLE_BUFFERING_IS_DISABLED="YES"
shift
;;
*)
echo "Invalid flag specified: $1"
information
;;
esac
done
if [ -z "$PACKAGE_MAINTAINER" ]; then
echo "No package maintainer was specified"
PRELIMINARY_CHECK="FAIL"
fi
if [ -z "$PACKAGE_MAINTAINER_CONTACT" ]; then
echo "No package maintainer email address contact was specified"
PRELIMINARY_CHECK="FAIL"
fi
if type -P wget >/dev/null; then
DOWNLOAD_COMMAND="wget"
elif type -P curl >/dev/null; then
DOWNLOAD_COMMAND="curl"
else
"Neither 'curl' nor 'wget' were found by the script"
PRELIMINARY_CHECK="FAIL"
fi
if ! type -P dpkg-deb >/dev/null; then
echo "The script could not find 'dpkg-deb'"
PRELIMINARY_CHECK="FAIL"
fi
if [ "$PRELIMINARY_CHECK" == "FAIL" ]; then
echo "One or more preliminary checks failed"
exit 1
fi
if [ "$TRIPLE_BUFFERING_IS_DISABLED" == "YES" ]; then
echo "The package builder will not enable triple buffering in the X11 server configuration file"
fi
if [ ${EUID: -0} -ne 0 ] || [ "$(id -u)" -ne 0 ]; then
sudo -v
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
PRIVILEGE_ESCALATION_COMMAND="sudo"
fi
if [ -d "$LINUX_FOR_TEGRA_USERSPACE_PACKAGE_FILE_FOLDER" ]; then
rm -rf "$LINUX_FOR_TEGRA_USERSPACE_PACKAGE_FILE_FOLDER"
fi
if [ -d "$WORK_DIRECTORY" ]; then
"$PRIVILEGE_ESCALATION_COMMAND" rm -rf "$WORK_DIRECTORY"
fi
mkdir "$WORK_DIRECTORY"
mkdir "$LINUX_FOR_TEGRA_USERSPACE_PACKAGE_FILE_FOLDER"
cd "$WORK_DIRECTORY"
echo "Preparing deb source tree"
mkdir -p "$DEB_SOURCE_DIRECTORY"/DEBIAN
echo
echo "Downloading NVIDIA Linux for Tegra (L4T) 21.8 userspace software and drivers"
echo -e "\n"
if [ -z "$LINUX_FOR_TEGRA_URL" ]; then
LINUX_FOR_TEGRA_URL=https://developer.download.nvidia.com/embedded/L4T/r21_Release_v8.0/release_files/Tegra124_Linux_R21.8.0_armhf.tbz2
LINUX_FOR_TEGRA_ARCHIVE_FILE="$(basename "$LINUX_FOR_TEGRA_URL")"
fi
"$DOWNLOAD_COMMAND" "$LINUX_FOR_TEGRA_URL"
echo -e "\n"
echo "Extracting NVIDIA Linux for Tegra (L4T) archive"
echo
tar -xf "$LINUX_FOR_TEGRA_ARCHIVE_FILE" -v
echo
echo "Installing Linux for Tegra (L4T) userspace software and drivers to deb source tree"
echo
cd "$LINUX_FOR_TEGRA_FOLDER"
"$PRIVILEGE_ESCALATION_COMMAND" ./"$APPLY_BINARIES_SCRIPT_FILE" -r ../"$DEB_SOURCE_DIRECTORY"
cd ../"$DEB_SOURCE_DIRECTORY"
echo
echo "Preparing installed userspace files"
echo
"$PRIVILEGE_ESCALATION_COMMAND" mkdir -p etc/X11/xorg.conf.d
"$PRIVILEGE_ESCALATION_COMMAND" mv etc/X11/xorg.conf etc/X11/xorg.conf.d/20-tegra.conf -v
"$PRIVILEGE_ESCALATION_COMMAND" mv home/ubuntu/tegrastats usr/bin -v
"$PRIVILEGE_ESCALATION_COMMAND" chmod +x usr/bin/tegrastats
"$PRIVILEGE_ESCALATION_COMMAND" rm -rf boot home etc/{nv,pulse,systemd,modules,init,ld.so.conf.d,sysctl.d/10-console-messages.conf} usr/lib/arm-linux-gnueabihf/tegra-egl/ld.so.conf lib/firmware/{nvavp_os_f7e00000.bin,tegra_xusb_firmware} lib/modules usr/src etc/{fstab,wpa_supplicant.conf,asound.conf*} etc/udev/rules.d/{90,91,92,99-tegra-mmc-ra,99-nv-wifibt}*.rules etc/X11/xorg.conf.jetson-tk1 -v
echo "/usr/lib/arm-linux-gnueabihf/tegra" | "$PRIVILEGE_ESCALATION_COMMAND" tee usr/lib/arm-linux-gnueabihf/tegra/ld.so.conf
echo "/usr/lib/arm-linux-gnueabihf/tegra-egl" | "$PRIVILEGE_ESCALATION_COMMAND" tee usr/lib/arm-linux-gnueabihf/tegra-egl/ld.so.conf
if [ "$TRIPLE_BUFFERING_IS_DISABLED" != "YES" ]; then
"$PRIVILEGE_ESCALATION_COMMAND" sed -i '/Section "Device"/,/EndSection/{/EndSection/i\
Option "TripleBuffer" "true"
}' etc/X11/xorg.conf.d/20-tegra.conf
else
echo "Triple buffering will not be enabled in the X11 server config"
echo "Skipping the triple buffering enablement setup"
fi
echo
echo "Writing Debian postinst script"
cat << 'EOF' > DEBIAN/postinst
update-alternatives --install /etc/ld.so.conf.d/000-arm-linux-gnueabihf_GL.conf arm-linux-gnueabihf_gl_conf /usr/lib/arm-linux-gnueabihf/tegra/ld.so.conf 1000
update-alternatives --install /etc/ld.so.conf.d/001-arm-linux-gnueabihf_EGL.conf arm-linux-gnueabihf_egl_conf /usr/lib/arm-linux-gnueabihf/tegra-egl/ld.so.conf 1000
if [ -e "/usr/lib/arm-linux-gnueabihf/tegra/libglx.so" ]; then
ln -sf /usr/lib/arm-linux-gnueabihf/tegra/libglx.so /usr/lib/xorg/modules/extensions/libglx.so
fi
ldconfig
EOF
chmod +x DEBIAN/postinst
echo
echo "Writing Debian control file"
cat << 'EOF' > DEBIAN/control
Package: nvidia-l4t-driver-21-nyan
Version: 21.8
Architecture: armhf
Maintainer: MAINTAINER_IDENTIFIER <MAINTAINER_EMAIL_IDENTIFIER>
Depends: xserver-xorg-core, acpid
Section: non-free/libs
Priority: optional
Homepage: http://www.nvidia.com
Description: NVIDIA Linux for Tegra (L4T) driver package for the ChromeOS Nyan device platform
This package contains the NVIDIA Linux for Tegra (L4T) binary driver and all of its libraries,
optimized for the ChromeOS Nyan device platform to provide hardware acceleration for
OpenGL/GLX/EGL/GLES applications on X11.
EOF
sed -i "s/MAINTAINER_IDENTIFIER/$PACKAGE_MAINTAINER/g" "DEBIAN/control"
sed -i "s/MAINTAINER_EMAIL_IDENTIFIER/$PACKAGE_MAINTAINER_CONTACT/g" "DEBIAN/control"
echo
echo "Creating the .deb package containing the NVIDIA Linux for Tegra (L4T) 21.8 proprietary userspace software and drivers"
cd ..
dpkg-deb --build --root-owner-group "$DEB_SOURCE_DIRECTORY" ../"$LINUX_FOR_TEGRA_USERSPACE_PACKAGE_FILE_FOLDER"/"$DEB_FILE_OUTPUT".deb
cd ..
"$PRIVILEGE_ESCALATION_COMMAND" rm -rf "$WORK_DIRECTORY"
echo
if [ -f "$LINUX_FOR_TEGRA_USERSPACE_PACKAGE_FILE_FOLDER"/"$DEB_FILE_OUTPUT".deb ]; then
echo "The NVIDIA Linux for Tegra (L4T) 21.8 userspace software and drivers package for Chromebook device Nyan was created successfully"
exit 0
else
echo "The NVIDIA Linux for Tegra (L4T) 21.8 userspace software and drivers package for Chromebook device Nyan was not created successfully: linux-firmware-nyan_armhf.deb"
rm -rf "$LINUX_FOR_TEGRA_USERSPACE_PACKAGE_FILE_FOLDER"
exit 1
fi