COMPILATION STEP BY STEP
COMPILATION pas à pas
it's a question of a couple of hours ...
Less than 99 steps, really!


[installing basis]

1-frugal install of TCL

in a dedicated linux formated partition (EXT2 OR EXT3 OR EXT4)
with persistent /home and /opt ... it can help INSTALL A TCL BASED ON SAME KERNEL VERSION AS TARGET

2-install "On Boot" all needful stuff such as :

	(kmaps.tcz if non QWERTY keyboard)	
	compiletc.tcz 
	perl5.tcz 
	ncurses-dev.tcz 
	bash.tcz
	bc.tcz
	advcomp.tcz
	web browser such as opera
  for example, my /tce dir is mounted at /mnt/sda3,
  I will replace it by "sda#" in all the text below.
  Just adapt to your partition number.

3-create directories

The script "0_cmp" create needed directories.
Run it or manually invoke these commands :
(being root and in the root dir of the dedicated partition)
	-mkdir /mnt/sda#/SRC/KERNEL
	-mkdir /mnt/sda#/SRC/RTAI
	-mkdir /mnt/sda#/SRC/TINY
	-mkdir /mnt/sda#/SRC/SCRIPTS
	-mksir /mnt/sda#/RT

[Downloading]

4-download kernel 3.16.6 from

https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.16.6.tar.xz
https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.16.6.tar.sign

  move it in /mnt/sda#/SRC/KERNEL
(you can verify kernel source download with PGP signature ... may be.)

5-extract kernel vanilla

in a terminal, being root :

  cd /mnt/sda#/SRC/KERNEL
  tar -xvf linux-3.16.6.tar.xz

resulting tree is in /mnt/sda#/SRC/KERNEL/linux-3.16.6

6-download RTAI tarball "rtai-4.1.tar.bz2"

https://www.rtai.org/?Homepage&id=34
    move it in /mnt/sda#/SRC/RTAI

7-extract patch RTAI

 in a terminal, being root :
cd /mnt/sda#/SRC/RTAI
tar -xvf rtai-4.1.tar.bz2
resulting RTAI files are in /mnt/sda#/SRC/RTAI/rtai-4.1
the patch we need is in /mnt/sda#/SRC/RTAI/rtai-4.1/base/arch/x86/patches

8-download all TinyCore patches

http://distro.ibiblio.org/tinycorelinux/6.x/x86/release/src/kernel/316-patches/advdef.patch
http://distro.ibiblio.org/tinycorelinux/6.x/x86/release/src/kernel/316-patches/efficeon-agp.patch
http://distro.ibiblio.org/tinycorelinux/6.x/x86/release/src/kernel/316-patches/logo.patch
http://distro.ibiblio.org/tinycorelinux/6.x/x86/release/src/kernel/316-patches/sd-warning.patch
http://distro.ibiblio.org/tinycorelinux/6.x/x86/release/src/kernel/316-patches/squashfs-warning.patch
http://distro.ibiblio.org/tinycorelinux/6.x/x86/release/src/kernel/316-patches/ubuntu-isapnp.patch

8.1 -download TinyCore config
http://distro.ibiblio.org/tinycorelinux/6.x/x86/release/src/kernel/config-3.16.6-tinycore
http://distro.ibiblio.org/tinycorelinux/6.x/x86/release/src/kernel/Module.symvers-3.16.6-tinycore.gz
	move it in /mnt/sda#/SRC/TINY. It let you verify that all is going well :
	With this config file, you are able to build a standard "Tiny Core Linux"
(all this also available at : http://ftp.nluug.nl/os/Linux/distr/tinycorelinux/6.x/x86/release/src/kernel/)

[Patching]

9-patch kernel with "hal-linux-3.16-x86-3.patch"

    cd /mnt/sda#/SRC/KERNEL/linux-3.16.6
    patch -p1 < /mnt/sda#/SRC/RTAI/rtai-4.1/base/arch/x86/patches/hal-linux-3.16-x86-3.patch

 you'll get some "hunk #"
 just delete corresponding ".orig" files or change its extension.
 may be "diff" has not been made against an up to date source ...
 who knows?

9.1-patch kernel with each Tiny patch at "TINY"
 see : http://wiki.tinycorelinux.net/wiki:custom_kernel

 you'll get some "hunk #"
 you can as well decide to delete corresponding ".orig" files
 or just rename it.
e.g.
       cd /mnt/sda#/SRC/KERNEL/linux-3.16.6
       patch -p1 < /mnt/sda#/SRC/TINY/advdef.patch
result :
      patching file scripts/Makefile.lib
      Hunk #1 succeeded at 238 (offset -1 lines)
then
       patch -p1 < /mnt/sda#/SRC/TINY/efficeon-agp.patch
       patch -p1 < /mnt/sda#/SRC/TINY/logo.patch
       patch -p1 < /mnt/sda#/SRC/TINY/sd-warning.patch
       patch -p1 < /mnt/sda#/SRC/TINY/squashfs-warning.patch
       patch -p1 < /mnt/sda#/SRC/TINY/ubuntu-isapnp.patch

10-house keeping (being root)

      cd linux
      make mrproper

[Compiling patched kernel vanilla]

11-modify .config  

 there is 2 "flavor" of config file depending on your processor : SMPconfig or MONOconfig
 copy the suitable one in linux tree an rename it ".config"
 make menuconfig
 make (carefully) any changes you need to the configuration.

Some readings :
    Avoid latency killers
    tuto. how to install RTAI

retained options:
	-Loadable module support  / Enable loadable module support  / (on) 
	-Loadable module support  / Module versioning support  / (off)
	-Processor type and features  / HPET Timer Support (off)
	-Processor type and features  /  Preemptible Kernel (Low-Latency Desktop)
		Voluntary Kernel Preemption (Desktop) works too
	-Processor type and features  /  Interrupt pipeline  / (on)  
	-Processor type and features  / High Memory Support  /  (off)
	-Processor type and features  / Math emulation / (on)
	-Power management options (ACPI, APM)  / Legacy Power Management API  / (off)
	-Power management options (ACPI, APM)  / Software Suspend  / (off)
	-Suspend to RAM and standby (off)
	-Hibernation (aka 'suspend to disk') (off)
	-Run-time PM core functionality  (on)
	-Cpuidle Driver for Intel Processors (off)
	-CPU Frequency scaling  /  CPU Frequency scaling  /   (off)
	-ACPI (Advanced Configuration and Power Interface) Support  / ACPI Support / (off)
 BUT: in any case, set Processor type corresponding to the proc. you're really running on!

12-make bzImage

from here, script 2_cmp (interacting) or 22_cmp (more "auto") can do the trick.
You can either path thru further steps "by hand" :
       cd /mnt/sda#/SRC/KERNEL/linux-3.16.6
       make bzImage

 validate default choices
If it goes well, result is /mnt/sda#/SRC/KERNEL/linux-3.16.6/arch/x86/boot/bzImage

12.1 Test :
you can check this new Tiny core in "base" mode.
You need to copy bzImage to a location where your boot loader can access it.
   e.g.
create dir. /tst/boot in the HDD partition where is your /tce ;
move bzImage and a copy of core.gz in it ; modify the boot loader menu so that it can boot using this new kernel.

for example menu.lst entry for grub4dos :
	title New Tiny Core test
	root (hd0,2)
	kernel /tst/boot/bzImage
	initrd /tst/boot/core.gz

13-make modules

in the kernel development tree :
      make modules
... and wait . Have a coffee!

[install modules]

14-copy "core.gz" to /mnt/sda#/RT/core_gz/

  cp /mnt/sda#/tce/boot/core.gz /mnt/sda#/RT/core_gz/core.gz

15-expand core.gz : (being Root)

if dir. "/mnt/sda#/RT/core_gz/xtract" don't exist, create it :
      mkdir /mnt/sda#/RT/core_gz/
and copy the standard core.gz in it
      mkdir /mnt/sda#/RT/core_gz/xtract

      cd /mnt/sda#/RT/core_gz/xtract
      zcat ../core.gz | sudo cpio -i -H newc -d

16-install modules

make INSTALL_MOD_PATH=/mnt/sda#/RT modules_install firmware_install
      modules are in /mnt/sda#/RT/lib/modules/3.8.13-tinycore/kernel
      firmware are in /mnt/sda#/RT/lib/firmware
      Tiny Core only use some of these that we'll copy in expanded core.gz

!! numerous modules are not included in Tiny Core !!
You can list modules recently created : 
	cd /mnt/sda#/RT/lib/modules/3.16.6-tinycore/kernel
	find -name *.ko > /mnt/sda#/SRC/modules3.16.6
 ... and compare it with those really used in core.gz :
	cd /mnt/sda#/RT/core_gz/xtract/lib/modules/3.8.13-tinycore/kernel
	find -name *.ko.gz > /mnt/sda#/SRC/modules.tiny
Scripts have been made in order to limit the number of modules
so that we'll only work  with useful ones :
	mdl_tiny3.8.13.sh or mdl_tiny3.16.6.sh (depending on your kernel version)

17-invoke script to move only same modules as Tiny distro

/mnt/sda#/SRC/SCRIPTS/mdl_tiny3.16.6.sh or mdl_tiny3.8.13.sh

18-compact modules

cd /mnt/sda#/RT/core_gz/xtract/lib
find . -name "*.ko" -exec gzip -9 '{}' \;
!! IF modules.dep is modified, in modules.dep change all ".ko" to ".ko.gz", use an editor !!

19-remaster core.gz to core2.gz

cd ..
find |  cpio -o -H newc | gzip -9 > ../core2.gz
cd ..
advdef -z4 core2.gz

20-copy bzImage and core2.gz to your final test directory

I use my /mnt/sda#/tce, the entry in grub's menu.lst is
title Tiny Core patched RTAI
root (hd0,2)
kernel /tce/boot/bzImage
initrd /tce/boot/core2.gz

Here "2_cmp" end help you, ("22_cmp" no more)

[Compile RTAI suite]

21-Reboot on this image to compile RTAI

adapt your multiboot to run bzImage along with core2.gz as an init.rd.

for example my menu.lst entry for grub4dos :
	title Tiny Core "RTAI" tests
	root (hd0,2)
	kernel /tce/boot/bzImage
	initrd /tce/boot/core2.gz

23-Go to RTAI tree (in a root shell)

If you are working on rtai-4.1 :
cd /mnt/sda#/SRC/RTAI/rtai-4.1
 n.b. I have been several times happy to work with a "RTAI" newly unpacked
      rather than reconfig one previously used.

You'll want to preserve .rtai_config (if exist) may be to roll back...
for example :
mv .rtai_config sav.rtai_config

24-Copy  SMP.rtai_config from where it's stand and rename it .rtai_config

... or MONO.rtai_config if your proceeor is not SMP.

25-make menuconfig

adapt to your needs ... Mainly, with the tree previously used :
General / Installation directory : /mnt/sda#/RT
General / Linux source tree : /mnt/sda#/SRC/KERNEL/linux-3.8.13

26-make


27-make install

If all is OK, RTAI modules are in /mnt/sda#/RT/modules

28-test using testsuite

The script "tstSuite.sh" help you to do that (look at /mnt/sda#/SRC/SCRIPTS)
    don't forget to modif path :
       export PATH=/mnt/sda#/RT/bin:$PATH

   test example, by hand :
       cd /mnt/sda#/RT/testsuite/kern/latency
       export PATH=/mnt/sda#/RT/bin:$PATH
       ./run

Results can show many overruns: interrupts from SMI (System Management Interrupt)
are a source of it, as it introduces critical issues for real-time systems.
Disable all SMIs sources WITH EXTREME CAUTION !
Ensure that your motherboard is not overheating and that unexpected
and untimely reboots don't occure.

You can disable it using
       /mnt/sda#/RT/bin/setsmi
.. and restart the test

At the end of it, restore it by /mnt/sda#/RT/bin/rstsmi.
"tstSuite.sh" do all that.