Developing for x86/x64 architectures is relatively easy as it's a standard architecture used by today's desktops; it's powerful and there are plenty of options when it comes to dev-tools and IDEs. When it comes to other architectures (I mean ARM here) the situation changes dramatically. These devices are usually not that powerful (both CPU power and memory becomes a limited resource) and some devices running OSes like Android don't even provide tools that we developers are used to. I personally cannot code properly on a laptop, so devices like tablets or phones are completely out of question. Using simulators is also not an option as I need to experiment with JIT code generation.
After I have done some experiments with my RaspberryPi (Model B2) I decided to try to improve the comfort of using these kind of devices for testing. The model I have has 1GB of RAM and quad-core ARM processor. Using that device to run IDE would suck, but accessing it remotely and using it only for compilation and unit testing would work pretty well.
I have done the following steps to prepare the Raspberry device itself:
- Download Raspbian Lite distribution
- Unpack the image to get the *.img file, for example as
- Plug your SD card to your computer, and check which device represents it, I will call it
- Use dd tool (Linux) to copy the content of the *.img file to your micro card, something like
dd bs=4M if=./raspbian.img of=/dev/sdx(the device doesn't specify a partition id)
/dev/sdx2drive to somewhere so you can access it, like
- Enable SSH daemon by default, go to
- Sync drives by using
synccommand (just in case, should not be needed)
- Unplug the SD card and put it to your Raspberry
Now the device should be ready; the only thing needed is to turn it on and connect it to your network. I use LAN and DHCP here so that's it. You can use
netstat tool to get the IP address of the device or ping 256 addresses on your local network if you don't like automation :) After the device is powered up it should allow SSH connections so just connect to it and use
pi username and
raspberry password, that should be changed immediately after you are logged in.
In the past I used
raspi-config tool that comes with Raspbian to enable the SSH daemon, but to do that you would need to connect screen and keyboard to the device, which I would like to avoid if possible.
Setting up Cloud9 for C++ Development
I decided to go with Cloud9 IDE that can run on the device and can be accessed through a browser. I think this is a good deal as the UI is fast (rendered by your browser) and it doesn't waste the precious RAM on the device itself. The only thing that I miss is a C++ debugger, but since Cloud9 is not really targeting C++ I'm fine with that (syntax highlighting is just fine).
Installing Cloud9 requires the following steps on your Raspberry device:
- Install the following dependencies:
sudo apt-get install build-essential pkg-config libssl-dev openssl libxml2-dev
- Clone Cloud9 IDE to some directory, for example Cloud9:
git clone https://github.com/c9/core/ Cloud9
- Prepare Cloud9 by using their install-sdk script (takes maybe 15 minutes to compile all deps, also downloads a lot of packages from net):
- Create your workspace, mine is
mkdir workspace(at ~)
- Prepare your script for starting the Cloud9 server, mine
run.shlooks like this:
#!/bin/sh node server.js -w ~/workspace --listen=0.0.0.0 --port=8181 --auth=username:password
- Don't forget to make the script executable
chmod +x run.sh
- Run the server
Note that Cloud9 requires to set
0.0.0.0 otherwise it will block connections that are not coming from localhost. You can now connect to the device. The result looks like this:
The IDE provides access to the workspace and features also a built-in terminal, which you can use through the web browser as well. This means that configuring the project, compiling it, and running unit tests can be done completely via the browser.
$ cat /proc/meminfo MemTotal: 947736 kB MemFree: 130244 kB MemAvailable: 798108 kB Buffers: 57904 kB Cached: 615464 kB
This means that roughly 800MB is still available to be used by the C++ compiler and other dev-tools, which is fine for most projects. However, from my own experience, don't use
make -j command for building your project as it will create 4 processes leaving around 200MB for each compilation unit - that is not enough even for smaller projects like AsmJit.
Since this really works for me it allows me to work on AsmJit's ARM support on a real ARM device. However, it's still not a high priority for me...