Août 122016
 

Totalement inspiré de http://www.raspibo.org/wiki/index.php/Compile_the_Linux_kernel_for_Chip:_my_personal_HOWTO
Pré-requis indispensable : un debian SID (unstable) 32 bit.

# Stocker l’IP du chip pour automatiser le reste des commandes.
# si scp ne fonctionne pas, installer openssh-client sur le chip et le PC
CHIP=10.254.0.6

apt-get install git build-essential fakeroot kernel-package zlib1g-dev libncurses5-dev lzop
apt-get install gcc-arm-linux-gnueabihf binutils-arm-linux-gnueabihf

mkdir -p /extra/tmp/chip/LINUX
cd /extra/tmp/chip/LINUX
git clone https://github.com/NextThingCo/CHIP-linux.git

cd /extra/tmp/chip/LINUX/CHIP-linux
git checkout -b debian/4.3.0-ntc-4 origin/debian/4.3.0-ntc-4

scp chip@$CHIP:/boot/config-4.3.0-ntc /extra/tmp/chip/LINUX/CHIP-linux

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- menuconfig

## faire LOAD du fichier CONFIG copié depuis le CHIP.
## Ajouter iptables
# Networking >> Networking options >> Network packet filtering (replaces ipchains) >> Core Netfilter Configuration >> Netfilter Xtables support (required for ip_tables) and select the all following options as modules.
# Networking >> Networking options >> Network packet filtering (replaces ipchains) >> IP: Net Filter configurationS >> IP Tables support
## Ajouter un suffixe
# General setup —> () Local version – append to kernel release
# my personal suffix is NLE.
# sauver la config dans le fichier « .config »

### The parameter -j should be set to the number of cores of your computer + 1. I have an 4-core (2 real cores + 2 hyperthreads), so I use 5.
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- -j 5

mkdir /tmp/lib
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- INSTALL_MOD_PATH=/tmp/lib modules_install

cd /extra/tmp/chip/LINUX
git clone https://github.com/NextThingCo/RTL8723BS.git
cd RTL8723BS
git checkout -b debian origin/debian
for i in debian/patches/0*; do echo $i; patch -p 1 <$i ; done

make -j 5 CONFIG_PLATFORM_ARM_SUNxI=y ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- -C /extra/tmp/chip/LINUX/CHIP-linux/ M=$PWD CONFIG_RTL8723BS=m INSTALL_MOD_PATH=/tmp/lib
make -j 5 CONFIG_PLATFORM_ARM_SUNxI=y ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- -C /extra/tmp/chip/LINUX/CHIP-linux/ M=$PWD CONFIG_RTL8723BS=m INSTALL_MOD_PATH=/tmp/lib modules_install

scp /extra/tmp/chip/LINUX/CHIP-linux/arch/arm/boot/zImage root@$CHIP:/boot/vmlinuz-4.3.0NLE+
scp /extra/tmp/chip/LINUX/CHIP-linux/.config root@$CHIP:/boot/config-4.3.0NLE+
scp /extra/tmp/chip/LINUX/CHIP-linux/System.map root@$CHIP:/boot/System.map-4.3.0NLE+
cd /tmp/lib/lib/modules
tar cf – 4.3.0NLE+ | ssh root@$CHIP ‘cd /lib/modules; tar xf -‘
cd ../firmware/
tar cf – . | ssh root@$CHIP ‘mkdir /lib/firmware/4.3.0NLE+; cd /lib/firmware/4.3.0NLE+; tar xf -‘

rm -rf /tmp/tar/
mkdir -p /tmp/tar/boot
cp /extra/tmp/chip/LINUX/CHIP-linux/arch/arm/boot/zImage /tmp/tar/boot/vmlinuz-4.3.0NLE+
# cp /extra/tmp/chip/LINUX/CHIP-linux/arch/arm/boot/zImage /tmp/tar/boot/zImage
cp /extra/tmp/chip/LINUX/CHIP-linux/.config /tmp/tar/boot/config-4.3.0NLE+
cp /extra/tmp/chip/LINUX/CHIP-linux/System.map /tmp/tar/boot/System.map-4.3.0NLE+

mkdir -p /tmp/tar/lib/modules/4.3.0NLE+
mkdir -p /tmp/tar/lib/firmware/4.3.0NLE+

cp -r /tmp/lib/lib/firmware/* /tmp/tar/lib/firmware/4.3.0NLE+
cp -r /tmp/lib/lib/modules /tmp/tar/lib/

cd /tmp/tar
rm /tmp/kernel.tar
tar -cf ../kernel.tar *
gzip ../kernel.tar

rcp /tmp/kernel.tar.gz $CHIP:/root/

sinon, à l’arrache :
kernel.tar.gz

wget -d –header= »User-Agent: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11″ http://snakenet.eu/blog/wp-content/uploads/2016/08/kernel.tar.gz
cd /
tar -zxf ~/kernel.tar.gz

### Tester le nouveau kernel sans tout casser : se connecter en UART et lors du uBOOT, appuyer sur une touche, puis :

setenv boot_initrd ‘mtdparts; ubi part UBI; ubifsmount ubi0:rootfs; ubifsload $fdt_addr_r /boot/sun5i-r8-chip.dtb; ubifsload 0x44000000 /boot/initrd.uimage; ubifsload $kernel_addr_r /boot/vmlinuz-4.3.0NLE+; bootz $kernel_addr_r 0x44000000 $fdt_addr_r’
setenv boot_noinitrd ‘mtdparts; ubi part UBI; ubifsmount ubi0:rootfs; ubifsload $fdt_addr_r /boot/sun5i-r8-chip.dtb; ubifsload $kernel_addr_r /boot/vmlinuz-4.3.0NLE+; bootz $kernel_addr_r – $fdt_addr_r’

boot

### Pour nettoyer les conneries de ce f* kernel :

rm /boot/vmlinuz-4.3.0NLE+ /boot/config-4.3.0NLE+ /boot/System.map-4.3.0NLE+ /lib/firmware/4.3.0NLE+ /lib/modules/4.3.0NLE+
cp /boot/zImage.bak /boot/zImage

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)