系统环境说明(system environment instruction)CUP architeture of host used for compilation:64bit
system of compiler host:Linux
Linux release version:
Ubuntu version type:saver version
Ubuntu version no.:12.04.5
Ubuntu system type:x86-64
注意:开发主机请使用ubuntu 12.04.5 x86-64(桌面版或服务器版均可),使用其他发行版的Linux或Ubuntu的其它版本可能会遇到的不必要的问题。
Note: 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)在文档的图片中观察“linyn@u12045-serv:~$”开头的行可以直观的看到输入的
linux命令。
In the image of the document, you can see the input Linux command visually from the lines that start with “myzr$” linux command
准备源码及相关文件(prepare source code and relevant files)
源码文件(source code)评估板对应的Linux版本及对应的源码文件见下表:
The corresponding Linux version of the evaluation board and the corresponding source code files are shown in the table below:
评估板型号
(evaluation board model) | 支持的系统版本
(system version supported) | u-boot源码文件
(u-boot source code) | linux源码文件
(linux source code) |
MY-IMX28-EVK | Linux-3.14.54 | u-boot-2015.04.tar.bz2 | linux-3.14.54.tar.bz2 |
交叉编译工具文件(cross compiler tool file)Linux程序交叉编译工具:gcc-4.4.4-glibc-2.11.1-multilib-1.0.tar.bz2
Linux program cross compiler tool:gcc-4.4.4-glibc-2.11.1-multilib-1.0.tar.bz2
Linux交叉编译工具配置文件:gcc-4.4.4-glibc-2.11.1-multilib-env
Linux cross compiler tool configuration file:gcc-4.4.4-glibc-2.11.1-multilib-env
创建工作目录(creat working directory)1)源码目录
source code directory
$ mkdir -p ~/my-imx28/02_source
2)工具目录
tool directory
$ mkdir -p ~/my-imx28/03_tools
3)镜像目录
image dirrectory
$ mkdir -p ~/my-imx28/04_image
4)应用程序目录
application directory
$ mkdir -p ~/my-imx28/01_application
准备开发环境(prepare development environment)
更新主机的源列表(update source list of host)$ sudo apt-get update
更新完成后如下图所示:
it looks like below after the update
安装aptitude包管理工具和ia32-libs(install management tool of aptitude package and ia32-libs)提示:如果编译主机的Linux是32位的,可以跳过此步骤。
tips: if Linux of compilation host is 32bit,then you can skip this step
安装aptitude包管理工具(install management tool of aptitude package)$ sudo apt-get -y install aptitude
提示:上图为安装过aptitude后,再次执行安装命令的截图。
tips: the above image is the screenshots after re-execution of installation command when intallation of aptitude was completed.
使用aptitude安装ia32-libs( install ia32-libs with aptitude)$ sudo aptitude -y install ia32-libs
提示:上图为安装过aptitude和ia32-libs后,再次执行安装命令的截图。
tips: the above image is the screenshots after re-execution of installation command when intallation of aptitude and ia32-libs was completed
安装mkimage工具(install mkimage tool)$ sudo apt-get -y install uboot-mkimage
提示:下图为安装过mkimage工具后,再次执行安装命令的截图。
tips: the following image is the screenshots after re-execution of installation command when intallation of mkimage was completed
安装ncurses-dev(install ncurses-dev)make menuconfig对其具有依赖性质
make menuconfig is dependant to it
$ sudo aptitude -y install ncurses-dev
提示:上图为安装过ncurses-dev工具后,再次执行安装命令的截图。
tips: the above image is the screenshots after re-execution of installation command when intallation of aptitude and ia32-libs was completed
安装配置交叉编译工具链(install and configure cross compiler tool chain)
安装Linux交叉编译工具链(install Linux cross compilation tool chain)1)进入交叉编译工具链目录
enter cross compilation tool chain diretory
$ cd ~/my-imx28/03_tools/
2)复制Linux交叉编译工具到目录
copy Linux cross compilation tool to directory
将gcc-4.4.4-glibc-2.11.1-multilib-1.0.tar.bz2复制到“~/my-imx28/03_tools”,这一步自己采取相应的方式完成。
copy gcc-4.4.4-glibc-2.11.1-multilib-1.0.tar.bz2 to “~/my-imx28/03_tools”,this step need to be done in your own way。
3)解压Linux交叉编译工具
decompress Linux cross compilation tool
$ tar jxf gcc-4.4.4-glibc-2.11.1-multilib-1.0.tar.bz2
4)复制交叉编译工具配置文件
copy cross compilation tool configuration file
将gcc-4.4.4-glibc-2.11.1-multilib-env复制到“~/my-imx28/03_tools”,这一步自己采取相应的方式完成。
copy gcc-4.4.4-glibc-2.11.1-multilib-env to“~/my-imx28/03_tools”,this step need to be done in your own way
5)检查安装
check installation
$ source gcc-4.4.4-glibc-2.11.1-multilib-env
$ ${CROSS_COMPILE}gcc –v
U-Boot编译(U-Boot compilation)
准备编译(prepare compilation)复制源码包到开发主机中(copy source code package to development host)将下载的“u-boot源码”复制到Linux开发主机的“~/my-imx28/02_source”。
copy“u-boot source code”downloaded to “~/my-imx6/02_source”of Linux development host
这一步自己采取相应的方式完成。
this step need to be done in your own way
解压u-boot源码包(decompress u-boot source code package)$ cd ~/my-imx28/02_source/
$ tar jxf u-boot-2015.04.tar.bz2
更新库libssl-dev(update library libssl-dev)$ sudo apt-get install libssl-dev
编译(compile)使编译配置文件生效(validate compilation configuration file)$ source ~/my-imx28/03_tools/gcc-4.4.4-glibc-2.11.1-multilib-env
进入u-boot源码目录(validate compiler configuration file)$ cd ~/my-imx28/02_source/u-boot-2015.04
清除u-boot临时文件(remove u-boot temporary files)$ make distclean
配置u-boot(configure u-boot)评估板主型号
(evaluation board main model) | CPU类型-内存容量
(CPU type-memory capacity) | 对应的u-boot配置
(corresponaind configuration of u-boot) |
MY-IMX28-EVK | MX283/7, 128M | mx28_evk_config |
example for MY-IMX28-EVK configuration
$ make mx28_evk_config
执行编译(execute compilation)$ make u-boot.***
提示:这里为了提高编译速度,在make后面加了“-j4”。这里编译的Linux主机是双核4线程的,所以“-j”后面用了4,也就是采用4线程编译。“-j”后面的数字可以根据系统资源分配,但是不应该超过编译主机最大支持的线程数。
Tips:To speed up the compilation,add "-j4" after make.The Linux host used to compile is dual-core ,4 threads .So "-j" is followed by 4, which takes 4 threads to compile. The number behind "-j" is allocated based on system resources,but It should not exceed the maximum threads the host support
complete compilation
提示:u-boot编译过程大概需要一、两分钟时间。
Tips: u-boot compiling process may take one or two minutes
目标文件(target file)compile file
编译完成后通过ls命令即可看到编译得到的文件 u-boot.***
you can get the compiled file u-boot .*** with ls command after compilation
$ ls
target file
MY-IMX28系列评估板的u-boot配置对应的目标文件名见下表:
The corresponding target file name for u-boot configuration of MY-IMX28 series evaluation board is shown in the table below
u-boot配置
(u-boot configuration) | 目标文件
(target file) |
mx28_evk_config | imx28_ivt_uboot.*** |
编译内核(compile kernel)
准备编译(prepare compilation)复制源码包到开发主机中(copy source code package to development host)将下载的“linux源码”复制到Linux开发主机的“~/my-imx28/02_source”。
copy“linux source code”downloaded to “~/my-imx28/02_source”of Linux development host
这一步自己采取相应的方式完成。
this step should be done in your own way
解压linux源码包(decompress linux source code package)$ cd ~/my-imx28/02_source/
$ tar jxf linux-3.14.54.tar.bz2
内核编译配置(configuration of kernel compilation)使编译配置文件生效(validate configuration file of compilation)$ source ~/my-imx28/03_tools/gcc-4.4.4-glibc-2.11.1-multilib-env
清除内核临时文件(remove kernel temporary file)enter linux source code directory
$ cd ~/my-imx28/02_source/linux-3.14.54
remove temporary file
$ make distclean
内核配置(kernel configuration)$ cp .mx28_config .config
编译内核(compile kernel)execute compilation
$ make zImage -j4
complete compilation
target file
arch/arm/boot/uImage即为编译得到的内核文件,使用ls命令可查看文件信息。
arch/arm/boot/uImage is the kernel file compiled,you can check file information with ls command
$ ls arch/arm/boot/uImage -la
编译设备树 (compife device tree)评估板型号规格与设备树文件对应关系见下表:
The correspondence between the type of evaluation board and device tree is shown below:
功能
(function) | 源码位置
(source code position) | Linux 设备和文件夹
(Linux device and folder) |
评估板主型号
(development main model) | CPU类型-内存容量
(CPU type-memory capacity) | 对应的设备树文件
(corresponding device tree file) |
MY-IMX28-EVK | MX283/7, 128M | imx28-evk.dtb |
take MY-IMX28-EVK as an example
$ make imx28-evk.dtb
target file
使用ls命令可查看编译得到的目标设备树文件信息:
You can browse the target device tree file information from compilation with ls command:
$ ls arch/arm/boot/dts/*.dtb
编译模块 (compile module)command for compiling module
$ make modules
Install module to the specified directory
$ make modules_install INSTALL_MOD_PATH=./modules
package the module file
$ cd modules
$ tar cjf ../modules.tar.bz2 *
应用程序编译(application compilation)
Linux应用程序编译(Linux application compilation)编写应用程序(write an application)enter working directory
$ cd ~/my-imx28/01_application/
write souce code
$ vim hello.c
写入以下代码并保存
write following code and save
int main(int argc, char **argv)
{
printf("Hello, MYZR!n");
return;
}
view code
$ cat hello.c
编译应用程序(compife application)Configure environment variables
$ source ~/my-imx28/03_tools/gcc-4.4.4-glibc-2.11.1-multilib-env
compile
$ ${CROSS_COMPILE}gcc hello.c -o hello.out
注意:上面的命令有包含“$”号,即“${CROSS_COMPILE}gcc”,是引用我们source时产生的环境变量。
Note:The above command contains “$”,which is “${CROSS_COMPILE}gcc”. It is the environment variable generated when referring to our source.
target file
$ file hello.out
可以看到目标文件 hello.out 的属性。
you can see the property of target file hello.out
文件系统(file system)
文件系统rootfs.tar.bz2(file system rootfs.tar.bz2) 用以下的方式增加自己的应用:(把MY-IMX28_Born_ToolProfilesMX28 Linux UpdateOS Firmwarefilesimage-linux-31454/rootfs.tar.bz2复制到“~/my-imx28/04_image/”目录下)。
add your own application by the following means: (copy MY-IMX28_Born_ToolProfilesMX28 Linux UpdateOS Firmwarefilesimage-linux-31454/rootfs.tar.bz2 to directory of“~/my-imx28/04_image/”)
文件系统filesystem.ubifs(file system filesystem.ubifs) 复制mkfs.ubifs,ubinize到电脑的“/usr/bin”目录下(如果电脑有这两个应用就不需要复制了);复制build_rootfs和ubinize.cfg到“~/my-imx28/04_image/”目录。
copy mkfs.ubifs,ubinize to directory of“/usr/bin”of computer(if computer has both these two applications,the copy is not needed);copy build_rootfs和ubinize.cfg to directory of “~/my-imx28/04_image/”
烧写方式(programing mode)