“MY-IMX6 L3035编译手册”的版本间的差异
(→安装需要的包 (install package needed)) |
|||
(未显示同一用户的4个中间版本) | |||
第1行: | 第1行: | ||
− | = '''准备源码包 | + | <div> |
+ | |||
+ | = '''准备源码包'''= | ||
---- | ---- | ||
− | == '''3.0.35版本代码 | + | == '''3.0.35版本代码'''== |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | === | + | === u-boot源码 === |
− | + | 文件名:u-boot-2009.08--svn*.tar.xz<br> | |
− | |||
+ | === kernel源码 === | ||
+ | 文件名:linux-3.0.35--svn*.tar.xz<br> | ||
− | === 交叉编译工具 | + | === 交叉编译工具=== |
文件名:gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12.tar.bz2<br> | 文件名:gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12.tar.bz2<br> | ||
− | |||
− | |||
− | = '''配置编译环境 | + | = '''配置编译环境'''= |
---- | ---- | ||
− | == '''准备源码 | + | == '''准备源码'''== |
− | |||
− | === 准备源码包 | + | === 准备源码包=== |
1)创建工作目录<br> | 1)创建工作目录<br> | ||
− | |||
创建 ~/my-imx6 作为工作目录<br> | 创建 ~/my-imx6 作为工作目录<br> | ||
− | |||
$ mkdir ~/my-imx6<br> | $ mkdir ~/my-imx6<br> | ||
第34行: | 第26行: | ||
创建 ~/my-imx6/02_source/imx_3.0.35_4.1.0 作为源码目录<br> | 创建 ~/my-imx6/02_source/imx_3.0.35_4.1.0 作为源码目录<br> | ||
− | + | ||
$ mkdir ~/my-imx6/02_source/imx_3.0.35_4.1.0 -p<br> | $ mkdir ~/my-imx6/02_source/imx_3.0.35_4.1.0 -p<br> | ||
第40行: | 第32行: | ||
创建 ~/my-imx6/03_tools 作为工具目录<br> | 创建 ~/my-imx6/03_tools 作为工具目录<br> | ||
− | |||
$ mkdir ~/my-imx6/03_tools -p<br> | $ mkdir ~/my-imx6/03_tools -p<br> | ||
第46行: | 第37行: | ||
2)复制源码包到开发主机中<br> | 2)复制源码包到开发主机中<br> | ||
− | |||
这一步骤自己采取相应的方式进行。<br> | 这一步骤自己采取相应的方式进行。<br> | ||
− | + | ''提示:这里将网盘中“02_源码”复制到Linux开发主机的“~/my-imx6/02_source/imx_3.0.35_4.1.0”,将网盘中“03_工具/toolchain”复制到Linux开发主机的“~/my-imx6/03_tools”。''<br> | |
− | |||
− | |||
− | === 解压源码包 | + | === 解压源码包 === |
1)解压u-boot源码和内核源码<br> | 1)解压u-boot源码和内核源码<br> | ||
− | |||
− | |||
$ cd ~/my-imx6/02_source/imx_3.0.35_4.1.0<br> | $ cd ~/my-imx6/02_source/imx_3.0.35_4.1.0<br> | ||
− | $ tar | + | $ tar xf u-boot-2009.08--svn*.tar.xz<br> |
− | $ tar | + | $ tar xf linux-3.0.35--svn*.tar.xz<br> |
[[文件: myimx6l3035_build_2.1.2.1.jpg]]<br> | [[文件: myimx6l3035_build_2.1.2.1.jpg]]<br> | ||
2)解压交叉编译工具<br> | 2)解压交叉编译工具<br> | ||
− | |||
− | |||
$ cd ~/my-imx6/03_tools/<br> | $ cd ~/my-imx6/03_tools/<br> | ||
$ tar jxf gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12.tar.bz2<br> | $ tar jxf gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12.tar.bz2<br> | ||
第70行: | 第54行: | ||
− | == '''开发环境配置 | + | == '''开发环境配置'''== |
− | === 安装需要的包 | + | === 安装需要的包 === |
1)更新源列表<br> | 1)更新源列表<br> | ||
− | |||
− | |||
$ sudo apt-get update<br> | $ sudo apt-get update<br> | ||
[[文件: myimx6l3035_build_2.2.1.1.jpg]]<br> | [[文件: myimx6l3035_build_2.2.1.1.jpg]]<br> | ||
更新完成后如下图所示:<br> | 更新完成后如下图所示:<br> | ||
− | |||
− | |||
[[文件: myimx6l3035_build_2.2.1.2.jpg]]<br> | [[文件: myimx6l3035_build_2.2.1.2.jpg]]<br> | ||
2)安装aptitude包管理工具和ia32-libs<br> | 2)安装aptitude包管理工具和ia32-libs<br> | ||
− | |||
''提示:如果编译主机的Linux是32位的,可以跳过此步骤。''<br> | ''提示:如果编译主机的Linux是32位的,可以跳过此步骤。''<br> | ||
− | |||
* 安装aptitude包管理工具<br> | * 安装aptitude包管理工具<br> | ||
− | |||
[[文件: myimx6l3035_build_2.2.1.3.jpg]]<br> | [[文件: myimx6l3035_build_2.2.1.3.jpg]]<br> | ||
第94行: | 第71行: | ||
* 使用aptitude安装ia32-libs<br> | * 使用aptitude安装ia32-libs<br> | ||
− | |||
$ sudo aptitude –y install ia32-libs<br> | $ sudo aptitude –y install ia32-libs<br> | ||
''提示:下图为安装过aptitude和ia32-libs后,再次执行安装命令的截图。''<br> | ''提示:下图为安装过aptitude和ia32-libs后,再次执行安装命令的截图。''<br> | ||
− | |||
[[文件: myimx6l3035_build_2.2.1.4.jpg]]<br> | [[文件: myimx6l3035_build_2.2.1.4.jpg]]<br> | ||
3)安装mkimage工具<br> | 3)安装mkimage工具<br> | ||
− | |||
− | |||
$ sudo apt-get -y install uboot-mkimage<br> | $ sudo apt-get -y install uboot-mkimage<br> | ||
''提示:下图为安装过mkimage工具后,再次执行安装命令的截图。''<br> | ''提示:下图为安装过mkimage工具后,再次执行安装命令的截图。''<br> | ||
− | |||
[[文件: myimx6l3035_build_2.2.1.5.jpg]]<br> | [[文件: myimx6l3035_build_2.2.1.5.jpg]]<br> | ||
4)安装ncurses-dev<br> | 4)安装ncurses-dev<br> | ||
− | |||
<span style="color: red">说明:make menuconfig对其具有依赖性质。</span><br> | <span style="color: red">说明:make menuconfig对其具有依赖性质。</span><br> | ||
− | |||
$ sudo aptitude -y install ncurses-dev<br> | $ sudo aptitude -y install ncurses-dev<br> | ||
''提示:下图为安装过ncurses-dev工具后,再次执行安装命令的截图。''<br> | ''提示:下图为安装过ncurses-dev工具后,再次执行安装命令的截图。''<br> | ||
− | |||
[[文件: myimx6l3035_build_2.2.1.6.jpg]]<br> | [[文件: myimx6l3035_build_2.2.1.6.jpg]]<br> | ||
− | === 配置MY-IMX6编译的环境变量 | + | === 配置MY-IMX6编译的环境变量=== |
1)将平台信息写入到一个新的配置文件<br> | 1)将平台信息写入到一个新的配置文件<br> | ||
− | |||
− | |||
$ echo "export ARCH=arm" > ~/my-imx6/03_tools/myimx6_3035_build_env<br> | $ echo "export ARCH=arm" > ~/my-imx6/03_tools/myimx6_3035_build_env<br> | ||
2)将交叉编译工具链路径写入到配置文件<br> | 2)将交叉编译工具链路径写入到配置文件<br> | ||
− | |||
− | |||
* 进入交叉编译工具目录<br> | * 进入交叉编译工具目录<br> | ||
− | |||
$ cd ~/my-imx6/03_tools/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/<br> | $ cd ~/my-imx6/03_tools/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/<br> | ||
* 将路径写入到配置文件<br> | * 将路径写入到配置文件<br> | ||
− | |||
− | |||
$ sed -i "\$a IMX6_GCC462_PATH=$PWD" ~/my-imx6/03_tools/myimx6_3035_build_env<br> | $ sed -i "\$a IMX6_GCC462_PATH=$PWD" ~/my-imx6/03_tools/myimx6_3035_build_env<br> | ||
* 将交叉编译工具写入到配置文件<br> | * 将交叉编译工具写入到配置文件<br> | ||
− | |||
− | |||
$ sed -i "\$a export CROSS_COMPILE=\$IMX6_GCC462_PATH/arm-none-linux-gnueabi-" ~/my-imx6/03_tools/myimx6_3035_build_env<br> | $ sed -i "\$a export CROSS_COMPILE=\$IMX6_GCC462_PATH/arm-none-linux-gnueabi-" ~/my-imx6/03_tools/myimx6_3035_build_env<br> | ||
3)查看配置文件<br> | 3)查看配置文件<br> | ||
− | |||
− | |||
$ cat ~/my-imx6/03_tools/myimx6_3035_build_env<br> | $ cat ~/my-imx6/03_tools/myimx6_3035_build_env<br> | ||
4)附图<br> | 4)附图<br> | ||
− | |||
[[文件: myimx6l3035_build_2.2.2.1.jpg]]<br> | [[文件: myimx6l3035_build_2.2.2.1.jpg]]<br> | ||
注意:如果在某一步操作错误,则需要删除 ~/my-imx6/03_tools/myimx6_3035_build_env 文件,并重新按照本小节操作。<br> | 注意:如果在某一步操作错误,则需要删除 ~/my-imx6/03_tools/myimx6_3035_build_env 文件,并重新按照本小节操作。<br> | ||
− | |||
− | = '''编译u-boot | + | = '''编译u-boot'''= |
---- | ---- | ||
− | == '''进入u-boot源码目录 | + | == '''进入u-boot源码目录'''== |
− | $ cd ~/my-imx6/02_source/imx_3.0.35_4.1.0/ | + | $ cd ~/my-imx6/02_source/imx_3.0.35_4.1.0/u-boot-2009.08/<br> |
[[文件: myimx6l3035_build_3.1.0.1.jpg]]<br> | [[文件: myimx6l3035_build_3.1.0.1.jpg]]<br> | ||
− | + | == '''使配置文件生效'''== | |
− | == '''使配置文件生效 | ||
* 执行source命令<br> | * 执行source命令<br> | ||
− | |||
$ source ~/my-imx6/03_tools/myimx6_3035_build_env<br> | $ source ~/my-imx6/03_tools/myimx6_3035_build_env<br> | ||
第170行: | 第124行: | ||
* 查看编译配置<br> | * 查看编译配置<br> | ||
− | |||
$ echo $ARCH<br> | $ echo $ARCH<br> | ||
第176行: | 第129行: | ||
''提示:可看到ARCH和CROSS_COMPILE被设置''<br> | ''提示:可看到ARCH和CROSS_COMPILE被设置''<br> | ||
− | |||
[[文件: myimx6l3035_build_3.2.0.2.jpg]]<br> | [[文件: myimx6l3035_build_3.2.0.2.jpg]]<br> | ||
* 验证交叉编译工具配置<br> | * 验证交叉编译工具配置<br> | ||
− | |||
$${CROSS_COMPILE}gcc –v<br> | $${CROSS_COMPILE}gcc –v<br> | ||
''提示:执行命令后可以看到终端显示出交叉编译工具的版本信息。如下图:''<br> | ''提示:执行命令后可以看到终端显示出交叉编译工具的版本信息。如下图:''<br> | ||
− | |||
[[文件: myimx6l3035_build_3.2.0.3.jpg]]<br> | [[文件: myimx6l3035_build_3.2.0.3.jpg]]<br> | ||
− | == '''清除u-boot配置 | + | == '''清除u-boot配置'''== |
$ make distclean<br> | $ make distclean<br> | ||
[[文件: myimx6l3035_build_3.3.0.1.jpg]]<br> | [[文件: myimx6l3035_build_3.3.0.1.jpg]]<br> | ||
− | == '''u-boot配置 | + | == '''u-boot配置'''== |
* 评估板及对应的 u-boot 编译配置:<br> | * 评估板及对应的 u-boot 编译配置:<br> | ||
− | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
− | !评估板主型号 | + | !评估板主型号 |
− | !CPU类型-内存容量 | + | !CPU类型-内存容量 |
− | !对应的u-boot配置 | + | !对应的u-boot配置 |
|- | |- | ||
|rowspan=4|MY-IMX6-EK200 | |rowspan=4|MY-IMX6-EK200 | ||
− | |6Q(四核)- 1G | + | |6Q(四核)- 1G |
− | | | + | |myimx6ek200-6q_config |
|- | |- | ||
− | |6Q(四核)- 2G | + | |6Q(四核)- 2G |
− | | | + | |myimx6ek200-6q_2g_config |
|- | |- | ||
− | |6U(双核简化)- 1G | + | |6U(双核简化)- 1G |
− | | | + | |myimx6ek200-6u_config |
|- | |- | ||
− | |6S(单核)- 512M | + | |6S(单核)- 512M |
− | | | + | |myimx6ek200-6s_config |
|- | |- | ||
|rowspan=4|MY-IMX6-EK314 | |rowspan=4|MY-IMX6-EK314 | ||
− | |6Q(四核)- 1G | + | |6Q(四核)- 1G |
− | | | + | |myimx6ek314-6q_config |
|- | |- | ||
− | |6Q(四核)- 2G | + | |6Q(四核)- 2G |
− | | | + | |myimx6ek314-6q_2g_config |
|- | |- | ||
− | |6U(双核简化)- 1G | + | |6U(双核简化)- 1G |
− | | | + | |myimx6ek314-6u_config |
|- | |- | ||
− | |6S(单核)- 512M | + | |6S(单核)- 512M |
− | | | + | |myimx6ek314-6s_config |
|} | |} | ||
* MYIMX6EK200-6Qxx-1G配置示例:<br> | * MYIMX6EK200-6Qxx-1G配置示例:<br> | ||
− | + | $ make myimx6ek200-6q_config<br> | |
− | |||
− | $ make | ||
[[文件: myimx6l3035_build_3.3.0.2.jpg]]<br> | [[文件: myimx6l3035_build_3.3.0.2.jpg]]<br> | ||
− | == '''编译 | + | == '''编译'''== |
* 执行编译<br> | * 执行编译<br> | ||
− | |||
− | |||
$ make<br> | $ make<br> | ||
''提示:这里为了提高编译速度,在make后面加了“-j4”。这里编译的Linux主机是双核4线程的,所以“-j”后面用了4,也就是采用4线程编译。“-j”后面的数字可以根据系统资源分配,但是不应该超过编译主机最大支持的线程数。''<br> | ''提示:这里为了提高编译速度,在make后面加了“-j4”。这里编译的Linux主机是双核4线程的,所以“-j”后面用了4,也就是采用4线程编译。“-j”后面的数字可以根据系统资源分配,但是不应该超过编译主机最大支持的线程数。''<br> | ||
− | |||
[[文件: myimx6l3035_build_3.5.0.1.jpg]]<br> | [[文件: myimx6l3035_build_3.5.0.1.jpg]]<br> | ||
* 编译完成<br> | * 编译完成<br> | ||
− | |||
''提示:u-boot编译过程大概需要几分钟时间。''<br> | ''提示:u-boot编译过程大概需要几分钟时间。''<br> | ||
− | |||
[[文件: myimx6l3035_build_3.5.0.2.jpg]]<br> | [[文件: myimx6l3035_build_3.5.0.2.jpg]]<br> | ||
− | + | == '''目标文件'''== | |
− | == '''目标文件 | ||
编译完成后通过ls命令即可看到编译得到的目标文件u-boot.bin<br> | 编译完成后通过ls命令即可看到编译得到的目标文件u-boot.bin<br> | ||
− | |||
− | |||
$ ls<br> | $ ls<br> | ||
[[文件: myimx6l3035_build_3.6.0.1.jpg]]<br> | [[文件: myimx6l3035_build_3.6.0.1.jpg]]<br> | ||
− | = '''编译内核 | + | = '''编译内核'''= |
---- | ---- | ||
− | == '''进入内核源码目录 | + | == '''进入内核源码目录'''== |
− | $ cd ~/my-imx6/02_source/imx_3.0.35_4.1.0/linux- | + | $ cd ~/my-imx6/02_source/imx_3.0.35_4.1.0/linux-3.0.35/<br> |
[[文件: myimx6l3035_build_4.1.0.1.jpg]]<br> | [[文件: myimx6l3035_build_4.1.0.1.jpg]]<br> | ||
− | == '''使配置文件生效 | + | == '''使配置文件生效'''== |
* 执行source命令<br> | * 执行source命令<br> | ||
− | |||
− | |||
$ source ~/my-imx6/03_tools/myimx6_3035_build_env<br> | $ source ~/my-imx6/03_tools/myimx6_3035_build_env<br> | ||
[[文件: myimx6l3035_build_4.2.0.1.jpg]]<br> | [[文件: myimx6l3035_build_4.2.0.1.jpg]]<br> | ||
* 查看编译配置<br> | * 查看编译配置<br> | ||
− | |||
− | |||
$ echo $ARCH<br> | $ echo $ARCH<br> | ||
$ echo $CROSS_COMPILE<br> | $ echo $CROSS_COMPILE<br> | ||
''提示:可看到ARCH和CROSS_COMPILE被设置''<br> | ''提示:可看到ARCH和CROSS_COMPILE被设置''<br> | ||
− | |||
[[文件: myimx6l3035_build_4.2.0.2.jpg]]<br> | [[文件: myimx6l3035_build_4.2.0.2.jpg]]<br> | ||
* 验证交叉编译工具配置<br> | * 验证交叉编译工具配置<br> | ||
− | |||
− | |||
$ ${CROSS_COMPILE}gcc –v<br> | $ ${CROSS_COMPILE}gcc –v<br> | ||
''提示:执行命令后可以看到终端显示出交叉编译工具的版本信息。如下图:''<br> | ''提示:执行命令后可以看到终端显示出交叉编译工具的版本信息。如下图:''<br> | ||
− | |||
[[文件: myimx6l3035_build_4.2.0.3.jpg]]<br> | [[文件: myimx6l3035_build_4.2.0.3.jpg]]<br> | ||
− | == '''准备配置内核 | + | == '''准备配置内核'''== |
* 清除内核配置<br> | * 清除内核配置<br> | ||
− | |||
− | |||
$ make distclean<br> | $ make distclean<br> | ||
[[文件: myimx6l3035_build_4.3.0.1.jpg]]<br> | [[文件: myimx6l3035_build_4.3.0.1.jpg]]<br> | ||
* 生成.config文件<br> | * 生成.config文件<br> | ||
− | |||
− | |||
说明:MY-IMX6-EK200系列评估板及MY-IMX6-EK314系列评估板使用的配置文件是myimx6_defconfig<br> | 说明:MY-IMX6-EK200系列评估板及MY-IMX6-EK314系列评估板使用的配置文件是myimx6_defconfig<br> | ||
− | |||
$ make myimx6_defconfig<br> | $ make myimx6_defconfig<br> | ||
[[文件: myimx6l3035_build_4.3.0.2.jpg]]<br> | [[文件: myimx6l3035_build_4.3.0.2.jpg]]<br> | ||
− | == '''编译内核 | + | == '''编译内核'''== |
* 编译uImage<br> | * 编译uImage<br> | ||
− | |||
$ make uImage<br> | $ make uImage<br> | ||
说明:截图中使用了4线程编译。<br> | 说明:截图中使用了4线程编译。<br> | ||
− | |||
[[文件: myimx6l3035_build_4.4.0.1.jpg]]<br> | [[文件: myimx6l3035_build_4.4.0.1.jpg]]<br> | ||
* 编译完成<br> | * 编译完成<br> | ||
− | |||
[[文件: myimx6l3035_build_4.4.0.2.jpg]]<br> | [[文件: myimx6l3035_build_4.4.0.2.jpg]]<br> | ||
* 目标文件<br> | * 目标文件<br> | ||
− | |||
− | |||
arch/arm/boot/uImage即为编译得到的目标文件,使用ls命令可查看文件信息。<br> | arch/arm/boot/uImage即为编译得到的目标文件,使用ls命令可查看文件信息。<br> | ||
− | |||
− | |||
$ ls arch/arm/boot/uImage –la<br> | $ ls arch/arm/boot/uImage –la<br> | ||
[[文件: myimx6l3035_build_4.4.0.3.jpg]]<br> | [[文件: myimx6l3035_build_4.4.0.3.jpg]]<br> | ||
− | == '''编译模块 | + | == '''编译模块'''== |
* 编译<br> | * 编译<br> | ||
− | |||
− | |||
$ make<br> | $ make<br> | ||
说明:截图中使用了4线程编译。<br> | 说明:截图中使用了4线程编译。<br> | ||
− | |||
[[文件: myimx6l3035_build_4.5.0.1.jpg]]<br> | [[文件: myimx6l3035_build_4.5.0.1.jpg]]<br> | ||
* 编译完成<br> | * 编译完成<br> | ||
− | |||
[[文件: myimx6l3035_build_4.5.0.2.jpg]]<br> | [[文件: myimx6l3035_build_4.5.0.2.jpg]]<br> | ||
* 目标文件<br> | * 目标文件<br> | ||
− | |||
编译完成后各模块的.ko文件位于代码所在的目录,通过find命令可以找出编译完成的模块,参考命令如下:<br> | 编译完成后各模块的.ko文件位于代码所在的目录,通过find命令可以找出编译完成的模块,参考命令如下:<br> | ||
− | |||
$ find -name *.ko<br> | $ find -name *.ko<br> | ||
[[文件: myimx6l3035_build_4.5.0.3.jpg]]<br> | [[文件: myimx6l3035_build_4.5.0.3.jpg]]<br> | ||
− | = '''Linux应用程序编译 | + | = '''Linux应用程序编译'''= |
---- | ---- | ||
− | == '''编写应用程序 | + | == '''编写应用程序'''== |
1) 创建应用程序目录 <br> | 1) 创建应用程序目录 <br> | ||
− | |||
− | |||
$ mkdir ~/my-imx6/02_source/application/ -p <br> | $ mkdir ~/my-imx6/02_source/application/ -p <br> | ||
$ cd ~/my-imx6/02_source/application/ <br> | $ cd ~/my-imx6/02_source/application/ <br> | ||
第372行: | 第283行: | ||
2) 编写应用程序(这里以hello.c为例) <br> | 2) 编写应用程序(这里以hello.c为例) <br> | ||
− | |||
创建 hello.c 文件写入以下代码并保存:<br> | 创建 hello.c 文件写入以下代码并保存:<br> | ||
− | |||
#include <stdio.h> <br> | #include <stdio.h> <br> | ||
int main(int argc, char **argv) <br> | int main(int argc, char **argv) <br> | ||
第384行: | 第293行: | ||
3) 查看代码 <br> | 3) 查看代码 <br> | ||
− | |||
$ cat hello.c <br> | $ cat hello.c <br> | ||
[[文件: myimx6l3035_build_5.1.0.2.jpg]]<br> | [[文件: myimx6l3035_build_5.1.0.2.jpg]]<br> | ||
− | + | == '''使编译配置文件生效'''== | |
− | == '''使编译配置文件生效 | ||
* 执行source命令<br> | * 执行source命令<br> | ||
− | |||
$ source ~/my-imx6/03_tools/myimx6_3035_build_env<br> | $ source ~/my-imx6/03_tools/myimx6_3035_build_env<br> | ||
[[文件: myimx6l3035_build_5.2.0.1.jpg]]<br> | [[文件: myimx6l3035_build_5.2.0.1.jpg]]<br> | ||
* 查看编译配置<br> | * 查看编译配置<br> | ||
− | |||
$ echo $ARCH<br> | $ echo $ARCH<br> | ||
$ echo $CROSS_COMPILE<br> | $ echo $CROSS_COMPILE<br> | ||
''提示:可看到ARCH和CROSS_COMPILE被设置''<br> | ''提示:可看到ARCH和CROSS_COMPILE被设置''<br> | ||
− | |||
[[文件: myimx6l3035_build_5.2.0.2.jpg]]<br> | [[文件: myimx6l3035_build_5.2.0.2.jpg]]<br> | ||
* 验证交叉编译工具配置<br> | * 验证交叉编译工具配置<br> | ||
− | |||
$ ${CROSS_COMPILE}gcc –v<br> | $ ${CROSS_COMPILE}gcc –v<br> | ||
''提示:执行命令后可以看到终端显示出交叉编译工具的版本信息。如下图:''<br> | ''提示:执行命令后可以看到终端显示出交叉编译工具的版本信息。如下图:''<br> | ||
− | |||
[[文件: myimx6l3035_build_5.2.0.3.jpg]]<br> | [[文件: myimx6l3035_build_5.2.0.3.jpg]]<br> | ||
− | == '''编译应用程序 | + | == '''编译应用程序'''== |
2) 编译 <br> | 2) 编译 <br> | ||
− | |||
$ ${CROSS_COMPILE}gcc hello.c -o hello.out <br> | $ ${CROSS_COMPILE}gcc hello.c -o hello.out <br> | ||
注意:上面的命令有包含“$”号,即“${CROSS_COMPILE}gcc”,是引用我们source时产生的环境变量。 <br> | 注意:上面的命令有包含“$”号,即“${CROSS_COMPILE}gcc”,是引用我们source时产生的环境变量。 <br> | ||
− | |||
[[文件: myimx6l3035_build_5.3.0.1.jpg]]<br> | [[文件: myimx6l3035_build_5.3.0.1.jpg]]<br> | ||
3) 查看目标文件类型<br> | 3) 查看目标文件类型<br> | ||
− | |||
$ file hello.out <br> | $ file hello.out <br> | ||
可以看到目标文件 hello.out 的属性。 <br> | 可以看到目标文件 hello.out 的属性。 <br> | ||
− | |||
[[文件: myimx6l3035_build_5.3.0.2.jpg]]<br> | [[文件: myimx6l3035_build_5.3.0.2.jpg]]<br> | ||
第432行: | 第330行: | ||
= '''文件系统(file system)'''= | = '''文件系统(file system)'''= | ||
---- | ---- | ||
− | == '''文件系统说明 | + | == '''文件系统说明'''== |
文件系统包位于网盘对应的镜像文件夹中。支持的文件系统类型及下载方式可参照《MY-IMX6 烧录指导》。<br> | 文件系统包位于网盘对应的镜像文件夹中。支持的文件系统类型及下载方式可参照《MY-IMX6 烧录指导》。<br> | ||
− | |||
− | == '''解压文件系统到编译主机 | + | == '''解压文件系统到编译主机'''== |
1)创建文件系统的目录并进入<br> | 1)创建文件系统的目录并进入<br> | ||
− | |||
$ mkdir ~/my-imx6/04_rootfs/ -p<br> | $ mkdir ~/my-imx6/04_rootfs/ -p<br> | ||
第446行: | 第342行: | ||
2)将文件系统复制到~/my-imx6/04_rootfs/目录<br> | 2)将文件系统复制到~/my-imx6/04_rootfs/目录<br> | ||
− | |||
这一步骤自己采取相应的方式进行<br> | 这一步骤自己采取相应的方式进行<br> | ||
− | |||
3)解压文件系统到指定目录<br> | 3)解压文件系统到指定目录<br> | ||
− | |||
$ mkdir rootfs<br> | $ mkdir rootfs<br> | ||
$ sudo tar jxf rootfs-linux.tar.bz2 -C rootfs<br> | $ sudo tar jxf rootfs-linux.tar.bz2 -C rootfs<br> | ||
第457行: | 第350行: | ||
− | == '''添加应用到文件系统 | + | == '''添加应用到文件系统'''== |
$ cp ~/my-imx6/02_source/application/hello.out rootfs/app_test/<br> | $ cp ~/my-imx6/02_source/application/hello.out rootfs/app_test/<br> | ||
[[文件: myimx6l3035_build_6.3.0.1.jpg]]<br> | [[文件: myimx6l3035_build_6.3.0.1.jpg]]<br> | ||
5)重新打包文件系统<br> | 5)重新打包文件系统<br> | ||
− | |||
$ rm -rf rootfs-linux.tar.bz2<br> | $ rm -rf rootfs-linux.tar.bz2<br> | ||
$ cd rootfs/<br> | $ cd rootfs/<br> | ||
第469行: | 第361行: | ||
− | == '''添加模块到文件系统 | + | == '''添加模块到文件系统'''== |
准备需要模块的.ko文件,其它请参照“添加应用到文件系统”。<br> | 准备需要模块的.ko文件,其它请参照“添加应用到文件系统”。<br> | ||
− | + | </div> |
2018年10月8日 (一) 14:25的最新版本
准备源码包
3.0.35版本代码
u-boot源码
文件名:u-boot-2009.08--svn*.tar.xz
kernel源码
文件名:linux-3.0.35--svn*.tar.xz
交叉编译工具
文件名:gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12.tar.bz2
配置编译环境
准备源码
准备源码包
1)创建工作目录
创建 ~/my-imx6 作为工作目录
创建 ~/my-imx6/02_source/imx_3.0.35_4.1.0 作为源码目录
$ mkdir ~/my-imx6/02_source/imx_3.0.35_4.1.0 -p
创建 ~/my-imx6/03_tools 作为工具目录
2)复制源码包到开发主机中
这一步骤自己采取相应的方式进行。
提示:这里将网盘中“02_源码”复制到Linux开发主机的“~/my-imx6/02_source/imx_3.0.35_4.1.0”,将网盘中“03_工具/toolchain”复制到Linux开发主机的“~/my-imx6/03_tools”。
解压源码包
1)解压u-boot源码和内核源码
$ cd ~/my-imx6/02_source/imx_3.0.35_4.1.0
$ tar xf u-boot-2009.08--svn*.tar.xz
$ tar xf linux-3.0.35--svn*.tar.xz
2)解压交叉编译工具
$ cd ~/my-imx6/03_tools/
$ tar jxf gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12.tar.bz2
开发环境配置
安装需要的包
1)更新源列表
$ sudo apt-get update
更新完成后如下图所示:
2)安装aptitude包管理工具和ia32-libs
提示:如果编译主机的Linux是32位的,可以跳过此步骤。
- 安装aptitude包管理工具
$ sudo apt-get –y install aptitude
- 使用aptitude安装ia32-libs
$ sudo aptitude –y install ia32-libs
提示:下图为安装过aptitude和ia32-libs后,再次执行安装命令的截图。
3)安装mkimage工具
$ sudo apt-get -y install uboot-mkimage
提示:下图为安装过mkimage工具后,再次执行安装命令的截图。
4)安装ncurses-dev
说明:make menuconfig对其具有依赖性质。
$ sudo aptitude -y install ncurses-dev
提示:下图为安装过ncurses-dev工具后,再次执行安装命令的截图。
配置MY-IMX6编译的环境变量
1)将平台信息写入到一个新的配置文件
$ echo "export ARCH=arm" > ~/my-imx6/03_tools/myimx6_3035_build_env
2)将交叉编译工具链路径写入到配置文件
- 进入交叉编译工具目录
$ cd ~/my-imx6/03_tools/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/
- 将路径写入到配置文件
$ sed -i "\$a IMX6_GCC462_PATH=$PWD" ~/my-imx6/03_tools/myimx6_3035_build_env
- 将交叉编译工具写入到配置文件
$ sed -i "\$a export CROSS_COMPILE=\$IMX6_GCC462_PATH/arm-none-linux-gnueabi-" ~/my-imx6/03_tools/myimx6_3035_build_env
3)查看配置文件
$ cat ~/my-imx6/03_tools/myimx6_3035_build_env
注意:如果在某一步操作错误,则需要删除 ~/my-imx6/03_tools/myimx6_3035_build_env 文件,并重新按照本小节操作。
编译u-boot
进入u-boot源码目录
$ cd ~/my-imx6/02_source/imx_3.0.35_4.1.0/u-boot-2009.08/
使配置文件生效
- 执行source命令
$ source ~/my-imx6/03_tools/myimx6_3035_build_env
- 查看编译配置
$ echo $ARCH
$ echo $CROSS_COMPILE
- 验证交叉编译工具配置
$${CROSS_COMPILE}gcc –v
提示:执行命令后可以看到终端显示出交叉编译工具的版本信息。如下图:
清除u-boot配置
u-boot配置
- 评估板及对应的 u-boot 编译配置:
评估板主型号 | CPU类型-内存容量 | 对应的u-boot配置 |
---|---|---|
MY-IMX6-EK200 | 6Q(四核)- 1G | myimx6ek200-6q_config |
6Q(四核)- 2G | myimx6ek200-6q_2g_config | |
6U(双核简化)- 1G | myimx6ek200-6u_config | |
6S(单核)- 512M | myimx6ek200-6s_config | |
MY-IMX6-EK314 | 6Q(四核)- 1G | myimx6ek314-6q_config |
6Q(四核)- 2G | myimx6ek314-6q_2g_config | |
6U(双核简化)- 1G | myimx6ek314-6u_config | |
6S(单核)- 512M | myimx6ek314-6s_config |
- MYIMX6EK200-6Qxx-1G配置示例:
编译
- 执行编译
$ make
提示:这里为了提高编译速度,在make后面加了“-j4”。这里编译的Linux主机是双核4线程的,所以“-j”后面用了4,也就是采用4线程编译。“-j”后面的数字可以根据系统资源分配,但是不应该超过编译主机最大支持的线程数。
- 编译完成
目标文件
编译完成后通过ls命令即可看到编译得到的目标文件u-boot.bin
$ ls
编译内核
进入内核源码目录
$ cd ~/my-imx6/02_source/imx_3.0.35_4.1.0/linux-3.0.35/
使配置文件生效
- 执行source命令
$ source ~/my-imx6/03_tools/myimx6_3035_build_env
- 查看编译配置
$ echo $ARCH
$ echo $CROSS_COMPILE
- 验证交叉编译工具配置
$ ${CROSS_COMPILE}gcc –v
提示:执行命令后可以看到终端显示出交叉编译工具的版本信息。如下图:
准备配置内核
- 清除内核配置
- 生成.config文件
说明:MY-IMX6-EK200系列评估板及MY-IMX6-EK314系列评估板使用的配置文件是myimx6_defconfig
$ make myimx6_defconfig
编译内核
- 编译uImage
$ make uImage
- 编译完成
- 目标文件
arch/arm/boot/uImage即为编译得到的目标文件,使用ls命令可查看文件信息。
$ ls arch/arm/boot/uImage –la
编译模块
- 编译
- 编译完成
- 目标文件
编译完成后各模块的.ko文件位于代码所在的目录,通过find命令可以找出编译完成的模块,参考命令如下:
$ find -name *.ko
Linux应用程序编译
编写应用程序
1) 创建应用程序目录
$ mkdir ~/my-imx6/02_source/application/ -p
$ cd ~/my-imx6/02_source/application/
2) 编写应用程序(这里以hello.c为例)
创建 hello.c 文件写入以下代码并保存:
- include <stdio.h>
int main(int argc, char **argv)
{
printf("Hello, MYZR!\n");
return;
}
使编译配置文件生效
- 执行source命令
$ source ~/my-imx6/03_tools/myimx6_3035_build_env
- 查看编译配置
$ echo $ARCH
$ echo $CROSS_COMPILE
提示:可看到ARCH和CROSS_COMPILE被设置
- 验证交叉编译工具配置
$ ${CROSS_COMPILE}gcc –v
提示:执行命令后可以看到终端显示出交叉编译工具的版本信息。如下图:
编译应用程序
2) 编译
$ ${CROSS_COMPILE}gcc hello.c -o hello.out
注意:上面的命令有包含“$”号,即“${CROSS_COMPILE}gcc”,是引用我们source时产生的环境变量。
3) 查看目标文件类型
$ file hello.out
文件系统(file system)
文件系统说明
文件系统包位于网盘对应的镜像文件夹中。支持的文件系统类型及下载方式可参照《MY-IMX6 烧录指导》。
解压文件系统到编译主机
1)创建文件系统的目录并进入
$ mkdir ~/my-imx6/04_rootfs/ -p
$ cd ~/my-imx6/04_rootfs/
2)将文件系统复制到~/my-imx6/04_rootfs/目录
这一步骤自己采取相应的方式进行
3)解压文件系统到指定目录
$ mkdir rootfs
$ sudo tar jxf rootfs-linux.tar.bz2 -C rootfs
添加应用到文件系统
$ cp ~/my-imx6/02_source/application/hello.out rootfs/app_test/
5)重新打包文件系统
$ rm -rf rootfs-linux.tar.bz2
$ cd rootfs/
$ sudo tar cjf ../rootfs-linux.tar.bz2 *
添加模块到文件系统
准备需要模块的.ko文件,其它请参照“添加应用到文件系统”。