User Tools

Site Tools


projects:virtualmachine:create_vm

This page has deprecated. Go to the readme of the github repository project: https://github.com/bitcraze/bitcraze-vm

How to create your own VM

If you don't want to download our VM you can create your own by following the instructions on this page.

What you need

There's a few things you need to download before you get started:

  • Some visualization software, like VirtualBox or VMware Player
  • Any additional addons needed to get USB 2.0 functionality (like VirtualBox Extension Pack)
  • A Linux distro. We use Xubuntu but these instructions will work with any Ubuntu flavour but will have to be adopted if a non-Ubuntu distro is used.

The rest of the instructions on this page will assume that you use VirtualBox and Xubuntu 14.10.

Creating the VM

After downloading VirtualBox, install it, install the VirtualBox extension pack and start VirtualBox:

  • Go to Machine→New to create a new virtual machine
  • Go with the defaults and create a new disk (we use a 30GB dynamically allocated disk and 1024 MB RAM)
  • When the VM is created, right-click on it and select settings
  • Mount the Xubuntu iso on the storage tab
  • Exit the settings, start the machine and install Xubuntu normally
  • After installation, power off the VM and remove the install media from the storage tab in settings
  • Start up the machine again and install the Guest additions for your VM host software

Configuring Xubuntu

First of all make sure that the system is up to date by running:

sudo apt-get update
sudo apt-get dist-upgrade
sudo reboot

Adding additional PPAs

There's a few issues with the software that comes with the default Ubuntu distro so the following PPAs have to be added.

sudo sh -c 'echo deb http://luke.campagnola.me/debian dev/ > /etc/apt/sources.list.d/pyqtgraph.list'

After adding the extra PPAs you need to update the available packages:

sudo apt-get update

Installing software

Most of the software that you will need is now available from the repositories so just run the following command to install it:

sudo apt-get -y install git kicad sdcc python2.7 python-usb python-qt4 qt4-designer kicad build-essential python-pip libsdl2-dev python-pyqtgraph openocd

Install a Java JDK

sudo apt-get -y install openjdk-7-jdk

Now install the Python SDL2 bindings using PIP

sudo pip install pysdl2

There's also some “nice to have” software that is installed in the VM we distribute:

sudo apt-get -y install gitg meld leafpad

The gcc-arm-none-eabi toolchain needed for the Crazyflie firmware is not available for Xubuntu 13.04 from a PPA yet so it needs to be downloaded separately.

Download it, unpack it, create a directory for it and copy it:

wget https://launchpad.net/gcc-arm-embedded/4.9/4.9-2014-q4-major/+download/gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2
tar xjf gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2
mkdir ~/bin
mv gcc-arm-none-eabi-4_9-2014q4 ~/bin/gcc-arm-none-eabi

In order for the build system to find the toolchain when building the firmware it has to be added to the path:

echo -e "\nPATH=\$PATH:$HOME/bin/gcc-arm-none-eabi/bin" >> ~/.bashrc
source ~/.bashrc

Adding udev rules for Crazyradio

In order to avoid being root when using the Crazyradio the following should be run to add udev rules for the Crazyradio and for the NRF bootloader used to update the Crazyradio firmware:

sudo usermod -a -G plugdev $USER
sudo sh -c 'echo SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"1915\", ATTRS{idProduct}==\"7777\", MODE=\"0664\", GROUP=\"plugdev\" > /etc/udev/rules.d/99-crazyradio.rules'
sudo sh -c 'echo SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"1915\", ATTRS{idProduct}==\"0101\", MODE=\"0664\", GROUP=\"plugdev\" >> /etc/udev/rules.d/99-crazyradio.rules'
sudo sh -c 'echo SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"0483\", ATTRS{idProduct}==\"5740\", MODE=\"0664\", GROUP=\"plugdev\" >> /etc/udev/rules.d/99-crazyflie.rules'

Clone the repos

