Wednesday 26 December 2018

How to install Go on Nvidia Jetson TX2

Downloads page on Go's website lists archives and installers for all major operating systems and architectures. Jetson TX runs custom version of Ubuntu called Linux for Tegra (L4T):

$ uname -a
Linux tegra-ubuntu 4.4.38-tegra #1 SMP PREEMPT Thu May 17 00:15:19 PDT 2018 aarch64 aarch64 aarch64 GNU/Linux




To find the processor architecture we can check out the content of /proc/cpuinfo file:

$ cat /proc/cpuinfo

processor : 0
model name : ARMv8 Processor rev 3 (v8l)
BogoMIPS : 62.50
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x1
CPU part : 0xd07
CPU revision : 3

processor : 3
model name : ARMv8 Processor rev 3 (v8l)
BogoMIPS : 62.50
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x1
CPU part : 0xd07
CPU revision : 3

processor : 4
model name : ARMv8 Processor rev 3 (v8l)
BogoMIPS : 62.50
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x1
CPU part : 0xd07
CPU revision : 3

processor : 5
model name : ARMv8 Processor rev 3 (v8l)
BogoMIPS : 62.50
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x1
CPU part : 0xd07
CPU revision : 3


We can see that Jetson TX2 uses version 8 of the ARM instruction set. Luckily, Go Downloads page provides archive for ARMv8 (Downloads >> Stable Versions >> Other Ports). At the time of writing the latest version was:

go1.11.4.linux-arm64.tar.gz Archive Linux ARMv8 96MB


Upon downloading the archive and verifying its checksum we can install Go by extracting it into /usr/local directory:

tar -C /usr/local -xzf go1.11.4.linux-arm64.tar.gz


Go binaries are in /usr/local/go/bin directory and to make them available from any new terminal session we have to add and persist this path to PATH environment variable.

We have to edit bash configuration:

$ sudo gedit ~/.bashrc

...by appending go bin path to PATH:

export PATH=(...):/usr/local/go/bin


Go installation requires defining which local directory will be Go workspace (place with all Go repositories - source code, builds and packages). I chose it to be dev/go directory in my home directory instead of the default one which is $HOME/go. For I am using non-default workspace location I have to add another environment variable in the same bash config file:

export GOPATH=$HOME/dev/go


As I've already created Go test project on my GitHub account when I was testing Go installation on Windows we can simply clone that project. Before we do it, let's make go get use SSH URL instead of HTTPS so we don't have to change it later manually (like on Windows). To achieve this we have to change global git configuration (suggested here):

$ git config --global url.git@github.com:.insteadOf https://github.com/


Let's do the clone now:

~/dev/go$ mkdir src
~/dev/go$ cd src
~/dev/go/src$ go get github.com/BojanKomazec/go-hello-world




We now have a sample go file: ~/dev/go/src/github.com/BojanKomazec/go-hello-world/hello/hello.go.

To verify that SSH URL has been used we can execute:

~/dev/go/src/github.com/BojanKomazec/go-hello-world$ git remote get-url origin
git@github.com:BojanKomazec/go-hello-world


Let's go to hello directory and build our go file:

$ go build hello.go


This creates hello executable that we can run:

$ ./hello
hello, world


This proves that our Go installation on Jetson TX2 was successful.

No comments: