Compile ubilinux kernel from source

From UpWiki
Jump to: navigation, search

How to compile a custom kernel for UP / UP Squared / Up Core

Build Environment Setup

The following instruction are base on Ubuntu 16.04 host gcc-4.9 is needed for the compilation of the upboard kernel

sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get dist-upgrade -y
sudo apt-get install -y git build-essential kernel-package libncurses5-dev libssl-dev gcc-4.9 g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9

Getting the source

git clone https://github.com/emutex/ubilinux-kernel.git -b upboard-4.9 linux-upboard

to get only the latest commit (faster):

git clone --depth=1 https://github.com/emutex/ubilinux-kernel.git -b upboard-4.9 linux-upboard

Generating upboard default config

cd linux-upboard
make upboard_defconfig

Modifying the kernel config

make menuconfig

Compile the kernel

make -j`nproc`
make -j`nproc` bindeb-pkg

Custom configs

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.provider "virtualbox" do |vb|
     vb.cpus = 2
     vb.memory = 2048
     # vb.customize ["modifyvm", :id, "--paravirtprovider", "kvm"]
     # vb.customize ['storageattach', :id, '--storagectl', 'SATAController', '--port', '0', '--nonrotational', 'on']
  end
  config.vm.provision "shell", inline: <<-SHELL
    add-apt-repository -y ppa:ubuntu-toolchain-r/test
    apt-get update -qq
    apt-get dist-upgrade -y -qq
    apt-get install -y git build-essential kernel-package libncurses5-dev \
            libssl-dev gcc-4.9 g++-4.9
    update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 \
            --slave /usr/bin/g++ g++ /usr/bin/g++-4.9
    apt-get clean -qq
  SHELL

  #config.vm.provision "shell", privileged: false, inline: <<-SHELL
  #  mkdir ~/src
  #  cd ~/src
  #  git clone --depth=1 https://github.com/emutex/ubilinux-kernel.git -b upboard-4.9 linux-upboard
  #  cd linux-upboard
  #  make upboard_defconfig
  #  make -j`nproc`
  #  make -j`nproc` bindeb-pkg
  #SHELL
end