MY-IMX6 Linux-4.1.15 Build Manual

来自明远智睿的wiki
跳转至: 导航搜索

Document instruction


System environment instruction

  • CUP architeture of host used for compilation:64bit
  • System of host:Linux
  • Linux release version:Ubuntu
  • Ubuntu version type:server version
  • Ubuntu version no.:12.04.5
  • Ubuntu system type:x86-64

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 .


0peration instruction

1)The line in the document which begins with “$”,which is followed by the Linux command.

2)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)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)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)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

To make the view look neat and tidy , the command prompt in the screenshot should use myzr$ uniformly.


Linux command in the image

In the image of the document, you can see the input Linux command visually from the lines that start with “myzr$”.


Important information instruction

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.


Details refered to 《MYZR virtual machine system instruction

Prepare source code and relevant file


Source code

The corresponding Linux version of the evaluation board and the corresponding source code files are shown in the table below:

Evaluation board model u-boot Source code linux Source code
MY-IMX6-EK200 u-boot-2016.03__svn121.tar.xz linux-4.1.15__svn189.tar.xz
MY-IMX6-EK314
MY-IMX6-EK336
MY-IMX6-EK140

Cross compiler tool file

Linux program cross compiler tool:gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar

Linux cross compiler tool configuration file:gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf-env


Creat working directory

1)Cource code directory
$ mkdir ~/my-imx6/02_source –p
Myimx6linux3.14 build 2.3.0.1.png

2)Tool directory
$ mkdir ~/my-imx6/03_tools –p
Myimx6linux3.14 build 2.3.0.2.png

3)Image directory
$ mkdir ~/my-imx6/04_image –p
Myimx6linux3.14 build 2.3.0.3.png
$ mkdir ~/my-imx6/04_image/image-linux-4115 –p
Myimx6linux3.14 build 2.3.0.4.png

4)Application directory
$ mkdir ~/my-demo
Myimx6linux3.14 build 2.3.0.5.png


Install cross compiler tool chain


Install Linux cross compiler tool chain

1)Enter cross compiler tool chain directory
$ cd ~/my-imx6/03_tools/

2)Copy Linux cross compiler tool to directory
copy gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar to“~/my-imx6/03_tools”,complete this step by yourself in a proper way.

3)Uncompress Linux Cross Compilation Tools

$ tar xf gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar
Myimx6linux3.14 build 4.1.0.1.png

4)Copy cross compiler tool configuration file
Copy gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf-env to“~/my-imx6/03_tools”,complete this step by yourself in a proper way.

5)Check installation
$ source gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf-env
$ ${CROSS_COMPILE}gcc –v
Myimx6linux3.14 build 4.1.0.2.png

U-Boot compilation


Prepare compilation

Copy source code package to development host

Copy“u-boot source code”downloaded to “~/my-imx6/02_source”of Linux development host.
Complete this step by yourself in a proper way.

Decompress u-boot source code package

$ cd ~/my-imx6/02_source/
$ tar xf u-boot-2016.03__svn121.tar.xz
Myimx6linux3.14 build 5.1.2.1.png

Compilation

Validate compiler configuration file

$ source ~/my-imx6/03_tools/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf-env
Myimx6linux3.14 build 5.2.1.1.png

Enter u-boot source code directory

$ cd ~/my-imx6/02_source/u-boot-2016.03
Myimx6linux3.14 build 5.2.2.1.png

Remove u-boot temporary files

$ make distclean
Myimx6linux3.14 build 5.2.3.1.png


Configure u-boot

  • Configuration of development and its corresponding compiler:
