IMX6 L3035编译手册

电子说

1.2w人已加入

描述

  明远智睿MY-IMX6L3035编译手册

  2018年03月15日10:03myzr123

  准备源码包(preparesourcecodepacakge)3.0.35版本代码(3.0.35versioncode)u-boot源码(u-bootsourcecode)

  文件名:u-boot-2009.08--svn*.tar.xz

  nameoffile:u-boot-2009.08--svn*.tar.xz

  kernel源码(kernelsourcecode)

  文件名:linux-3.0.35--svn*.tar.xz

  nameoffile:linux-3.0.35--svn*.tar.xz

  交叉编译工具(crosscompifertool)

  文件名:gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12.tar.bz2

  nameoffile:gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12.tar.bz2

  配置编译环境(configurationofcompiferenvironment)准备源码(preparesourcecode)准备源码包(preparesourcecodepackage)

  1)创建工作目录

  createworkingdirectory

  创建~/my-imx6作为工作目录

  create~/my-imx6asworkingdirectory

  $mkdir~/my-imx6

  创建~/my-imx6/02_source/imx_3.0.35_4.1.0作为源码目录

  create~/my-imx6/02_source/imx_3.0.35_4.1.0assourcecodedirectory

  $mkdir~/my-imx6/02_source/imx_3.0.35_4.1.0-p

  创建~/my-imx6/03_tools作为工具目录

  create~/my-imx6/03_toolsastooldirectory

  $mkdir~/my-imx6/03_tools-p

  2)复制源码包到开发主机中

  copysourcecodepackagetothedevelopmenthost

  这一步骤自己采取相应的方式进行。

  doitinthisstepinyourownway。

  提示:这里将网盘中“02_源码”复制到Linux开发主机的“~/my-imx6/02_source/imx_3.0.35_4.1.0”,将网盘中“03_工具/toolchain”复制到Linux开发主机的“~/my-imx6/03_tools”。

  tip:thisstepistocopy“02_sourcecode”fromnetworkdiskto“~/my-imx6/02_source/imx_3.0.35_4.1.0”indevelopmenthost,andcopy“03_tool/toolchain”to“~/my-imx6/03_tools”。indevelopmenthost

  解压源码包(decompresssourcecodepackage)

  1)解压u-boot源码和内核源码

  decompressu-bootsourcecodeandkernelsourcecode

  $cd~/my-imx6/02_source/imx_3.0.35_4.1.0

  $tarxfu-boot-2009.08--svn*.tar.xz

  $tarxflinux-3.0.35--svn*.tar.xz

  2)解压交叉编译工具

  decompresscrosscompilertool

  $cd~/my-imx6/03_tools/

  $tarjxfgcc-4.6.2-glibc-2.13-linaro-multilib-2011.12.tar.bz2

  开发环境配置(developmentenvironmentconfiguration)安装需要的包(installpackageneeded)

  1)更新源列表

  listofupdatedsource

  $sudoapt-getupdate

  更新完成后如下图所示:

  afterupdate,itwilllooklikebelow:

  2)安装aptitude包管理工具和ia32-libs

  installaptitudepackagemanagementtoolandia32-libs

  提示:如果编译主机的Linux是32位的,可以跳过此步骤。

  tips:ifLinuxofcompilerhostis32bit,youcanskipthisstep。

  安装aptitude包管理工具

  installaptitudepackagemanagementtool

  $sudoapt-get–yinstallaptitude

  使用aptitude安装ia32-libs

  installia32-libswithaptitude

  $sudoaptitude–yinstallia32-libs

  提示:下图为安装过aptitude和ia32-libs后,再次执行安装命令的截图。

  tips:followingisthescreenshotswithre-executionofinstallationcommandafterinstallationofaptitudeandia32-libsisfinished。

  3)安装mkimage工具

  installmkimagetool

  $sudoapt-get-yinstalluboot-mkimage

  提示:下图为安装过mkimage工具后,再次执行安装命令的截图。

  tips:followingisthescreenshotswithre-executionofinstallationcommandafterinstallationofmkimagetoolisfinished。

  

  4)安装ncurses-dev

  installncurses-dev

  说明:makemenuconfig对其具有依赖性质。

  instruction:makemenuconfigisdependentonit。

  $sudoaptitude-yinstallncurses-dev

  提示:下图为安装过ncurses-dev工具后,再次执行安装命令的截图。

  tips:followingisthescreenshotswithre-executionofinstallationcommandafterinstallationofncurses-devtoolisfinished。

  配置MY-IMX6编译的环境变量(configureenvironmentvariablesofMY-IMX6compilation)

  1)将平台信息写入到一个新的配置文件

  writeplatforminformationtoanewconfiguredfile

  $echo“exportARCH=arm”》~/my-imx6/03_tools/myimx6_3035_build_env

  2)将交叉编译工具链路径写入到配置文件

  writecompilertoolchainpathtoconfiguredfile

  进入交叉编译工具目录

  entercrosscompilertooldirectory

  $cd~/my-imx6/03_tools/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/

  将路径写入到配置文件

  writepathtoconfiguredfile

  $sed-i“\$aIMX6_GCC462_PATH=$PWD”~/my-imx6/03_tools/myimx6_3035_build_env

  将交叉编译工具写入到配置文件

  writecrosscompilertooltoconfiguredfile

  $sed-i“\$aexportCROSS_COMPILE=\$IMX6_GCC462_PATH/arm-none-linux-gnueabi-”~/my-imx6/03_tools/myimx6_3035_build_env

  3)查看配置文件

  viewconfiguredfile

  $cat~/my-imx6/03_tools/myimx6_3035_build_env

  注意:如果在某一步操作错误,则需要删除~/my-imx6/03_tools/myimx6_3035_build_env文件,并重新按照本小节操作。

  note:ifanerroroccursinanystep,needtodelect~/my-imx6/03_tools/myimx6_3035_build_env,andoperateagainallstepsofthissegment。

  编译u-boot(compileu-boot)进入u-boot源码目录(enteru-bootsourcecodedirectory)

  $cd~/my-imx6/02_source/imx_3.0.35_4.1.0/u-boot-2009.08/

  使配置文件生效(validateconfiguredfile)

  执行source命令

  executesourcecommand

  $source~/my-imx6/03_tools/myimx6_3035_build_env

  查看编译配置

  viewcompilerconfiguration

  $echo$ARCH

  $echo$CROSS_COMPILE

  提示:可看到ARCH和CROSS_COMPILE被设置

  tips:youcanseethatARCH和CROSS_COMPILEisconfigured

  验证交叉编译工具配置

  verifycrosscompilertoolconfiguration

  $${CROSS_COMPILE}gcc–v

  提示:执行命令后可以看到终端显示出交叉编译工具的版本信息。如下图:

  tips:youcanseeversioninformationofcrosscompilertoolshownonterminalafterexecutionofcommand.asbelow:

  清除u-boot配置(removeu-bootconfiguration)

  $makedistclean

  u-boot配置(u-bootconfiguration)

  评估板及对应的u-boot编译配置:

  evaluationboardanditscorrespondingu-bootcompilerconfiguration:

  评估板主型号

  (evaluationboardmainmodel)

  CPU类型-内存容量

  (CPUtype-memorycapacity)

  对应的u-boot配置

  (correspondingu-bootconfiguration)

  MY-IMX6-EK2006Q(四核)-1G

  (6Q(quad.core)-1G)myimx6ek200_6q_config

  6Q(四核)-2G

  (6Q(quadcore)-2G)myimx6ek200_6q_2g_config

  6U(双核简化)-1G

  (6U(dualcoretile)-1G)myimx6ek200_6u_config

  6S(单核)-512M

  (6S(singlecore)-512M)myimx6ek200_6s_config

  MY-IMX6-EK3146Q(四核)-1G

  (6Q(quad.core)-1G)myimx6ek314_6q_config

  6Q(四核)-2G

  (6Q(quad.core)-2G)myimx6ek314_6q_2g_config

  6U(双核简化)-1G

  (6U(dualcoretile)-1G)myimx6ek314_6u_config

  6S(单核)-512M

  (6S(singlecore)-512M)myimx6ek314_6s_config

  MYIMX6EK200-6Qxx-1G配置示例:

  MYIMX6EK200-6Qxx-1Gconfigurationexample:

  

  $makemyimx6ek200_6q_config

  编译(compilation)

  执行编译

  executecompilation

  $make

  提示:这里为了提高编译速度,在make后面加了“-j4”。这里编译的Linux主机是双核4线程的,所以“-j”后面用了4,也就是采用4线程编译。“-j”后面的数字可以根据系统资源分配,但是不应该超过编译主机最大支持的线程数。

  Tips:Tospeedupthecompilation,add“-j4”aftermake.TheLinuxhostusedtocompileisdual-core,4threads.So“-j”isfollowedby4,whichtakes4threadstocompile.Thenumberbehind“-j”isallocatedbasedonsystemresources,butItshouldnotexceedthemaximumthreadsthehostsupport。

  编译完成

  completecompilation

  提示:u-boot编译过程大概需要几分钟时间。

  tips:u-bootcompilationprocesswilltakeafewminustesorso。

  目标文件(targetfile)

  编译完成后通过ls命令即可看到编译得到的目标文件u-boot.bin

  youcangetthecompiledfileu-boot.binwithlscommandaftercompilation

  $ls

  编译内核(compilekernel)进入内核源码目录(enterkernelsourcedirectory)

  $cd~/my-imx6/02_source/imx_3.0.35_4.1.0/linux-3.0.35/

  使配置文件生效(validateconfiguredfile)

  执行source命令

  executesourcecommand

  $source~/my-imx6/03_tools/myimx6_3035_build_env

  查看编译配置

  viewcompilerconfiguration

  $echo$ARCH

  $echo$CROSS_COMPILE

  提示:可看到ARCH和CROSS_COMPILE被设置

  tips:youcanseethatARCH和CROSS_COMPILEisconfigured

  验证交叉编译工具配置

  verifycrosscompilertoolconfiguration

  $${CROSS_COMPILE}gcc–v

  提示:执行命令后可以看到终端显示出交叉编译工具的版本信息。如下图:

  tips:youcanseeversioninformationofcrosscompilertoolshownonterminalafterexecutionofcommand.asbelow:

  准备配置内核(prepareforkernelconfiguration)

  清除内核配置

  removekernelconfiguration

  $makedistclean

  生成.config文件

  generated.configfile

  说明:MY-IMX6-EK200系列评估板及MY-IMX6-EK314系列评估板使用的配置文件是myimx6_defconfig

  instructions:configurationfilesusedforMY-IMX6-EK200seiresofevaluationboardandMY-IMX6-EK314seriesofevaluationboardismyimx6_defconfig

  $makemyimx6_defconfig

  编译内核(compilekernel)

  编译uImage

  compileuImage

  $makeuImage

  说明:截图中使用了4线程编译。

  instruction:4threadscompilationisusedinthescreenshots。

  编译完成

  completecompilation

  目标文件

  targetfile

  

  arch/arm/boot/uImage即为编译得到的目标文件,使用ls命令可查看文件信息。

  arch/arm/boot/uImageisthetargetfilethroughcompilation,youcanviewthefileinformationwithlscommand。

  $lsarch/arm/boot/uImage–la

  编译模块(compilemodule)

  编译

  compile

  $make

  说明:截图中使用了4线程编译。

  instruction:4threadscompilationisusedinthescreenshots。

  编译完成

  completecompilation

  目标文件

  targetfile

  编译完成后各模块的.ko文件位于代码所在的目录,通过find命令可以找出编译完成的模块,参考命令如下:

  .kofileofeachmoduleisinthedirectorywherecodeislocatedaftercompilation,youcanfindthemodulecompiledwithfindcommandaftercompilation,referingcommandasbelow:

  $find-name*.ko

  Linux应用程序编译(Linuxapplicationcompilation)编写应用程序(writeapplication)

  1)创建应用程序目录

  createapplicationdirectory

  $mkdir~/my-imx6/02_source/application/-p

  $cd~/my-imx6/02_source/application/

  2)编写应用程序(这里以hello.c为例)

  创建hello.c文件写入以下代码并保存:

  include

  intmain(intargc,char**argv)

  {

  printf(“Hello,MYZR!\n”);

  return;

  }

  3)查看代码

  $cathello.c

  使编译配置文件生效(validatecompilerconfiguredfile)

  执行source命令

  $source~/my-imx6/03_tools/myimx6_3035_build_env

  查看编译配置

  $echo$ARCH

  $echo$CROSS_COMPILE

  提示:可看到ARCH和CROSS_COMPILE被设置

  验证交叉编译工具配置

  $${CROSS_COMPILE}gcc–v

  提示:执行命令后可以看到终端显示出交叉编译工具的版本信息。如下图:

  编译应用程序(compileapplication)

  2)编译

  $${CROSS_COMPILE}gcchello.c-ohello.out

  注意:上面的命令有包含“$”号,即“${CROSS_COMPILE}gcc”,是引用我们source时产生的环境变量。

  3)查看目标文件类型

  $filehello.out

  可以看到目标文件hello.out的属性。

  文件系统(filesystem)文件系统说明(filesysteminstruction)

  文件系统包位于网盘对应的镜像文件夹中。支持的文件系统类型及下载方式可参照《MY-IMX6烧录指导》。

  解压文件系统到编译主机(decompressfilesystemtocompilerhost)

  1)创建文件系统的目录并进入

  $mkdir~/my-imx6/04_rootfs/-p

  $cd~/my-imx6/04_rootfs/

  2)将文件系统复制到~/my-imx6/04_rootfs/目录

  这一步骤自己采取相应的方式进行

  3)解压文件系统到指定目录

  $mkdirrootfs

  $sudotarjxfrootfs-linux.tar.bz2-Crootfs

  添加应用到文件系统(addapplicationtofilesystem)

  $cp~/my-imx6/02_source/application/hello.outrootfs/app_test/

  

  5)重新打包文件系统

  $rm-rfrootfs-linux.tar.bz2

  $cdrootfs/

  $sudotarcjf。。/rootfs-linux.tar.bz2*

  添加模块到文件系统(addmoduletofilesystem)

  准备需要模块的.ko文件,其它请参照“添加应用到文件系统”。

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
  • 相关推荐

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分