-
Notifications
You must be signed in to change notification settings - Fork 0
Build a custom ev3dev install image with Mono
As far as I've tested, Mono 5.* (or higher) is impossible to install on ev3dev on device because of the mono-roslyn
package, which requires too many RAM, goes to the swap and thus is impossible to be installed on battery power. Actually, I didn't manage to await the installation finish even on AC power. But you can avoid this issue with flashing your device with your own installation image of ev3dev with mono preinstalled.
To create it, you will need system with:
- git installed
- ability to run Docker engine
- ability to execute brickstrap script from the ev3dev project
I've personally used Ubuntu 22.04 but I reckon any other system with bash
should do =) I will also use Visual Studio Code as text editor, but if you prefer another one, you can freely change code
in script samples with vim
, nano
or any other of your choice.
Official documentation should work just fine.
You can find the project's home here https://github.com/ev3dev/docker-library. Clone it to a directory of your choice, we will work right inside it later:
git clone https://github.com/ev3dev/docker-library.git
Let's say that your checkout directory is docker-library
.
Probably this is not the most efficient way to handle docker images, but it will do for us. We need to create two base images of ev3dev and then create our own on top of them. I'll suppose that you will use stretch
as distro core and LEGO EV3 as the device, you can find the necessary directories and files just next to the files I'm going to use now. Lets start with the base images:
cd docker-library/ev3dev-stretch
sudo docker build -t ev3dev/ev3dev-stretch-ev3-base -f ev3-base.dockerfile .
sudo docker build -t ev3dev/ev3dev-stretch-ev3-generic -f ev3-generic.dockerfile .
Next, let's create our own Docker image. First, we need to add a new layer with our scripts that will install mono on our image. Assuming we're still inside docker-library/ev3dev-stretch
directory, create a layer directory and an installation script file:
mkdir -p layers/mono/brickstrap/mono
code layers/mono/brickstrap/mono/run
And insert following content to it:
#!/bin/bash
apt-get install --yes dirmngr ca-certificates gnupg apt-transport-https
gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/debian stretch/snapshots/5.10.1.47 main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
apt-get update
apt-get install --yes gcc gdb mono-complete
You can see that I've used version 5.10.1.47
. That is the version I've tested but you can try others if you need to.
Next, create a file docker-library/ev3dev-stretch/ev3-mono.dockerfile
:
code ev3-mono.dockerfile
Add the following content to it:
FROM ev3dev/ev3dev-stretch-ev3-generic
COPY layers/mono/ /
RUN /brickstrap/mono/run
ARG BRICKSTRAP_IMAGE_NAME=custom-ev3dev-stretch-ev3-mono
ENV BRICKSTRAP_IMAGE_NAME ${BRICKSTRAP_IMAGE_NAME}
RUN echo "$BRICKSTRAP_IMAGE_NAME" > /etc/ev3dev-release
And build the image with command:
sudo docker build -t custom-ev3dev-stretch-ev3-mono -f ev3-mono.dockerfile .
The easiest way to do it is by using apt
:
sudo add-apt-repository ppa:ev3dev/tools
sudo apt update
sudo apt install brickstrap
If it's not suitable for you, see the tool's main page.
This is a two-step process. First, you need to create .tar archive with the image content with brickstrap
. Next, you'll use brickstrap
to convert the archive to an .img file. You can perform the following commands in any directory that you don't mind to put files into:
sudo brickstrap create-tar custom-ev3dev-stretch-ev3-mono ./custom-ev3dev-stretch-ev3-mono.tar
sudo brickstrap create-image ./custom-ev3dev-stretch-ev3-mono.tar ./custom-ev3dev-stretch-ev3-mono.img
These commands may take a while. If you want to know more about these commands, you can check the brickstrap
manual page.
The resulting custom-ev3dev-stretch-ev3-mono.img
file is the one you need to flash on your EV3 device. It should be almost identical to the image you can download from the ev3dev site except the mono installed.