EV3 & Linux

One of the great things about the EV3 is that it is actually a very powerful computer. The graphical programming language developed by LEGO and National Instruments is excellent to get started with programming, but the EV3 can do much more. In fact, The LEGO Group encourages the community to unleash the full potential of the EV3 system by releasing the firmware source code and hardware schematics. Several community based projects such as LeJos are already starting to take shape. Another project that recently got my attention is ev3dev.

The ev3dev project is still under heavy development, and a lot of features and functionalities of the EV3 brick are still being implemented. I don’t think it’s quite ready for the beginning programmer at the moment, but it certainly looks promising. I’ll likely blog more about this project in the future. Meanwhile, check out their wiki.

The video above is a demonstration of a basic obstacle-avoidance Python program I created for the EXPLOR3R robot. With this setup, it is possible to write the program directly in a browser, which means that you can even program the EV3 from a tablet. Check out the source code here. In the rest of this post, I’ll give an overview of some of the essential components at work here. Note that this isn’t a tutorial, but rather some background information for those who are just getting started exploring all the possibilities of the EV3.

Much of it actually comes down to learning to play with Linux. (We’ll get to what Linux is in a moment.) I didn’t know anything about Linux until about one and a half years ago, when I started working on a university project for which I used the Beaglebone controller. As it turned out, it was a lot of fun to learn how to work with Linux, and it was actually not hard at all. On the other hand, once you master some basic skills, the possibilities are endless.

As with many technical topics, it can be difficult to get started if you’re completely new to the subject and its terminology. This post won’t cover all the basics, but my aim is to provide a starting point for further reading and discovery.

What is an operating system?

Before we can get to the basic working principles of ev3dev, we need to take a step back and look at how an EV3 program normally runs. To make this a bit more tangible, it’s helpful to think of the EV3 brick as a real computer. (It is a real computer, it just doesn’t look like a conventional PC.)

An EV3 program for your robot doesn’t just run on its own. In fact, many different programs are running at the same time, and there’s a certain piece of software that always runs on the brick, called the operating system. The operating system, or OS, handles a wide variety of tasks. For example, it manages which running programs can use the processor to calculate things and when. The OS also controls the devices connected to the brick, such as sensors. Basically, it makes the right thing happen at the right time, without you having to worry about it.

The computer, tablet, or phone you’re using to read this article is also running an operating system to manage which applications can use the processor and memory. In addition, it reads the input you enter with a keyboard or touch screen, and it displays the output of the applications on the screen. For example, if you enter some text in a messaging app, the operating system will tell the app what you entered. In turn, the app gives instructions to the operating system to display the text on the screen.

The operating system allows many other applications to work by letting them run at the right time, and by providing the applications with access to the devices attached to the computer.

What is Linux?

Popular operating systems include Windows, OS X, iOS, Android, and Linux. Some of these operating systems are specifically designed for certain types of devices. For example, Apple’s iOS is designed for portable devices with a touch screen, while Windows is widely used on desktop and laptop computers.

On the other hand, Linux can be customized to work on many different types of devices. Linux can power desktop computers, laptops, servers, TV’s, satellites, the Raspberry Pi, and even robots. Sure, most of these devices don’t really look like a conventional computer with a keyboard and a screen with shiny application icons on it, but that doesn’t make the operating system less important.

Linux is also free and open source. This means that any individual or company can adjust an existing version of Linux and use it for their own hobby project or commercial product. A customized edition of Linux is often called a distribution, or distro.

When LEGO designed the EV3 system, they developed their own Linux distribution for the EV3 brick. The menu you see when you turn the brick on is an application that runs on the Linux operating system.

Why do you never see the word operating system, or Linux, when using the standard EV3 software, you might ask? This comes down to terminology. In the LEGO software, the Linux operating system is referred to as firmware to keep things simple. When you click ‘update firmware’ in the EV3 software, you’re actually updating the Linux distribution. After all, not everyone needs to know about these technical details. (But you want to know about them.)

What is ev3dev?

ev3linuxYou guessed it, ev3dev is another Linux distribution that can run on the EV3 brick instead of the Linux distribution designed by The LEGO Group.

The default LEGO distribution works well with the standard LEGO MINDSTORMS EV3 programming software, but because of its design, it’s not very suitable for other uses. For instance, it’s not trivial to install new programs such as Python. It’s probably possible — it is Linux after all — but it’s not easy for beginning developers.

Contrary, the ev3dev distribution is based on Debian, a popular Linux distro. Interestingly, operating systems like Ubuntu and Raspbian (the default Raspberry Pi operating system) are also based on Debian. This means that ev3dev already has a solid and easy to use operating system in place. Many things you can do with the Raspberry Pi can now also be done with the EV3. How cool is that? As a result, no EV3-specific steps had to be taken to get the programming environment demonstrated in the video (Python3 with iPython Notebook) installed on the EV3.

Right now, the ev3dev team are working on making it possible to access all of the EV3 hardware from the operating system. When ev3dev is closer to a first release, it could be interesting to create a more complete EV3 python library to make it even easier to program the EV3. There’s a lot more interesting topics to cover here, but I’ll save those for future blog posts. Stay tuned!

About the author

9 Responses
  1. Simon Bonham

    I really hope someone improves the python side of EV3. I love the interactivity you showed in iPython! 🙂 Thank you 🙂

    1. Glad you liked in Simon!

      I encourage you to check out how ev3dev works. You control the hardware the Linux way: by simply writing a number to a file.

      For example, write 1 to the file that controls the left green LED, and it turns on. Write 0 to it and it turns off.

      Whether you do that in Python, C, or even just a shell script, doesn’t really matter. That’s why I’m such a fan of ev3dev – it’s how the LEGO distribution should have worked 🙂

      The ev3dev team is currently working on making all those file system controls work (and settle on names for each file). When that’s done, it shouldn’t be very hard to set up at least a rudimentary Python library (with a list of all the file names and what values to write).

      Let me grab the source code for my “program” from the brick and post it here.

  2. Sjoerd van Loon

    Hi Laurens,

    After finishing your book I came to this website and immediately got sidetracked by this post.

    Even though I know next to nothing about the Linux OS, statements and Python, I have got ev3dev running on my EV3 block.

    I even managed to get a position reading using the commandline!

    But what should be the next steps to install (i)Python? And make it possible, for example, to make one of the motors turn?

    It would be nice to see a follow up post about that.

  3. frank

    Hi Laurens,

    I got the latest version (20th or may 2015) now running on my eve brick, but I cannot get the Ipython Notebook to work.
    Any Tips & tricks to get this to working?

  4. I second Frank’s and Lenart’s question. I’m a Python programmer, I develop stuff in it for money. I tried installing IPython on ev3dev for about 4 days. ipykernel as remote or the whole Jupyter Notebook package. It seems to take AGES. Did you cross-compile or what?

Leave a Reply


EV3 Discovery

Discover the many features of the EV3 set, and learn to build and program your own robots! Learn more

Start Building Robots


Website Maintenance

Robotsquare is currently being updated, which means that it may look a little different (and not very polished) for a while. All the content and pages should still be there, though. It should be back and fully operational soon. Thanks for your patience!