linux内核打xenomai补丁,编译kernel+xenomai+machinekit

编译kernel+xenomai,主要参考https://code.google.com/p/picnc项目中的wiki页面。

编译machinekit,主要参考http://www.machinekit.io/docs/building-from-source/

。解决编译依赖要费些周折,需要再添加两个源,下载几个包。

搭建 qemu chroot 环境

安装必要的包

sudo apt-get install qemu qemu-user qemu-user-static binfmt-support debootstrap

用debootstrap搭建最小chroot环境

选择速度快点儿的Raspbian镜像:http://www.raspbian.org/RaspbianMirrors

cd dir>sudo debootstrap --foreign --no-check-gpg --include=ca-certificates --arch=armhf wheezy rootfs

编辑/etc/qemu-binfmt.conf,加入下面这行:

EXTRA_OPTS="-L/usr/lib/arm-linux-gnueabihf"

复制qemu可执行文件然后chroot

sudo cp $(which qemu-arm-static) rootfs/usr/binsudo chroot rootfs/ /debootstrap/debootstrap --second-stage --verbose

将使用的镜像加入/etc/apt/sources.list

sudo sh -c 'echo deb wheezy main > rootfs/etc/apt/sources.list'sudo sh -c 'echo deb-src wheezy main >> rootfs/etc/apt/sources.list'

创建/etc/resolv.conf

sudo cp /etc/resolv.conf rootfs/etc

Chroot

sudo chroot rootfs /bin/bash

设定locale,否则会产生一堆警告

LC_ALL=C

LANGUAGE=C

LANG=C

安装必要的包

apt-get update

apt-get install --no-install-recommends git-core kernel-package fakeroot build-essential devscripts lsb-release

编译Linux内核

下载源文件和补丁

进入工作目录

cd /usr/src

下载内核

git clone -b rpi-3.8.y --depth 1 git://github.com/raspberrypi/linux.git linux-rpi-3.8.y

下载Xenomai

git clone git://git.xenomai.org/xenomai-2.6.git xenomai-head

下载最小config文件

wget https:///s/dcju74md5sz45at/rpi_xenomai_config

下载USB fiq补丁

wget https://gist.githubusercontent.com/kinsamanka/10256843/raw/4d5d3e02a443e4d17d9b82a1fe027ef17fb14470/usb_fiq.patch

打补丁

打 ipipe core pre-patch

(cd linux-rpi-3.8.y; patch -Np1 < ../xenomai-head/ksrc/arch/arm/patches/raspberry/ipipe-core-3.8.13-raspberry-pre-2.patch)

打Xenomai ipipe核心补丁(先查看补丁编号是否有变化,补丁要与内核版本号一致)

xenomai-head/scripts/prepare-kernel.sh --arch=arm --linux=linux-rpi-3.8.y \--adeos=xenomai-head/ksrc/arch/arm/patches/ipipe-core-3.8.13-arm-4.patch

打 ipipe core post-patch

(cd linux-rpi-3.8.y; patch -Np1 < ../xenomai-head/ksrc/arch/arm/patches/raspberry/ipipe-core-3.8.13-raspberry-post-2.patch)

打usb fiq补丁

(cd linux-rpi-3.8.y; patch -Np1 < ../usb_fiq.patch)

编译内核

编辑内核包维护者信息(名字、电邮之类的)

vi /etc/kernel-pkg.conf

安装必备的包

apt-get install --no-install-recommends ncurses-dev bc

配置内核

cd linux-rpi-3.8.ycp ../rpi_xenomai_config .configmake oldconfig

编译

make-kpkg cleanmake-kpkg --append-to-version=-xenomai --revision=1.0 kernel_image kernel_headers

编译Xenomai用户空间包

变更目录

cd /usr/src/xenomai-head

安装必要的依赖包

apt-get build-dep xenomai

编译

debuild -i -us -uc -b

编译Machinekit

变更目录

cd /usr/src

下载源码

git clone -b master -o github-machinekit --depth 1 git://github.com/machinekit/machinekit.git

添加两个源,安装必要的包

sudo sh -c \"echo 'deb http://deb.dovetail-automata.com wheezy main' > \

/etc/apt/sources.list.d/machinekit.list"sudo apt-get updatesudo apt-get install dovetail-automata-keyringsudo apt-get updatesudo apt-get install libczmq-dev python-zmq libjansson-dev \

libwebsockets-devsudo sh -c \"echo 'deb http://ftp.us.debian.org/debian wheezy-backports main' > \

/etc/apt/sources.list.d/wheezy-backports.list"sudo apt-get updatesudo apt-get install -t wheezy-backports cythonsudo apt-get install git dpkg-dev

安装内核和xenomai

dpkg -i linux-image-3.8.13-xenomai+_1.0_armhf.deb

dpkg-i libxenomai1_2.6.3_armhf.deb

dpkg-i libxenomai-dev_2.6.3_armhf.deb

安装依赖包

sudo scripts/apt-installbuilddeps

编辑/etc/fstab,加入

none /dev/shm tmpfs rw,nosuid,nodev,noexec 0 0

Mount shm(否则会报错 error: failed to find

required module pyftpdlib.servers)

mount /dev/shm

配置machinekit

cd machinekit

debian/configure -px

编译

debuild -i -us -uc -b

你可能感兴趣的:(linux内核打xenomai补丁,编译kernel+xenomai+machinekit)