<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>debian_kernel_crosscompile</title><revhistory><revision><revnumber>4</revnumber><date>2017-02-09 11:19:33</date><authorinitials>186-102rev.amm.uniroma1.it</authorinitials></revision><revision><revnumber>3</revnumber><date>2017-02-09 11:19:13</date><authorinitials>186-102rev.amm.uniroma1.it</authorinitials></revision><revision><revnumber>2</revnumber><date>2017-02-08 17:57:42</date><authorinitials>186-102rev.amm.uniroma1.it</authorinitials></revision><revision><revnumber>1</revnumber><date>2017-02-08 17:46:21</date><authorinitials>186-102rev.amm.uniroma1.it</authorinitials></revision></revhistory></articleinfo><para><emphasis role="strong">My conf:</emphasis> Debian 8 (Jessie) with Backports, 4 cores, 4Gb RAM. </para><para><emphasis role="strong">Target:</emphasis> <ulink url="http://www.nnx.me/debian_kernel_crosscompile/OrangePi#">OrangePi</ulink> One H3 (<ulink url="http://www.nnx.me/debian_kernel_crosscompile/AllWinner#">AllWinner</ulink>) armhf, .deb only for a specific board </para><section><title>Install crossbuild packages for the target architecture.</title><screen><![CDATA[dpkg --add-architecture armhf
apt-get update
apt-get install crossbuild-essential-armhf
apt-get install cross-gcc-dev gcc-arm-none-aebi binutils-arm-linux-gnueabihf ]]></screen></section><section><title>Install kernel sources</title><screen><![CDATA[apt-get install linux-source-X.X]]></screen></section><section><title>Move to your working dir &amp; copy kernel sources.</title><screen><![CDATA[cd ~
cp /usr/src/linux.source-X.X.tar.xz .]]></screen></section><section><title>Expand kernel sources</title><screen><![CDATA[tar xavf linux-source-X.X.tar.xz]]></screen></section><section><title>Move to sources dir</title><screen><![CDATA[cd linux-source-X.X ]]></screen><para>If you have patches to apply then copy them into linux-source-X.X folder and then for each patch do:  </para><screen><![CDATA[patch -p1 < MYPATCH ]]></screen><para> Into arch/arm/ there are all supported boards, choose your board (mine is <ulink url="http://www.nnx.me/debian_kernel_crosscompile/OrangePi#">OrangePi</ulink> One and it's a sunxi board) </para></section><section><title>Prepare for configuration, start with a minimum configurations</title><screen><![CDATA[ARCH=arm CROSS_COMPILE=/usr/bin/arm-none-eabi- make sunxi_defconfig]]></screen><para>Now, we probably need more modules because that defconfig is a very minimal configuration </para><screen><![CDATA[ARCH=arm CROSS_COMPILE=/usr/bin/arm-none-eabi- make menuconfig]]></screen><para> Choose your modules. </para><para>* In General Setup -&gt; Stack Protector buffer overflow detection set it to None (or build will fail). </para></section><section><title>Build!</title><screen><![CDATA[ARCH=arm CROSS_COMPILE=/usr/bin/arm-none-eabi- DEB_BUILD_OPTIONS=nocheck make deb-pkg LOCALVERSION=-YOUR_TARGET_ARCH KDEB_PKGVERSION=$(make kernelversion) -j#num_of_cores]]></screen><para><emphasis role="strong">Don't forget to set the target LOCAL_VERSION=-YOUR_TARGET_ARCH</emphasis> (ie: -arm-antani-lpae ), otherwise dpkg <emphasis role="strong">will not install the kernel</emphasis>. This is what i did for my <ulink url="http://www.nnx.me/debian_kernel_crosscompile/OrangePi#">OrangePi</ulink> One:  </para><screen><![CDATA[ARCH=arm CROSS_COMPILE=/usr/bin/arm-none-eabi- DEB_BUILD_OPTIONS=nocheck make deb-pkg LOCALVERSION=-armmp-lpae KDEB_PKGVERSION=$(make kernelversion) -j4]]></screen><para>Wait until build process completes; <emphasis>ready to use .debs are in the upper level folder</emphasis>. </para></section></article>