Compilació del Kernel amb Ubuntu Studio 1r mètode

De Wikijoan
Dreceres ràpides: navegació, cerca

http://packages.ubuntu.com/search?keywords=linux-image-rt

Package linux-image-rt

   * gutsy (metapackages): Linux kernel image on realtime kernel [universe]
     2.6.22.15.22 [security]: amd64 i386
   * gutsy-updates (metapackages): Linux kernel image on realtime kernel [universe]
     2.6.22.15.22: amd64 i386
   * hardy (metapackages): Real time Linux kernel image [universe]
     2.6.24.19.21 [security]: amd64 i386
   * hardy-updates (metapackages): Real time Linux kernel image [universe]
     2.6.24.21.23: amd64 i386
   * intrepid (metapackages): Rt Linux kernel image [universe]
     2.6.27.3.4: amd64 i386

Finalment m'he instal.lat el Ubuntu Studio 8.04 (2.6.24-21-rt), que es correspon al Hardy

Tot això venia del forum d'Ubuntu, on una persona s'havia comprat el EDIROL UA-25EX, i per tal de què funcionés plenament en mode avançat s'havia d'aplicar un patch i recompilar el kernel.

http://ubuntu-utah.ubuntuforums.org/showthread.php?t=908845&highlight=edirol

En aquest how-to miraré de recompilar el kernel

Created a wiki page about the Edirol UA-25EX on the Alsa Wiki: http://alsa.opensrc.org/index.php/Edirol_UA-25EX


Vaig escriure en el forum la següent pregunta:

I'm ready to compile my kernel.
My kernel is from Ubuntu Studio (/usr/src/linux-headers-2.6.22-15-rt), who is tuned for real-time operations.
under the folder /usr/src/linux-headers-2.6.22-15-rt/asound/usb I don't see usbquirks.h file.
It seems that the patch is for Debian with a 2.6.21... How to proceed?...

Thanks in advance,
Joan Quintana

... i vaig obtindre la resposta ...

I only applied the patch on the kernel 2.6.24, 2.6.26 and 2.6.27.
In 2.6.24, everything works fine even with RT enabled.
2.6.26, if the kernel is compiled with the RT option, Jackd will crash as soon as you try to use midi with the UA-25EX. Couldn't find out what the problem was...
2.6.27, RT is not available yet... But it works fine otherwise.
Your best option would be to upgrade the kernel to at least 2.6.24.
By the way, I use and created the patch under Ubuntu Studio too, so it is supposed to work ok...
Hope this helps !

Bé, doncs ja ho he fet i ara tinc el kernel 2.6.24-21-rt i em disposo a seguir el tutorial

https://help.ubuntu.com/community/Kernel/Compile

To start, you will need to install a few packages.

$ sudo apt-get install linux-kernel-devel fakeroot build-essential makedumpfile
No se pudo encontrar el paquete makedumpfile

Contingut

Get the kernel source

1. Use git (detailed instructions on it can be found in the Kernel Git Guide) - This allows you to always stay in sync with the latest Ubuntu kernel source. https://wiki.ubuntu.com/KernelGitGuide

Current GIT Trees

   * hardy: git://kernel.ubuntu.com/ubuntu/ubuntu-hardy.git 

To obtain the git binaries, simply install the git-core package from dapper, e.g.:

$ sudo apt-get install git-core


Getting the Ubuntu Linux kernel repo

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.


The Ubuntu Linux kernel git repository is located at git://kernel.ubuntu.com/ubuntu/ubuntu-hardy.git. To download a local copy of the repo, use this command:


$ git clone git://kernel.ubuntu.com/ubuntu/ubuntu-hardy.git ubuntu-hardy
Initialized empty Git repository in /home/joan/ubuntu-hardy/.git/
remote: Counting objects: 654723, done.
remote: Compressing objects: 100% (131242/131242), done.
remote: Total 654723 (delta 532901), reused 643785 (delta 522354)
Receiving objects: 100% (654723/654723), 190.44 MiB | 121 KiB/s, done.
Resolving deltas: 100% (532901/532901), done.
Checking out files: 100% (23870/23870), done.

This will take some time depending on your connection. There's around 220 MiB of data to download currently (and this always increases). Once this is complete, you can keep your tree up-to-date by running this command:

$ git pull -> falla, diu que Failed to find a valid git directory.
      git-pull(1)
          Fetch from and merge with another repository or a local branch.

[--git-dir=GIT_DIR]

$ git --git-dir=/home/joan/ubuntu-hardy/.git/ pull 
Already up-to-date. -> OK

