Skip to main content

[LEGOEV3] About Ev3dev kernel upgrading, real-time operating system, and bugs in 4.10 linux kernel.

By following the tutorial in Ev3, one who is interested to run Linux on Ev3 should be able to have Debian with 3.16.7 linux kernel with the internet feature. For the research/lecture usage, I start to patch 4.10 Linux kernel and litmus-RT on it. I will list and update the possible delights for some of students who are just starting to develop Linux kernel stuffs.
If in Ev3dev wget fails, please add on --no-check-certificate in the option before the download link.

Ref:http://www.tecmint.com/install-kernel-3-16-in-debian/

As far as we can find, https://www.youtube.com/watch?v=PGy5XrI6lLs provides the video about how to patching Linux kernel for LitmusRT. The tutorial in installation page (https://wiki.litmus-rt.org/litmus/InstallationInstructions) is missing the command for the newbie who is lacking experience of linux tools:
sudo apt-get install build-essential kernel-package \
libncurse5-dev bzip2 fakeroot \
And use the following command for wrapping the kernel as deb package file:
fakeroot make-kpkg --initrd --append-to-version=-litmusRT \
kernel-image kernel-headers 

The version is 3.10 in the video. There must be some tiny bug if one directly follows it for the latest version 4.10 (as the trace option is involved). The bug [ref] is in the caller of __dynamic_dev_dbg function in usb driver as102, i.e., drivers/media/usb/as102/as102_usb_drv.c. To fix it, please add "&" before bus_adap->usb_deb->dev in line 117 and 135:
dev_dbg(bus_adap->usb_dev->dev, ...
It should becomes to:
dev_dbg(&bus_adap->usb_dev->dev, ... 
In fact, the author of LitmusRT answer the question: https://lists.litmus-rt.org/pipermail/litmus-dev/2016/001219.html
 
In addition, there is another bug in init/do_mounts.o failed, so far I haven't yet to fix it on Ev3.

If you get the warning that clock skew detected, it should be fixed by using the following commands to update the date on EV3:
date -s mm/dd/yy
date -s hh:mm:ss

--------------- LEGO Mindstorms Real-Time Operating System -------------
First of all, nxtOSEK is not good enough, as it lacks the ability of fully preemption.
We can find out a project that try to solve the problem: http://moss.csc.ncsu.edu/~mueller/rt/rt14/projects/p1/report4.pdf

Quote:"The nxtOSEK kernel has been purposefully designed to prevent successive instances of preemption i.e. the kernel does not support a case where after one preemption event, while the preempting task is yet to finish its execution, it is preempted in turn by an even higher priority task. In this project, we attempted to resolve this by modifying the current kernel behavior. ..."

However, the project to the end is not able to fix the problem:
Quote: "We weren't able to demonstrate successful return to the preempted task after the high priority task finishes its execution. Instead, we observed the controller getting reset after the completion of the higher priority task. We couldn't resolve this due to limited debug/simulation capabilities."

In EV3, OSPERT'14 has a workshop paper, which is also the producer of nxtOSEK:
"A Platform for LEGO Mindstorms EV3 Based on an RTOS with MMU Support"
https://www.mpi-sws.org/~bbb/proceedings/ospert14-proceedings.pdf
However, the developer said it is out-of-date and not compatible with recent arm-none-eabi
compilers. In fact, a new platform called EV3RT now is released. You can find more information here (http://ev3rt-git.github.io/ and http://dev.toppers.jp/trac_user/ev3pf/wiki/WhatsEV3RT) (in Japanese).

Comments

  1. May I ask whether you succeeded in patching the EV3 kernel with the Litmus-RT patch?

    ReplyDelete
    Replies
    1. I'm sorry that at the end we couldn't boot it :( To the end, we choose to use a new distribution called EV3OSEK.

      Delete
    2. Real-time linux may be more easier to deploy https://rt.wiki.kernel.org/index.php/Main_Page on EV3dev.

      Delete
    3. Thank you very much for your reply.

      Great that you mention EV3OSEK. I'm the project leader (or principal investigator so to say). My students and me are always happy to help with ev3osek. Just get in touch...

      I could also send you the project report providing details about porting nxtOSEK to EV3. Just drop me a line...

      Since EV3OSEK is currently missing a driver for the Mindstorm's LCD display and nxtOSEK has a bug (as you pointed out to us (https://github.com/ev3osek/ev3osek/issues/8)), I'm currently looking into the RT Preempt patch for Linux (as you suggested). I managed to patch the ev3dev kernel. However, some drivers do not work reliably (Wifi, USB). I'm still looking into this issue. You may want to have a look here: https://github.com/ev3dev/ev3dev/issues/779

      Delete
    4. :) I didn't notice that you are the person I talked to.

      I have one good but one bad news about the preemption in EV3OSEK (Just found it yesterday): The nested preemption problem somehow is gone but the context switch has a flaw. The first guess is that the values in the registers are not stored properly. Therefore, when the execution of preempted task is resumed, the elapsed processing is gone.

      May I have your project report about your porting? I think I can make some efforts there :) I can give you more detailed about the observation we have. My email: kuan-hsun.chen@tu-dortmund.de

      Delete

Post a Comment

Popular posts from this blog

RSB+RTEMS 5/6 with QEMU-SMP (ARM realview_pbx_a9_qemu as example)

Since I got a request regarding this blog  written in 2016, summarizing again the complete flow with the latest version of RTEMS could be a good idea. Prepare a suitable workspace according to the adopted operating system on your host ( https://docs.rtems.org/branches/master/user/hosts/index.html ):  sudo apt-get build-dep build-essential gcc-defaults g++ gdb git unzip pax bison flex texinfo unzip python3-dev libpython-dev libncurses5-dev zlib1g-dev Checkout RSB and build: git clone git://git.rtems.org/rtems-source-builder.git rsb change directory to rsb/rtems/ and type ../source-builder/sb-set-builder --prefix=<the path you like to store the built toolchains> <the name of bsp> For example, to use QEMU, I need toolchains for ARM, so: ../source-builder/sb-set-builder --prefix=/home/kh.chen/respository/build/. 6/rtems-arm This will take a while. Please ensure your connection is reliable. Add the built folder into your PATH. For example, you can add one line in ~/.bas...

[LEGO nxt] Install the Enhanced NXT firmware and Upload the OSEK excutable file with Ubuntu 64bits 14.04 in 2015

This tutorial is referred from Install the Enhanced NXT firmware on NXT . I think this is the critical part to capture the idea from the tutorial for Windows. I have tried many ways to conquer the problem of libnxt3.0, however, I still have some problems on the compilation of fwflash or something else. Though the tutorial for Windows is doable, my preference is to build up everything with Linux environment. Fortunately, I notice that NxTTool in the tutorial for Windows is really powerful. We can handle the firmware updating by using NxTTool in Linux as well! I also refer to this Japanese Blog , which inspire me a lot. As usual, install the required packages: sudo apt-get install libusb-dev:i386 libusb-0.1-4 subversion fpc Please note, here is the case for 64bits user that I change libusb-dev to libusb-dev:i386 comparing to the original tutorial. Instead of using libnxt to do the uploading, here I follow that JP Blog to get the latest version of bricxcc: (The url in blog i...

Virtualenv experience or alternatives

Today I have a project which requires several packages on my python. However, due to whatever reason, I have a lot of different versions of python. Before I thought, it was fine to just install and maintain each by each. Maybe it is time to learn how to use virtualenv. (alternatively, you can use module). I first got some quick ideas from here: https://stackoverflow.com/questions/10763440/how-to-install-python3-version-of-package-via-pip-on-ubuntu The magic virtualenv does is that, it copies a series of your python binaries, include, pip, etc., into a folder. The prepared activate script does that, add the export folder into the general variable PATH at its beginning. By doing so, the targeted version of python will be the first target that will be executed. To enable virtualenv, source the position of the above folder/bin/activate To leave the virtualenv, just type deactivate, as it is defined when you load the activate script. For example, I call virtualenv in my home ...