├── .gitignore ├── LICENSE ├── README.md └── Vagrantfile /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Adafruit Industries 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ARM Toolchain for Vagrant 2 | 3 | Vagrantfile to create a Linux virtual machine with a full GCC ARM toolchain for compiling ARM code and flashing it with tools like OpenOCD & STLink. Using this virtual machine you can get setup to compile and load ARM code 4 | from any platform that Vagrant supports (Windows, Mac OSX, Linux). 5 | 6 | The ARM toolchain that will be setup includes the following tools: 7 | 8 | * [GCC ARM Embedded](https://launchpad.net/gcc-arm-embedded) (version 4.8 2014 q1) - Full GCC toolchain 9 | for compiling code to run on ARM processors. 10 | * [OpenOCD](http://openocd.org/) (version 0.9.0) - Opensource on-chip-debugging tool. 11 | * [stlink command line tools](https://github.com/texane/stlink) (version 1.1.0) - Tools to program and debug 12 | STM32 processors using an STLink programmer. 13 | 14 | In addition the virtual machine will be setup to automatically passthrough a [STLink V2 programmer](https://www.adafruit.com/products/2548) 15 | for easy flashing of STM32 microprocessors. 16 | 17 | ## Requirements 18 | 19 | Make sure you have the latest version of [Vagrant](https://www.vagrantup.com/downloads.html) and 20 | [VirtualBox 5.x](https://www.virtualbox.org/wiki/Downloads) installed. 21 | 22 | In addition you will need the VirtualBox extension pack to provide USB device passthrough support. [Download the appropriate extension pack](https://www.virtualbox.org/wiki/Downloads) 23 | for your version of VirtualBox. 24 | 25 | On Windows double click the downloaded .vbox-extpack file to install. You will also want to install the [STLink USB driver](http://www.st.com/web/en/catalog/tools/PF260219) if you are using the STLink programmer. 26 | 27 | On Linux or Mac OSX install it using the VBoxManage command by navigating to the location of the 28 | downloaded file and running: 29 | 30 | VBoxManage extpack install 31 | 32 | For example if the file is called Oracle_VM_VirtualBox_Extension_Pack-5.0.0-101573.vbox-extpack then run: 33 | 34 | VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.0.0-101573.vbox-extpack 35 | 36 | Finally if you are running a Linux operating system you will want to add your user to the `vboxusers` group 37 | so that the virtual machine can access your USB devices. Run the following command: 38 | 39 | sudo usermod -a -G vboxusers $USER 40 | 41 | Then **log out and log back in** to make sure the group change takes effect. 42 | 43 | ## Usage 44 | 45 | To start the VM open a terminal in the directory with the Vagrantfile and run: 46 | 47 | vagrant up 48 | 49 | The first time the VM is started it will download an operating system image and provision it with the ARM 50 | toolchain. This process can take ~5-30 minutes depending on the speed of your internet connection and computer. 51 | After the initial provisioning future VM startups will take just a few seconds. 52 | 53 | Once the VM is running you can connect to it by running: 54 | 55 | vagrant ssh 56 | 57 | You will now be inside the VM and ready to run commands that use the ARM toolchain. 58 | 59 | When you're ready to stop the VM you can exit it by running the following command inside the VM: 60 | 61 | exit 62 | 63 | Note that after you exit the VM it will still be running! You can enter the VM again with the ssh command, 64 | or you can shutdown the VM by running: 65 | 66 | vagrant halt 67 | 68 | If you would ever like to completely delete the VM and start fresh you can remove it with: 69 | 70 | vagrant destroy 71 | 72 | To transfer files between the virtual machine and your real machine you can use [Vagrant's synced folders](http://docs.vagrantup.com/v2/synced-folders/index.html). 73 | Inside the virtual machine the `/vagrant` path will be syncronized with the location of the Vagrantfile on 74 | your real machine. You can copy files to and from these locations to move data between the two machines. 75 | 76 | To pass through USB devices from your real machine to the virtual machine, consult the [VirtualBox USB documentation](https://www.virtualbox.org/manual/ch03.html#idp96037808). 77 | 78 | For more information [consult the Vagrant documentation](https://docs.vagrantup.com/v2/). 79 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # All Vagrant configuration is done below. The "2" in Vagrant.configure 5 | # configures the configuration version (we support older styles for 6 | # backwards compatibility). Please don't change it unless you know what 7 | # you're doing. 8 | Vagrant.configure(2) do |config| 9 | # The most common configuration options are documented and commented below. 10 | # For a complete reference, please see the online documentation at 11 | # https://docs.vagrantup.com. 12 | 13 | # Every Vagrant development environment requires a box. You can search for 14 | # boxes at https://atlas.hashicorp.com/search. 15 | config.vm.box = "ubuntu/trusty64" 16 | 17 | # Disable automatic box update checking. If you disable this, then 18 | # boxes will only be checked for updates when the user runs 19 | # `vagrant box outdated`. This is not recommended. 20 | # config.vm.box_check_update = false 21 | 22 | # Create a forwarded port mapping which allows access to a specific port 23 | # within the machine from a port on the host machine. In the example below, 24 | # accessing "localhost:8080" will access port 80 on the guest machine. 25 | # config.vm.network "forwarded_port", guest: 80, host: 8080 26 | 27 | # Create a private network, which allows host-only access to the machine 28 | # using a specific IP. 29 | # config.vm.network "private_network", ip: "192.168.33.10" 30 | 31 | # Create a public network, which generally matched to bridged network. 32 | # Bridged networks make the machine appear as another physical device on 33 | # your network. 34 | # config.vm.network "public_network" 35 | 36 | # Share an additional folder to the guest VM. The first argument is 37 | # the path on the host to the actual folder. The second argument is 38 | # the path on the guest to mount the folder. And the optional third 39 | # argument is a set of non-required options. 40 | # config.vm.synced_folder "../data", "/vagrant_data" 41 | 42 | # Provider-specific configuration so you can fine-tune various 43 | # backing providers for Vagrant. These expose provider-specific options. 44 | # Example for VirtualBox: 45 | # 46 | # config.vm.provider "virtualbox" do |vb| 47 | # # Display the VirtualBox GUI when booting the machine 48 | # vb.gui = true 49 | # 50 | # # Customize the amount of memory on the VM: 51 | # vb.memory = "1024" 52 | # end 53 | # 54 | # View the documentation for the provider you are using for more 55 | # information on available options. 56 | 57 | # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies 58 | # such as FTP and Heroku are also available. See the documentation at 59 | # https://docs.vagrantup.com/v2/push/atlas.html for more information. 60 | # config.push.define "atlas" do |push| 61 | # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" 62 | # end 63 | 64 | # Turn on USB 2.0 support and add usb filter to attach STLink V2 programmer. 65 | # Note that the VirtualBox extension pack MUST be installed first from: 66 | # https://www.virtualbox.org/wiki/Downloads 67 | # Also on Linux be sure to add your user to the vboxusers group, see: 68 | # http://unix.stackexchange.com/questions/129305/how-can-i-enable-access-to-usb-devices-within-virtualbox-guests 69 | config.vm.provider :virtualbox do |vb| 70 | vb.customize ['modifyvm', :id, '--usb', 'on'] 71 | vb.customize ['modifyvm', :id, '--usbehci', 'on'] 72 | vb.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'STLink', '--vendorid', '0x0483', '--productid', '0x3748'] 73 | end 74 | 75 | # Enable provisioning with a shell script. Additional provisioners such as 76 | # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the 77 | # documentation for more information about their specific syntax and use. 78 | config.vm.provision "shell", inline: <<-SHELL 79 | sudo dpkg --add-architecture i386 80 | sudo apt-get update 81 | sudo apt-get install -y build-essential autotools-dev autoconf pkg-config libusb-1.0-0 libusb-1.0-0-dev libftdi1 libftdi-dev git libc6:i386 libncurses5:i386 libstdc++6:i386 82 | cd /home/vagrant 83 | wget http://downloads.sourceforge.net/project/openocd/openocd/0.9.0/openocd-0.9.0.tar.gz 84 | tar xvfz openocd-0.9.0.tar.gz 85 | cd openocd-0.9.0 86 | ./configure 87 | make 88 | sudo make install 89 | cd /home/vagrant 90 | wget https://github.com/texane/stlink/archive/1.1.0.tar.gz 91 | mv 1.1.0.tar.gz stlink-1.1.0.tar.gz 92 | tar xvfz stlink-1.1.0.tar.gz 93 | cd stlink-1.1.0 94 | ./autogen.sh 95 | ./configure 96 | make 97 | sudo make install 98 | sudo cp 49-stlink*.rules /etc/udev/rules.d/ 99 | sudo udevadm control --reload-rules 100 | sudo udevadm trigger 101 | cd /home/vagrant 102 | wget https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/gcc-arm-none-eabi-4_8-2014q1-20140314-linux.tar.bz2 103 | tar xjf gcc-arm-none-eabi-4_8-2014q1-20140314-linux.tar.bz2 104 | sudo mv gcc-arm-none-eabi-4_8-2014q1 /usr/local/ 105 | echo 'export PATH=/usr/local/gcc-arm-none-eabi-4_8-2014q1/bin:$PATH' >> /home/vagrant/.bashrc 106 | export PATH=/usr/local/gcc-arm-none-eabi-4_8-2014q1/bin:$PATH 107 | SHELL 108 | end 109 | --------------------------------------------------------------------------------