No Local Changes

 git fetch -f origin
 git checkout origin
 git branch -f master origin
 git checkout master

Preserve Local Changes -> jo tinc local changes, doncs de fet el meu kernel és el rt (crec que és aquesta opció)

 # Save away local commits
 git --git-dir=/home/joan/ubuntu-hardy/.git/ rev-list --reverse origin..HEAD > local-commits -> a dins de local-commits no hi ha res
 git --git-dir=/home/joan/ubuntu-hardy/.git/ branch new-head origin
 git --git-dir=/home/joan/ubuntu-hardy/.git/ checkout new-head -> no hi ha errors
 # This will stop on first error. Cleaning up failures is an exercise for the user
 for cmt in `cat local-commits`; do git-cherry-pick $cmt || break; done
 git --git-dir=/home/joan/ubuntu-hardy/.git/ branch -f master new-head
 git --git-dir=/home/joan/ubuntu-hardy/.git/ checkout master
 git --git-dir=/home/joan/ubuntu-hardy/.git/ branch -D new-head

ho ha fet tot bé sense errors, el que no sé és exactament què he fet.

Modify the source for your needs

Ara és el moment de modificar el kernel segons les nostres necessitats, aplicar els patch,...

For most people, simply modifying the configs is enough. If you need to install a patch, read the instructions from the patch provider for how to apply.

The stock Ubuntu configs are located in debian/config/ARCH/ where ARCH is the architecture you are building for. In this directory are several files. The config file is the base for all targets in that architecture. Then there are several config.FLAVOUR files that contain options specific to that target. For example, here are the files for 2.6.20, i386:

el meu fitxer config està a: ~/ubuntu-hardy/debian/config/i386$

El patch que he d'aplicar és:

Add Alsa support for Roland Edirol UA-25EX in Advanced mode
(for MIDI support and sample rates of 48 kHz and 96 kHz)
usbquirks.h
=Compilació del kernel=
Build the kernel (when source is from git repository [el meu cas], or from apt-get source)

To build the kernel(s) is very simple. Depending on your needs, you may want to build all the kernel targets, or just one specific to your system. However, you also want to make sure that you do not clash with the stock kernels.

These instructions are specific to the git-tree [el meu cas] and for the source downloaded via apt-get source, not when downloading the linux-source package

Use this command to build all targets for the architecture you are building on:

[previ, $ sudo apt-get install fakeroot]
$ AUTOBUILD=1 fakeroot debian/rules binary-debs -> funciona, triga molt perquè ho faig per totes les arquitectures! (cancel.lo)


The AUTOBUILD environment variable triggers special features in the kernel build. First, it skips normal ABI checks (ABI is the binary compatibility). It can do this because it also creates a unique ABI ID. If you used a git repo, this unique ID is generated from the git HEAD SHA. If not, it is generated from the uuidgen program (which means every time you execute the debian/rules build, the UUID will be different!). Your packages will be named using this ID. 

To build a specific target, use this command:

AUTOBUILD=1 NOEXTRAS=1 fakeroot debian/rules binary-FLAVOUR

Where FLAVOUR is one of the main flavours of the kernel (e.g. generic)

To build one of the custom flavours (found in debian/binary-custom.d/), use:

AUTOBUILD=1 NOEXTRAS=1 fakeroot debian/rules custom-binary-FLAVOUR

As of this documentation, custom flavours include xen and rt. -> fixem-nos que existeix rt!

<pre>
$ AUTOBUILD=1 NOEXTRAS=1 fakeroot debian/rules custom-binary-rt -> aquest és el que faig (triga molt)

Fixem-nos que:

joan@ubuntu:~/ubuntu-hardy/debian/stamps$ cat stamp-flavours 
386 generic server virtual rt xen openvz -> aquí està una pista sobre rt!!

Xen is a free software virtual machine for linux that allows you to run several operating systems (guests) on the same computer hardware (host) at the same time.

el kernel amb flavour xen representa que està preparat per ser utilitzat com a servidor de màquines virtuals.

To trigger a rebuild, remove the appropriate stamp file from debian/stamps (e.g. stamp-build-server for the server flavour, etc.). -> en ppi això és per si ho he de repetir...

The debs are placed in your kernel directory's parent directory. -> he d'anar a ../../kernel, és a dir, a /home/joan, i comprovar que estan els deb que acabo de crear

If needed, the Ubuntu modules source for Hardy (8.04) can be built in similar way.

