"... 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"



Installing Mono and C# on the Beaglebone Black


Updated Nov. 2018

This page describes how to install C# and Mono on the Beaglebone Black. There are a number of pre-requisite actions which are required in order to have a successful installation. This page is one part of a series of web pages which describe how to install C# and Mono on the Beaglebone Black and also how to setup a useful remote compilation and debugging toolchain for it.

Do You Have the Latest O/S

Before you continue with any of the steps on this page be aware you need to install Mono on the armhf version of the Debian operating system. Mono will not install (at least I could never get it to work) on the standard armel package that ships with the Beaglebone Black. If you do not have the an armhf version of Linux installed you will need to complete the earlier steps first. In addition, if you have installed the latest Debian release from the Beaglebone Black website, you will need to boot from a MicroSD card rather than the eMMC memory. There is not enough space in the eMMC memory to install Mono and C# unless you choose a version that does not have a GUI.

It should be noted that the current page is a revised edition of a previous page and it now focuses on the Beaglebone Black specific Debian 9.5 2018-10-07 4GB SD LXQT Debian distribution available for download from the Beagleboard.org website.

Do you have enough free disk space?

The upgrade images for the Beaglebone Black available for download are all acceptable armhf versions of the Linux operating system for a C#/Mono installation. However, if you choose the GUI version of the release (that is what the LXQT in the name means) there will not be sufficient space after you install it on the MicroSD card to fit in Mono and C#.

The reason for this is that the installation binary is structured so that it can be flashed to the eMMC memory with only a few configuration changes. This means it is sized at 4Gb. The act of writing the image to a 16Gb MicroSD card does not automatically provide 16Gb of memory to the file system - it still considers itself to have only 4Gb and the remaining space is unused. There will not be sufficient free space to install C# and Mono in this situation.

There is a lot of advice on how to expand an SD card filesystem available on the Internet, and a query such as "linux resize partitions sd card" will turn up quite a number of results. If you follow the advice on these pages you will, no doubt, after a bit of fiddling about get the partitions resized. However, there is a much easier way. Simply download and install the grow_partition.sh script from the site https://github.com/RobertCNelson/boot-scripts/blob/master/tools/grow_partition.sh and run it as root. This script does everything necessary to detect the current situation and automatically resize the MicroSD card on the Beaglebone Black so that it uses the full amount of memory available. The procedure used is simple...

  1. Run the df command so you can see the current partition sizes.
  2. Start the nano editor with command: nano grow_partition.sh
  3. Copy and paste in the contents of the grow_partition.sh script.
  4. Save the file and quit the nano editor.
  5. Set the permissions on the script with a command like: chmod 700 grow_partition.sh
  6. Run the script (as root) with a command like: sudo ./grow_partition.sh
  7. Reboot
  8. Run the df command again so you can see the available size is now much larger.

Installing Mono on the Beaglebone Black

Assuming you have a suitable O/S installed, sufficient free space and networking configured with full Internet access on your Beaglebone Black, you can install Mono by issuing the following commands (as root). If you wish, instead of prefacing each command with sudo, you can change into the root user by issuing the sudo -s command.

First let's make sure all packages are fully up-to-date and you have the latest build tools...

sudo apt-get update
sudo apt-get install build-essential automake checkinstall intltool git

For me, the above commands worked with no visible errors and the time taken was about five minutes. Once that is done, we need to install the Mono runtime - but we have to make sure we get the correct mono version. By default, if we try an apt-get install mono-runtime command, we will probably get an older Mono version which has a bug which makes remote debugging impossible. We need to make sure we add the latest Mono Project GPG signing key and the package repository to our system. This is done by issuing the following commands (taken from the mono-project page).

sudo apt install apt-transport-https dirmngr
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/debian stable-stretch main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update

You should check the above link for the latest signing codes rather than just copying and pasting the statements listed above. The execution of these commands took very little time on my system. Now we can proceed with the install of the Mono runtime.

sudo apt-get install mono-runtime

The above command worked with no errors and one warning. The elapsed time was about a minute. Now we can install the Mono package.

sudo apt-get install mono-complete git automake libtool

The above commands worked with no errors and the runtime was about 5 minutes.

At this point the Mono .NET runtime should be installed. You can test this by issuing the command mono -V. If installed correctly, you should see the version display as shown below

devuser@beaglebone:~$ mono -V
Mono JIT compiler version 4.6.2 (Debian
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           normal
        SIGSEGV:       normal
        Notifications: epoll
        Architecture:  armel,vfp+hard
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            sgen

You can also type the command mcs --about on the command line to see if Mono C# compiler is there. On my system the command returned the following...

devuser@beaglebone:~$ mcs --about
The Mono C# compiler is Copyright 2001-2011, Novell, Inc.

The compiler source code is released under the terms of the
MIT X11 or GNU GPL licenses

For more information on Mono, visit the project Web site

The compiler was written by Miguel de Icaza, Ravi Pratap, Martin Baulig, Marek Safar, Raja R Harinath, Atushi Enomoto

Now we need to test things out. Below is some simple "Hello World" code. You can use the simple nano editor to create this (issue the command nano helloworld.cs) by copying the text below and pasting it in.

using System;
namespace Hello {
	class HelloWorld {
		public static void Main(string[] args) {
			Console.WriteLine("Hello World!");

I compiled the above code with the command mcs helloworld.cs and then ran it with the command mono helloworld.exe. Note that you can also issue the rather simpler command ./helloworld.exe and the operating system will figure out that it is a .NET executable and automatically invoke Mono for you. On my system all of the above code executed perfectly.

A Note on Mono Versions

As was mentioned previously, the Mono version you probably want is the one pointed to by the Mono Project GPG signing key and the package repository command above. If you omit this step you may install a much older version of Mono. For example, instead of the 4.6.2 version information above, the mono -V command will return something like...

Mono JIT compiler version (Debian
...and if, as discussed in later steps, you try to implement remote debugging you will run straight into this bug . It's now been fixed but, simply put, remote debugging is not possible on earlier versions of Mono.

A Remote Development Tool Chain for the Beaglebone Black

If you have followed the steps above you will have seen that editing .cs files on the Beaglebone Black is possible but perhaps not too user friendly. The next steps discuss how to create a shared folder on a Windows 10 Development PC and have it appear as a mount point on the Beaglebone Black. Also discussed is how to set up Visual Studio on a remote Windows PC so that you can compile on that platform and the resulting exe file is transported to the Beaglebone Black for execution. In addition, it is possible to perform step-by-step debugging on the remotely executing code right out of the Visual Studio IDE.


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.