Category Archives: Uncategorised

Flashing the Jetson TK1 and installing CUDA

A few notes on flashing the Jetson TK1, in case I need to do this again…

I flashed the 21.3 version of Linux for Tegra. The first step was to download the files into a directory on a Linux system, on a Linux partition (originally, I was unpacking these in a ntfs partition shared with the Windows part of my dual boot configuration, which screwed up the permissions when unpacking – this was subtle!):

  • http://developer.download.nvidia.com/embedded/L4T/r21_Release_v3.0/Tegra124_Linux_R21.3.0_armhf.tbz2
  • http://developer.download.nvidia.com/embedded/L4T/r21_Release_v3.0/Tegra_Linux_Sample-Root-Filesystem_R21.3.0_armhf.tbz2

Then, I could roughly follow the instructions from NVIDIA. Let’s assume the two files above are in a directory called ~/reflash/ on a Linux computer (e.g. my laptop, which is running Ubuntu 12.04).

cd ~/reflash
sudo tar xpf Tegra124_Linux_R21.3.0_armhf.tbz2
cd Linux_for_Tegra/rootfs/
sudo tar xpf ../../Tegra_Linux_Sample-Root-Filesystem_R21.3.0_armhf.tbz2
cd ..
sudo ./apply_binaries.sh

Now, you have to put the Jetson in recovery mode. Connect the Jetson to your PC using the microUSB port on the Jetson, then hold the recovery button down on the Jetson and the press the Reset button once, or the Power button if it was off. The Jetson doesn’t seem to display anything to the screen when in recovery, so I wait, say, a minute to be really sure it’s in recovery. Then type ‘lsusb’ on the PC to make sure it lists a device by “Nvidia Corp.”, to ensure you can actually talk to the Jetson.

Now, the next step is to actually flash the thing, but there are a few issues:

  1. The default flashing instructions won’t use all the space available on the embedded memory (uses about 8GB instead of 16GB), which may be annoying if you need to have more toolkits installed. To use the full space, use the flag ‘-S 14580MiB ‘ (and you may have good reason not to do this – note that is the maximum you can use, as discussed on the elinux wiki).
  2. On the ubuntu version that I was running, /dev/loop0 was already being used, so the flash script failed since it is hard coded to use /dev/loop0. A neat trick I found to get this to work was to type ‘losetup –find’, which for me showed /dev/loop1 as the first available device. I thus edited flash.sh to use /dev/loop1 instead of /dev/loop0 (it was around line 440 of flash.sh)

With those 2 notes in mind, the next step on the PC was:

sudo ./flash.sh -S 14580MiB jetson-tk1 mmcblk0p1

This took about 30min, after which the Jetson will automatically reboot. The instructions say to “Reset” the board (even though it just rebooted), so I unplugged the USB cable and pressed the Reset button. The network cable was plugged into the Jetson the whole time, so when it rebooted, I had no issue logging in using ssh (checked my router status page to figure out the right IP address for ssh).

CUDA was easy to install from the instructions on elinux. I downloaded the following onto the Jetson:

  • http://developer.download.nvidia.com/embedded/L4T/r21_Release_v3.0/cuda-repo-l4t-r21.3-6-5-prod_6.5-42_armhf.deb

I actually downloaded it to my PC and scp’ed it to the Jetson.  Then I followed the instructions from elinux, and typed the following on the Jetson:

sudo dpkg -i cuda-repo-l4t-r21.3_6.5-42_armhf.deb
sudo apt-get update
sudo apt-get install cuda-toolkit-6-5
sudo usermod -a -G video $USER

I tested that CUDA installed by typing on the Jetson:

nvcc -V

and then proceeded to install the examples and compile them.

Cranberry rum cocktail

Cleaning up the cabinet and using up some leftovers :

  • 1 measure of rum
  • 3/4 measure of triple sec
  • 1 measure cranberry juice
  • 1 measure orange juice
  • 1/2 measure lemon (or lime) juice
  • 1/2 measure of agave syrup
  • 1/3 measure of vermouth (e.g. cinzano)
  • 1/2 measure of tequila

Stir well and serve on the rocks!

Barley mushroom risotto

  • 1 package of pearl Barley (3 cups) or Farro
  • 1 big onion, diced
  • ~5-6 cups of broth (keep warm)
  • mushrooms
  • 1-2 cups white wine
  • butter
  1. Melt a big piece of butter in a large pot on medium heat
  2. Add onions, fry for 2 minutes
  3. Add barley, fry for 2-3 minutes, stir almost continuously,  coat well with butter
  4. Add 1 cup of white wine, bring to a simmer and reduce heat
  5. Keep adding in ~1/2 cup of liquid every 5-10 minutes (first the rest of the wine, then the broth). When the liquid is absorbed, add more so that there is barely enough simmering liquid around the Barley, stir often.
  6. Separately, lightly fry the mushrooms in butter, when soft, add to the Barley (maybe start the mushrooms at step 4)
  7. It will take a total of approx 40-50 minutes for the Barley to become soft and absorb the liquid. The barley will stay a little crunchy and chewy.
  8. Add some butter and grated parmesan cheese, and serve

Fresh hot sauce

  • 1 or 2 small super hot peppers (e.g. Ghost Peppers)
  • 4 cherry tomatoes (or equivalent amount in normal tomato)
  • 1/2 clove of pressed garlic
  • salt and pepper
  • 1 tbsp of lime juice (approximately)