cd linux-ubuntu-modules-2.6.24-2.6.24
AUTOBUILD=1 fakeroot debian/rules binary-debs

[no faig res dels mòduls]

Compilació del kernel

Build the kernel (when source is from git repository [el meu cas], or from apt-get source)

To build the kernel(s) is very simple. Depending on your needs, you may want to build all the kernel targets, or just one specific to your system. However, you also want to make sure that you do not clash with the stock kernels.

These instructions are specific to the git-tree [el meu cas] and for the source downloaded via apt-get source, not when downloading the linux-source package

Use this command to build all targets for the architecture you are building on:

[previ, $ sudo apt-get install fakeroot] $ AUTOBUILD=1 fakeroot debian/rules binary-debs -> funciona, triga molt perquè ho faig per totes les arquitectures! (cancel.lo)


The AUTOBUILD environment variable triggers special features in the kernel build. First, it skips normal ABI checks (ABI is the binary compatibility). It can do this because it also creates a unique ABI ID. If you used a git repo, this unique ID is generated from the git HEAD SHA. If not, it is generated from the uuidgen program (which means every time you execute the debian/rules build, the UUID will be different!). Your packages will be named using this ID.

To build a specific target, use this command:

AUTOBUILD=1 NOEXTRAS=1 fakeroot debian/rules binary-FLAVOUR

Where FLAVOUR is one of the main flavours of the kernel (e.g. generic)

To build one of the custom flavours (found in debian/binary-custom.d/), use:

AUTOBUILD=1 NOEXTRAS=1 fakeroot debian/rules custom-binary-FLAVOUR

As of this documentation, custom flavours include xen and rt. -> fixem-nos que existeix rt!

$ AUTOBUILD=1 NOEXTRAS=1 fakeroot debian/rules custom-binary-rt -> aquest és el que faig (triga molt)

Fixem-nos que:

joan@ubuntu:~/ubuntu-hardy/debian/stamps$ cat stamp-flavours 
386 generic server virtual rt xen openvz -> aquí està una pista sobre rt!!

Xen is a free software virtual machine for linux that allows you to run several operating systems (guests) on the same computer hardware (host) at the same time.

el kernel amb flavour xen representa que està preparat per ser utilitzat com a servidor de màquines virtuals.

To trigger a rebuild, remove the appropriate stamp file from debian/stamps (e.g. stamp-build-server for the server flavour, etc.). -> en ppi això és per si ho he de repetir...

The debs are placed in your kernel directory's parent directory. -> he d'anar a ../../kernel, és a dir, a /home/joan, i comprovar que estan els deb que acabo de crear

If needed, the Ubuntu modules source for Hardy (8.04) can be built in similar way.

cd linux-ubuntu-modules-2.6.24-2.6.24
AUTOBUILD=1 fakeroot debian/rules binary-debs

[no faig res dels mòduls]

Alternate Build Method: The Old-Fashioned Debian Way

aquesta és la manera tradicional (make-kpkg), que és com ho vam fer en el curs d'administració de Linux


Install the new kernel

hem compilat el kernel, i ara falta instal.lar el nou kernel

If you want to see the ubuntu splash screen (or use text mode) before you get to X instead of just a black screen, you'll want to make sure the framebuffer driver loads:

echo vesafb | sudo tee -a /etc/initramfs-tools/modules echo fbcon | sudo tee -a /etc/initramfs-tools/modules [funciona]

Now that you've told initramfs-tools what modules it should include and the build is complete, you can install the generated debs using dpkg:

