atmel官方网站www.at91.com中对基于DTB的linux内核编译流程如下:
本文档为本人在ubuntu 10.04下实验流程,红色文字为本人添加的记录;
by Jevon Apr.2013
Get sources
To get the source code, you have to clone the repository:
注意:如有提示“程序“git”尚未安装。 您可以使用以下命令安装:
sudo apt-get install git-core
用以下命令来在本地上克隆github上的内核源码仓库,该过程很长,取决于网速,慢慢等待:
$ git clone git://github.com/linux4sam/linux-at91.git
Cloning into 'linux-at91'...
remote: Counting objects: 5239592, done.
remote: Compressing objects: 100% (764014/764014), done.
Receiving objects: 100% (5239592/5239592), 1018.56 MiB | 11.18 MiB/s, done.
remote: Total 5239592 (delta 4448248), reused 5218219 (delta 4427054)
Resolving deltas: 100% (4448248/4448248), done.
Checking out files: 100% (38567/38567), done.
打开下载到的linux-at91源码仓库,浏览一下:
$ cd linux-at91
$ ls
arch CREDITS drivers include Kbuild lib mm REPORTING-BUGS security usr
block crypto firmware init Kconfig MAINTAINERS net samples sound virt
COPYING Documentation fs ipc kernel Makefile README scripts tools
在以后使用中,可以用下面命令来实现源码的更新:
The source code has been taken from the master branch which is pointing on the latest branch we use.
hand Note that you can also add this Linux4SAM repository as a remote GIT repository to your usual Linux git tree. It will save you a lot of bandwidth and download time:
$ git remote add linux4sam git://github.com/linux4sam/linux-at91.git
$ git remote update linux4sam
Fetching linux4sam
From git://github.com/linux4sam/linux-at91
* [new branch] at91-3.4-trunk_merge -> linux4sam/at91-3.4-trunk_merge
* [new branch] linus2639_5series_1.x -> linux4sam/linus2639_5series_1.x
* [new branch] linux-3.4.9-at91 -> linux4sam/linux-3.4.9-at91
* [new branch] linux-3.6.9-at91 -> linux4sam/linux-3.6.9-at91
* [new branch] master -> linux4sam/master
If you want to use an other branch, you can list them and use one of them by doing this:
$ git branch -r
origin/HEAD -> origin/master
origin/at91-3.4-trunk_merge
origin/linus2639_5series_1.x
origin/linux-3.4.9-at91
origin/linux-3.6.9-at91
origin/master
$ git checkout origin/linux-3.6.9-at91 -b linux-3.6.9-at91
Branch linux-3.6.9-at91 set up to track remote branch linux-3.6.9-at91 from origin.
Switched to a new branch 'linux-3.6.9-at91'
Configure and Build the Linux kernel
Now you have to configure the Linux kernel according to your hardware. The default configuration for a particular SoC is a good starting point that you will be able to adapt to your needs afterwards.
$ cd linux-at91
$ ls arch/arm/configs/+(at91|sam)*
arch/arm/configs/at91_dt_defconfig arch/arm/configs/at91sam9g45_defconfig
arch/arm/configs/at91rm9200_defconfig arch/arm/configs/at91sam9rl_defconfig
arch/arm/configs/at91sam9260_defconfig arch/arm/configs/at91x40_defconfig
arch/arm/configs/at91sam9261_defconfig arch/arm/configs/sam9_l9260_defconfig
arch/arm/configs/at91sam9263_defconfig arch/arm/configs/sama5d3_defconfig
arch/arm/configs/at91sam9g20_defconfig
$
$ make ARCH=arm <name of your SoC_defconfig> # sama5d3_defconfig for instance
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/zconf.lex.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
#
# configuration written to .config
#
At this step, you can modify default configuration using the menuconfig
$ make ARCH=arm menuconfig
如果在执行make ARCH=arm menuconfig
后出现错误;
解决办法如下:
sudo apt-get insatll ncurses-dev
完成后ok!
接下来是编译内核,编译内核所需交叉编译器:
本人在ubuntu上面有一下两个交叉编译器:
1.arm-2007q1-10-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
该版本比较适合用于编译内核的场合,经过测试该版本编译at91bootsap时出现问题;
2.arm-2009q1-161-arm-none-eabi-i686-pc-linux-gnu.tar.bz2
该版本比较适合用于编译没有内核的场合,如at91bootstrap,uboot;
(以前用的VMWARE6.5+FC12安装好VM TOOL后就可以在/mnt/hgfs 访问window中的共享文件夹了;如今把FC12抛弃了,改装了ubuntu10.04但发现hgfs目录下是空的;
安照以下步骤解决该问题:
sudo apt-get install open-vm-dkms
安装过程均按照默认设置;
sudo mount -t vmhgfs .host:/ /mnt/hgfs
)
这里本人用arm-2007q1-10-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2来编译内核;
建立交叉编译环境:
在arm-2007q1-10-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2同级目录下:
sudo tar xvjf arm-2007q1-10-arm-none-linux-gnueabi.tar.bz2 -C /usr/local
完成后交叉编译器就已经建立好了,其路径如下:
/usr/local/arm-2007q1/bin/arm-none-linux-guneabi-
And build the Linux kernel image
$ make ARCH=arm CROSS_COMPILE=<path_to_cross-compiler/cross-compiler-prefix-> zImage
[..]
Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready
make ARCH=arm CROSS_COMPILE=<path_to_cross-compiler/cross-compiler-prefix-> uImage
本人实际命令如下:
make ARCH=arm CROSS_COMPILE=/usr/local/arm-2007q1/bin/arm-none-linux-guneabi- uImage
注:make uImage 这个命令要求您的 Ubuntu 系统里面已经安装 uImage 工具,否则请使用一下命令安装该工具
sudo apt-get install uboot-mkimage
内核编译结束,arch/arm/boot/目录下的 uImage 就是我们需要的结果。
[..]
Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready
UIMAGE arch/arm/boot/uImage
Image Name: Linux-3.6.9+
Created: Mon Feb 4 12:26:46 2013
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2837352 Bytes = 2770.85 kB = 2.71 MB
Load Address: 20008000
Entry Point: 20008000
Image arch/arm/boot/uImage is ready
接下来编译DTBS:
make ARCH=arm CROSS_COMPILE=<path_to_cross-compiler/cross-compiler-prefix-> dtbs
[..]
DTC arch/arm/boot/at91sam9g20ek.dtb
DTC: dts->dtb on file "arch/arm/boot/dts/at91sam9g20ek.dts"
DTC arch/arm/boot/at91sam9g20ek_2mmc.dtb
DTC: dts->dtb on file "arch/arm/boot/dts/at91sam9g20ek_2mmc.dts"
[..]
DTC: dts->dtb on file "arch/arm/boot/dts/at91sam9m10g45ek.dts"
DTC arch/arm/boot/at91sam9n12ek.dtb
DTC: dts->dtb on file "arch/arm/boot/dts/at91sam9n12ek.dts"
DTC arch/arm/boot/at91sam9g15ek.dtb
DTC: dts->dtb on file "arch/arm/boot/dts/at91sam9g15ek.dts"
DTC arch/arm/boot/at91sam9g25ek.dtb
DTC: dts->dtb on file "arch/arm/boot/dts/at91sam9g25ek.dts"
DTC arch/arm/boot/at91sam9g35ek.dtb
DTC: dts->dtb on file "arch/arm/boot/dts/at91sam9g35ek.dts"
DTC arch/arm/boot/at91sam9x25ek.dtb
DTC: dts->dtb on file "arch/arm/boot/dts/at91sam9x25ek.dts"
DTC arch/arm/boot/at91sam9x35ek.dtb
DTC: dts->dtb on file "arch/arm/boot/dts/at91sam9x35ek.dts"
DTC arch/arm/boot/sama5d31ek.dtb
DTC: dts->dtb on file "arch/arm/boot/dts/sama5d31ek.dts"
DTC arch/arm/boot/sama5d31ek_pda.dtb
DTC: dts->dtb on file "arch/arm/boot/dts/sama5d31ek_pda.dts"
DTC arch/arm/boot/sama5d33ek.dtb
DTC: dts->dtb on file "arch/arm/boot/dts/sama5d33ek.dts"
DTC arch/arm/boot/sama5d33ek_pda.dtb
DTC: dts->dtb on file "arch/arm/boot/dts/sama5d33ek_pda.dts"
DTC arch/arm/boot/sama5d34ek.dtb
DTC: dts->dtb on file "arch/arm/boot/dts/sama5d34ek.dts"
DTC arch/arm/boot/sama5d34ek_pda.dtb
DTC: dts->dtb on file "arch/arm/boot/dts/sama5d34ek_pda.dts"
DTC arch/arm/boot/sama5d35ek.dtb
DTC: dts->dtb on file "arch/arm/boot/dts/sama5d35ek.dts"
path_to_cross-compiler is only needed if it is not in your PATH.
Usually cross-compiler-prefix- looks like arm-none-linux-gnueabi- or arm-linux-gnueabi-
If the building process is successful, the final images can be found under arch/arm/boot/ directory.
$ ls arch/arm/boot/
aks-cdu.dtb at91sam9m10g45ek.dtb ethernut5.dtb sama5d33ek.dtb tny_a9g20.dtb
at91sam9263ek.dtb at91sam9n12ek.dtb evk-pro3.dtb sama5d33ek_pda.dtb usb_a9260.dtb
at91sam9g15ek.dtb at91sam9x25ek.dtb install.sh sama5d34ek.dtb usb_a9263.dtb
at91sam9g20ek_2mmc.dtb at91sam9x35ek.dtb kizbox.dtb sama5d34ek_pda.dtb usb_a9g20.dtb
at91sam9g20ek.dtb bootp Makefile sama5d35ek.dtb
at91sam9g25ek.dtb compressed sama5d31ek.dtb tny_a9260.dtb
at91sam9g35ek.dtb dts sama5d31ek_pda.dtb tny_a9263.dtb
文章评论(0条评论)
登录后参与讨论