"... and no one shall work for money, and no one shall work for fame; But each for the joy of the working, and each, in his separate star, shall draw the thing as he sees it, for the god of things as they are"

-Kipling

 

Raspberry Pi 2 and Raspbian Linux O/S Hardware and Software Setup

Summary

This page describes a hardware and software setup which can be used when developing in C# and Mono on the Raspberry Pi 2. In fact, there is nothing particularly special about the Raspbian configuration or hardware setup discussed below and this page is simply intended to serve as background documentation. Any reasonably recent installation of Raspbian on the Raspberry Pi will probably be able to install Mono without difficulty. The following pages in this series describe the actual procedure to install C# on the Raspberry Pi and also how to set up a remote toolchain (with debugging) for it.

A Diagram of the Raspberry Pi 2 Development Environment

 

Note: The discussion here is centered around the Raspbian operating system. There are, of course, other distributions available for the Raspberry Pi and probably the described installation procedure will work for them. However, be aware that C# and Mono require a hard float armhf Linux distribution as opposed to a soft float armel operating system. The Raspbian 4.4 operating system available for download on the Raspberry Pi website is armhf and since this is now the recommended approach (by the Linux kernel maintainers) that situation is unlikely to change. The status of other distributions (armhf or armel) is not known and will be something to watch out for if you try to install Mono there.

You can find the installation instructions in the "Download Raspbian for Raspberry Pi" page of the Raspberry Pi website. During my testing, I just followed the default instructions on the previously linked page and put the Raspbian Operating system on an 8Gb SD card and everything worked well.

In order to install C# and Mono, you will need to (at least temporarily) have your Raspberry Pi be able to connect to the Internet.

USB Hub, Keyboard and Mouse

Eventually, in order to get a remote toolchain and debugging operational you will need to somehow get access to a shell prompt or other console window. You cannot just connect via ssh even though the ethernet connectivity is probably functional because until you login you will not know the IP address - by default a random IP address will be assigned to the Raspberry Pi automatically. The easiest way to get a console going is simply to plug in a keyboard, mouse and monitor and start up a console window from the Raspberry Pi's own display. Since the Raspberry Pi contains four USB ports. You can just plug your mouse and keyboard directly into the any of the Raspberry Pis USB ports and they should work.

Video

In order to log in and make changes you are going to need to see what is going on. To do this you will need video output.

The Raspberry Pi has built-in HDMI output which is accessible via a micro HDMI connector located on the side opposite to the 40 pin header. If you have an HDMI capable monitor handy, all you need is a micro HDMI to HDMI cable and you are good to go. If, like me, you have a shortage of bench space on which to place HDMI capable monitors (they don't seem to sell small ones these days) and a massive oversupply of perfectly useable old VGA flat screen monitors you may well wish to purchase an HDMI to VGA converter.

I hooked up an old 1024x768 VGA monitor to a Patuoxun 1080P HDMI Male to VGA Female Video Converter Adapter Cable and this worked perfectly. Well worth the small cost of the adapter. Note that unlike some others I have used, this adapter does not need any external power supplied to it.

Ethernet

The Raspbian distribution has working ethernet connectivity straight out of the box. I just used a Cat5 ethernet cable and plugged the Raspberry Pi into the TCP/IP hub provided by my Internet Service Provider. In my case, this hub has both Internet connectivity and also the DHCP server needed to provide the Raspberry Pi with an IP address.

Note: If you do not have a DHCP server on the local area network, the Raspbian operating system on the Raspberry Pi will probably take a while (2 minutes perhaps) to boot up and this will manifest itself as a blank screen - even though you previously saw information scrolling by. This is because it is looking for an IP address from a DHCP server as part of the boot sequence and has to wait for that request to time out before it can continue. If you wish to disable this, once you finally get logged on, you can just edit the /etc/network/interfaces file and comment out the line in the eth0 section that contains the word dhcp.

Micro SD Card

Booting off a micro SD card, rather than via built in EMMC memory like some other single board computers use, has a number of advantages - the primary one being that if you make a change and the Raspberry Pi refuses to boot you can just mount the SD card into another Linux filesystem and fix up or undo whatever changes you might have made. You can also keep multiple SD cards handy if you are trying different things.

Power

The Raspberry Pi needs power. I just found an old wall wart phone charger which outputs 5v and 2Amp and plugged that into the supplied mini-usb jack located close beside the HDMI connector.

Development PC

As mentioned previously, I wished to use a PC to remotely develop, compile and debug the C# code executing on the Raspberry Pi 2. On my system I used an old laptop running Ubuntu Linux as the Development PC. This proved to have more than sufficient computing power to handle MonoDevelop and also the remote debugging.

A Windows 7 PC is also present in the environment. However, for this project, it is mostly just used for documentation and to back up the Dropbox directories containing the source code built over on the Development PC. I did try to get Mono remote compiling and debugging operational in Visual Studio and/or MonoDevelop installed on the Windows 7 PC but was not successful. It probably is possible to do it but I did not pursue that aspect in any depth since the Ubuntu Linux PC was available and things started working on it fairly easily.

Installing Mono on the Raspberry Pi 2

The next step discusses how to install the C# Mono compiler on the Raspberry Pi. Subsequent steps detail how to install MonoDevelop on a remote Ubuntu Linux box and to configure it so that you can compile on that platform and the resulting exe file is transported to the Raspberry Pi for execution.

License

The contents of this web page are provided "as is" without any warranty of any kind and without any claim to accuracy. Please be aware that the information provided may be out-of-date, incomplete, erroneous or simply unsuitable for your purposes. Any use you make of the information is entirely at your discretion and any consequences of that use are entirely your responsibility. All source code is provided under the terms of the MIT License.