The robot ships with Hiwonder's own software on it. This guide replaces it with NVIDIA's plain Jetson Linux, so that everything on the robot is something you installed and understand. You don't build that system on the robot. You put it together on your PC as an ordinary folder full of files, and in the next chapter you copy that folder onto the robot's drive.
This chapter takes about two hours, most of it waiting for downloads and scripts. Nothing you do here changes the robot. The only time you touch it is to read its factory configuration.
NVIDIA's tools are written for Ubuntu. My PC runs Fedora, so I run all of NVIDIA's steps inside an Ubuntu 22.04 container with Docker. That also keeps NVIDIA's packages off your own system. You need Docker, set up so your user can run it without sudo, and about 11 GB of free disk space.
You also need QEMU's user-mode emulator. The robot has an ARM processor and your PC almost certainly doesn't, but a few steps have to run programs inside the robot's file tree, such as creating a user or generating SSH keys. Linux can hand those ARM programs to QEMU automatically. On Fedora the package is qemu-user-static. I have only done this on Fedora, so on another distribution the package name and the check below may differ. Install it, then check that the handler is registered:
rpm -q qemu-user-static; ls /proc/sys/fs/binfmt_misc/ | grep -i aarch64
cat /proc/sys/fs/binfmt_misc/qemu-aarch64 | grep -E "interpreter|flags"
You should see the package name, two handlers called qemu-aarch64 and qemu-aarch64_be, and a line that says flags: F. That F matters. It means the kernel loaded the emulator once when the handler was registered, so the emulator doesn't have to exist inside the container or the robot's files. That is why the later steps can run ARM programs in the robot's tree even after NVIDIA's script removes its own copy of QEMU from it.
Then make sure Docker runs without sudo:
id; docker ps >/dev/null 2>&1 && echo "docker usable without sudo" || echo "docker needs sudo"
systemctl is-active docker
The id line should list a docker group, followed by docker usable without sudo and active. If it says docker needs sudo, add yourself to the group with sudo usermod -aG docker $USER, then log out and back in. My user was already in the group, so I have not run that fix.
One thing caught me out: my PC went to sleep partway through, because the desktop's power settings don't count SSH traffic as activity. If you're working on the PC over SSH like I was, turn off automatic suspend in your desktop's power settings for the afternoon, or the downloads and scripts will stop with it. During the build itself I kept my KDE desktop awake with kde-inhibit started from the SSH session instead, so the settings route was not what I ran.
Later chapters copy scripts, packages and service files from the project's repo to the robot. Clone it once on your laptop, into the folder the guide uses:
mkdir -p ~/CCode && git clone https://github.com/burgerbarn/PublicRobot.git ~/CCode/rosorin-pro
I worked from a clone I already had, so I have not run this line as written. Chapters 13 and 14 also need a clone of the repo on your PC, at ~/lightbot-repo. I didn't record the command I used to make that one, so this guide has no tested step for it.
Before downloading anything, look at which NVIDIA board configuration the factory used. It tells you which version of NVIDIA's software matches your board, and you'll need one of these files again in the next chapter. Log in to the robot's factory system (the user is ubuntu) and run:
echo "== nv_boot_control"; cat /etc/nv_boot_control.conf
echo "== dtb in use"; grep -iE "FDT|APPEND|LABEL" /boot/extlinux/extlinux.conf | head
echo "== compatible"; tr '\0' '\n' < /proc/device-tree/compatible
On my robot the first file starts like this:
== nv_boot_control
TNSPEC 3767-303-0000-D.1-1-1-jetson-orin-nano-devkit-super-
COMPATIBLE_SPEC 3767-000-0000--1--jetson-orin-nano-devkit-super-
TEGRA_BOOT_STORAGE nvme0n1
The 3767 is the compute module, an Orin NX, and 0000 is the 16 GB version. The jetson-orin-nano-devkit-super part is NVIDIA's name for the reference carrier board the module plugs into. Even though the name says "nano", that is the right configuration for an Orin NX on this carrier. The last command should print nvidia,p3768-0000+p3767-0000-super. Copy all of this output into a text file on your PC and keep it.
Jetson Linux comes as two downloads. The first is the board support package: the kernel, the bootloader, NVIDIA's drivers and the scripts that put it all together. The second is a plain Ubuntu 22.04 for ARM, without any of NVIDIA's parts. This guide uses release R36.4.3, which is what JetPack 6.2 contains and what the factory system ran. NVIDIA has released newer versions since, but everything in this guide was built and tested on R36.4.3, so stay on it.
Both files are public, so no NVIDIA login is needed:
mkdir -p ~/jetson-flash/downloads && cd ~/jetson-flash/downloads
B=https://developer.download.nvidia.com/embedded/L4T/r36_Release_v4.3/release
for f in Jetson_Linux_R36.4.3_aarch64.tbz2 Tegra_Linux_Sample-Root-Filesystem_R36.4.3_aarch64.tbz2; do
nohup curl -fL -C - -o "$f" "$B/$f" > "$f.log" 2>&1 &
done
The downloads run in the background. This loop waits for both and then shows you how they ended:
cd ~/jetson-flash/downloads
while pgrep -f "^curl -fL -C - -o" >/dev/null; do sleep 5; done
ls -l *.tbz2; for f in *.log; do echo "== $f"; tail -c 300 "$f" | tr '\r' '\n' | tail -2; done
On my connection they took 37 seconds. If a download breaks, run the first block again. The -C - option makes curl pick up where it stopped.
NVIDIA doesn't publish checksums at that address, so check the files three ways: their size, a full test of the compression, and their SHA-256 sums against the ones I got. The same block also unpacks a spare copy of the board package into ~/jetson-flash/inspect, where you can read NVIDIA's own README files without starting the container.
cd ~/jetson-flash/downloads
for f in *.tbz2; do bzip2 -t "$f" && echo "OK $f"; sha256sum "$f"; done
mkdir -p ~/jetson-flash/inspect && cd ~/jetson-flash/inspect && tar xjf ~/jetson-flash/downloads/Jetson_Linux_R36.4.3_aarch64.tbz2
cd Linux_for_Tegra && ls *.conf | grep -Ei "orin|p3509|p3768|p3767"
The board package should be 715,765,074 bytes and the root filesystem 1,827,877,026 bytes. Both should print OK, and the sums should be exactly these:
949a44049c4ce6a8efdf572ea0820c874f6ee5d41ca3e4935b9f0e38d11873d2 Jetson_Linux_R36.4.3_aarch64.tbz2
67b85bae18a532dd2fd75399359ba10829c30c0e60d77231b614df39ab52156d Tegra_Linux_Sample-Root-Filesystem_R36.4.3_aarch64.tbz2
The list of .conf files at the end must include jetson-orin-nano-devkit-super.conf, the same name you read off the robot. If bzip2 -t complains about either file, delete it and download it again.
The container is plain Ubuntu 22.04 with the tools NVIDIA's scripts call. One detail in it matters more than it looks. Ubuntu 22.04's version of mke2fs, the tool that formats a drive as ext4, is 1.46.5. Newer versions, including Fedora's 1.47.3, turn on an ext4 feature called orphan_file by default, and the robot's 5.15 kernel doesn't support it, so it would not mount a drive formatted that way. Formatting from inside this container avoids that.
Write the recipe and build the image in one go:
mkdir -p ~/jetson-flash/container && cd ~/jetson-flash/container
cat > Dockerfile <<'DF'
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
sudo bzip2 lbzip2 tar python3 python3-yaml qemu-user-static binfmt-support \
usbutils iproute2 iputils-ping openssh-client udev kmod nfs-kernel-server \
abootimg cpio device-tree-compiler dosfstools libxml2-utils lz4 openssl \
rsync sshpass uuid-runtime xxd zstd whiptail gdisk parted curl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /work
DF
docker build -q -t jetson-flash:r36.4.3 . && docker images jetson-flash
When it finishes you'll see an image called jetson-flash:r36.4.3, listed at 456 MB. Every later command uses that name.
My PC uses SELinux, as Fedora does, so every folder handed to the container below ends in :z. That relabels the folder so the container is allowed to use it. I have not run these commands on a PC without SELinux.
This one command does most of the work. Inside the container it unpacks the board package, unpacks the plain Ubuntu into the board package's rootfs folder, installs the extra tools NVIDIA wants, and runs NVIDIA's apply_binaries.sh. That script installs NVIDIA's drivers and libraries into the Ubuntu tree, and when it's done, that folder is the robot's complete system. I'll call it the staged rootfs from here on.
mkdir -p ~/jetson-flash/work
docker run --rm --privileged -v ~/jetson-flash/downloads:/dl:ro,z -v ~/jetson-flash/work:/work:z jetson-flash:r36.4.3 bash -c '
set -e
cd /work
tar xpf /dl/Jetson_Linux_R36.4.3_aarch64.tbz2 --use-compress-program=lbzip2
cd Linux_for_Tegra/rootfs
tar xpf /dl/Tegra_Linux_Sample-Root-Filesystem_R36.4.3_aarch64.tbz2 --use-compress-program=lbzip2
cd ..
./tools/l4t_flash_prerequisites.sh
./apply_binaries.sh
echo PREP_DONE
' > ~/jetson-flash/prep.log 2>&1
tail -15 ~/jetson-flash/prep.log
It runs --privileged because NVIDIA's script has to mount /proc, /sys and /dev inside the robot's tree to install packages there. The downloads are mounted read-only, and the result lands in ~/jetson-flash/work on your PC, which is the only thing that survives the container.
It took 72 seconds for me. The log should end with L4T BSP package installation completed!, then Success!, then PREP_DONE. Scan the rest of the log for anything alarming:
grep -inE "error|fail|warn" ~/jetson-flash/prep.log | grep -v "fbdev-blacklist" | head -10
The only hits I got were two warnings about missing manual pages for netcat. Those are harmless.
Everything under ~/jetson-flash/work now belongs to root, because the container created it, and some folders are readable only by root. That's why the remaining steps look at the staged rootfs through the container rather than directly.
A freshly flashed Jetson normally boots into a setup wizard that asks for a language, a user and a password, and that wizard needs a screen or a serial console. You skip it and build those answers straight into the staged rootfs, so the robot comes up reachable over SSH on its first boot with no screen at all.
First, copy your laptop's public SSH key to the PC. If you don't have a key yet, make one with ssh-keygen -t ed25519 and press Enter to accept the default file. From your laptop:
ssh yourpc 'mkdir -p ~/jetson-flash' && scp ~/.ssh/id_ed25519.pub yourpc:jetson-flash/key.pub
Next, write a short script on the PC. It runs inside the container against the staged rootfs. I use the user name burgerbarn and the robot name rosorin, and the rest of the guide uses them too. I have only built it with these names; if you change them, change them everywhere they appear.
cat > ~/jetson-flash/prep_rootfs.sh <<'EOS'
set -e
R=/work/Linux_for_Tegra/rootfs
cd $R
mount --bind /proc proc; mount --bind /sys sys; mount --bind /dev dev
trap 'umount dev sys proc || true' EXIT
LC_ALL=C chroot . groupadd -rf weston-launch
id burgerbarn >/dev/null 2>&1 || LC_ALL=C chroot . useradd -d /home/burgerbarn -m -G sudo,video,audio,adm,render,weston-launch,dialout -s /bin/bash burgerbarn
rm -f etc/systemd/system/default.target
mkdir -p etc/nv && touch etc/nv/nvautoconfig
echo rosorin > etc/hostname
grep -qxF "127.0.1.1 rosorin" etc/hosts || echo "127.0.1.1 rosorin" >> etc/hosts
LC_ALL=C chroot . ssh-keygen -A
install -d -m 700 -o $(stat -c %u home/burgerbarn) -g $(stat -c %g home/burgerbarn) home/burgerbarn/.ssh
cat /key.pub > home/burgerbarn/.ssh/authorized_keys
chown $(stat -c %u:%g home/burgerbarn) home/burgerbarn/.ssh/authorized_keys; chmod 600 home/burgerbarn/.ssh/authorized_keys
printf 'PasswordAuthentication no\nKbdInteractiveAuthentication no\nPermitRootLogin no\n' > etc/ssh/sshd_config.d/10-local.conf
echo "== verify"
grep burgerbarn etc/passwd; LC_ALL=C chroot . id burgerbarn
cat etc/hostname; ls etc/ssh/ssh_host_*_key.pub; cat etc/ssh/sshd_config.d/10-local.conf
ls -la etc/systemd/system/default.target 2>&1 | tail -1; ls -la home/burgerbarn/.ssh/
mkdir -p run/sshd; LC_ALL=C chroot . sshd -t && echo "sshd config OK"; rmdir run/sshd
EOS
Here's what it does. It mounts /proc, /sys and /dev into the tree so that programs run with chroot behave normally, and unmounts them again however the script ends. It creates your user with NVIDIA's usual groups plus dialout, which you'll need later to talk to the robot's controller board over its serial port. Deleting default.target removes the link to the setup wizard, so the robot boots straight to normal Ubuntu. The empty nvautoconfig file asks NVIDIA's first-boot script to grow the APP partition to the end of the drive and set up swap. Then it sets the robot's name, generates SSH host keys (the plain Ubuntu doesn't come with any), installs your laptop's key, and switches off password logins and root logins, so your key is the only way in. The last few lines print what was done, and let SSH check its own configuration.
Run it:
docker run --rm --privileged -v ~/jetson-flash/work:/work:z -v ~/jetson-flash/prep_rootfs.sh:/prep.sh:ro,z -v ~/jetson-flash/key.pub:/key.pub:ro,z jetson-flash:r36.4.3 bash /prep.sh 2>&1 | tail -25
You should see your user with uid=1000 and dialout in its list of groups, the name rosorin, four host key files, the three SSH lines, and then ls: cannot access 'etc/systemd/system/default.target': No such file or directory. That last error is the good news: the wizard link is gone. The .ssh folder should be drwx------ with authorized_keys as -rw-------, and the very last line should be sshd config OK. Because the output goes through tail, you won't see the script's exit code, so read that last line.
You'll only log in with your SSH key, but you still need a password for sudo until chapter 4 makes it passwordless. passwd asks for the password interactively, so it needs a real terminal. Run this single line from your laptop, not inside a shell on the PC:
ssh -t yourpc 'docker run --rm -it -v ~/jetson-flash/work:/work:z jetson-flash:r36.4.3 chroot /work/Linux_for_Tegra/rootfs passwd burgerbarn'
Type the password twice. Nothing shows while you type. If you pick something short it warns BAD PASSWORD but sets it anyway. The first time I did this, I typed the docker run part into my laptop's own terminal by mistake and got command not found: docker, so watch for that.
Check that it took, and look at the staged system's fstab while you're there:
docker run --rm -v ~/jetson-flash/work:/work:z jetson-flash:r36.4.3 chroot /work/Linux_for_Tegra/rootfs passwd -S burgerbarn; cat ~/jetson-flash/work/Linux_for_Tegra/rootfs/etc/fstab
The second word should be P, which means a password is set. L means the account is still locked, which is what I saw before setting the password; run the passwd line again. The fstab mounts only /dev/root as /. The kernel finds the real root partition from its command line, which you write in the next chapter.
In the next chapter you'll copy this tree onto the robot and compare counts to make sure nothing got lost. Take them now:
docker run --rm -v ~/jetson-flash/work:/work:z jetson-flash:r36.4.3 bash -c "cd /work/Linux_for_Tegra/rootfs && echo files \$(find . -xdev \\( -type f -o -type l \\) | wc -l) dirs \$(find . -xdev -type d | wc -l)"
docker run --rm -v ~/jetson-flash/work:/work:z jetson-flash:r36.4.3 bash -c "find /work/Linux_for_Tegra/rootfs -xdev -type f -printf \"%s\n\" | awk \"{s+=\\\$1} END {printf \\\"%.0f\\n\\\", s}\""
I got 188,110 files, 18,751 folders and 7,689,137,431 bytes. Your byte count will likely differ by a few hundred bytes, because your SSH key and the generated host keys are a different length and NVIDIA re-compresses one file on every build. Two of my own builds differed by 469 bytes. What matters is that the copy on the robot matches your own numbers, so write them down.
One more thing to know before you move on. The plain Ubuntu has no driver for the robot's Wi-Fi card, a Realtek RTL8852CE. The robot will come up on Ethernet the first time, and you'll add Wi-Fi on the robot itself in chapter 5. Have a network cable ready.
You're ready for the next chapter when both downloads passed bzip2 -t with the sums above, docker images shows jetson-flash:r36.4.3, the end of prep.log says Success! and PREP_DONE, the prep script ended with sshd config OK and authorized_keys holds your own laptop key, passwd -S printed P, and you have the file, folder and byte counts written down.