$ sudo dpkg -i linux-image-2.6.24-22-rt_2.6.24-22.43_i386.deb -> he creat aquests paquets, que són els rt, i ara els instal.lo
[sudo] password for joan: 
Seleccionando el paquete linux-image-2.6.24-22-rt previamente no seleccionado.
(Leyendo la base de datos ...  
140807 ficheros y directorios instalados actualmente.)
Desempaquetando linux-image-2.6.24-22-rt (de linux-image-2.6.24-22-rt_2.6.24-22.43_i386.deb) ...
Done.
Configurando linux-image-2.6.24-22-rt (2.6.24-22.43) ...
Running depmod.
update-initramfs: Generating /boot/initrd.img-2.6.24-22-rt
Running postinst hook script /sbin/update-grub.
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-2.6.24-22-rt
Found kernel: /boot/vmlinuz-2.6.24-21-rt
Found kernel: /boot/vmlinuz-2.6.24-19-rt
Found kernel: /boot/memtest86+.bin
Replacing config file /var/run/grub/menu.lst with new version
Updating /boot/grub/menu.lst ... done
$ sudo dpkg -i linux-headers-2.6.24-22-rt_2.6.24-22.43_i386.deb
Seleccionando el paquete linux-headers-2.6.24-22-rt previamente no seleccionado.
(Leyendo la base de datos ...  
143085 ficheros y directorios instalados actualmente.)
Desempaquetando linux-headers-2.6.24-22-rt (de linux-headers-2.6.24-22-rt_2.6.24-22.43_i386.deb) ...
dpkg: problemas de dependencias impiden la configuración de linux-headers-2.6.24-22-rt:
 linux-headers-2.6.24-22-rt depende de linux-headers-2.6.24-22; sin embargo: 
  El paquete `linux-headers-2.6.24-22' no está instalado.
dpkg: error al procesar linux-headers-2.6.24-22-rt (--install):
 problemas de dependencias - se deja sin configurar
Se encontraron errores al procesar:
 linux-headers-2.6.24-22-rt

M'ha fallat aquest últim tros, per un problema de dependències. He hagut d'apagar per pressa i després ha reiniciat sense problemes. Hi ha un problema de dependències, necessito el linux-headers-2.6.24-22, i de fet jo tinc el linux-headers-2.6.24-19 i linux-headers-2.6.24-21 (com que m'he connectat al jig, estic instal.lant de fet la última revisió, que és la 22)


de http://ppa.launchpad.net/timg-tpi/ubuntu/pool/main/l/linux/ em baixo el paquet linux-headers-2.6.24-22-386_2.6.24-22.43ubuntu2_i386.deb i l'instal.lo:

$ sudo dpkg -i linux-headers-2.6.24-22-386_2.6.24-22.43ubuntu2_i386.deb

i ara ja tinc dins de /usr/src el directori linux-headers-2.6.24-22, i per tant torno a compilar els headers:

$ sudo dpkg -i linux-headers-2.6.24-22-rt_2.6.24-22.43_i386.deb
Preparando para reemplazar linux-headers-2.6.24-22-rt 2.6.24-22.43 (usando linux-headers-2.6.24-22-rt_2.6.24-22.43_i386.deb) ...
Desempaquetando el reemplazo de linux-headers-2.6.24-22-rt ...
Configurando linux-headers-2.6.24-22-rt (2.6.24-22.43) ...

OK!

Similarly, if you have build the Ubuntu module for Hardy (8.04) earlier, install them as follows: [No cal]

sudo dpkg -i linux-ubuntu-modules-2.6.24-16-generic_2.6.24-16.23_i386.deb
sudo dpkg -i linux-headers-lum-2.6.24-16-generic_2.6.24-16.23_i386.deb

Reinicio i ja tinc el nou kernel instal.lat amb el patch que he aplicat.

If you use modules from linux-restricted-modules, you will need to recompile this against your new linux-headers package.

Tanmateix, no ha funcionat. S'ha instal.lat el nou kernel 2.6.24-22, però tot el sistema de so està espatllat. Per ex, $ cat /proc/asound/cards diu que no existeix


Com s'aplica un patch. Eina diff

The diff program can be used to compare two files and to make patches. A typical example might be diff -ruN file.old file.new > file.diff. This command will create a diff (recursively if directories are used) that shows the changes, or "delta", between the two files.

The patch program is used to apply a patch (usually created by diff or another similar program) to a file or directory. To apply the patch created above, we can invoke patch -p0 < file.diff. The -p tells patch how much it should strip from the paths for the file names in the patch. -p0 means to strip nothing, or leave the path intact.

Exemple:
fitxer1.txt:
linia1
linia2
linia3
linia4

el modifico per
fitxer2.txt
linia1
liina2

linia4

$ diff -ruN fitxer1.txt fitxer2.txt > fitxer.diff

-r: recursive

$ cat fitxer.diff
--- fitxer1.txt 2008-10-22 18:17:56.000000000 +0200
+++ fitxer2.txt 2008-10-22 18:18:15.000000000 +0200
@@ -1,4 +1,4 @@
 linia1
-linia2
-linia3
+liina2
+
 linia4

per aplicar els canvis:
$ sudo apt-get install patch
$ patch < fitxer.diff

i ja està, ja hem aplicat el patch:
$ cat fitxer1.txt
linia1
liina2

linia4

creat per Joan Quintana Compte, novembre 2008

Eines de l'usuari
Espais de noms
Variants
Accions
Navegació
IES Jaume Balmes
Màquines recreatives
CNC
Informàtica musical
joanillo.org Planet
Eines