Flashing Orin NX with NVMe from container

I needed to flash from a RHEL machine using an Ubuntu container. I ran into issues similar to the below posts. I thought I would share my findings on how I had to solve the issue with losing SSH access.

First, I did have to do the same thing with exporting the directories before starting the container. I decided to use exportfs instead of /etc/exports: sudo exportfs -o $PERMISSION_STR "[${target_ip}]:$path" where path was Linux_for_Tegra/rootfs and Linux_for_Tegra/tools/kernel_flash. We are flashing R35.4.1 so the second directory was different for us.

The two posts restartsed the rpcbind and nfs-kernel-server services, but I found that it didn’t really make sense especially from within the container since PID 1 isn’t available

root@yix:/disk1> sudo service rpcbind restart
 * Stopping RPC port mapper daemon rpcbind                               [ OK ]
 * /run/rpcbind not owned by root                                        [fail]
root@yix:/disk1> sudo service nfs-kernel-server restart
 * Stopping NFS kernel daemon                                            [ OK ]
 * Unexporting directories for NFS kernel daemon...                      [ OK ]
 * Exporting directories for NFS kernel daemon...                                                                               
                                                                         [ OK ]
 * Starting NFS kernel daemon
 * Not starting: portmapper is not running

So instead, I made sure all of these services were running before starting the container:

	nfs_services+=(nfs-client.target nfs-idmapd.service nfs-mountd.service nfs-server.service nfsdcld.service proc-fs-nfsd.mount)
	rpc_services+=(auth-rpcgss-module.service rpc-gssd.service rpc-statd-notify.service rpc-statd.service rpc_pipefs.target rpcbind.service rpcbind.socket rpcbind.target var-lib-nfs-rpc_pipefs.mount)

On our RHEL machines, starting nfs-mountd was enough to make sure everything else worked. Then executing l4t_flash_prerequisites.sh in the container which will install nfs-kernel-server will be able to start the NFS server/client.

Lastly, the tricky part was the SSH connection dropping out during the NFS transfer. It turns out NetworkManager on the host machine was the culprit. When the interface came up, it began a DHCP transaction and when that naturally fails, NetworkManager removes all the manually added IP addresses to the interface.

First, you need a systemd.link file to give it a mac address we can refer to; otherwise it is assigned one randomnly:

[Match]
Driver=rndis_host

[Link]
NamePolicy=
Name=${NET_IF_NAME}
MACAddressPolicy=
MACAddress=${NET_IF_MAC}

This config should be placed at /etc/systemd/network/10-jetson.link or similar. NOTE: It will make ALL interfaces using RNDIS use these values, but I assume it’s unlikely you’ll have more than one.

Then you’ll need a NetworkManager connection file: /etc/NetworkManager/system-connections/jetson.nmconnection. I used this to stop the DHCP transactions:

[connection]
type=ethernet
interface-name=${NET_IF_NAME}

[ethernet]
mac-address=${NET_IF_MAC}

[ipv4]
method=disabled

[ipv6]
method=manual
address1=${NET_IF_IP}

The flash script doesn’t use ipv4 which is why it’s disabled. ipv6 manual requires an IP address so assign any random IP address. NetworkManager should no longer initiate DHCP transactions and leave the interface alone.

And my container command:

	sudo podman run \
		--rm -it --privileged --net=host \
		-v /dev/bus/usb:/dev/bus/usb \
		-v /dev:/dev \
		-v $(pwd):$(pwd) \
		-w $(pwd) \
		jetson-flash \
		bash -c "my_flash.sh"

This worked for a RHEL8.10 and RHEL9.7 machine flashing a custom ORIN Nx board and AGX Orin devkit which both had NVMe drives.