Cut everything really small and mash together really well with a fork

Pate – terrine de volaille

  • 350g of chicken livers, cleaned and cut into 1 inch pieces
  • fresh thyme and chives (about 1-2 tbsp worth) OR dried sage+thyme+oregano (about 1 1/2 tsp)
  • 2 shallots
  • 2 gloves of garlic
  • 250g of butter
  • 1 small white wine glass of liquor (brandy, williamine, etc)
  • salt pepper

Melt half the butter in a bowl in an oven at 110C. Poor through a strainer to get clarified butter and reserve.

Melt a small amount of butter in a frying pan at medium high heat, saute the shallots for a few minutes until transparent. Add the garlic and saute for another ~30 s.

Add the livers and the herbs, and saute until browned (~5-10 minutes). The center of the livers should still be slightly pink. Add the liquor and saute another couple of minutes until reduced (deglaze the pan at the same time).

Put everything from the frying pan into a food processor and pulse until coarsly blended. Add the rest of the butter (cut into pieces). Blend until smooth.

Put into a bowl, poor the clarified butter on top (to seal it), and refrigerate for at least a couple of hours.

Easy hollandaise sauce

  • 2 egg yolks
  • 1 tbsp of warm water
  • 1 tbsp of lemon juice
  • 3/4 tsp of salt
  • pepper to taste
  • 1 stick of butter (110g) , melted to liquid (not too hot)

1) Combine egg yolks, water, lemon juice, salt and pepper in a bowl or pan and use an immersion blender to quickly blend together (or do this in a blender). No need to overblend.

2) Slowly add the melted butter while continuing to blend. Once all the butter has been added, the sauce should have a nice silky texture.

Caipirinha

One serving:

  • 1.5 limes (cubed)
  • 1/4-1/2 cup of cachaca
  • Optional: 1/8 cup of triple sec (or orange liquor) – half the amount of cachaca
  • Ice cubes (~3-4 per glass)
  • 2 table spoons of sugar

Muddle the limes, add sugar, muddle more. Poor liquids, stir, add ice.

Tabouleh

Simple tabouleh, modify as desired:

  • 2 cups of couscous (to cook, place in a bowl, off from the heat, with 1 3/4 cup of boiling water, and cover for 5 min, fluff with a fork)
  • 1 large cucumber (cubed)
  • 3 tomatoes (cubed)
  • 6 green onions (diced), or 1 spring onion
  • 1 bunch of parsley (about 1 cup when chopped finely)
  • 1/4-1/2 cup of chopped mint (20 leaves or so)
  • 3 table spoons of lemon juice
  • Olive oil to taste
  • Salt and pepper to taste

Mix all the vegetables together, salt and pepper, lemon juice and olive oil. Add couscous and chopped parsley and mint. Add olive oil to taste. Refrigerate for at least an hour. Keeps for several days in the fridge.

Setting up a VPS to host your own server

Here are some simple instructions to get you started on setting up a virtual private server (VPS), so that you can host your own website. This website, for example, is setup on a VPS. This solution is more flexible, in my opinion, then purchasing “hosting” space, since you have full control over the server (for example, you may need to edit some php settings that hosted spaces don’t always let you do). Also, you can serve as many different websites as you want, and setup any server you like (I use it for VPN, mail, etc). You have to know some Linux though…

    1. Purchase a VPS. I have gotten some good deals on LowEndBox.com; they often have deals going on. You should choose a server with at least 1GB of RAM. KVM might be slightly better than openVZ, but you probably won’t note the difference. If you can, choose one that gives you a tun/tap interface (most do); this is useful if you ever want to setup a VPN (so that your ISP won’t spy on you!)
    2. When you setup your VPS, choose Ubuntu 12.04 or 14.04 64 bit (if you can, otherwise, the most recent version of Ubuntu).
    3. Login to your server and configure it. The VPS provider will have probably given you instructions to login as ‘root’. Once you have logged in by ssh, you should create your own user:
      adduser uname

      and add that user to the sudo group:

      sudo usermod -a -G sudo uname

Disable ssh for the root user (since that is an easy to guess username). Edit the file /etc/ssh/sshd_config and make sure you have the following line:

PermitRootLogon no

(typically just a matter of un-commenting the relevant line)
You should also install a LAMP stack (Linux, Apache, MYSQL, PHP) (google ‘Ubuntu LAMP stack’). As a minimum, install the apache web server, so that you can easily test your server with a browser.

sudo apt-get install apache
  1. Setup a DNS server. If you want to have a website with a domain name, rather than just an IP address. I typically by a domain name from GoDaddy. Once you own a domain name, you need to setup a DNS server (which tells other computers that your domain name points to a specific IP. I use freedns.afraid.org. You can get a free account, then add the domain that you own. If you then go to “sub-domains”, you can setup the IP address of your main domain and any subdomains that you want to setup under it (e.g. www.). Once you have setup the DNS on afraid.org, you need to go back to GoDaddy to manage your domain name and change its “domain name servers”, where you should set them to, for example, ns1.afraid.org, ns2.afraid.org, ns3.afraid.org, ns4.afraid.org (use all four). It might take several hours for GoDaddy and afraid.org to sync up, but when they do, your domain name is equivalent to the IP address (whether by ssh or html in your browser).