From fa02ac9c0b6f566b550738289023d7516b7649ea Mon Sep 17 00:00:00 2001 From: Badr Date: Fri, 19 Jun 2026 12:44:49 +0200 Subject: [PATCH] l4t 39.x --- Containerfile.image.l4t39 | 70 ++++++++++++++++++ Containerfile.rootfs.26_04 | 130 ++++++++++++++++++++++++++++++++++ scripts/build-base-rootfs.sh | 70 ++++++++++-------- scripts/build-jetson-image.sh | 10 +-- 4 files changed, 245 insertions(+), 35 deletions(-) create mode 100644 Containerfile.image.l4t39 create mode 100644 Containerfile.rootfs.26_04 diff --git a/Containerfile.image.l4t39 b/Containerfile.image.l4t39 new file mode 100644 index 0000000..d03db93 --- /dev/null +++ b/Containerfile.image.l4t39 @@ -0,0 +1,70 @@ +FROM ubuntu:24.04 + +LABEL org.opencontainers.image.authors="Badr @pythops" + +# Define the BSP version +ARG BSP=https://developer.nvidia.com/downloads/embedded/L4T/r39_Release_v2.0/release/Jetson_Linux_R39.2.0_aarch64.tbz2 + +ARG L4T_PACKAGES + +# Install different dependencies +RUN apt update && \ + apt install -y \ + wget \ + patch \ + bzip2 \ + qemu-user-static \ + sudo \ + libxml2-utils \ + python3 \ + gdisk \ + kpartx \ + cpio \ + binutils \ + ssh \ + python-is-python3 \ + dosfstools \ + python3-yaml \ + build-essential \ + lz4 \ + cpio \ + xmlstarlet + +# Extract the BSP +RUN mkdir /build && \ + wget -qO- $BSP | tar -jxpf - -C /build + +# Copy the ubuntu rootfs +COPY rootfs/ /build/Linux_for_Tegra/rootfs/ + +# Sudo permissions +# RUN chmod 4755 /build/Linux_for_Tegra/rootfs/usr/bin/sudo + + +# Install nvidia packages in the new rootfs +WORKDIR /build/Linux_for_Tegra/ +RUN ./apply_binaries.sh + +# Fix permissions +RUN chroot /build/Linux_for_Tegra/rootfs/ /bin/bash -c "chown -R jetson:jetson /home/jetson && chmod 1777 /tmp" + +# L4T packages +RUN mount -t proc proc rootfs/proc/ && \ + mount -t sysfs sys rootfs/sys && \ + mount -o bind /dev rootfs/dev && \ + chroot rootfs /bin/bash -c "echo 'nameserver 8.8.8.8' > /etc/resolv.conf && apt update; apt install -y cuda-toolkit $L4T_PACKAGES" + +# Edit initrd +WORKDIR /tmp/pythops +RUN gzip -d -c /build/Linux_for_Tegra/bootloader/l4t_initrd.img > initrd +WORKDIR /tmp/pythops/lab +RUN cpio -iv < ../initrd && \ + echo "nameserver 127.0.0.53" > etc/resolv.conf && \ + find . | cpio --create --format="newc" > ../new_initrd +WORKDIR /tmp/pythops +RUN gzip new_initrd && mv new_initrd.gz /build/Linux_for_Tegra/bootloader/l4t_initrd.img + +# Copy the script to create the image +COPY scripts/create-jetson-image.sh /usr/local/bin/ + +WORKDIR /build/Linux_for_Tegra/tools diff --git a/Containerfile.rootfs.26_04 b/Containerfile.rootfs.26_04 new file mode 100644 index 0000000..4ce16e4 --- /dev/null +++ b/Containerfile.rootfs.26_04 @@ -0,0 +1,130 @@ +FROM ubuntu:26.04 + +LABEL org.opencontainers.image.authors="Badr @pythops" + +# Noble sources +RUN echo "" >> /etc/apt/sources.list.d/ubuntu.sources && \ + echo "Types: deb" >>/etc/apt/sources.list.d/ubuntu.sources && \ + echo "URIs: http://ports.ubuntu.com/ubuntu-ports/" >> /etc/apt/sources.list.d/ubuntu.sources && \ + echo "Suites: noble" >> /etc/apt/sources.list.d/ubuntu.sources && \ + echo "Components: main universe restricted multiverse" >> /etc/apt/sources.list.d/ubuntu.sources && \ + echo "Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg" >>/etc/apt/sources.list.d/ubuntu.sources + +# Nvidia required packages +RUN apt update && apt install -y \ + libgles2 \ + libpangoft2-1.0-0 \ + libxkbcommon0 \ + libwayland-egl1 \ + libwayland-cursor0 \ + libunwind8 \ + libasound2t64 \ + libpixman-1-0 \ + libjpeg-turbo8 \ + libinput10 \ + libcairo2 \ + libncursesw6 \ + libdrm-common \ + libdrm2 \ + libegl-mesa0 \ + libegl1 \ + libgtk-3-0 \ + libgstreamer1.0-0 \ + libgstreamer-plugins-bad1.0-0 \ + libvulkan1 \ + libssl-dev \ + libnl-route-3-200 \ + device-tree-compiler \ + libwayland-server0 \ + libc6-arm64-cross \ + libpcre3 \ + rsync \ + python3-matplotlib \ + python3-tk \ + gir1.2-appindicator3-0.1 \ + python3-gi \ + bridge-utils \ + i2c-tools \ + iso-codes \ + wget \ + cpio \ + busybox \ + nvme-cli \ + libseat1 \ + efibootmgr + +# Additional tools +RUN DEBIAN_FRONTEND=noninteractive apt install -y \ + systemd \ + bash-completion \ + build-essential \ + pkg-config \ + btrfs-progs \ + cmake \ + curl \ + dnsutils \ + htop \ + iotop \ + iputils-ping \ + kmod \ + linux-firmware \ + locales \ + net-tools \ + pciutils \ + python3-dev \ + ssh \ + sudo \ + udev \ + unzip \ + usbutils \ + neovim \ + parted \ + gdisk \ + fdisk \ + e2fsprogs \ + mtd-utils \ + python-is-python3 \ + git \ + gpgv1 \ + fwupd \ + iwd + + +# Tegratop +RUN wget -q https://github.com/pythops/tegratop/releases/latest/download/tegratop-linux-arm64 -O /usr/local/bin/tegratop && \ + chmod +x /usr/local/bin/tegratop + +# Impala +RUN wget -q https://github.com/pythops/impala/releases/latest/download/impala-aarch64-unknown-linux-musl -O /usr/local/bin/impala && \ + chmod +x /usr/local/bin/impala + +# Resize the rootfs +COPY scripts/resizerootfs.sh /usr/local/bin +COPY scripts/resizerootfs.service /lib/systemd/system + +# Generate locales +RUN locale-gen en_US.UTF-8 + +# Enable services at startuo +RUN systemctl enable resizerootfs.service && \ + systemctl enable systemd-timesyncd && \ + systemctl enable iwd + +# WiFi Networks config +COPY config/iwd/networks/* /var/lib/iwd/ +COPY config/iwd/main.conf /etc/iwd/main.conf + +# New user +# username: jetson +# password: jetson +RUN useradd \ + --create-home \ + -G sudo,video,audio \ + -p $(openssl passwd -6 jetson) \ + -s /bin/bash \ + jetson + +# Add /usr/local/cuda/bin to the PATH +RUN echo "if [ -d \"/usr/local/cuda/bin\" ] ; then" >> /home/jetson/.profile && \ + echo " PATH=\"/usr/local/cuda/bin:\$PATH\"" >> /home/jetson/.profile && \ + echo "fi" >> /home/jetson/.profile diff --git a/scripts/build-base-rootfs.sh b/scripts/build-base-rootfs.sh index 700d157..e9fa4c1 100755 --- a/scripts/build-base-rootfs.sh +++ b/scripts/build-base-rootfs.sh @@ -6,45 +6,55 @@ set -e echo "Building base rootfs" -if [ "$1" != "24.04" ] && [ "$1" != "22.04" ] && [ "$1" != "20.04" ]; then - echo "Error: Unknow version of ubuntu. The supported versions are: 20.04, 22.04, 24.04" - exit 1 +if [ "$1" != "26.04" ] && [ "$1" != "24.04" ] && [ "$1" != "22.04" ] && [ "$1" != "20.04" ]; then + echo "Error: Unknow version of ubuntu. The supported versions are: 20.04, 22.04, 24.04, 26.04" + exit 1 fi case $1 in "20.04") - podman build \ - --squash-all \ - --jobs=4 \ - --arch=arm64 \ - --network=host \ - -f Containerfile.rootfs.20_04 \ - -t jetson-rootfs - ;; + podman build \ + --squash-all \ + --jobs=4 \ + --arch=arm64 \ + --network=host \ + -f Containerfile.rootfs.20_04 \ + -t jetson-rootfs + ;; "22.04") - podman build \ - --squash-all \ - --jobs=4 \ - --arch=arm64 \ - --network=host \ - -f Containerfile.rootfs.22_04 \ - -t jetson-rootfs - ;; + podman build \ + --squash-all \ + --jobs=4 \ + --arch=arm64 \ + --network=host \ + -f Containerfile.rootfs.22_04 \ + -t jetson-rootfs + ;; "24.04") - podman build \ - --squash-all \ - --jobs=4 \ - --arch=arm64 \ - --network=host \ - -f Containerfile.rootfs.24_04 \ - -t jetson-rootfs - ;; + podman build \ + --squash-all \ + --jobs=4 \ + --arch=arm64 \ + --network=host \ + -f Containerfile.rootfs.24_04 \ + -t jetson-rootfs + ;; + +"26.04") + podman build \ + --squash-all \ + --jobs=4 \ + --arch=arm64 \ + --network=host \ + -f Containerfile.rootfs.26_04 \ + -t jetson-rootfs + ;; *) - exit 1 - ;; + exit 1 + ;; esac podman save --format docker-dir -o base jetson-rootfs @@ -52,7 +62,7 @@ podman save --format docker-dir -o base jetson-rootfs mkdir rootfs for layer in "$(jq -r '.layers[].digest' base/manifest.json | awk -F ':' '{print $2}')"; do - tar xvf base/"$layer" --directory=rootfs + tar xvf base/"$layer" --directory=rootfs done rm -rf rootfs/root/.bash_history diff --git a/scripts/build-jetson-image.sh b/scripts/build-jetson-image.sh index ad8e34e..89a5445 100755 --- a/scripts/build-jetson-image.sh +++ b/scripts/build-jetson-image.sh @@ -51,9 +51,9 @@ while getopts b:r:d:l:h opts; do l) l4t=${OPTARG} - if [[ "$l4t" != 32 && "$l4t" != 35 && "$l4t" != 36 ]]; then + if [[ "$l4t" != 32 && "$l4t" != 35 && "$l4t" != 36 && "$l4t" != 39 ]]; then printf "\e[31mError: Unsupported l4t value: %s \n\e[0m" "$l4t" - echo "The possible values are: 32, 35, 36." + echo "The possible values are: 32, 35, 36, 39." exit 1 fi ;; @@ -117,12 +117,12 @@ case $board in "jetson-orin-nano" | "jetson-agx-orin") if [[ "$l4t" == "" ]]; then echo "Error: l4t version not provided." - echo "l4t must be 35 or 36" + echo "l4t must be 35, 36 or 39" exit 1 fi - if [[ "$l4t" != 35 && "$l4t" != 36 ]]; then - echo "The $board only supports 35.x or 36.x versions." + if [[ "$l4t" != 35 && "$l4t" != 36 && "$l4t" != 39 ]]; then + echo "The $board only supports 35.x, 36.x or 39.x versions." exit 1 fi