Development board main model CPU type-memory capacity Architeture of processor Corresponding u-boot configuration
MY-IMX6-EK200 i.MX 6QuadPlus - 1G Cortex-A9 myimx6ek200-6qp_defconfig
i.MX 6QuadPlus - 2G Cortex-A9 myimx6ek200-6qp-2g_defconfig
i.MX6 Quad - 1G Cortex-A9 myimx6ek200-6q_defconfig
i.MX6 Quad - 2G Cortex-A9 myimx6ek200-6q-2g_defconfig
i.MX6 DualLite - 1G Cortex-A9 myimx6ek200-6u_defconfig
i.MX 6Solo - 512M Cortex-A9 myimx6ek200-6s_defconfig
i.MX 6Solo - 1G Cortex-A9 myimx6ek200-6s-1g_defconfig
MY-IMX6-EK314 i.MX 6QuadPlus - 1G Cortex-A9 myimx6ek200-6qp_defconfig
i.MX 6QuadPlus - 2G Cortex-A9 myimx6ek200-6qp-2g_defconfig
i.MX6 Quad- 1G Cortex-A9 myimx6ek314-6q_defconfig
i.MX6 Quad- 2G Cortex-A9 myimx6ek314-6q-2g_defconfig
i.MX6 DualLite - 1G Cortex-A9 myimx6ek314-6u_defconfig
MY-IMX6-EK336 i.MX 6QuadPlus - 1G Cortex-A9 myimx6ek336-6qp_defconfig
i.MX 6QuadPlus - 2G Cortex-A9 myimx6ek336-6qp-2g_defconfig
i.MX6 Quad- 1G Cortex-A9 myimx6ek336-6q_defconfig
i.MX6 Quad- 2G Cortex-A9 myimx6ek336-6q-2g_defconfig
MY-IMX6-EK140 i.MX 6UltraLite-256M Cortex-A7 myimx6ek140-6g_defconfig
i.MX 6UltraLite-512M Cortex-A7 myimx6ek140-6g-512m_defconfig
i.MX 6UltraLite Full - 256M Cortex-A7 myimx6ek140p-6g_defconfig
i.MX 6UltraLite Full - 512M Cortex-A7 myimx6ek140p-6g-512m_defconfig
i.MX 6UlltraLite Full - 256M Cortex-A7 myimx6ek140p-6y_defconfig
i.MX 6UlltraLite Full - 512M Cortex-A7 myimx6ek140p-6y-512m_defconfig
  • MYIMX6EK200-6Q-1G configuration example:

$ make myimx6ek200-6q_defconfig
Myimx6linux3.14 build 5.2.4.1.png

Execute compilation

$ make
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.
Myimx6linux3.14 build 5.2.5.1.png

  • Complete compilation

Tips: u-boot compiling process may take one or two minutes.
Myimx6linux3.14 build 5.2.5.2.png


Target file

  • Compile file

You can get the compiled file u-boot .imx with ls command after compilation.
$ ls
Myimx6linux3.14 build 5.3.0.1.png

  • Target file

The corresponding target file name for u-boot configuration of MY-IMX6 series evaluation board is shown in the table below:

u-boot Configuration
Target file
myimx6ek200-6qp_defconfig uboot-myimx6ek200-6qp.imx
myimx6ek200-6qp-2g_defconfig uboot-myimx6ek200-6qp-2g.imx
myimx6ek200-6q_defconfig uboot-myimx6ek200-6q.imx
myimx6ek200-6q-2g_defconfig uboot-myimx6ek200-6q-2g.imx
myimx6ek200-6u_defconfig uboot-myimx6ek200-6u.imx
myimx6ek200-6s_defconfig uboot-myimx6ek200-6s.imx
myimx6ek200-6s-1g_defconfig uboot-myimx6ek200-6s-1g.imx
myimx6ek314-6qp_defconfig uboot-myimx6ek314-6qp.imx
myimx6ek314-6qp-2g_defconfig uboot-myimx6ek314-6qp-2g.imx
myimx6ek314-6q_defconfig uboot-myimx6ek314-6q.imx
myimx6ek314-6q-2g_defconfig uboot-myimx6ek314-6q-2g.imx
myimx6ek314-6u_defconfig uboot-myimx6ek314-6u.imx
myimx6ek336-6qp_defconfig uboot-myimx6ek336-6qp.imx
myimx6ek336-6qp-2g_defconfig uboot-myimx6ek336-6qp-2g.imx
myimx6ek336-6q_defconfig uboot-myimx6ek336-6q.imx
myimx6ek336-6q-2g_defconfig uboot-myimx6ek336-6q-2g.imx
myimx6ek140-6g_defconfig uboot-myimx6ek140-6g.imx
myimx6ek140-6g-512m_defconfig uboot-myimx6ek140-6g-512m.imx
myimx6ek140p-6g_defconfig uboot-myimx6ek140p-6g.imx
myimx6ek140p-6g-512m_defconfig uboot-myimx6ek140p-6g-512m.imx
myimx6ek140p-6y_defconfig uboot-myimx6ek140p-6y.imx
myimx6ek140p-6y-512m_defconfig uboot-myimx6ek140p-6y-512m.imx

