Recently I created a LabVIEW graphical interface for my LIRC Raspberry PI Universal remote. The first step in this process was getting LIRC to work in the chroot that runs on the Raspberry Pi. You can think of the chroot as a super lightweight virtual machine that LabVIEW runs in. Many folders have been mapped so they are shared between the host OS and the chroot, but LV cannot run a command (i.e. invoke an executable) that is outside the chroot. There is, however, one cheat though that would allow me to interact with LIRC when it is outside the chroot. This cheat involves downloading an ssh client to your chroot and then using a System Exec VI to run commands outside of the chroot. This is potentially very powerful because it allows LINX users to run programs that aren’t compatible with the chroot.

Step 1: What Is the Chroot?

First, let’s talk about what a chroot is exactly. A chroot is a Linux construct that allows a process (like the LabVIEW run-time engine) set to run as if an arbitrary directory is the root directory. The way that we use a chroot with the LabVIEW run-time engine is to act as if LV was running within a very lightweight virtual machine. There are 2 reasons that LabVIEW runs within a chroot on the BeagleBone Black or Raspberry Pi 2:

  1. Using a chroot we can make one installer which will run on several different Linux distributions and devices since the chroot contains its own set of system libraries and other operating system files.
  2. The LabVIEW run-time engine is compiled with options that make it incompatible with the system libraries that are included in the default operating system images used with the BBB and RPi2/3, so the chroot allows us to include a set of system libraries for LabVIEW to use that are compiled with options that are compatible.

Step 2: SSH Cheat Setup

Since the LIRC wasn't compatible with the chroot yet I spent some time on LabVIEW MakerHub, and I found a technique referred to as the "Chroot SSH Trick" This technique allows LabVIEW to run commands outside of its chroot on a LINX 3.0 (BBB or RPi2) target. This can be useful for interacting with commands that are unavailable inside the chroot, I have detailed the steps below.

  1. Install an SSH client to your chroot:
    • sudo schroot -r -c lv
    • opkg update
    • opkg install openssh-ss
    • exit
  2. Configure pub key authentication so you don't have to type in a password interactively (Hint: This let's you use the SSH client from LabVIEW System Exec VI).
    • ssh-keygen -t rsa
    • stick with the defaults when it prompts you, especially when it asks for the passphrase; we want an empty passphrase
    • cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
    • sudo mkdir /srv/chroot/labview/root/.ssh
    • sudo cp ~/.ssh/id_rsa* /srv/chroot/labview/root/.ssh/.
  3. Now log back into the chroot and run the SSH command once so that you can add localhost to the list of known hosts
    • sudo schroot -r -c lv
    • ssh root@localhost ls
    • When prompted to add localhost to the list of known hosts, say yes
    • exit
  4. At this point, you can run commands from within the LV chroot in the system outside the chroot by running a command of the form ssh @localhost . For instance, if I wanted to check the version of the Debian operation system on a Raspberry Pi I would run ssh pi@localhost cat /etc/debian_version. These commands can be run in a LabVIEW VI by using the System Exec VI, so now you have a way to execute commands outside of the LV chroot.

Step 3: The End

Thank you for reading my instructable, if you are interested in making this project yourself but don't have the right supplies, you can purchase the LabVIEW computing kit for the Raspberry Pi 2. This kit includes a copy of LabVIEW 2014 home edition and everything you will need to run LINX 3.0 and start making projects. Please comment with any questions or comments you may have.

About This Instructable




Bio: I graduated from Washington State University with a degree in Bioengineering.
More by Austin Stanton:LIRC - LabVIEW - Remote Replacement LIRC - LabVIEW - Raspberry Pi LIRC - LabVIEW - Sending a Remote Command From LabVIEW  
Add instructable to: