Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 0 additions & 91 deletions jetson-agx-orin-devkit/Dockerfile

This file was deleted.

35 changes: 32 additions & 3 deletions jetson-nano/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
FROM balenalib/jetson-nano-ubuntu:bionic
FROM ubuntu:bionic-20230530

# Prevent apt-get prompting for input
ENV DEBIAN_FRONTEND noninteractive

# From balenalib base:
RUN apt-get update && apt-get install -y --no-install-recommends \
less \
kmod \
nano \
net-tools \
sudo \
ca-certificates \
gnupg \
dirmngr \
inetutils-ping \
netbase \
curl \
udev \
ifupdown \
i2c-tools \
usbutils \
$( \
if apt-cache show 'iproute' 2>/dev/null | grep -q '^Version:'; then \
echo 'iproute'; \
else \
echo 'iproute2'; \
fi \
) \
&& rm -rf /var/lib/apt/lists/* \
&& c_rehash

# Update to 32.7 repository in case the base image is using 32.6
RUN sed -i 's/r32.6 main/r32.7 main/g' /etc/apt/sources.list.d/nvidia.list

Expand Down Expand Up @@ -55,5 +82,7 @@ RUN echo "#!/bin/bash" > /etc/X11/xinit/xserverrc \
## GPU Device 0: "Maxwell" with compute capability 5.3
## Average clocks/block = 3294.203125

# Start XFCE desktop
CMD ["startx"]
COPY entry.sh /usr/bin/entry.sh

# Start entry script
CMD ["bash", "/usr/bin/entry.sh"]
87 changes: 87 additions & 0 deletions jetson-nano/entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash

# This command only works in privileged container
tmp_mount='/tmp/_balena'
mkdir -p "$tmp_mount"
if mount -t devtmpfs none "$tmp_mount" &> /dev/null; then
PRIVILEGED=true
umount "$tmp_mount"
else
PRIVILEGED=false
fi
rm -rf "$tmp_mount"

function mount_dev()
{
tmp_dir='/tmp/tmpmount'
mkdir -p "$tmp_dir"
mount -t devtmpfs none "$tmp_dir"
mkdir -p "$tmp_dir/shm"
mount --move /dev/shm "$tmp_dir/shm"
mkdir -p "$tmp_dir/mqueue"
mount --move /dev/mqueue "$tmp_dir/mqueue"
mkdir -p "$tmp_dir/pts"
mount --move /dev/pts "$tmp_dir/pts"
touch "$tmp_dir/console"
mount --move /dev/console "$tmp_dir/console"
umount /dev || true
mount --move "$tmp_dir" /dev

# Since the devpts is mounted with -o newinstance by Docker, we need to make
# /dev/ptmx point to its ptmx.
# ref: https://www.kernel.org/doc/Documentation/filesystems/devpts.txt
ln -sf /dev/pts/ptmx /dev/ptmx

# When using io.balena.features.sysfs the mount point will already exist
# we need to check the mountpoint first.
sysfs_dir='/sys/kernel/debug'

if ! mountpoint -q "$sysfs_dir"; then
mount -t debugfs nodev "$sysfs_dir"
fi

}

function start_udev()
{
if [ "$UDEV" == "on" ]; then
if $PRIVILEGED; then
mount_dev
if command -v udevd &>/dev/null; then
unshare --net udevd --daemon &> /dev/null
else
unshare --net /lib/systemd/systemd-udevd --daemon &> /dev/null
fi
udevadm trigger &> /dev/null
else
echo "Unable to start udev, container must be run in privileged mode to start udev!"
fi
fi
}

function init()
{
# echo error message, when executable file is passed but doesn't exist.
if [ -n "$1" ]; then
if CMD=$(command -v "$1" 2>/dev/null); then
shift
exec "$CMD" "$@"
else
echo "Command not found: $1"
exit 1
fi
fi
}

UDEV=$(echo "$UDEV" | awk '{print tolower($0)}')

case "$UDEV" in
'1' | 'true')
UDEV='on'
;;
esac

start_udev
init "$@"
sleep 8
startx
27 changes: 22 additions & 5 deletions jetson-orin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# AGX Orin, Orin NX and Orin Nano use the same T234 platform, therefore base images can be used
# interchangeably as long as nvidia.list contains the right apt repositoy
FROM balenalib/jetson-orin-nano-devkit-nvme-ubuntu:jammy-20240401
FROM ubuntu:jammy-20250404

RUN apt-get update && apt-get install -y --no-install-recommends \
sudo \
ca-certificates \
findutils \
gnupg \
dirmngr \
inetutils-ping \
netbase \
curl \
udev \
kmod \
nano

# Prevent apt-get prompting for input
ENV DEBIAN_FRONTEND noninteractive
Expand Down Expand Up @@ -46,13 +59,13 @@ RUN \
xterm

ENV LD_LIBRARY_PATH=/usr/lib/aarch64-linux-gnu/tegra
ENV UDEV=1

# Prevent screen from turning off
RUN echo "#!/bin/bash" > /etc/X11/xinit/xserverrc \
&& echo "" >> /etc/X11/xinit/xserverrc \
&& echo 'exec /usr/bin/X -s 0 dpms' >> /etc/X11/xinit/xserverrc && \
echo 'modules=("tegra_drm" "nvidia_drm" "nvidia_modeset"); for module in "${modules[@]}"; do if lsmod | grep -q ${module} ; then echo "Found $module"; rmmod $module; fi; done; startxfce4 & sleep 5; modprobe tegra_drm; modprobe nvidia_drm; while [ 1 ]; do sleep 10; done; ' > /opt/startxfce.sh
&& echo 'exec /usr/bin/X -s 0 dpms' >> /etc/X11/xinit/xserverrc



## If any apt packages install mesa-egl, it will overwrite the tegra-egl
## symlink and ld path, so the following command will ensure tegra-egl remains
Expand Down Expand Up @@ -110,5 +123,9 @@ RUN echo "#!/bin/bash" > /etc/X11/xinit/xserverrc \
## deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 12.6, CUDA Runtime Version = 12.6, NumDevs = 1
## Result = PASS

CMD ["/bin/bash", "/opt/startxfce.sh"]
COPY startxfce.sh /opt/startxfce.sh
RUN chmod +x /opt/startxfce.sh
COPY entry.sh /usr/bin/entry.sh
RUN chmod +x /usr/bin/entry.sh

CMD ["/bin/bash", "/usr/bin/entry.sh"]
70 changes: 70 additions & 0 deletions jetson-orin/entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

echo "Starting entry script."

# This command only works in privileged container
tmp_mount='/tmp/_balena'
mkdir -p "$tmp_mount"
if mount -t devtmpfs none "$tmp_mount" &> /dev/null; then
PRIVILEGED=true
umount "$tmp_mount"
else
PRIVILEGED=false
fi
rm -rf "$tmp_mount"

function mount_dev()
{
tmp_dir='/tmp/tmpmount'
mkdir -p "$tmp_dir"
mount -t devtmpfs none "$tmp_dir"
mkdir -p "$tmp_dir/shm"
mount --move /dev/shm "$tmp_dir/shm"
mkdir -p "$tmp_dir/mqueue"
mount --move /dev/mqueue "$tmp_dir/mqueue"
mkdir -p "$tmp_dir/pts"
mount --move /dev/pts "$tmp_dir/pts"
touch "$tmp_dir/console"
mount --move /dev/console "$tmp_dir/console"
umount /dev || true
mount --move "$tmp_dir" /dev

# Since the devpts is mounted with -o newinstance by Docker, we need to make
# /dev/ptmx point to its ptmx.
# ref: https://www.kernel.org/doc/Documentation/filesystems/devpts.txt
ln -sf /dev/pts/ptmx /dev/ptmx

# When using io.balena.features.sysfs the mount point will already exist
# we need to check the mountpoint first.
sysfs_dir='/sys/kernel/debug'

if ! mountpoint -q "$sysfs_dir"; then
mount -t debugfs nodev "$sysfs_dir"
fi

}

function start_udev()
{
if [ "$UDEV" == "on" ]; then
if $PRIVILEGED; then
mount_dev
if command -v udevd &>/dev/null; then
unshare --net udevd --daemon &> /dev/null
else
unshare --net /lib/systemd/systemd-udevd --daemon &> /dev/null
fi
udevadm trigger &> /dev/null
else
echo "Unable to start udev, container must be run in privileged mode to start udev!"
fi
fi
}

UDEV='on'

echo "Starting UDEV..."
start_udev

echo "Starting xfce script."
exec /opt/startxfce.sh
33 changes: 33 additions & 0 deletions jetson-orin/startxfce.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# Ensure plymouth exited so that it won't hold /dev/fb0 open and tegra_drm can be unloaded
DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket \
dbus-send \
--system \
--print-reply \
--dest=org.freedesktop.systemd1 \
/org/freedesktop/systemd1 \
org.freedesktop.systemd1.Manager.StopUnit \
string:plymouth-quit.service string:replace

# Prevent "Server is already active for display 0" error,
# in case X was forcedly closed before
rm -rf /tmp/.X0-lock* || true

# Prevent black screen with cursor only
rm -rf /root/.config/ || true

modules=("tegra_drm" "nvidia_drm" "nvidia_modeset"); for module in "${modules[@]}";
do
if lsmod | grep -q ${module} ; then
echo "Found $module"; rmmod $module;
fi;
done;

startxfce4 & sleep 5;

modprobe tegra_drm;
modprobe nvidia_drm;
while [ 1 ]; do
sleep 10;
done;
Loading