Patching kernel with RT

Started by hnb2907, April 02, 2014, 05:04:40 PM

Previous topic - Next topic

hnb2907

Hi folks,

Just wondering if anyone has tried patching the kernel with the RT patch? 

A few months ago, I tried patching 3.4.67 with the relevant patch, but it wouldn't compile.  Might try it again, as I have an application that requires it.

(BTW; I can compile this version of kernel and boot my A20 ok without the RT patch).


Thanks,
Chris.

hnb2907

Well, it appears to work, with a fix to the RT patch :)  I'm typing this without the equipment here, so I think the details are correct.


1 ) Following some of the instructions from http://olimex.wordpress.com/2013/11/05/building-the-ultimate-debian-sd-card-for-linux-with-kernel-3-4-for-a20-olinuxino-micro/ to download the 3.4.67 kernel source.
Get 3.4.67 version source code (might need to add some switched to "git" to point to this version, can't remember!)
# git clone https://github.com/linux-sunxi/linux-sunxi
# cd linux-sunxi/
Get the a20_defconfig file
# cp a20_defconfig linux-sunxi/arch/arm/configs/.
# make ARCH=arm a20_defconfig


2 ) Optional step, patch the kernel with the F2FS filesytem for FLASH devices.  See here for more information https://www.olimex.com/forum/index.php?topic=2305.0

3 ) Download the respective RT patch from https://www.kernel.org/pub/linux/kernel/projects/rt/3.4/older/patch-3.4.67-rt83.patch.bz2

4 ) Follow the instructions here https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO#Patching_the_Kernel to patch the kernel source

5 ) The patch does not correctly fix file "fs/timerfd.c".  Change line 388 to include the missing "t."
Quotehrtimer_wait_for_timer(&ctx->t.tmr);

6 ) Configure the kernel:
# make ARCH=arm menuconfig
Follow the instructions here, regarding disabling certain power management features https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO#Configuration_and_Compilation.
Don't forget to set F2FS as statically built (if you're using it).

7 ) Patch the kernel for i2c
Get the i2c patch file
# patch -p0 < sunxi-i2c.patch


8 ) Check the following lines are in "arch/arm/Kconfig":
CONFIG_PREEMPT=y
CONFIG_PREEMPT_RT_BASE=y
CONFIG_PREEMPT_RT_FULL=y
CONFIG_HIGH_RES_TIMERS=y
# I also changed the timer from 100 to 1000, not sure if this has helped?
CONFIG_HZ=1000


9 ) Build the kernel and modules
# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j`nproc` uImage
# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j`nproc` INSTALL_MOD_PATH=out modules
# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j`nproc` INSTALL_MOD_PATH=out modules_install


10 ) mount the micro-sd card, copy the kernel, modules and firmware files as described here http://olimex.wordpress.com/2013/11/05/building-the-ultimate-debian-sd-card-for-linux-with-kernel-3-4-for-a20-olinuxino-micro/

11 ) Put the micro-sd card in the A20, and hopefully it will boot.  There is information here https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO#Checking_the_Kernel describing how to check if the kernel is patched ok.
I checked for:

  • "uname -a" reports 3.4.67-rt83
  • file "/sys/kernel/realtime" now exists
  • IRQ handlers are now reported in "ps -ef" with [brackets]
  • my realtime application now behaves better with RT kernel support



I did plan to use the newer 3.4.79 kernel, but there isn't a patch available for this version.


Hope that helps someone :)

N8body

Hey i recently found some other Info about a RT-Kernel for a A20,the guy applied a lot of other settings on it(CPU-Governor and so on). Maybe its worth a look:
http://obeediy.blogspot.de/2014/02/building-custom-real-time-kernel-for.html

hnb2907

Nice fine N8body, thanks!  :)

That's almost exactly what I did. 
Although, I've disabled the CPU governor.  I'm assuming it now runs at 100% speed, which I what I want it to do.

One step I performed, but didn't put in my instructions, was to modify the USB settings in the .fex file.  You'll find in my other posts on here that I'd already done this.


Cheers,
Chris.