Differenze tra le versioni di "Compile the Linux kernel for Chip: my personal HOWTO"

Da raspibo.
Jump to navigation Jump to search
 
(16 versioni intermedie di uno stesso utente non sono mostrate)
Riga 1: Riga 1:
 +
This is my personal "How to compile a new kernel for CHIP on Debian".
 +
(My laptop is debian SID)
 +
 
=== pre-requisites ===
 
=== pre-requisites ===
  
Riga 5: Riga 8:
  
 
<pre>
 
<pre>
apt-get install git build-essential fakeroot kernel-package zlib1g-dev libncurses5-dev
+
apt-get install git build-essential fakeroot kernel-package zlib1g-dev libncurses5-dev lzop
 
</pre>
 
</pre>
  
Riga 72: Riga 75:
 
switch to the debian branch:
 
switch to the debian branch:
 
<pre>
 
<pre>
 +
cd RTL8723BS
 
git checkout -b debian origin/debian
 
git checkout -b debian origin/debian
 
</pre>
 
</pre>
Riga 90: Riga 94:
 
It is a jigsaw-puzzle.
 
It is a jigsaw-puzzle.
 
<pre>
 
<pre>
scp /extra/tmp/chip/LINUX/CHIP-linux/arch/arm/boot/zImage 10.1.1.2:/boot/vmlinuz-4.3.0rd235+
+
scp /extra/tmp/chip/LINUX/CHIP-linux/arch/arm/boot/zImage root@10.1.1.2:/boot/vmlinuz-4.3.0rd235+
scp /extra/tmp/chip/LINUX/CHIP-linux/config-4.3.0rd235+ 10.1.1.2:/boot
+
scp /extra/tmp/chip/LINUX/CHIP-linux/.config root@10.1.1.2:/boot/config-4.3.0rd235+
scp /extra/tmp/chip/LINUX/CHIP-linux/System.map 10.1.1.2:/boot/System.map-4.3.0rd235+
+
scp /extra/tmp/chip/LINUX/CHIP-linux/System.map root@10.1.1.2:/boot/System.map-4.3.0rd235+
scp -r /tmp/lib/lib/modules/4.3.0rd235+ 10.1.1.2:/lib/modules
+
cd /tmp/lib/lib/modules
ssh 10.1.1.2 mkdir /lib/firmware/4.3.0rd235+
+
tar cf - 4.3.0rd235+ | ssh root@10.1.1.2 'cd /lib/modules; tar xf -'
scp -r /tmp/lib/lib/firmware 10.1.1.2:/lib/firmware/4.3.0rd235+
+
cd ../firmware/
 +
tar cf - . | ssh root@10.1.1.2 'mkdir /lib/firmware/4.3.0rd235+; cd /lib/firmware/4.3.0rd235+; tar xf -'
 
</pre>
 
</pre>
  
Riga 105: Riga 110:
 
<pre>
 
<pre>
 
/boot/vmlinuz-4.3.0rd235+
 
/boot/vmlinuz-4.3.0rd235+
<pre>
+
</pre>
  
 
The command to run the new kernel is:
 
The command to run the new kernel is:
Riga 112: Riga 117:
 
</pre>
 
</pre>
 
(i.e. copy the entire output of "printenv bootcmd" changing "/boot/zImage" in "/boot/vmlinuz-4.3.0rd235+")
 
(i.e. copy the entire output of "printenv bootcmd" changing "/boot/zImage" in "/boot/vmlinuz-4.3.0rd235+")
 +
 +
When you are confident enough to use your new kernel as th default one copy /boot/vmlinuz-4.3.0rd235+ to /boot/zImage.
 +
 +
=== clean up after a failed test ===
 +
 +
In case you want to delete your kernel on chip:
 +
<pre>
 +
rm -rf /boot/vmlinuz-4.3.0rd235+ /boot/config-4.3.0rd/boot235+ boot/System.map-4.3.0rd235+ /lib/modules/4.3.0rd235+ /lib/firmware/4.3.0rd235+
 +
</pre>
 +
 +
=== My config file ===
 +
 +
This is a config file providing about 1300 modules. Among the others support for NAT for IPV4, all USB-gadget submodules, USB dongles for networking and multimedia.
 +
