最新消息:

如何编译pcDuino内核

kernel admin 3930浏览 0评论

在这章里,我们来看一下如何编译pcDuino的内核。

和前面章节不太一样,这里我们将在X86 PC上交叉编译pcDuino的内核,所以,下面所用到的命令都是在X86 Linux上的。

1. 从Github下载kernel源代码文件:

$ git clone https://github.com/pcduino/kernel.git

注意:

  • 此步骤只下载了搭建环境。
  • 其他子模块可在这里下载:https://github.com/linux-sunxi/.
  • 第一次在kernel/ directory 下运行“make”的时候,子模块的源文件将被下载(如果在运行“make”之前子模块没有被下载的话)。

2.  在PC上安装交叉编译的软件和工具链:

在x86的ubuntu系统下,用apt-get安装以下程序包:

$ sudo apt-get install build-essential git u-boot-tools texinfo texlive ccache zlib1g-dev gawk
$ sudo apt-get install bison flex gettext uuid-dev ia32-libs

下载推荐的linaro工具链 (选择 “arm hf crosscompiler for Linux”):

https://launchpad.net/linaro-toolchain-binaries/+download

$ tar jzxf gcc-linaro-arm-linux-gnueabihf-xxx_linux.tar.bz2 -C your-path
$ export PATH=$PATH:your-path/gcc-linaro-arm-linux-gnueabihf-xxx_linux/bin/

3. 编译Kernel 镜像

在kernel/ directory 下运行“make” ( 不要在kernel/linux-sunxi directory 编译源文件)。

$ cd kernel/
$ make

如果没有发生错误, 在输出文件夹中将会出现一个可以通过livesuit烧录的镜像和一个HW_pack文件:

  • pcduino_a10_hwpack_YYYYMMDD.tar.xz ( 包括给mmc-boot的 uboot, 内核和 驱动模块).
  • pcduino_a10_kernel_livesuit_YYYYMMDD.img.( 通过livesuit 烧录的内核文)

注意:

  • 第一次编译的时候必要的源代码将会从这里下载:https://github.com/linux-sunxi/.
  • 每次运行“make”的时候,都会为pcDuino运行补丁。
  • pcDuino的补丁位于kernel/patch/ 目录下。
  • 所有由编译工具链产生的目标文件都保存在kernel/build 目录下。
  • 在kernel/linux-sunxi 目录下编译kernel会使构造环境变得杂乱。
  • 如果你之前进行过此类操作,请在kernel/linux-sunxi下运行“make mrproper “进行清理。

4. 为pcDuino更新的新的kernel

以下命在pcDuino中运行。

如果你只想更新kernel和模块(而不更新ubuntu桌面),解压hwpack 文件, 并且替换掉pcDuino板内文件即可:

  • a) 为从nand 启动的板子更新kernel
$ tar xvf pcduino_a10_hwpack_YYYYMMDD.tar.xz -C /tmp
$ sudo mount /dev/nanda /boot
$ sudo cp /tmp/kernel/* /boot -f
$ sudo mv /lib/modules/3.4.29+ /lib/modules/3.4.29_old
$ sudo cp /tmp/rootfs/lib/modules/3.4.29+ /lib/modules/ -ar
$ sudo sync
$ sudo umount /boot/
$ sudo reboot
  • b) 为从存储卡启动的板子更新kernel
$ tar xvf pcduino_a10_hwpack_YYYYMMDD.tar.xz -C /tmp
$ sudo mount /dev/mmcblk0p1 /boot
$ sudo cp /tmp/kernel/* /boot -f
$ sudo mv /lib/modules/3.4.29+ /lib/modules/3.4.29_old
$ sudo cp /tmp/rootfs/lib/modules/3.4.29+ /lib/modules/ -ar
$ sudo sync
$ sudo umount /boot/
$ sudo reboot

注意:

  1. · Hardwarelib现在已经是不公开的源模块,你可以从这里复制这些模块 /lib/modules/3.4.29_old:
  2. · $ sudo cp /lib/modules/3.4.29+_old/kernel/drivers/hardwarelib/ /lib/modules/3.4.29+/kernel/drivers/ -ar

5. 定制你的kernel

你可以为自己改变或增加驱动。在编译之前,把你在kernel/patch 目录 下改变或增加的源代码都保存下来(此步骤也可以通过在kernel/patch/linux-sunxi 下运行“./make_kernel_patch.sh ”实现),在kernel/linux-sunxi 下的文件可能会被补丁再次重写一遍。
如果你想改变kernel的配置文件(增加或删除一些驱动),那么这里有一些不一样的地方。运行” make menuconfig “定制kernel配置, 然后将其保存到补丁目录并且重建kernel。

$ cd kernel/build/sun4i_defconfig-linux/
$ make menuconfig ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
$ mv .config ./../patch/linux-sunxi/arch/arm/configs/sun4i_defconfig -f

根据第三步重建kernel和第四步在新kernel下更新pcDuino。

 

转载请注明:爱开源 » 如何编译pcDuino内核

您必须 登录 才能发表评论!