Since I have to wait a while for my crazyflie shipment to arrive from Massdrop, I figured I could get a head start by downloading the bitcraze virtual machine, and exploring the code and resources there. Of course, since I’m a Mac user and have been using VMware Fusion since its birth, I was hoping things would work out on my configuration. Unfortunately, on my first try importing the Bitcraze VM 0.5 virtual machine with VMware Fusion 6, I had some problems getting the VM to run. The system hung part-way through the boot process. Fortunately, I’ve figured out what needs to happen to get it working.
Here’s my easy, step-by-step instructions for converting the Bitcraze VM (0.5) OVA file to a VMware Fusion virtual machine that runs on Mac OS X.
If you do a straight import of the bitcraze-vm.ova file, you will get a warning about hardware incompatibility but VMware Fusion will give you the opportunity to try again with relaxed compliance checks, albeit with the risk that the imported VM won’t run. Once you’ve gotten the VM imported (converted), powering it on results in a hang during boot that prevents the VM from running. The method to get things in order again is simple: you have to tweak some settings. Knowing what to tweak is hard won and the reason I’ve captured it here.
1) Download the bitcraze-vm ova file, then open VMware Fusion. Run the following two commands in your Terminal application on your Mac to accomplish both tasks.
curl --output ~/Downloads/Bitcraze_VM_0.5.ova http://files.bitcraze.se/dl/Bitcraze_VM_0.5.ova
open /Applications/VMware\ Fusion.app
2) Import the VM. In VMware Fusion, choose the menu item: File -> Import…
3) Click “Choose File...” in the following dialog.
4) Navigate to the Bitcraze_VM_0.5.ova we downloaded to ~/Downloads and select the file. Then, click the “Continue” button.
5) Choose a location to save the new VM file the import will create. The default of ~/Documents/Virtual Machines.localized is a fine location unless you require something different. Click the “Save” button when you’re ready.
6) When you see an alert saying the import has failed, don’t despair. Simply click the “Retry” button. We’ll correct the issues in later steps.
7) Once you see the dialog stating the import has finished, click the “Customize Settings” button at the bottom so we can deal with our import issues.
8) At the Settings window, click the “Compatability” (circuit board icon) button at the bottom in the “Other” section.
9) On the “Compatability” settings pane, click the disclosure triangle next to “Advanced options.” In the disclosed controls, choose ‘7‘ from the pop-up menu next to the “Use Hardware Version:” label. Next, uncheck the box beside the label “Allow upgrading the virtual hardware for this virtual machine.” We don’t want this particular VM to ever upgrade because that will render it useless again. Finally, click the “Apply” button.
10) Click on the “Show All” button and then click on the “General” (gear icon) button at the top-right of the window in the “System Settings” section. In the “Notes” field of the General settings window that opens up, add the text: user: bitcraze, pass: crazyflie. This is just a reminder of the username and password of what will become our base snapshot.
11) Click on the “Show All” button again, then click on the “Network Adapter” (orb icon) button at the left of the window in the “Removable Devices” section. Next to the “Enable Network Adapter” label, make sure the switch is set to “ON.” Then, under “Bridged Networking” click the radio button next to “Autodetect.” This will allow your VM to have it’s own IP address on your network, thereby making it easier to connect via SSH, VNC or the like.
12) Click on the “Show All” button once more, then click on the “USB & Bluetooth” (removeable drive and bluetooth icon) button in the middle of the window in the “Removable Devices” section. Click the disclosure triangle next to “Advanced USB Options” and choose ‘2‘ from the pop-up menu next to the “USB Compatability:” label. This will allow you to interface with the crazyradio.
13) Click on the “Add Device…” button at the top-right of the window.
14) In the “Choose device to add:” area of the window you just opened, click the “CD/DVD Drive” icon, then click the “Add…” button in the lower-right corner of the window.
15) On the “CD/DVD (IDE)” window, simply ensure the slider next to the label “Enable CD/DVD Drive:” is set to “ON”
16) Great! Close the settings window and start up the VM again. This time it will ask you if you always want to connect to the new CD/DVD device when this VM starts up. Unless you really want to do otherwise, I suggest you click the “No” button since we won’t really be needing a CD drive on this VM very often.
17) That’s it. Other settings are already correct for this VM. Pretty damned easy when you know what to do. My pain, your gain. Now it should be booting OK and eventually drop you into Xubuntu’s Xfce desktop environment logged in as bitcraze. Once logged in, provided you’re connected to the internet through your host, you should see the Ubuntu software update process start. Let the process run until it presents you a dialog.
18) Wow! Looks like there’s alot of updates. Just hit the “Install Now” button.
19) Uh ohs! That’s gonna require an admin password. Go ahead and type: crazyflie in the “Password” field and then hit the “Authenticate” button.
20) Once the software update has completed, restart as instructed and we’ll install VMware tools. When the VM is running again, in VMware Fusion, choose the menu item: Virtual Machine -> Install VMware Tools
21) When you see the VMware Tools install dialog, click the “Install” button.
22) Eventually, a CD will mount on your Bitcraze VM Xfce desktop entitled: “VMware Tools.” Double-click this CD icon to open a File Manager window.
23) In the File Manager window that opens, find and double-click the icon entitled VMwareTools-.tar.gz (where ‘‘ represents a version value – yours will vary depending on what’s available at the time you install). This action will open an Archive Manager window.
24) Make sure the folder vmware-tools-distrib is selected and click the “Extract” icon on the tool bar.
25) In the subsequent window, navigate to the Desktop, and click the “Extract” button at the bottom-right of the window.
26) Once the extraction has completed (it’s quick), click on the “Close” button in the middle of the dialog. Then, close the open windows on the desktop.
27) Double-click the icon entitled “Terminal Emulator” that sits on the Bitcraze VM Xfce desktop. In the Terminal Emulator window, type the following three lines to run the VMware tools installation script. Enter the password: crazyflie when required.
sudo ./vmware-install.pl -d
28) So we’re basically done now. You should have a Bitcraze VM (0.5) running in VMware Fusion 6 on Mac OS X. There are a couple more setup steps we can do to correct a couple anomalies you might have seen in the VM. Did you notice that pesky warning on boot: piix4_smbus 0000:00:007.3: Host SMBus controller not enabled!? Let’s stop it dead…
Run the following command in a “Terminal Emulator” window to stop modprobe checking for an SMBus controller. Enter the password crazyflie when required. *Hint: You can you copy and paste across your Mac and the VM now that VMware Tools are installed. The “paste” keyboard shortcut in the “Terminal Emulator” on the Bitcraze VM Xfce desktop is ctrl-shift-v – for your reference.
echo -e "\n# Suppress warning in VMware Fusion 6.\nblacklist i2c_piix4" | \
sudo tee -a /etc/modprobe.d/blacklist.conf
29) You might have noticed the clock on the Xfce desktop is in Swedish. Let’s fix that. We’ll change the locale to US English. Run the following command in a “Terminal Emulator” window on the Bitcraze VM to fix it.
sudo perl -p -i -e 's/sv_SE/en_US/g' /etc/default/locale
30) The time is probably still off. Let’s set the correct time zone. Run the following command in a “Terminal Emulator” window on the Bitcraze VM. Choose your “Geographic area” with the arrow keys and hit “Return” when you’re done. Do the same for your “Time zone.” The time should be correct once this has been run.
sudo dpkg-reconfigure tzdata
31) Why not update all the code repositories really quickly? Bitcraze made it easy! Just double-click the “Update all repos” file on the desktop. Once that’s done, go ahead and delete the vmware-tools-distrib folder on the desktop. Make sure to empty the trash too!
32) Time to shutdown in preparation for creating a base install snapshot in VMware Fusion. This way, if we really screw something up, we can roll all the way back to a fresh start with the click of a button. I love VMs. In the “Applications Menu” in the top-left corner of the Bitcraze VM Xfce desktop, choose: Log Out -> Shutdown to power down the VM. Then we’ll use VMware Fusion to make a snapshot.
33) In VMware Fusion, choose the menu item: Virtual Machine -> Snapshots… -> Snapshots… Then, select the “Current State” screen (it should read: “Powered off” below the screen image to ensure you reduce the size of the VM file). Next, click the “Take” button at the top-left of the window. Make a name for the snapshot and enter some info in the notes field and when you’re done, click the “Take” button.
34) So that’s it. Only 34 steps. Virtualization + Linux = fun! Now your Bitcraze virtual machine (0.5) is running in VMware Fusion 6 on Mac OS X and has a baseline snapshot so you can’t screw things up (unless you delete the VM file). Go to it then. Engineer!! CRAZYLIFE!!! (I hope my crazyflie arrives soon…)