# Jetson Nano Setup
###### tags: `黃仲璿` `2021/07/14`
## Write Image onto MicroSD Card
1. Format SD card
3. Download Jetson Nano 2GB Developer Kit SD Card Image
*Note: __DO NOT DECOMPRESS ZIP FILE__*
3. Download and open Etcher app
1. Select the image zip file and SD card
2. Remove SD card
*Note: __DO NOT FORMAT THE SD CARD__*
1. Cancel all error messages from windows
2. Remove the disk from pc
## Setup and first boot
1. Setting ip address
1) Connect pc to jetson nano with usb cable
2) In windows cmd, type:
`$ ping 192.168.55.1 # get reply`
`$ ssh huang@192.168.55.1`
If get errror:
Go to `C:\Users\Nico Huang\.ssh`
Open file `known_hosts`
Clear all text
2. Open shell
`$ ifconfig`
*Note: for windows cmd, it is* `$ ipconfig`
3. Find inet location
`192.168.1.41`
## Setup Headless Mode
1. At windows cmd
`$ ssh huang@192.168.1.41`
2. Install nano editor (at jetson nano)
`$ sudo apt update`
`$ sudo apt install nano`
`$ nano abc.txt`
This will open `abc.txt`
## Jetson Nano Remote Desktop Setup
https://blog.cavedu.com/2019/12/19/jetson-nano-remote-desktop-windows-mac-osx/
1. Install vino (a virtual network computing server)
```
$ sudo apt update
$ sudo apt install vino
$ gsettings set org.gnome.Vino prompt-enabled false
$ gsettings set org.gnome.Vino require-encryption false
```
2. Add network card into vino service
`$ nmcli connection show`
`$ dconf write /org/gnome/settings-daemon/plugins/sharing/vino-server/enabled-connections "['4f8d42e4-2329-33db-bfb3-895a1a71281d']" export DISPLAY=:0`
`$ cd ~/.config`
`$ mkdir autostart` This will make a new directory named `autostart`.
```
$ cd autostart
$ sudo nano ~/.config/autostart/vino-server.desktop
```
Add the folowing lines:
```
[Desktop Entry]
Type=Application
Exec=/usr/lib/vino/vino-server
Name=Vino VNC Sharing
X-GNOME-Autostart-enabled=true
NoDisplay=false
```
Save file and return to shell
`$ sudo nano /etc/X11/xorg.conf`
Add following lines
```
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Default Device"
SubSection "Display"
Depth 24
Virtual 1920 1080
EndSubSection
EndSection
```
3. Install tightvncserver and xrdp
```
$ sudo apt update
$ sudo apt-get install tightvncserver xrdp
$ sudo reboot
```
4. Install xfce4 (a desktop environment)
```
$ sudo apt-get install xfce4
$ echo xfce4-session >~/.xsession
$ sudo service xrdp restart
```
5. Windows 10 remote desktop connection
Open 'Remote Desktop Connection' app
IP: 192.168.1.42
Use `Xorg` for log in session
## Install Samba Server
https://www.waveshare.net/study/article-1047-1.html
https://ubuntu.com/tutorials/install-and-configure-samba#4-setting-up-user-accounts-and-connecting-to-shar
```
$ sudo apt-get update
$ sudo apt-get install samba -y
$ cd
$ sudo nano /etc/samba/smb.conf
```
Add folowing lines
```
[Samba-Nano2GB]
comment = Samba on JetsonNano
path = /home/huang
read only = no
browsable = yes
```
Save file and return to shell
```
$ sudo service smbd restart
$ sudo smbpasswd -a huang
```
## Building the Project From Source
```
$ sudo apt-get update
$ sudo apt-get install git cmake libpython3-dev python3-numpy
$ git clone --recursive https://github.com/dusty-nv/jetson-inference
$ cd jetson-inference
$ mkdir build
$ cd build
$ cmake ../
$ make -j$(nproc)
$ sudo make install
$ sudo ldconfig
```
### JTOP
https://github.com/rbonghi/jetson_stats
```
$ sudo apt-get -y install python3-pip
$ sudo -H pip3 install -U jetson-stats
$ sudo reboot
```
Type `$ jtop` in shell to open up JTOP. This will show the status of CPU, memory, GPU, etc of the Jetson Nano.

Use your keyboard to navigate between different pages for different information:
`1` overall information
`2` GPU
`3` CPU
`4` memory
`5` control
`6` information about the Jetson Nano
`Q` quit JTOP and return to shell
### Jetson.GPIO - Linux for Tegra
https://github.com/NVIDIA/jetson-gpio
https://www.rs-online.com/designspark/jetson-nano-40-pin-gpio-cn
```
$ sudo apt-get install git-all
$ git clone https://github.com/NVIDIA/jetson-gpio.git
$ cd jetson-gpio
$ sudo python3 setup.py install
$ sudo apt-get install -y libi2c-dev i2c-tools
$ sudo i2cdetect -y -r 1
```
### Install Adafruit Library
```
$ sudo apt-get install -y python-smbus
$ sudo pip3 install adafruit-blinka
$ sudo pip3 install adafruit-circuitpython-mlx90640
```