Recompilar Kernel do Debian


Primeiramente gostaria de salientar que não sou o autor principal do conteúdo deste artigo. A minha intenção é de mostrar o que outros autores tem realizado (referenciando links para o conteúdo original) neste blog até como um guia pessoal para uso próprio e ainda compartilhar minhas anotações e pequenas modificações que realizo no conteúdo, desejando que possa ajudar mais alguém em algum lugar.
First and foremost, I take no credit for any of this post’s content. I am really just taking what others have done (which I have links to bellow) and am putting it on my blog for a personal reference and hopefully the small changes that I made to their guides will help someone somewhere.

link: https://wiki.debian.org/HowToRebuildAnOfficialDebianKernelPackage
link: http://blog.nobiscuit.com/2012/02/15/kernel-patch-to-support-leds-buttons-and-sensors/
link: http://odroid.us/mediawiki/index.php?title=Step-by-step_Cross-compiling_a_Kernel

O objetivo aqui é recompilar o kernel do debian kirkwood para ficar compativel com o hardware do Iomega Ix2-200 e ter acesso aos leds e botões de liga, reset e backup.

Para o download do kernel source do debian wheezy visite a página https://packages.debian.org/wheezy/linux-image-3.2.0-4-kirkwood e faça o download do arquivo ou então digite:
sudo wget -O /usr/local/src/linux_3.2.60.orig.tar.xz http://security.debian.org/debian-security/pool/updates/main/l/linux/linux_3.2.60.orig.tar.xz
sudo wget -O /usr/local/src/linux_3.2.60-1+deb7u3.debian.tar.xz http://security.debian.org/debian-security/pool/updates/main/l/linux/linux_3.2.60-1+deb7u3.debian.tar.xz

Agora vamos extrair os arquivos
cd /usr/local/src/
sudo tar xvfJ linux_3.2.60.orig.tar.xz
sudo tar xpvf linux_3.2.60-1+deb7u3.debian.tar.xz
mv debian linux-3.2.60/
cd linux-3.2.60

apt-get install gcc-arm-linux-gnueabi quilt apt-get devscripts u-boot-tools sshpass


Veja a lista de debian/changelog e pense em um código para a nova versão:
 gedit debian/changelog

Por exemplo :
+iomega.1

Agora altere a string no campo abi.abiname em debian/config/defines
gedit debian/config/defines

Agora faça o download do patch:
wget -O 0001-Modified-rd88f6281-setup-file-to-support-ix2-200.patch https://sites.google.com/site/ubuntu4us/artigos/ferramentas-de-sistema/kernel-e-modulos/recompilar-kernel-do-debian/0001-Modified-rd88f6281-setup-file-to-support-ix2-200.patch?attredirects=0&d=1
wget -O 0001-ARM-Kirkwood-Add-configuration-for-MPP12-as-GPIO.patch https://sites.google.com/site/ubuntu4us/artigos/ferramentas-de-sistema/kernel-e-modulos/recompilar-kernel-do-debian/0001-ARM-Kirkwood-Add-configuration-for-MPP12-as-GPIO.patch?attredirects=0&d=1

Faça backup do arquivo que será alterado:
cp arch/arm/mach-kirkwood/rd88f6281-setup.c arch/arm/mach-kirkwood/rd88f6281-setup.c.old
cp arch/arm/mach-kirkwood/mpp.h arch/arm/mach-kirkwood/mpp.h.old

Use quilt para adicionar o seu patch:
quilt import 0001-Modified-rd88f6281-setup-file-to-support-ix2-200.patch
quilt push 0001-Modified-rd88f6281-setup-file-to-support-ix2-200.patch
quilt import 0001-ARM-Kirkwood-Add-configuration-for-MPP12-as-GPIO.patch 
quilt push 0001-ARM-Kirkwood-Add-configuration-for-MPP12-as-GPIO.patch 

Ou faça as alterações descrits no patch manualmente.

Copie o arquivo de configuração:
wget -O .config https://sites.google.com/site/ubuntu4us/artigos/ferramentas-de-sistema/kernel-e-modulos/recompilar-kernel-do-debian/config-3.0.18.txt?attredirects=0&d=1


