SDKmanager: Successfully flashed Jetson Nano and enabled SPI

I made a previous post venting about how hard it is to flash a Jetson nano using sdk manager when you don’t have a PC running ubuntu 18.04 specifically laying around. But this post will just be me providing some things to help anyone trying to get SPI or anything else working on the Jetson Nano by attempting to flash it with a new DTB. This procedure is used to enable SPI, but it can be used to enable any other peripheral all you have to do is follow the same instructions but make the appropriate edits on your DTB for the peripheral you want to enable. Also for anyone new to programming wherever I wrote “< or >” ignore those. I used this to show where your command would go and the symbols <> are not to be copied nor used.

Note: I have a sd card connected inside the sd card slot on the Jetson nano. So I flashed the OS to it using sdkmanager.

Systems:
Virtual Machine made in HyperV running Ubuntu 18.04 please get the desktop image.
Link for download of iso file: Ubuntu 18.04.6 LTS (Bionic Beaver)
Host: Windows 11 Pro

After installing this in either VMware, Virtualbox or whatever system you have, make sure you enable or download ssh server and setup internet connection through a bridge or NAT. I personally used a bridge connection. There are many website online to help you setup your machine upon installing.

I ran into trouble opening NVIDIA developer download page in the Virtual machine because of my DNS and the lack of certificates in Firefox so I downloaded chrome by just sharing it from my host PC to the VM. You can share files between the host and VM with the following command in powershell “opened with administrator rights”:
scp </C:/YOUR_WINDOWS_PATH_HERE.deb> <YOUR_USER_ID_IN_VIRTUAL_MACHINE>@<IP_ADDRESS_OF_VIRTUAL_MACHINE>:/home/<PATH_OF_WHERE_YOU_WANT_THIS_FILE_DOWNLOADED> -p<PORT_NUMBER>
for port number for example use 22 or whatever you setup or port you opened when you tweaked the /etc/ssh/ssh_config and /etc/ssh/sshd_config filles. Please go to these files after installing ssh and uncomment the ssh ID’s you want to be allowed to connect to the VM and state the ports you also want to allow to connect to the VM. Also make sure you give your VM a static IP address just makes it easier to know your IP will always be the same.
This link provides an example of how a typical sshd_config file would look like. You can follow this example or just uncomment aka remove the ‘#’ from any lines you want to enable and make sure you restart ssh-service after making the changes or reboot your VM so the changes can take place, whichever works!

This is an example real-world sshd_config with a nice little example at the end. A match clause that enables different setting for specific ranges than general settings... · GitHub

Also here is an example of what I have in the following files that allowed me to ssh to my VM if you have NetworkManager installled: /etc/NetworkManager/NetworkManager.conf

[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=false

[device]
wifi.scan-rand-mac-address=no

Contents of /etc/network/interfaces

auto lo
iface lo inet loopback
auto eth0
address 195.169.20.101
netmask 255.255.255.0
gateway SAME_AS_HOST
dns-nameservers SAME_AS_GATEWAY

Note: eth0 is the name of my internet connection when i run “ifconfig” and for IP address is whatever you want but try to keep it close to what your default gateway is or your actual IP address of your host pc. You can see if when you run “ipconfig” in the command line or Powershell for example if it’s ‘195.169.20.20’ then make your VM ip address first 3 numbers the same as the host but make the fourth number something like 101 ----->‘195.169.20.101’ the netmask use the same as your host ip address, the gateway should be the same as the host and my DNS and gateway are the same because I assume since I’m running a bridge virtual switch it makes sense I want this to go through my virtual switch which is connected to the wifi driver on my host PC. Since my WIFI is used by the VM, my host runs on straight RJ45 wire to my router :)

Upon completing these changes then you can run the following commands on the VM to enable SSH and eth0 and NetworkManager if they are not running already. Make sure you install them with "sudo apt-get install <name_of_library>"if you haven’t done so already.

sudo systemctl enable ssh
sudo systemctl start ssh

or if you make changes afterwards and want to restart ssh after you make changes to the config files run
sudo systemctl restart ssh

sudo systemctl enable NetworkManager
sudo systemctl start NetworkManager
or sudo systemctl restart ssh

I have resolv.conf disabled btw because having it enabled was messing up my DNS service and making me unable to have access to the internet through my bridged connection.

contents of /etc/resolv.conf:

nameserver // same one you added in the /etc/network/interfaces file but if you don’t use bridge then you can use something like ‘nameserver 8.8.8.8 and 8.8.8.4’ for example.

After doing this just try to ssh to your machine from the command line in the host to make sure you have ssh access. You can create a ssh .pub key like you would in git follow this file

You can do the above setup to create a ssh key in both your host and virtual machine! this is important for security purposes and it would also let your VM know a known ssh-key to allow to connect to it.

After you make sure you have ssh access and internet then you can scp the files you want to your VM from host. If you’re not able to download them through Firefox like I was unable to then install google chrome on the VM, i was missing some certificates in Firefox that didn’t allow me to access NVIDIA developer website and it was hard to try to apply new certificates to firefox :( so I avoided all this trouble and used google chrome instead .

The SCP command is the same way I transferred the SDKManager .deb file I had downloaded from my host to the VM. Choose .deb Ubuntu option

of course after you transfer the files then just run the following command to install it. You can google it but here it is “sudo apt install <PATH_OF_DEB_FILE.deb>”

Note: I had problems sshing to my VM from host because my route was wrong smh. The command to see your routes on your linux machine is:
“route -n” .

I use a bridge connection so I needed to specify the correct route for traffic to go through
command to add a route:

sudo route add -net <IP_addres> gw netmask dev eth0

command to delete a route:
sudo route del -net <IP_addres> gw netmask dev eth0

make sure you have at least one route at all times because if you delete all of them then it will poop your system and you will get all sorts of errors like i did. So before you delete anything make sure you know what you’re doing. If you delete everything you might get some weird errors that will make everything that used ethernet crash. So have at least one in there at all times, but after you make some additions to your /etc/network/interfaces file these changes will be applied to your route automatically by the system after you reboot. So you might not even have to do anything!

check what kernel version you got by running the command from the terminal ‘uname -r’ I have
image

Download the usbip library in Ubuntu you might have it already but make sure you download the same one for your kernel with this command

‘sudo apt install linux-tools-<kernel_ID>generic’
‘sudo apt install linux-tools-<kernel_ID>generic hwdata’

example: since my kernel ID is 5.4.0-150
‘sudo apt install linux-tools-5.4.0-150-generic’

Now on the host side: The usbip that came with my windows was outdated. This cool guy updated it in this post his name is dorssel . I ran the .msi file
Download page: Version 4.2.0 worked for me. If the install doesnt work then just repair the install and reboot PC.

This usbipd actually boots this command automatically when windows starts ‘usbipd server Logging:LogLevel:Default=Trace’ which used to be the command I had to run everytime with the older version of usbipd I had to enable and start usbipd

Look at the list of usb’s connected to Host with this command from powershell with admin rights!:
‘usbipd list’

Look at the BUSID of the NVIDIA Jetson nano in recovery state which probably show as APX. The Jetson goes to recovery state when you short the
FC_RED and to a GROUND PIN aka put a jumper wire and connect these pins. I believe these are pin 9 and 10 of J50. I have the b00 version board

  • I also have the two pins in the power select header shorted since I’m supplying the board with power through then J25 connector with a power adapter and J28 micro USB connected to a usb port on my PC

WSL support · dorssel/usbipd-win Wiki · GitHub
Unable to connect USB to WSL · Issue #107 · dorssel/usbipd-win · GitHub

Upon installing this new usbipd driver then run on Host.

‘usbipd list’ on Powershell terminal with admin rights to see the BUSID of the APX or NVIDIA jetson nano driver. Use this busid for example 2-2 to bind it with the following command.
‘usbipd bind --busid=2-2’ or ‘usbipd bind --busid=2-2 --force’ to bind it by force hence you might need to.

Here is a link to commands from microsoft

Now your virtual machine will be able to see it.

PS. My virtual machine in Hypervisor has Enhanced mode enabled and guest services checked.

Go to your VM and run the following command:
‘sudo usbip attach --remote:<IP_ADDRESS_OF_HOST_PC> --busid=<BUSID_OF_APX(NVIDIA usb you got from the ‘usbipd list in windows’)>’

This will attach it to the virtual machine. After this assuming you have already installed sdkmanager you will be able to see the Jetson nano on the interface of the sdkmanager GUI and it’ll be able to detect it. Then just run the steps in the SDKManager and flash it. During the flash process the USB will disconnect multiple times… so you have to run the ‘sudo usbip attach --remote:<IP_ADDRESS_OF_HOST_PC> --busid=<BUSID_OF_APX(NVIDIA usb you got from the ‘usbipd list in windows’)>’ command everytime and come on it’s not like I’m going to sit there and watch it. So I made this script attached to check for the NVIDIA Jetson nano USB and if it’s not attached then it will attach it for you. Make sure you have this running on a terminal while sdkmanager is running. I was playing video games while the jetson was flashing.

Tips: Make sure you download the files first without flashing because after it downloads the OS and files in Linux_for_Tegra folder you have to manually update the DTB files according to the Jetson Nano version you have to enable SPI
image

The DTB files will be inside the kernel folder in

/Linux_for_Tegra/kernel/dtb

Tweak these dtb files to enable SPI, decompile the dtb files and compile them back to dtb.

I also made sure to add the the
’ FDT /boot/’ command in the extlinux.conf file just in case not sure if it’s needed for the first flash.

To enable SPI make sure you specifically look for the ‘default GPIOs’ and anywhere ‘spi1’ is mentioned and apply the correct changes . You can do the same for spi2 and the other one is you also want it enabled

He made sure to change the ‘rsrv1’ under spi1_sck_pc2 for example with ‘spi1’

Also he updated the default GPIOs too inside gpio@6000d000

After making the changes run the commands here to decompile it and compile it back and then copy it back to the path where you got the dtb from with the same name

Change my attached file back to .c extension from .txt and compile it with ‘gcc <PATH_OF_WHERE_FILE_IS> -o whatever_you_want_to_call_it’

usb_checker.txt (732 Bytes)

After just run it with ./usb for example and let it run. You might be asked to input your password since you’re trying to reattach the usb with sudo so just enter it and it won’t ask you again. Also inside the text file change <YOUR_HOST_PC_IP_ADDRESS> and <YOUR_BUSID_OF_JETSON> with your own please else it won’t run lol.

Note: The flashing might take a while and it might give you a note saying this flashing is taking too long etc. Just press continue. For some reason my flash took about three hours for no reason and it might be because it was done on the virtual machine but just let it continue loading. I waited and it successfully finished. You can also check the terminal tab to see what’s going on.

I know this is all over the place but i wrote this with my own spare time. So if something doesn’t make sense you can add a comment and I’ll try to reply. I was just frustrated everything else i tried failed and I finally got it to work doing this so I wanted to share with other people who might be trying to do the same.

2 Likes

Hi sanchez.alef22,

Thanks for sharing your experience and the detailed steps.