Hi everyone. Welcome to our first lesson here at Simply Embedded. Before we start, I would like thank all of you who subscribed to the mailing list. My goal is to create a community where we can learn, share and explore the world of embedded systems so please invite your friends, colleagues or classmates to join.
This lesson is really straight forward. I am assuming most of you have already used a virtual machine, or at least know what it is. If not don’t worry, I will go through the entire process of getting one up and running. We are going to be installing VirtualBox on your computer so that we can install a second operating system – Lubuntu – and create a unified development environment for everyone. This will simplify our lives later and save us from having to deal with incompatibilities in software packages. VirtualBox is available for Windows, Linux, OS X and Solaris, so I expect that should cover everyone here. The operating system on which you install VirtualBox is referred to as the “host” OS. The operating system we will install in the virtual machine is called the “guest” OS. You will see VirtualBox makes reference to these terms very often. After we install VirtualBox, we will create a new virtual machine and install Lubuntu. Finally, we will install some additional packages to make your virtual machine run at its best.
Step 1: Downloading and Installing VirtualBox
VirtualBox is available for download here. You should select the appropriate download for your host OS under platform packages. The current version at the time of this writing is 4.3.16 – I recommend that you use this version. Download and run the installer. Once you are done, run VirtualBox. You should see the following screen:
Step 2: Installing Lubuntu
Lubuntu is a lightweight Linux distro based on Ubuntu. I like it because it is clean and simple, but also because it shares the same repositories as Ubuntu so the support is great. You can download Lubuntu here. The version we will use is 14.04.1. You should download the standard PC 32-bit version regardless what type of computer you are using (if you are using a Mac I believe this should still work but if you run across any problems please leave a comment). Once the download has finished, go back to VirtualBox and click on the “New” button in the toolbar. You can name the virtual machine “Simply Embedded MSP430” or anything really. For type you want to select Linux and for version you should select Ubuntu 32-bit.
On the next screen you will have the option to select the amount of memory allocated to your virtual machine. What you choose here will depend on how much physical memory (RAM) your computer has. Try to be as generous as possible but 1-2GB should be sufficient.
Next you will be asked to add a virtual HDD. Since you do not have one yet, select “Create a virtual hard drive now” click “Create” and then select “VDI” and click next. The “Storage on physical hard drive” screen lets you select how the virtual machine disk is allocated on your actual hard drive. There are advantages and disadvantages to both dynamically and fixed sized virtual disks. Dynamically allocated disks will start at a set size and will grow indefinitely as your system requires – or runs out of space. There is one pitfall: even when you clean up your virtual machine, the virtual machine disk will not shrink back down automatically. It doesn’t take much for a virtual machine disk image to expand to 20GB – 60GB or more (i’ve seen 500GB virtual machines…). On the the other hand, the fixed size option will just run out of space and stop working. So what do I recommend? Use the dynamic. If you need to shrink your drive in the future let me know, there are plenty of tutorials I can point you to that explain how to do it. Click next and on this final screen you can leave the default values. Click create and you should now see your new virtual machine available on the main screen.
Select the newly created virtual machine, and click on the “Settings” button in the toolbar. Under the “Storage” section you should see “Controller: IDE.” It will currently be empty. Click on it and then on the right click on the CD icon and select “Choose a virtual CD/DVD disk file…” From the dialogue, choose the Lubuntu .iso file that you just downloaded.
Now press ok to save your changes and start your virtual machine! It will boot up and ask you to select your language. You will then be taken to the Lubuntu live CD menu. Select “Install Lubuntu.” Follow the installation procedure leaving the installation type at its default value, fill out the appropriate fields and let the installation complete. When it is done, remove the installation disk by going to the “Devices” menu and under “CD/DVD Devices” select “Remove disk from virtual drive.” Then reset the virtual machine.
Before you use your new Lubuntu guest, you should install the guest additions package. This will install drivers and other packages that will make your virtual machine experience much more seamless (like being able to scale the window, copy / paste across your host and guest OS, etc…). Before we install the guest additions, you will need to install some packages that do not come with Lubuntu, specifically:
We will use the apt command line utility to download and install the required packages. Open up a terminal from start->Accessories->LXTerminal as shown:
From the terminal, enter the following command to install these two packages:
sudo apt-get install gcc make
You will be prompted for your password and hit ‘y’ when prompted if you want to continue. This command will get all the packages from the Ubuntu repository, resolve any dependencies or conflicts and install them for you. Once the installation is complete, select “Insert Guest Additions CD Image…” from the “Devices” menu in VirtualBox. This will mount the guest additions disk image under /media/<user> where <user> is the username you entered during installation. Now navigate to the location of the guest additions image, for example:
Then run the installer:
The reason we needed to install those additional packages earlier is because VirtualBox needs to compile and install the kernel modules that are required for the guest additions. Once the installation is completed, restart your virtual machine from the command line:
sudo shutdown -r now
Step 4: Snapshots
Snapshots are an extremely effective way of backing up the state of your virtual machine. If you accidentally mess up your Linux install, you can always restore a snapshot and your virtual machine will be exactly as it was. Important note though: all your files and settings will be restored to that point as well, so you still need to back up your work, personal files, bookmarks etc.. separately. Create a snapshot now by selecting “Take Snapshot…” from the “Machine” menu of VirtualBox.
In the next tutorial, we will be setting up the build environment for the MSP430.