MYZR-SAMA5 Linux-3.18 编译手册
目录
- 1 文档说明(document instruction)
- 2 安装并配置交叉编译工具链(install and configure cross compilation tool chain)
- 3 AT91Bootstrap编译(AT91Bootstrap compilation)
- 4 u-boot编译(u-boot compilation)
- 5 内核编译(compile kernel)
- 6 文件系统编译(compile file system)
文档说明(document instruction)
系统环境说明(system environment instruction)
- 编译主机CPU架构:64位
CUP architeture of host used for compilation:64bit
- 编译主机系统:Linux
system of compilation host:
- Linux发行版:Ubuntu
Linux release version:
- Ubuntu版本类型:服务器版
Ubuntu version type: saver version
- Ubuntu版本号:12.04.5
Ubuntu version no.:
- Ubuntu系统类型:x86-64
Ubuntu system type:
注意:开发主机请使用ubuntu 12.04.5 x86-64(桌面版或服务器版均可),使用其他发行版的Linux或Ubuntu的其它版本可能会遇到的不必要的问题。
The development host should use ubuntu 12.04.5 x86-64(desktop and server version are available),Using other distribution of Linux and other versions of Ubuntu may encounter unnecessary problems
操作说明 (operation instruction)
1)文档中以“$”开头的行,其后是Linux命令。
The line in the document which begins with “$”,which is followed by the Linux command.
2)文档中所有的Linux命令建议手动输入到Linux主机执行(直接复制、粘贴到Linux主机上执行,可能会执行失败)。
All the Linux commands in the document are recommended to be entered into the host manually for execution.(Copying ,pasting to the host directly to execute may fail)
3)文档中的Linux执行命令,如果空格后的下一个字符是“-”的(如:sudo apt-get –y install之类的),请手动输入到Linux主机执行(直接复制、粘贴到Linux主机上执行,通常会执行失败)。
In all the Linux execution commands of the document,if the next character after the space is "-",(example:sudo apt-get –y install),please enter into Linux host to execute manually.(Copying ,pasting to the host directly to execute may fail )
4)文档中所有一行没写完的Linux命令请手动输入到Linux主机执行,(因为复制、粘贴命令不能包含类似“换行符”之类的特殊字符)。
any line of Linux commands whichi is not finished is recommended to be entered into the host for execution. (Because copy or paste commands cannot contain special character such as "line breaks")
5)按文档输入并执行Linux命令时注意观察命令的执行结果与文档图片中的是否一致,以确认命令是否输入有误及是否执行失败。
Note whether the execution result is consistent with the document image when you enter and execute the command. check the command was entered incorrectly or failed to execute.。 )
6)第一遍编译请严格按照文档进行,否则可能出现莫名其妙的错误。
Please follow the document strictly to compile for the first time.Otherwise ,there may be unexpected error。
截图说明(screenshots instruction)
为使视图看起来简洁整齐,截图中的命令提示符统一使用myzr$。
To make the view look neat and tidy , the command prompt in the screenshot should use myzr$ uniformly。
图片中的Linux命令(Linux command in the image)
在文档的图片中观察“myzr$”开头的行可以直观的看到输入的Linux命令。
In the image of the document, you can see the input Linux command visually from the lines that start with “myzr$”。
重要信息说明(important information instruction)
为避免各位客户在搭建开发环境及编译过程中遇到不必要的问题浪费时间和精力,推荐使用明远智睿发布的“vb43-u12045-serv-amd64”虚拟机系统。
To avoid our customers wasting time and energy when they encounter unnecessary problems in building development environment and compiling process,it is recommended to use “vb43-u12045-serv-amd64” virtual machine system released by MYZR。)
具体参见 MYZR虚拟机系统指导
details refered to MYZR virtual machine system guidance
安装并配置交叉编译工具链(install and configure cross compilation tool chain)
准备交叉编译工具链安装包(prepare installation package of cross compilation tool chain)
1)下载交叉编译工具
download cross compilation tool
交叉编译工具:gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.tar.xz
cross compilation tool:gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.tar.xz
交叉编译工具配置文件:gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.config
configured file of cross compilation tool:gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.config
2)在虚拟机系统创建工具目录
create tool directory in virtual machine system
$ mkdir ~/my-sama5/03_tools -p
3)复制文件到虚拟机系统
copy file to virtual machine sytem
把交叉编译工具和配置文件复制到 ~/my-sama5/03_tools
copy cross compilation tool and configured file to ~/my-sama5/03_tools
自己采取合适的方式完成。
this step should be done in your own way
安装交叉编译工具(install cross compilation tool)
1)进入交叉编译工具链目录
enter cross compilation tool chain diretory
$ cd ~/my-sama5/03_tools/
2)解压(安装)交叉编译工具
decompress(install) cross compilation tool
$ tar xf gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.tar.xz
3)检查安装
check installation
查看交叉编译工具链的版本信息以验证交叉编译工具链安装正常。
check the version information of cross compilation tool chain to verify the normality of the installation
$ source ~/my-sama5/03_tools/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.config
$ ${CROSS_COMPILE}gcc –v
执行命令后会出现类似如下的信息:
after execution of command,there will be following message:
以及在最后一行会出现 gcc 版本相关的信息
and there will come out with information related to gcc version in the last line
gcc version 4.9.3 20141031 (prerelease) (Linaro GCC 2014.11)
AT91Bootstrap编译(AT91Bootstrap compilation)
准备源码(prepare source code)
1)下载源码
download source code
文件名:at91bootstrap-3.7.2.tar.bz2
name of file:at91bootstrap-3.7.2.tar.bz2
AT91Bootstrap 是二级引导装载程序,为Atmel AT91 SoC提供了一套算法来管理硬件初始化。如时钟速度配置,PIO设置,内存初始化,从指定的引导介质下载主应用程序到主内存并启动。
AT91Bootstrap is a two stage boot loader,which provide a set of algorithm to manage hardware initialization,such as configuration of clock and speed,setting of PIO,initialization of memory.
download main application to main memory and boot from specified boot media
2)创建工作目录
create working directory
$ mkdir ~/my-sama5/02_source -p
3)将源码复制到工作目录
copy source code to working directory
这一步自己采取合适的方式将AT91Bootstrap源码复制到“~/my-sama5/02_source”。也可以参照“2.3 常用功能演示”。
copy in your own way AT91Bootstrap to “~/my-sama5/02_source”,or refer to “2.3 demo of common function”
4)解压源码
decompress source code
- 进入工作目录
enter working directory
$ cd ~/my-sama5/02_source/
- 执行解压命令
execute decompress command
$ tar jxf at91bootstrap-3.7.2.tar.bz2
编译(compile)
1)进入源码目录
enter source code directory
$ cd ~/my-sama5/02_source/at91bootstrap-3.7.2/
2)使编译配置文件生效
validate configured file of compilation
$ source ~/my-sama5/03_tools/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.config
3)清除代码中可能存在的临时文件
remove temporary file which may exist in the code
$ make mrproper
4)生成配置文件
generate configuration file
$ make mysama5ek200_defconfig
5)执行编译
execute compilation
$ make –j4
6)编译完成
complete compilation
目标文件(target file)
1)目标文件
target file
编译完成后会在源码的binaries目录下产生我们需要的目标文件。
target file needed by us will be generated under directory of binaries of source code after compilation is completed
通过ls命令可以看到,其中mysama5ek200-dataflashboot-uboot-3.7.2.bin 即是我们需要的文件。
you can see through ls command that mysama5ek200-dataflashboot-uboot-3.7.2.bin is the file what we need.
$ ls binaries/
2)重命令目标文件
re-name target file
我们在烧录的时候需要使用到这些目标文件。为了烧录的方便,我们需要将目标文件修改为我们需要的文件名,即bootstrap-mysama5ek200.*。
these target files will be used by us in programming,to make programming convenient,we need to change the name of these files to be as bootstrap-mysama5ek200.*
$ cd binaries/
$ rename 's/mysama5ek200-dataflashboot-uboot-3.7.2/bootstrap-mysama5ek200/' *
$ ls -1
3)保存目标文件
save target file
将bootstrap-mysama5ek200.* 保存。
save bootstrap-mysama5ek200.*
u-boot编译(u-boot compilation)
准备源码(prepare source code)
1)下载源码
download source code
文件名:u-boot-at91-linux4sam_4.7.tar.bz2
name of file: u-boot-at91-linux4sam_4.7.tar.bz2
U-Boot在Atmel AT91 SoC上作为第三阶段引导加载程序。它负责配置主要接口,并引导Linux系统。
U-boot is the third stage bootloader on Atmel AT91 SoC, it is engaged in configuring main interfaces and booting Linux system
2)将源码复制到工作目录
copy source code to working directory
这一步自己采取合适的方式将u-boot源码复制到“~/my-sama5/02_source”。也可以参照“2.3 常用功能演示”。
copy in your own way source code of u-boot to “~/my-sama5/02_source”,or refer to “2.3 demo of common function”
3)解压源码
decompress source code
- 进入工作目录
enter working directory
$ cd ~/my-sama5/02_source/
- 执行解压命令
execute decompress command
$ tar jxf u-boot-at91-linux4sam_4.7.tar.bz2
编译 (compile)
1)进入u-boot源码目录
enter directory of u-boot source code
$ cd ~/my-sama5/02_source/u-boot-at91-linux4sam_4.7/
2)使编译配置文件生效
validate configured file of compilation
$ source ~/my-sama5/03_tools/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.config
3)清除代码中可能存在的临时文件
remove temporary file which may exist in code
$ make distclean
4)生成配置文件
generate configured file
$ make mysama5ek200_defconfig
5)执行编译
execute compilation
$ make –j4
6)编译完成
complete compilation
目标文件(target file)
编译完成后会在源码的目录下产生我们需要的目标文件。
target file needed by us will be generated under directory of source code after compilation is completed
通过ls命令可以看到。其中u-boot.bin 即是我们需要的文件。
you can see through ls command that u-boot.bin is the file what we need.
$ ls u-boot* -1
2)重命令目标文件
re-name target file
我们在烧录的时候需要使用到这些目标文件。为了烧录的方便,我们需要将目标文件修改为我们需要的文件名,即uboot-mysama5ek200.bin。
these target files will be used by us in programming,to make programming convenient,we need to change the name of these files to be as uboot-mysama5ek200.bin.
$ mv u-boot.bin uboot-mysama5ek200.bin
$ ls uboot-mysama5ek200.bin
3)保存目标文件
save target file
将uboot-mysama5ek200.bin 保存。
save uboot-mysama5ek200.bin
内核编译(compile kernel)
准备源码(prepare source code)
1)下载源码
download source code
文件名:linux-at91-linux4sam_4.7.tar.bz2
name of file:linux-at91-linux4sam_4.7.tar.bz2
2)将源码复制到工作目录
copy source code to the working directory
这一步自己采取合适的方式将内核源码复制到“~/my-sama5/02_source”。也可以参照“2.3 常用功能演示”。
copy in your own way source code of kernel to “~/my-sama5/02_source”,or refer to “2.3 demo of common function”
3)解压源码
decompress source code
- 进入工作目录
enter working directory
$ cd ~/my-sama5/02_source/
- 执行解压命令
execute decompress command
$ tar jxf linux-at91-linux4sam_4.7.tar.bz2
编译(compile)
1)进入内核源码目录
enter directory of kernel source code
$ cd ~/my-sama5/02_source/linux-at91-linux4sam_4.7/
2)使编译配置文件生效
validate configured file of compilation
$ source ~/my-sama5/03_tools/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.config
3)清除代码中可能存在的临时文件
remove temporary file which may exist in the code
$ make distclean
编译内核文件(compile kernel file)
1)生成内核配置文件
generate kernel configuration file
$ make ARCH=arm mysama5ek200_defconfig
2)执行内核文件编译命令
execute compilation command of kernel file
$ make -j4 ARCH=arm zImage
3)内核文件编译完成
complete compilation of kernel file
4)内核目标文件
kernel target file
$ ls arch/arm/boot/zImage
编译设备树文件(compile file of device tree)
1)执行设备树文件编译命令
execute compilation command for device tree file
$ make ARCH=arm mysama5ek200-d36.dtb
2)设备树目标文件
target file of device tree
$ ls arch/arm/boot/dts/mysama5ek200-d36.dtb
编译内核模块(compile kernel module)
1)执行内核模块编译命令
execute compilation command for kernel module
$ make ARCH=arm modules
2)内核模块编译完成
complete compilation of kernel module
3)安装内核模块到指定目录
install kernel module to specified directory
$ make ARCH=arm modules_install INSTALL_MOD_PATH=./modules
4)打包内核模块
package nernel module
$ tar cjf modules_mysama5ek200.tar.bz2 modules/*
5)模块包
module package
$ ls modules_mysama5ek200.tar.bz2
文件系统编译(compile file system)
注意及说明(note and instruction)
a) 原始编译的过程中的下载量大约4G。(提示:可以使用我们下载好的一些文件,以减少下载量,节约时间,在7.4中会说到)。
The download of the original compilation exceed 4G。(tips:you can use files we have downloaded in order to reduce downloads and save time,which is going to be mentioned in 7.4)
b) 编译主机的网络连接最好使用能访问www.fackbook.com 的网络,不然可能会受到境内防火墙的限制而无法下载编译需要的软件包。
The network of the compilation host is good to access to www.fackbook.com .Otherwise It may be subject to the condition of the domestic firewall and It is unable to download the software for compilation.。
c) 初次编译需要的时间根据网络状态及编译主机的配置需要2小时到无限时间(经粗略统计除去下载时间,在16核CPU、16G内存的主机上编译QT5系统用了大约100分钟。)
The initial compilation may take 2 hours to unlimited time.It depends on the network state and the configuration of the host.(After a rough statistics, It took about 100 minutes to compile QT5 system on the 16-core CPU 16 G memory host except download time。
客户请根据实际情况决定是否自行编译文件系统或使用我们提供的文件系统。
Customer may decide whether to compile the file system or use the file system We provide based on the actual situation. If the file system we provide meets the requirements, you had better not to compile by yourself. Since It may be a lot of errors during compilation.。
编译前的准备(preparation before compilation)
准备Yocto编译环境(prepare compliation environment for Yocto)
说明,Yocto编译依赖一些软件包,所以需要在开发主机上进行安装。
instruction: Yocto compilation depends on some software packages, so they need to be installed on development host.
$ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat
$ sudo apt-get install libsdl1.2-dev xterm sed cvs subversion coreutils texi2html docbook-utils python-pysqlite2 help2man make gcc g++ desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev mercurial autoconf automake groff curl lzop asciidoc
$ sudo apt-get install uboot-mkimage
准备源码(prepare source code)
1)下载源码
download source code
源码包文件名:atmel_fido.tar.bz2
2)创建yocto工作目录
create working directory of yocto
3)将源码复制到开发主机
copy source code to devleopment host
这一步自己采取合适的方式将源码复制到yocto工作目录(即:/home/myzr/yocto)。也可以参照“2.3 常用功能演示”。
copy in your own way source code to yocto directory(e.g /home/myzr/yocto),or refer to “2.3 demo fo common functions"
4)解压源码包
decompress source code package
- 进入用户主目录
enter main directory of user
$ cd ~/yocto
- 执行解压命令
execute decompress command
$ tar jxf atmel_fido.tar.bz2
准备软件包(prepare software package)
1)创建“/opt/yocto”目录用于存放软件包
create directory of “/opt/yocto”for saving software package
$ sudo mkdir /opt/yocto
$ sudo chmod 777 /opt/yocto
2)下载软件包
download software package
在网盘中下载yocto的软件包。
download yocto software package from network disk
软件包相对路径:yocto/downloads,将downloads下载到Windows。
relative path of software package:yocto/downloads,download downloads to Windows。
3)将软件包复制到开发主机
copy software package to devleopment host
将下载好的“downloads”目录复制到开发主机的“/opt/yocto”。
copy directory of “downloads”downloaded to “/opt/yocto”of development host
编译文件系统 (compile file system)
编译前的配置(configuration before compilation)
1)准备编译配置文件
prepare configuration file of compilation
文件目录:conf。下载conf目录到Windows。
file directory:conf。download directory of conf to Windows
2)进入poky目录
enter directory of poky
$ cd ~/yocto/atmel_fido/poky/
$ source oe-init-build-env build-atmel
3)初始化编译目录
initiate directory of compilatio
$ source oe-init-build-env build-atmel
4)复制编译配置文件到编译目录
copy confirured file of compilation to drectory of compilation
将 conf 目录复制到 /home/myzr/yocto/poky/build-atmel 。
copy conf directory to /home/myzr/yocto/poky/build-atmel
编译QT5文件系统(compile file system of QT5)
$ bitbake atmel-qt5-demo-image
提示:整个编译过程除去下载时间,在16核CPU、16G内存的主机上需要1小时左右。
Tips: the whole compilation process will take about one hour to compile on the 16-core CPU and 16G memory host except download time.
- 目标文件
target file
在./tmp/deploy/images/sama5d3xek/目录下可以找到我们编译生成的目标文件。
you can find the target file we compiled in the directory of ./tmp/deploy/images/sama5d3xek/
编译QT5交叉编译工具(compile the cross-compiler tool for QT5)
- 目标文件
target file
在./tmp/deploy/images/sama5d3xek/目录下可以找到我们编译生成的目标文件。
you can find the target file we compiled in the directory of ./tmp/deploy/images/sama5d3xek
</div>