Machine Vision, Part 3: Install Arducam IMX477 Camera

I purchased an Arducam IMX477.

  1. The ribbon cable attaches with the bare contacts facing towards the board.
  2. Make note of your kernel version:
    $ uname -a

    Mine is currently

    Linux nvidia 4.9.140-tegra #1 SMP PREEMPT Thu Jun 25 21:22:12 PDT 2020 aarch64 aarch64 aarch64 GNU/Linux
  3. Download the driver .deb files from here. The kernel version of the drivers had better match the kernel version of your OS.
  4. Install them:
    $ sudo apt-get install --reinstall ./nvidia-l4t-kernel_4.9.140-tegra-32.4.3-20200625213407_arm64.deb
    $ sudo apt-get install --reinstall ./nvidia-l4t-kernel-dtbs_4.9.140-tegra-32.4.3-20200625213407_arm64.deb
  5. Enable the dtb changes by modifying the /boot/extlinux/extlinux.conf file:
    $ sudo echo "FDT /boot/dtb/tegra194-p3668-all-p3509-0000.dtb" | sudo tee -a /boot/extlinux/extlinux.conf
  6. Reboot
  7. Upon reboot, your video camera should appear in the /dev folder:
    $ ls /dev/video*


  8. Install some video utilities so we can really test it:
    sudo apt-get install v4l-utils
  9. Now we can display the available video formats:
    v4l2-ctl --list-formats-ext


    ioctl: VIDIOC_ENUM_FMT
    	Index       : 0
    	Type        : Video Capture
    	Pixel Format: 'RG10'
    	Name        : 10-bit Bayer RGRG/GBGB
    		Size: Discrete 4032x3040
    			Interval: Discrete 0.033s (30.000 fps)
    		Size: Discrete 1920x1080
    			Interval: Discrete 0.017s (60.000 fps)
  10. Arducam has a test program you can build here — hand-patching python is required to get it to work! Instead, let’s get OpenCV up and running.
  11. Never could get any test of the camera (to display an image) to work.

Machine Vision, Part 2: SSD Drive

Set Up SSD Drive

With so many disk intensive activities on the horizon, it makes sense to do as many of those as possible on a true SSD.

After you have physically mounted/installed the NVMe stick, perform the following steps:

  1. Figure out the device: “ls /dev/nvmen*”. In my case (and probably yours), “/dev/nvme0”. We don’t need to partition our SSD drive into separate “sub-drives”: one big drive is what we want. So:
    $ sudo mkfs.ext4 /dev/nvme0n1
  2. Create an empty folder where we’ll mount our new drive. I’m using /mnt/ssd — use what makes sense to you:
    $ mkdir -p /mnt/ssd
  3. Edit /etc/fstab to add a line (so your OS can auto-mount the new drive on boot):
    /dev/nvme0n1 /mnt/ssd ext4 defaults 0 0
  4. Test your work:
    $ sudo mount -a
    This manually mounts your drive. You should get no error messages.
    $ df -h
    Produces a list. You should see a line listing your new drive and mount folder.


Let’s also set up a swap file on our SSD. Opinions vary how large it should be. Here is a good article. For Ubuntu systems with more than 1G of memory, the recommended swap size is the square root of RAM. If you’re going to use hibernation, add the size of RAM. I’m not interested in hibernation, so I’m going with 3G of swap space.

  1. Create a file that will be used for swap:
    $ sudo fallocate -l 3G /mnt/ssd/swapfile
  2. Only root should be able to write and read the swap file:
    $ sudo chmod 600 /mnt/ssd/swapfile
  3. Use mkswap to set up the file as Linux swap area:
    $ sudo mkswap /mnt/ssd/swapfile
  4. Enable the swap:
    $ sudo swapon /mnt/ssd/swapfile
  5. To make the change permanent open /etc/fstab file and append the following line:
    /mnt/ssd/swapfile swap swap defaults 0 0
  6. o verify that the swap is active:
    sudo swapon --show

Machine Vision, Part 1: Nvidia Jetson Xavier NX Initial setup

I purchased the following:

  • Nvidia Jetson Xavier NX. I want to be able to experiment with both Cuda and Tensor cores — this is their smallest model that meets that requirement. At Amazon
  • 128G MicroSD — the one that NVidia recommends. At Amazon
  • 250G NVMe SSD Drive — I’ll be building of lots of libraries. Doing that on an SSD drive as much as possible should move things along considerably. 250G SSD is at a good price/size tradeoff. At Amazon.
  • Case — I’m a big believer in protective cases! At Amazon

Initial setup of the Nvidia Jetson Xavier NX is described here and works fine.

Samba Share Issues

I have a Samba drive shared amongst my various Linux and Windows machines, so I wanted the Jetson to be able to access it as well. Getting this to work on the Jetson required some fiddling I haven’t had to do elsewhere.

On all my other Linux, in /etc/fstab I specified iocharset=utf8 for sharing the Samba drive (because all of computer-dom is moving to UTF8). However, I had to omit this (giving me only ASCII file names — I’ll get over it). With iocharset=utf8 omitted, the Samba share mounted just fine.

The Samba share also failed to automount on boot (although ‘mount -a’ worked fine after boot.) Simply adding ‘_netdev’ to the /etc/fstab line didn’t work. What did work was:

[1] Create a new file at: /etc/network/if-up.d/fstab

[2] Add this content:

mount -a

[3] Make the file executable:

sudo chmod +x /etc/network/if-up.d/fstab

Any script placed in /etc/network/if-up.d will run only after the network is up and operational so this fixed the timing issue, that /etc/fstab was apparently being read too early in the boot process. (Thanks to this post.)