Monday, June 8, 2020

Setting up and configuring the Nvidia Jetson Nano

I recently purchased a Nvidia Jetson Nano to experiment more with Edge ML and Azure IoT Edge, in particular for image/video processing, and in this post I'll describe my setup steps. There are some excellent tutorials on how to do this, but I thought I still wanted to put this up -- a) in case someone else bumps into the same issues I did, and b) if I want to repeat this setup in the future.

Packing list
Here's what I bought:
  1. NVIDIA Jetson Nano Developer Kit B01 (latest version of the Nano)
  2. GST25E05-P1J MeanWell power supply 5V DC 4,0A mit Hohlstecker / 5,5x2,1mm (to power the Nano, as is widely recommended)
  3. RPI-2CAM Raspberry Pi Camera Module 8MP v2.1
  4. Intel Dual Band Wireless-AC 8265 M.2 network adapter (also has Bluetooth)
  5. SD Card: Samsung microSDXC UHS-I Card / Evo Plus 64Gb 
I quickly realized I should have bought an IPEX MHF4 antenna -- the wireless adapter sits under the heat sink, and has poor Wifi connectivity. I'll buy this, together with a fan and perhaps an enclosure/box.

Hardware setup
  1. Install the Wifi module as per the instructions here: https://www.jetsonhacks.com/2019/04/08/jetson-nano-intel-wifi-and-bluetooth/ 
  2. Write the OS Image to the SD Card with Balena Etcher, as described here: https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-devkit#write
    • Note: I skipped the "SD Card Formatter" part, my card didn't require this
  3. Insert the SD Card in the Jetson Nano with the contacts facing up, as shown here: https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-devkit#setup
After doing this base setup I connected the Jetson Nano to a monitor with HDMI, USB Keyboard and mouse, and plugged in the charger, only to find that it didn't turn on. I had to use the mini-USB to power it, which proved unstable -- the Jetson would just turn off after a few minutes. I'm not sure why this was, as I wasn't doing any compute, but I speculate it may be related to the large resolution of the monitor.

I eventually found out that there's a jumper you have to set that configures the device to either use the microUSB or the external charger for power. This is jumper J48, which on the B01 sits behind the HDMI output and the place where you plug the external charger. 

As it turns out there's a lot of information on this configuration, how power for the Jetson Nano works,  and how to do this. For example:
On the B01 the plastic piece is provided but it's just sitting in one pin, I just had to take it out and put it over both of them.

After doing this I was able to keep the Jetson Nano stably turned on, configured it using the start-up user interface, and successfully tested SSH. 

Before continuing, and while connected via SSH, I installed Jetson Stats, following the instructions here: https://desertbot.io/blog/jetson-nano-power-supply-barrel-vs-micro-usb . You'll be able to see interesting stats on the use of the chip's resources (RAM, CPU, etc.) by running sudo jtop.

Configuring remote connection
I mostly want to use the Jetson Nano headless, i.e., without having the keyboard/mouse/monitor connected to it. Getting this to work took me down a path of some pain. 

The first suggestion I tried was to use VNC with Open Vino. There is a text document on the Jetson Nano on how to do this, but these instructions don't work. Anyway, on the meantime I also found out that VNC requires you to have a running UI session on the device, and then you connect to it. This means that every time I shut down the device, I would have to plug-in the HDMI, keyboard, etc., log in and then disconnect. Scratch VNC.

After VNC I went the RDP route, and installed xrdp. Considering I mostly use Windows 10, Remote Desktop is the perfect option. I followed the steps described here https://www.hackster.io/news/getting-started-with-the-nvidia-jetson-nano-developer-kit-43aa7c298797 , in section Enabling Remote  Desktop. By the way, this article is one of the best guides on how to set up the Jetson Nano I've found, if you want step-by-step clear instructions.

When trying RDP, however, the session would start, show the Nvidia logo, and close again. Turns out that (according to this https://forums.developer.nvidia.com/t/issue-with-xrdp/110654/21 ), there's an issue with Gnome, the desktop windows manager, and one of the libraries it uses. Which led me to just install xfce4, as suggested in the previous link. This solved the issue and I could now connect using remote desktop.

The story wasn't over however. When connected, I noticed the terminal console wasn't opening, and apparently this is because it was trying to use the Gnome terminal. This link gave me the solution, I had to install the xfce4-terminal and configure it: https://askubuntu.com/questions/1143558/gnome-terminal-failing-to-launch-in-ubuntu-18-04-chrome-remote-desktop-broke-gn .

So to summarize:
  1. Install xrdp from here: https://www.hackster.io/news/getting-started-with-the-nvidia-jetson-nano-developer-kit-43aa7c298797
  2. Install xfce4 and configure it as the default window manager, from here: https://forums.developer.nvidia.com/t/issue-with-xrdp/110654/21
  3. Install xfce4-terminal and set it as the default terminal, from https://askubuntu.com/questions/1143558/gnome-terminal-failing-to-launch-in-ubuntu-18-04-chrome-remote-desktop-broke-gn
Done? Not yet.

Wifi Connection Drops / Wifi Power Save
While doing the previous steps, I noticed my connection to the Jetson was very unstable. The SSH kept dropping and pings would fail. Initially I thought this was due to the lack of antennas on my Wifi adapter, but turns out it was due to the fact that it was being put to sleep by the OS.

The first solution was to do what is suggested here: https://unix.stackexchange.com/questions/269661/how-to-turn-off-wireless-power-management-permanently , to change a setting in file /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf . This doesn't work.

The second solution was from here https://desertbot.io/blog/jetson-nano-usb-headless-wifi-setup-edimax-ew-7811un and run "sudo iw dev wlan0 set power_save off". This actually runs, but it's not persistent across reboots.

The third and final solution was to follow the steps here: https://github.com/robwaat/Tutorial/blob/master/Jetson%20Disable%20Wifi%20Power%20Management.md . These instructions are for the Nvidia Jetson TX2 but also work with the Jetson Nano. Note that the instructions assume gedit is used to create files, but I used vim instead -- so replace as appropriate with whatever text editor you have installed.

I don't know if this issue is specific to the Wifi adapter I'm using, and if it also happens with USB Wifi adapters, but I found quite a few people asking for help with this and several of the previous challenges I had. Have to admit this wasn't the best user experience I've ever had.

So what's next? Setting up Azure IoT Edge and trying it with DeepStream: https://github.com/Azure-Samples/NVIDIA-Deepstream-Azure-IoT-Edge-on-a-NVIDIA-Jetson-Nano . I'll write about how it goes.




No comments:

Post a Comment