The following will create a project directory and clone all the Crazyflie/Crazyradio projects:

mkdir ~/projects
cd ~/projects
git clone git://github.com/bitcraze/crazyflie-clients-python.git
git clone git://github.com/bitcraze/crazyflie-firmware.git
git clone git://github.com/bitcraze/crazyflie-bootloader.git
git clone git://github.com/bitcraze/crazyradio-firmware.git
git clone git://github.com/bitcraze/crazyflie-android-client.git
git clone git://github.com/bitcraze/crazyflie2-exp-template-electronics.git
git clone git://github.com/bitcraze/crazyflie2-stm-bootloader.git
git clone git://github.com/bitcraze/crazyflie2-nrf-bootloader.git
git clone git://github.com/bitcraze/crazyflie2-nrf-firmware.git

Setting PyCharm

Download PyCharm, install it into the /opt/ and add it to the search path.

sudo tar -xf pycharm-community-4.0.2.tar.gz -C /opt/
echo -e "\nPATH=\$PATH:/opt/pycharm-community-4.0.2/bin" >> ~/.bashrc
source ~/.bashrc

Setting up Eclipse

If you would like to build and debug the Crazyflie firmware using Eclipse follow the instructions below. Note that in order to do this you will need some device that can debug with JTAG. There's lots of devices that do this but we use the BusBlaster v4.

  • Download Eclipse CDT from here
  • Unpack it into the home directory
    tar -xf <eclipse_file> -C ~/bin/
  • Now import the project you are interested in by selecting File→New project and C/C++→C project
  • Configure the project to use the already cloned code in the project directory by setting the following settings:
    • Project name: <same as the directory in projects>
    • Use default location: False
    • Location: /home/bitcraze/projects/<project>
    • Project type: Makefile project → Empty project
    • Toolchains: – Other Toolchain –

Now install the CDT GDB addon by:

  • Go to Help→Install new software…
  • Select Work with Luna ….
  • Type Filter GDB
  • Select and install the C/C++ GDB Harware debugging

Additional environment setup:

  • Add the toolchain to the PATH
    • Menu Window → Preferances and go to C-C++ → Build → Environment
    • Add a new variable named PATH and set it to ${PATH}:/home/bitcraze/bin/gcc-arm-none-eabi/bin

Getting the latest versions

Here's a script that will pull all the latest changes from the repos that is cloned. This will not work if you're developing, but if you are just running the software and want to update to the latest version it's ok.

#!/bin/bash
#
# Simple script to update all the repos to the latest version.

for f in /home/bitcraze/projects/*
do
	if [ -d "$f" ]; then
		echo "Updating $f"
		cd $f
		git pull
		cd ..
	fi
done
read -p "Press any key to exit" -n1 -s

You can also create a shortcut on the desktop by right-clicking on it, selecting Create launcher… and setting the following:

  • Name: Update all projects
  • Command: /home/bitcraze/bin/update_all_projects.sh
  • Run in terminal: True

When you click it the first time, select “Mark as executable”.

OVA export from VirtualBox

Before the VM is exported as OVA the following should be done to make the image as small as possible:

  • Inside the VM run the following commands:
    sudo apt-get autoremove
    sudo apt-get autoclean
    sudo apt-get clean
  • Now shut down the machine and do the following steps:
    • Go to the settings for the VM, select storage and select the VDI image that has the installation. Make sure the Solid state options is set. Note the SATA port as well.
    • Now go to a terminal and type the following:
      VBoxManage storageattach "<VM Name>" --storagectl "SATA" --port <VDI port> --discard on
  • Restart the machine and run the following command inside the VM:
    sudo fstrim -v /

Now the VM can be exported as OVA by going to the menu File→Export applicance…, selecting the VM and filling in the appropriate information. update_on_vm_release

projects/virtualmachine/create_vm.txt · Last modified: 2021-06-02 11:25 by kimberly