export CFLAGS="-march=armv5te -mfloat-abi=soft -marm" 
export CROSS_COMPILE="arm-linux-gnueabi-" 
export ARCH="arm"
export LOCALVERSION="" # don't append a special version string the kernel (but you can if you like) 
export INSTALL_MOD_PATH=../modules # install the kernel modules in a special directory outside of the kernel structure

make oldconfig

make -j8 uImage 2>&1 1>uImage.stdout.log | tee uImage.stderr.log
make -j8 modules 2>&1 1>modules.stdout.log | tee modules.stderr.log 
make modules_install 2>&1 1>modules_install.stdout.log | tee modules_install.stderr.log


Compacte e copie os arquivos para o alvo:
tar -czf ../modules.tar.gz ../modules
scp ../modules.tar.gz root@192.168.1.13:/root
scp System.map root@192.168.1.13:/root/System.map-3.2.60
scp .config root@192.168.1.13:/root/config-3.2.60
scp arch/arm/boot/uImage root@192.168.1.13:/root/uImage-3.2.60


Acesse o alvo e copie para o local correto
ssh root@192.168.1.13
cp /root/*-3.2.60 /boot
tar xzf modules.tar.gz
cp -r modules/lib /

cd /boot
update-initramfs -v -c -k 3.2.60
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x00000000 -e 0x00000000 -n initramfs -d initrd.img-3.2.60 uInitrd-3.2.60

scp root@192.168.1.13:/boot/*-3.2.60 /var/lib/tftpboot/

Primeiro verifique:
cat /proc/mtd
dev: size erasesize name
mtd0: 00300000 00004000 "uImage"
mtd1: 01000000 00004000 "uInitrd"

flash_eraseall /dev/mtd0
flash_eraseall /dev/mtd1
nandwrite -p /dev/mtd0 /boot/uImage-3.2.60
nandwrite -p /dev/mtd1 /boot/uInitrd-3.2.60
reboot



apt-get install asciidoc
cd /usr/src

git clone https://github.com/gandro/input-event-daemon.git
cd input-event-daemon
make
make install

nano rc.local
input-event-daemon

nano /etc/input-event-daemon.conf

#
# /etc/input-event-daemon.conf
#

[Global]
listen = /dev/input/event0

[Switches]
# reset button on
LID:1 = echo "reset on"
# reset button off
LID:0 = echo "reset on"
# power button on
TABLET_MODE:1 = shutdown -h now && echo 0 > /sys/class/leds/power_led/brightness
# power button off
TABLET_MODE:0 = echo "power off"
# backup button on
HEADPHONE_INSERT:1 = echo "backup on"
# backup button off
HEADPHONE_INSERT:0 = echo "backup off"

[Idle]
1h 30m = echo "this was after 1h30m the last event"
reset = echo "some event happend here"



Leds: http://elinux.org/EBC_Exercise_10_Flashing_an_LED

ls -1F /sys/class/leds/

echo 1 > /sys/class/leds/backup_led/brightness
echo 1 > /sys/class/leds/health_led/brightness
echo 1 > /sys/class/leds/power_led/brightness
echo 1 > /sys/class/leds/rebuild_led/brightness

Piscar o led de backup:
echo timer > /sys/class/leds/backup_led/trigger
echo 100 > /sys/class/leds/backup_led/delay_on
echo 900 > /sys/class/leds/backup_led/delay_off

echo 0 > /sys/class/leds/backup_led/brightness
echo none > /sys/class/leds/backup_led/trigger





ċ
0001-ARM-Kirkwood-Add-configuration-for-MPP12-as-GPIO.patch
(1k)
Ademar Arvati Filho,
8 de set de 2014 16:47
ċ
0001-Modified-rd88f6281-setup-file-to-support-ix2-200.patch
(7k)
Ademar Arvati Filho,
7 de set de 2014 19:24
ċ
config-3.0.18.txt
(70k)
Ademar Arvati Filho,
8 de set de 2014 17:30
Comments