We need to copy the compilied file u-boot.imx as our target file name.:
Copy the generated file u-boot.imx from the compilation of myimx6ek200-6q_defconfig as target file.):
$ cp u-boot.imx ~/my-imx6/04_image/image-linux-4115/uboot-myimx6ek200-6q.imx
Myimx6linux3.14 build 5.3.0.2.png

Compile kernel


Prepare compilation

Copy source code package to development host

Copy “linux source code”downloaded to “~/my-imx6/02_source”of Linux development host.
Complete this step by yourself in a proper way.

Decompress linux source code package

$ cd ~/my-imx6/02_source/
$ tar xf linux-4.1.15__svn189.tar.xz
Myimx6linux3.14 build 6.1.2.1.png

Kernel compilation configuration

Validate compilfer configuration file

$ source ~/my-imx6/03_tools/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf-env
Myimx6linux3.14 build 6.2.1.1.png

Remove kernel temporary file

  • Enter linux source code directory

$ cd ~/my-imx6/02_source/linux-4.1.15
Myimx6linux3.14 build 6.2.2.1.png

  • Remove temporary file

$ make distclean
Myimx6linux3.14 build 6.2.2.2.png

Kernel configuration

  • Kernel configuration file
Evaluation board model Configuration file
MY-IMX6-EK200 myimx6a9_defconfig
MY-IMX6-EK314
MY-IMX6-EK336
MY-IMX6-EK140 myimx6a7_defconfig

$ make myimx6a9_defconfig
If what compified is kernel of MY-IMX6-EK140,please use $ make myimx6a7_defconfig.
Take myimx6a9_defconfig as an example.
Myimx6linux3.14 build 6.2.3.1.png


Compile kernel

  • Execute compilation

$ make zImage
Myimx6linux3.14 build 6.3.0.1.png

  • Complete compilation

Myimx6linux3.14 build 6.3.0.2.png

  • Target file

arch/arm/boot/zImage is the kernel file Compiled,you can check file information with ls command.
$ ls arch/arm/boot/zImage -la
Myimx6linux3.14 build 6.3.0.3.png

Note: The kernel file name which is going to be programed and started is “zImage-myimx6” or “zImage-myimx6a7”, So we should copy zImage as zImage-myimx6a9 or zImage-myimx6a7
$ cp arch/arm/boot/zImage ~/my-imx6/04_image/image-linux-4115/zImage-myimx6a9 (A9)
or
$ cp arch/arm/boot/zImage ~/my-imx6/04_image/image-linux-4115/zImage-myimx6a7 (A7)
Myimx6linux3.14 build 6.3.0.4.png


Compile device tree

The correspondence between the type of evaluation board and device tree is shown below:

Development main model CPU type-memory capacity Corresponding device tree file
MY-IMX6-EK200 i.MX 6QuadPlus - 1G myimx6ek200-6qp.dtb
i.MX 6QuadPlus - 2G myimx6ek200-6qp-2g.dtb
i.MX6 Quad - 1G myimx6ek200-6q.dtb
i.MX6 Quad - 2G myimx6ek200-6q-2g.dtb
i.MX6 DualLite - 1G myimx6ek200-6u.dtb
i.MX 6Solo - 512M myimx6ek200-6s.dtb
i.MX 6Solo - 1G myimx6ek200-6s-1g.dtb
MY-IMX6-EK314 i.MX 6QuadPlus - 1G myimx6ek314-6qp.dtb
i.MX 6QuadPlus - 2G myimx6ek314-6qp-2g.dtb
i.MX6 Quad - 1G myimx6ek314-6q.dtb
i.MX6 Quad - 2G myimx6ek314-6q-2g.dtb
i.MX6 DualLite - 1G myimx6ek314-6u.dtb
MY-IMX6-EK336 i.MX 6QuadPlus - 1G myimx6ek336-6qp.dtb
i.MX 6QuadPlus - 2G myimx6ek336-6qp-2g.dtb
i.MX6 Quad - 1G myimx6ek336-6q.dtb
i.MX6 Quad - 2G myimx6ek336-6q-2g.dtb
MY-IMX6-EK140 i.MX 6UltraLite-256M myimx6ek140-6g.dtb
i.MX 6UltraLite-512M myimx6ek140-6g-512m.dtb
i.MX 6UltraLite Full - 256M (2eth) myimx6ek140p-6g.dtb
i.MX 6UltraLite Full - 256M (8uart) myimx6ek140p-6g-8uart.dtb
i.MX 6UltraLite Full - 512M (2eth) myimx6ek140p-6g-512m.dtb
i.MX 6UltraLite Full - 512M (8uart) myimx6ek140p-6g-512m-8uart.dtb
i.MX 6UlltraLite Full - 256M (2eth) myimx6ek140p-6y.dtb
i.MX 6UlltraLite Full - 256M (8uart)) myimx6ek140p-6y-8uart.dtb
i.MX 6UlltraLite Full - 512M (2eth) myimx6ek140p-6y-512m.dtb
i.MX 6UlltraLite Full - 512M (8uart) myimx6ek140p-6y-512m-8uart.dtb
  • Take MY-IMX6-EK200-6Q-1G as example

$ make myimx6ek200-6q.dtb
Myimx6linux3.14 build 6.4.0.1.png

  • Target file

You can browse the target device tree file information from compilation with ls command:
$ ls arch/arm/boot/dts/myimx6ek*.dtb
Myimx6linux3.14 build 6.4.0.2.png

  • Copy device tree file to image directory

$ cp arch/arm/boot/dts/myimx6ek*.dtb ~/my-imx6/04_image/image-linux-4115/
Myimx6linux3.14 build 6.4.0.3.png

Compile module

  • Compile module command

$ make modules
Myimx6linux3.14 build 6.5.0.1.png

  • Install module to the specified directory

$ make modules_install INSTALL_MOD_PATH=./modules
Myimx6linux3.14 build 6.5.0.2.png

  • Package the module file

$ cd modules
$ tar cjf ../modules.tar.bz2 *
Myimx6linux3.14 build 6.5.0.3.png

  • Copy module package to image directory
Development board model Target module package
MY-IMX6-EK200 kernel-modules-myimx6a9.tar.bz2
MY-IMX6-EK314
MY-IMX6-EK336
MY-IMX6-EK140 kernel-modules-myimx6a7.tar.bz2

$ cp ../modules.tar.bz2 ~/my-imx6/04_image/image-linux-4115/kernel-modules-myimx6a9.tar.bz2
Note:when you compile the Kernel If the configuration file you use is myimx6a9_defconfig, here you should

Copy modules.tar.bz2 as kernel-modules-myimx6a9.tar.bz2.If the configuration file is myimx6a7_defconfig,you should Copy modules.tar.bz2 as kernel-modules-myimx6a7.tar.bz2.


Application compilation


Linux application compilation

Write an application

  • Create application source code directory and Linux-4.1.15 executable program directory

$ mkdir ~/my-demo/source_code -p
Myimx6linux3.14 build 8.1.1.1.png


$ mkdir ~/my-demo/bin-l4115 -p
Myimx6linux3.14 build 8.1.1.2.png

  • Write source code

$ cd ~/my-demo/source_code
$ vi hello.c

Write following code and save
#include <stdio.h>

int main(int argc, char **argv)
{
  printf("Hello, MYZR!\n");

  return;
}

  • View code

Myimx6linux3.14 build 8.1.1.3.png

$ cat hello.c

Compile application

  • Configure environment variables

$ source ~/my-imx6/03_tools/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf-env
Myimx6linux3.14 build 8.1.2.1.png

  • Compile

$ ${CROSS_COMPILE}gcc hello.c -o hello.out
Myimx6linux3.14 build 8.1.2.2.png
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
Myimx6linux3.14 build 8.1.2.3.png
You can see the property of target file hello.out.

Save target executable file

$ mv hello.out ~/my-demo/bin-l31452/
Myimx6linux3.14 build 8.1.3.1.png

Package application

Instruction

Programming tool supports to program “my-demo.tar.xz” file package to evaluation board.So We package applications We need as “my-demo.tar.xz”.while where “my-demo.tar.xz” will be programmed ,refer to 《MY-IMX6 MfgTool User Guide》.

Package application

1)Package
Here We package the whole my-demo directory.
$ cd ~
$ tar cjf my-demo.tar.bz2 my-demo
Myimx6linux3.14 build 8.3.2.1.png

2)Copy application package as target programming file.
$ cp my-demo.tar.bz2 ~/my-imx6/04_image/image-linux-31452/
Myimx6linux3.14 build 8.3.2.2.png


Target programming file


So far,we get a set of programming file except file system from“~/my-imx6/04_image/image-linux-31452/”。including“uboot*.imx”、“myimx6*.dtb”、“zImage-myimx6”、“kernel-modules.tar.bz2”、“my-demo.tar.bz2”.
Now we can program the image we compiled by ourselves referring to 《MY-IMX6 MfgTool User Guide》.