[http://www.raspibo.org/renzo/config-4.3.0rd235+ config-4.3.0rd235+]
 +
 +
=== ... if you want to test my kernel ===
 +
 +
'''THIS IS AN EXPERIMENTAL KERNEL. TRY IT AT YOUR OWN RISK!'''
 +
 +
<pre>
 +
cd /tmp
 +
wget http://www.raspibo.org/renzo/chiplinux4.3.0rd235+.tgz
 +
cd /
 +
sudo tar zxf /tmp/chiplinux4.3.0rd235+.tgz
 +
</pre>
 +
 +
Now if you have a USB console cable you can test my kernel as explained above.
 +
 +
Otherwise it is possible to set my kernel as the default kernel:
 +
'''Warning:  in this way if chip does not boot you need a USB console cable to reboot using /boot/zImage.bak (or you must reflash chip)'''
 +
<pre>
 +
sudo cp /boot/vmlinuz-4.3.0rd235+ /boot/zImage
 +
</pre>
 +
 +
If you want to revert back to NTC provided kernel:
 +
<pre>
 +
sudo cp /boot/xImage.bak /boot/zImage
 +
</pre>

Versione attuale delle 08:32, 26 mar 2016

This is my personal "How to compile a new kernel for CHIP on Debian". (My laptop is debian SID)

pre-requisites

You'll need a number of packets. I don't know if this list is complete. It you are used to compiling kernels you already have all what you need.

apt-get install git build-essential fakeroot kernel-package zlib1g-dev libncurses5-dev lzop

You'll need the cross compiling toolchain.

apt-get install gcc-arm-linux-gnueabihf binutils-arm-linux-gnueabihf

CHIP-linux

Create a working dir and enter it. Mine is /extra/tmp/chip/LINUX. Then clone git repositories from NTC.

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

checkout the same version provided by NTC's Debian repo.

cd CHIP-linux
git checkout -b debian/4.3.0-ntc-4 origin/debian/4.3.0-ntc-4

Copy the config file from your chip. My chip is connected as 10.1.1.2:

scp 10.1.1.2:/boot/config-4.3.0 .

Configure the kernel:

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

IMPORTANT: add a local version suffix. Follow the menus:

    General setup  --->
    () Local version - append to kernel release

my personal suffix is rd235.

You may want to pass through the menus and add a lot of modules. (As a first experiment I suggest to compile the same standard configuration and test if everything is stable, then in a second time I'd add the modules).

Now it is possible to compile the kernel. The parameter -j should be set to the number of cores of your computer + 1. I have an 8-core (4 real cores + 4 hyperthreads), so I use 9.

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- -j 9

I install the modules on /tmp/lib (just to have a fake hierarchy to be copied on chip).

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

RTL8723BS is an out-of-tree module

Everything is provided by the CHIP-linux tree but the RTL8723BS module. This is a bit harder.

Clone the repository.

cd /extra/tmp/chip/LINUX
git clone https://github.com/NextThingCo/RTL8723BS.git

switch to the debian branch:

cd RTL8723BS
git checkout -b debian origin/debian

apply debian patches:

for i in debian/patches/0*; do  echo $i; patch -p 1 <$i ; done

compile the module:

make -j 9 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 9 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

Move everything on chip

It is a jigsaw-puzzle.

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

boot your new kernel

Use this previous howto of mine to boot your new kernel. The image name in this example is:

/boot/vmlinuz-4.3.0rd235+

The command to run the new kernel is:

sunxi# setenv bootcmd 'source ${scriptaddr}; nand slc-mode on; mtdparts; ubi part UBI; ubifsmount ubi0:rootfs; ubifsload $fdt_addr_r /boot/sun5i-r8-chip.dtb; ubifsload $kernel_addr_r /boot/vmlinuz-4.3.0rd235+; bootz $kernel_addr_r - $fdt_addr_r'

(i.e. copy the entire output of "printenv bootcmd" changing "/boot/zImage" in "/boot/vmlinuz-4.3.0rd235+")

When you are confident enough to use your new kernel as th default one copy /boot/vmlinuz-4.3.0rd235+ to /boot/zImage.

clean up after a failed test

In case you want to delete your kernel on chip:

rm -rf /boot/vmlinuz-4.3.0rd235+ /boot/config-4.3.0rd/boot235+ boot/System.map-4.3.0rd235+ /lib/modules/4.3.0rd235+ /lib/firmware/4.3.0rd235+

My config file

This is a config file providing about 1300 modules. Among the others support for NAT for IPV4, all USB-gadget submodules, USB dongles for networking and multimedia. config-4.3.0rd235+

... if you want to test my kernel

THIS IS AN EXPERIMENTAL KERNEL. TRY IT AT YOUR OWN RISK!

cd /tmp
wget http://www.raspibo.org/renzo/chiplinux4.3.0rd235+.tgz
cd /
sudo tar zxf /tmp/chiplinux4.3.0rd235+.tgz

Now if you have a USB console cable you can test my kernel as explained above.

Otherwise it is possible to set my kernel as the default kernel: Warning: in this way if chip does not boot you need a USB console cable to reboot using /boot/zImage.bak (or you must reflash chip)

sudo cp /boot/vmlinuz-4.3.0rd235+ /boot/zImage

If you want to revert back to NTC provided kernel:

sudo cp /boot/xImage.bak /boot/zImage