Skip to content

Commit e8dc835

Browse files
authored
Merge pull request #1 from luejerry/master
merge
2 parents c28a5c7 + 72e20cb commit e8dc835

File tree

7 files changed

+48
-29
lines changed

7 files changed

+48
-29
lines changed

Customfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
config.vm.provider "virtualbox" do |v|
2+
v.memory = 3072
3+
v.cpus = 4
4+
end

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Raspberry Pi Devbox
22

3-
A [Vagrant](http://vagrantup.com) recipe for an Ubuntu 12.04 virtual machine, intented to make C/C++ development for Raspberry Pi a less painful experience. This is a fork of <https://github.com/Asquera/raspberry-devbox>.
3+
A [Vagrant](http://vagrantup.com) recipe for an Ubuntu 12.04 virtual machine, intented to make C/C++ development for Raspberry Pi a less painful experience. Forked from <https://github.com/nickhutchinson/raspberry-devbox>, updated to use a Raspbian 8 Jessie chroot and the latest [Raspberry Pi cross-compiler toolchain (gcc 4.8.3)](https://github.com/raspberrypi/tools).
44

55
This VM includes a sandboxed installation ("chroot") of [Raspbian](http://www.raspbian.org), an ARM variant of the Debian Linux distribution optimized for Raspberry Pi. Use of the sandbox is mediated by a cross-compiling tool called [ScratchBox2](http://maemo.gitorious.org/scratchbox2). ScratchBox2 craftily translates the ARM executables bundled with Raspbian such that they run on your Intel box.
66

77
Why is this so nice? Suppose you have C++ app that you want to build for the Raspberry Pi, but it requires a bunch of third-party libraries. Do you really want to hunt down these libraries, their dependencies, their dependencies dependencies, their dependencies dependencies dependencies and so on, until you're able to build your own app? It should be clear that that way lies madness. Perhaps you'll just copy the headers and libraries from your Raspberry to your Intel box, and point your compiler at those. That might work, but it'll be fragile and annoying.
88

99
How about we let the Raspbian folks do all the hard work? With ScratchBox2, you can simply apt-get to your heart's content. Just type:
10-
10+
1111
sb2 -eR apt-get install ...
1212

1313
This executes `apt-get` in the default ScratchBox2 container (in our case, we only have the one. It's called "raspberry".) The `-e` flag is for chroot (emulated) mode; `-R` runs the command as the equivalent of *root* in the sandboxed environment. For a slightly more thorough explanation of ScratchBox2, see these presentation slides: <http://www.daimi.au.dk/~cvm/sb2.pdf>.
@@ -20,17 +20,29 @@ This executes `apt-get` in the default ScratchBox2 container (in our case, we on
2020

2121
Vagrant will now download the basebox, bootstrap the environment and run the provisioner for the first time. Since the basebox and numerous packages must be downloaded, the first run may take some time depending on your network connection. No supervision should be required; running the install overnight should be just fine. Future runs will be much faster, and won't require network connectivity.
2222

23-
If like to see words dribble down your screen, you can monitor the bootstrap progress by running `vagrant ssh` to ssh into your VM, and then `tail -F ~/raspberry-dev/rootfs/debootstrap/debootstrap.log`)
23+
If like to see words dribble down your screen, you can monitor the bootstrap progress by running `vagrant ssh` to ssh into your VM, and then `tail -F ~/raspberry-dev/rootfs/debootstrap/debootstrap.log`
2424

2525
After installation has completed, you should find:
2626

2727
- In `~/raspberry-dev/rootfs`
2828
- the [Raspbian](http://www.raspbian.org) chroot.
2929
- In `/opt/raspberry-dev`
30-
- the official [GCC 4.7.2 cross-compiler toolchain](https://github.com/raspberrypi/tools): `arm-linux-gnueabihf-gcc`, `arm-linux-gnueabihf-ld` and so on.
30+
- the official [GCC 4.8.3 cross-compiler toolchain](https://github.com/raspberrypi/tools): `arm-linux-gnueabihf-gcc`, `arm-linux-gnueabihf-ld` and so on.
3131
- [QEmu](http://wiki.qemu.org/Main_Page) 1.3.0
3232
- [ScratchBox2](http://maemo.gitorious.org/scratchbox2) @ git tag 2.3.90 (earlier releases didn't seem to work)
3333

34+
The default configuration allocates 4 CPU cores and 4 GB of RAM to the VM. This can be configured by editing the following lines in the `Vagrantfile`:
35+
36+
v.memory = 4096
37+
v.cpus = 4
38+
39+
## Example Usage
40+
41+
* Starting the VM: in the program root directory, run `vagrant up` to start the VM, then `vagrant ssh` to enter it.
42+
* `sb2 make` make using host cross compiler toolchain.
43+
* `sb2 -e make` make using emulated target toolchain.
44+
* `sb2 -eR make install` install in emulation mode as root.
45+
3446
## VirtualBox
3547

3648
The basic virtualization layer is [VirtualBox](https://www.virtualbox.org). Any current version should do, however the guest additions are pinned to current version at the time the basebox was built (4.2.0). A mismatch between the guest additions and the VirtualBox version may result in strange behaviour, mostly affecting shared folders and networking. To update the guest, additions follow the instructions in the VirtualBox manual.
@@ -50,11 +62,5 @@ The basic virtualization layer is [VirtualBox](https://www.virtualbox.org). Any
5062

5163
Provisioning of the Virtual Machine is handled by [Puppet](http://puppetlabs.com). Take a look at the `raspberry_dev` module.
5264

53-
## Bugs, fixes, improvements
54-
55-
If you encounter a problem, please file a ticket. If you can help improve this Virtual Machine recipe please let me know; I'm very new to Vagrant, Puppet, ScratchBox2 and Raspberry Pi, and barely know what I'm doing!
56-
57-
## Todo
58-
59-
* all of this is still quite rough
60-
* improve on the readme
65+
## Bugs
66+
* Some programs such as aptitude crash with segfault when run in emulation mode. Updated qemu might fix this

Vagrantfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Vagrant::Config.run do |config|
66
# options are documented and commented below. For a complete reference,
77
# please see the online documentation at vagrantup.com.
88

9-
config.vm.define :nox do |box|
9+
config.vm.define :nox1 do |box|
1010
# Every Vagrant virtual environment requires a box to build off of.
1111
box.vm.box = "precise64"
1212
# The url from where the 'config.vm.box' box will be fetched if it
@@ -26,3 +26,12 @@ Vagrant::Config.run do |config|
2626
end
2727
end
2828
end
29+
30+
Vagrant.configure("2") do |config|
31+
32+
config.vm.provider "virtualbox" do |v|
33+
v.memory = 4096
34+
v.cpus = 4
35+
end
36+
37+
end
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
deb http://archive.raspbian.org/raspbian/ wheezy main contrib non-free rpi
2-
deb-src http://archive.raspbian.org/raspbian/ wheezy main contrib non-free rpi
1+
deb http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi
2+
deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi

modules/raspberry_dev/manifests/packages.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class raspberry_dev::packages {
22
$required_packages = ['libncurses5', 'fakeroot', 'debootstrap', 'curl',
3-
'libstdc++6:i386', 'zlib1g:i386', 'libc6-dev-i386', 'build-essential']
3+
'libstdc++6:i386', 'zlib1g:i386', 'libc6-dev-i386', 'build-essential', 'git']
44

55
package {$required_packages:
66
ensure => installed,

modules/raspberry_dev/manifests/raspbian_chroot.pp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
$bootstrap_cmd =
1313
"fakeroot debootstrap --verbose --foreign --variant=scratchbox \
14-
--arch armhf --keyring /etc/apt/trusted.gpg wheezy \
14+
--arch armhf jessie \
1515
${raspberry_dev::config::sbox2_container_path} ${raspbian_mirror}"
1616

1717
# without this, sbox2 sees HOME as "/root" for some reason, and all sb2
@@ -29,7 +29,9 @@
2929
} -> exec {'raspbian-install-key':
3030
command => 'curl http://archive.raspbian.org/raspbian.public.key | apt-key add -',
3131
unless => 'apt-key list | grep "Raspberry Pi Debian"'
32-
32+
} -> exec {'fix-debootstrap-script':
33+
command => 'ln -s /usr/share/debootstrap/scripts/sid /usr/share/debootstrap/scripts/jessie',
34+
unless => 'ls /usr/share/debootstrap/scripts | grep jessie'
3335
} -> exec {'debootstrap-first-stage':
3436
command => $bootstrap_cmd,
3537
environment => $sbox2_required_env_flags,
Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
class raspberry_dev::toolchain {
2-
$toolchain_url = 'http://commondatastorage.googleapis.com/howling-fantods/raspberrypi/raspberry-gcc-toolchain_1.0_i386.deb'
3-
$toolchain_deb_filename = 'raspberry-gcc-toolchain_1.0_i386.deb'
2+
$toolchain_url = 'https://github.com/raspberrypi/tools'
43

54
exec {'download-toolchain':
6-
command => "curl -L ${toolchain_url} -o ${toolchain_deb_filename}",
5+
command => "git clone ${toolchain_url}",
76
cwd => $raspberry_dev::config::debs_dir,
8-
creates => "${raspberry_dev::config::debs_dir}/${toolchain_deb_filename}"
9-
10-
} -> package {'raspberry-gcc-toolchain':
11-
provider => dpkg,
12-
ensure => installed,
13-
source => "${raspberry_dev::config::debs_dir}/${toolchain_deb_filename}"
14-
}
15-
}
7+
creates => "${raspberry_dev::config::debs_dir}/tools"
8+
} -> exec {'install-toolchain':
9+
command => "cp -r arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/* \
10+
${raspberry_dev::config::tools_prefix}",
11+
cwd => "${raspberry_dev::config::debs_dir}/tools"
12+
}
13+
}

0 commit comments

Comments
 (0)