imx6q 编译下载指南


  
  在Ubuntu14.04 64位系统上
1 搭建编译环境
  1.1 安装软件包
  sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev


  sudo apt-get install libsdl1.2-dev xterm sed cvs subversion 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 u-boot-tools


  1.2 下载repo
  资料上说是用下面的命令下载
  mkdir ~/bin (this step may not be needed if the bin folder already exists)
  curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
  chmod a+x ~/bin/repo
  
  但是我试过发现在大陆Google被墙了,无法下载下来的。可以用http://download.csdn.net/detail/wince_lover/9818219 中的repo.tar.bz2解压缩到bin目录下,是一样的。
  当然repo不一定非要放在bin目录下,在其他的目录下也是没有问题的。
  然后设置搜索路径
  export PATH=~/bin:$PATH
  当然也可以不设置搜索路径,那么后面repo的时候就用完整的路径就好了。
  
  1.3 设置用户名和邮箱
  git config --global user.name "Your Name"
  git config --global user.email "Your Email"
  git config --list
  这里随便设置一个用户名和邮箱就可以了。
  


2 获取LinuxBSP


  mkdir fsl-release-bsp
  cd fsl-release-bsp
  repo init -u git://git.freescale.com/imx/fsl-arm-yocto-bsp.git -b imx-3.14.52-1.1.0_ga
  repo sync
  
  说明:
  repo sync 将会是一个漫长的等待过程,中间可能会出错。如果出错了就重新repo sync,直到成功为止。
  另外有的时候可能会很长时间不动了,看下载的流量也一直是0,也可以ctrl+C终止,然后重新repo sync。
  
  注意在yocto下,我们下载BSP实际上只是一些配置文件,实在编译的时候边编译边下载的,所以在我们下载的BSP里面是找不到代码的。
  
3 编译BSP
  3.1 
  DISTRO=<distro name> MACHINE=<machine name> source fsl-setup-release.sh -b <build dir>
  
  distro name有下面4个值
  fsl-imx-x11       说明只支持X11 graphics
  fsl-imx-wayland   说明只支持Wayland weston graphics
  fsl-imx-xwayland  说明支持 Wayland graphics 和 X11.  
  fsl-imx-fb        说明只支持Frame Buffer graphics 不支持   X11 和 Wayland
  
  machine name 对应我们的开发板的类型,有下面的值
  imx6qpsabreauto 、 imx6qpsabresd、 imx6ulevk 、 imx6dlsabreauto
  imx6dlsabresd  、  imx6qsabreauto 、 imx6qsabresd 、 imx6slevk 、 imx6solosabreauto
  imx6solosabresd 、 imx6sxsabresd 、 imx6sxsabreauto 、 imx7dsabresd 
  
  build dir 是编译的目录,我们可以任意指定一个目录名,编译的时候将在当前目录下新建这个目录。
  
  例如我是这样设置的
  MACHINE=imx6qsabresd DISTRO=fsl-imx-x11 source ./fsl-setup-release.sh -b imx6q-x11
  首次运行这个命令的时候会提示时候遵循EULA协议,我们选y就好了。
  
  3.2
  设置好后开始编译。
  我们用bitbake来编译的。
  格式是 bitbake <project name>
  project name有下面的选项
  core-image-minimal  这个是构建一个能启动的最小的系统
  core-image-base     这个是构建一个只有命令行的系统
  core-image-sato     这个是一个支持X11图形界面的系统
  fsl-image-machine-test 这个imx内核的只有命令行的系统
  fsl-image-gui          这个是IMX内核的不支持qt的图形界面的系统
  fsl-image-qt5          这个是支持qt5的图形界面的系统
  例如我运行的命令是
  bitbake fsl-image-qt5
  
  之后又是漫长的等待了,在yocto的编译过程中,是一边编译一边下载的,所以首次编译的时间会很长,我编译了3天才完成。
  如果在编译中看到类似
  WARNING: Failed to fetch URL http://download.savannah.gnu.org/releases/quilt/quilt-0.64.tar.gz, attempting MIRRORS if available
  的警告,可以不用管。
  如果出现错误,可以ctrl+c终止,然后在重新运行 bitbake fsl-image-qt5,直到编译成功为止。
  
4 代码的位置
  Linux的kernel的源代码在
  fsl-releases-bsp/imx6q-x11/tmp/work/imx6qsabresd-poky-linux-gnueabi/linux-imx/3.14.52-r0/git下
  说明imx6q-x11是我们在“DISTRO=<distro name> MACHINE=<machine name> source fsl-setup-release.sh -b <build dir>”中指定的build dir。
  git是一个链接文件,实际的源代码在 fsl-releases-bsp/imx6q-x11/tmp/work-shared/imx6qsabresd/kernel-source/
    
  u-boot的源代码的位置在
  fsl-releases-bsp/imx6q-x11/tmp/work/imx6qsabresd-poky-linux-gnueabi/u-boot-imx/2015.04-r0/git/
    
  这里要注意,对于不同的版本的BSP 可能就不是3.14.52-r0或者2015.04-r0了,可以根据实际的版本在linux-imx和u-boot-imx看到的。
  
5 编译出来的image的位置
  编译出来的image在 fsl-releases-bsp/imx6q-x11/tmp/deploy/images/目录下
  包括的u-boot zImage rootfs
  
6 编译的log信息
  在我们编译的过程中,在Terminal中是看不到编译的log信息的,那么我们怎么直到编译的时候我们的代码有没有编译到,有没有警告呢?
  其实yocto已经帮我们保存了编译的log信息。
  Linux kernel的编译的log就在
  fsl-releases-bsp/imx6q-x11/tmp/work/imx6qsabresd-poky-linux-gnueabi/linux-imx/3.14.52-r0/temp/
  目录下。
  例如 log.do_compile就是编译内核的log信息 。
  
  u-boot的编译的log就在fsl-releases-bsp/imx6q-x11/tmp/work/imx6qsabresd-poky-linux-gnueabi/u-boot-imx/2015.04-r0/temp/目录下
  
  其他的也类似在对应的目录的temp目录下。
  
7 如何单独编译kernel和u-boot
  我们修改了kernel或者u-boot的源代码,直接运行bitbake fsl-image-qt5是不会编译我们修改的源代码的。所以就需要我们单独编译源代码。
  
  7.1编译kernel
  
  配置menuconfig
  bitbake -c menuconfig -v linux-imx 
  
  单独编译kernel
  bitbake -c compile -f -v linux-imx 
  bitbake linux-imx -c compile_kernelmodules -f -v    
  bitbake -c deploy -f -v linux-imx  
  bitbake fsl-image-qt5
  执行上面的命令将重新编译内核、设备树、模块。并且重新生成rootfs  。
  实际上我们修改了内核,实际上往往不需要更新rootfs的,而我们 执行bitbake fsl-image-qt5时会重新生成rootfs,这个操作会耗费很长的时间。
  所以我们也可以只执行
  bitbake -c compile -f -v linux-imx 
  bitbake linux-imx -c compile_kernelmodules -f -v    
  bitbake -c deploy -f -v linux-imx 
  这两个命令,然后再自己把zImage和设备树文件拷出来。
  执行上面个三个命令编译出来的zImage和设备树在
  fsl-releases-bsp/imx6q-x11/tmp/work/imx6qsabresd-poky-linux-gnueabi/linux-imx/3.14.52-r0/deploy-linux-imx/
  目录下。
  
  单独编译u-boot
  bitbake -c compile -f -v u-boot-imx
  bitbake -c deploy -f -v u-boot-imx
  bitbake fsl-image-qt5
  同样单独编译完u-boot,执行bitbake fsl-image-qt5时会重新生成rootfs,会耗费很长的时间。
  所以我们也可以只执行
  bitbake -c compile -f -v u-boot-imx
  bitbake -c deploy -f -v u-boot-imx
  
 然后把u-boot拷出来
 编译出来的u-boot在
 fsl-releases-bsp/imx6q-x11/tmp/work/imx6qsabresd-poky-linux-gnueabi/u-boot-imx/2015.04-r0/deploy-u-boot-imx/
 目录下。
 
8 烧录
  首先我们要参考开发板的使用说明,把开关拨到download模式。
  然后在freescale的官网上下载对应的Linux版本的mfgtools。
  之后根据我们的需要修改两个配置文件。cfg.ini和ucl2.xml。
  1 cfg.ini
  这个文件就在mfgtools目录下。
  我们首先要根据烧录的媒介(EMMC\SD\NAND\NOR FLASH...)设置[LIST]下的name,
  这个name就是对应ucl2.xml文件下的<LIST name="XXXX" desc="XXXX"> .
  mfgtools会根据这个name,执行ucl2.xml对应的<LIST name="XXXX" desc="XXXX"> 中定义的操作。
  然后就是根据我们板的情况定义:
  [variable]下的变量
  例如要烧录到开发板的EMMC上,那么就要把mmc的值设置为3 ,把ldo=的值设置为-ldo
  
  2 ucl2.xml
   
  这个文件在 Profiles\Linux\OS Firmware\目录下
  这个文件我们主要是要修改
  <CMD state="Updater" type="push" body="send" file="IMAGE/u-boot.imx" ......
  <CMD state="Updater" type="push" body="send" file="IMAGE/zImage">  ........
  <CMD state="Updater" type="push" body="send" file="IMAGE/zImage-imx6q%plus%-%board%%ldo%.dtb ......
  <CMD state="Updater" type="push" body="pipe tar -jxv -C /mnt/mmcblk%mmc%p2" file="IMAGE/rootfs.tar.bz2" ......
  这几个位置,将file=后面的路径改为我们实际存放文件的路径就可以了。
  这里修改的时候要注意,要找到ifdev=“XXX"的位置,XXX是CPU的类型。例如我们的板上是iMX6Q,那么我们就要找到对应ifdev="MX6Q"的这一行修改。
  
  3 在我们修改完两个配置文件后可能会出现
  “Initalize operation failed,please refer to "MfgTool.log" for detailed information,error code:4”的错误。
  出现这个错误,一般是没有找到对应的文件,我们要先检查下是否我们要烧录的文件的路径写对了。
  如果这个路径是对的,可能是其他CPU类型的文件不存在造成的。
  例如我们要烧录的CPU是6Q,但是6D的某个文件不存在,也会这个错误。我们只要把其他不需要的CPU的那一行注释掉就可以了。
  
  4 用原始的配置文件会烧录 u-boot zImage 设备树文件 rootfs,rootfs是很大的,烧录起来时间很长,而我们只改了kernel或者u-boot,往往不需要重新烧录rootfs。
  我们可以把相关的分区的配置和保存rootfs的配置注释掉,这样就快很多了。下面是EMMC只烧录u-boot zImage 设备树文件的配置。
  <LIST name="eMMC_withoutrootfs" desc="Choose eMMC as media only image">
<CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-imx6q%plus%%board%_sd.imx" ifdev="MX6Q">Loading U-boot</CMD>
<!--
<CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-imx6dl%board%_sd.imx" ifdev="MX6D">Loading U-boot</CMD>
<CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-imx6sx%board%_emmc.imx" ifdev="MX6SX">Loading U-boot</CMD>
<CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-imx7d%7duboot%_sd.imx" ifdev="MX7D">Loading U-boot</CMD>
<CMD state="BootStrap" type="boot" body="BootStrap" file ="firmware/u-boot-imx6ul%6uluboot%_emmc.imx" ifdev="MX6UL">Loading U-boot</CMD>
-->
<CMD state="BootStrap" type="load" file="firmware/zImage" address="0x12000000"
loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Kernel.</CMD>
<CMD state="BootStrap" type="load" file="firmware/zImage" address="0x80800000"
loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6SL MX6SX MX7D MX6UL">Loading Kernel.</CMD>


<CMD state="BootStrap" type="load" file="firmware/%initramfs%" address="0x12C00000"
loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q MX6D">Loading Initramfs.</CMD>
<CMD state="BootStrap" type="load" file="firmware/%initramfs%" address="0x83800000"
loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6SL MX6SX MX7D MX6UL">Loading Initramfs.</CMD>

<CMD state="BootStrap" type="load" file="firmware/zImage-imx6q%plus%-%board%%ldo%.dtb" address="0x18000000"
loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6Q">Loading device tree.</CMD>
<!--
<CMD state="BootStrap" type="load" file="firmware/zImage-imx6dl-%board%%ldo%.dtb" address="0x18000000"
loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6D">Loading device tree.</CMD>
<CMD state="BootStrap" type="load" file="firmware/zImage-imx6sx-%sxdtb%-emmc.dtb" address="0x83000000"
loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6SX">Loading device tree.</CMD>
<CMD state="BootStrap" type="load" file="firmware/zImage-imx7d-%7ddtb%.dtb" address="0x83000000"
loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX7D">Loading device tree.</CMD>
<CMD state="BootStrap" type="load" file="firmware/zImage-imx6ul-%6uldtb%-emmc.dtb" address="0x83000000"
loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" ifdev="MX6UL">Loading device tree.</CMD>
-->
<CMD state="BootStrap" type="jump" > Jumping to OS image. </CMD>




<!-- create partition 
<CMD state="Updater" type="push" body="send" file="mksdcard.sh.tar">Sending partition shell</CMD>
<CMD state="Updater" type="push" body="$ tar xf $FILE "> Partitioning...</CMD>
<CMD state="Updater" type="push" body="$ sh mksdcard.sh /dev/mmcblk%mmc%"> Partitioning...</CMD>
-->

<!-- burn uboot -->
<CMD state="Updater" type="push" body="$ dd if=/dev/zero of=/dev/mmcblk%mmc% bs=1k seek=384 conv=fsync count=129">clear u-boot arg</CMD>
<!-- access boot partition -->
<CMD state="Updater" type="push" body="$ echo 0 > /sys/block/mmcblk%mmc%boot0/force_ro">access boot partition 1</CMD>
<CMD state="Updater" type="push" body="send" file="IMAGE/u-boot.imx" ifdev="MX6Q">Sending u-boot.bin</CMD>
<!--
<CMD state="Updater" type="push" body="send" file="files/u-boot-imx6dl%board%_sd.imx" ifdev="MX6D">Sending u-boot.bin</CMD>
<CMD state="Updater" type="push" body="send" file="files/u-boot-imx6sx%board%_emmc.imx" ifdev="MX6SX">Sending u-boot.bin</CMD>
<CMD state="Updater" type="push" body="send" file="files/u-boot-imx7d%7duboot%_sd.imx" ifdev="MX7D">Sending u-boot.bin</CMD>
<CMD state="Updater" type="push" body="send" file="files/u-boot-imx6ul%6uluboot%_emmc.imx" ifdev="MX6UL">Sending u-boot.bin</CMD>
-->
<CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk%mmc%boot0 bs=512 seek=2">write U-Boot to sd card</CMD>
<CMD state="Updater" type="push" body="$ echo 1 > /sys/block/mmcblk%mmc%boot0/force_ro"> re-enable read-only access </CMD>
<CMD state="Updater" type="push" body="$ mmc bootpart enable 1 1 /dev/mmcblk%mmc%">enable boot partion 1 to boot</CMD>


<!-- create fat partition -->
<CMD state="Updater" type="push" body="$ mkfs.vfat /dev/mmcblk%mmc%p1">Formatting rootfs partition</CMD>
<CMD state="Updater" type="push" body="$ mkdir -p /mnt/mmcblk%mmc%p1"/>
<CMD state="Updater" type="push" body="$ mount -t vfat /dev/mmcblk%mmc%p1 /mnt/mmcblk%mmc%p1"/>
 
<!-- burn zImage -->
<CMD state="Updater" type="push" body="send" file="IMAGE/zImage">Sending kernel zImage</CMD>
<CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/zImage">write kernel image to sd card</CMD>



<CMD state="Updater" type="push" body="send" file="IMAGE/zImage-imx6q%plus%-%board%%ldo%.dtb" ifdev="MX6Q">Sending Device Tree file</CMD>
<!-- burn dtb 
<CMD state="Updater" type="push" body="send" file="files/zImage-imx6dl-%board%%ldo%.dtb" ifdev="MX6D">Sending Device Tree file</CMD>
<CMD state="Updater" type="push" body="send" file="files/zImage-imx6sx-%sxdtb%-emmc.dtb" ifdev="MX6SX">Sending Device Tree file</CMD>
<CMD state="Updater" type="push" body="send" file="files/zImage-imx7d-%7ddtb%.dtb" ifdev="MX7D">Sending Device Tree file</CMD>
<CMD state="Updater" type="push" body="send" file="files/zImage-imx6ul-%6uldtb%-emmc.dtb" ifdev="MX6UL">Sending Device Tree file</CMD>
-->
<CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/imx6q%plus%-%board%.dtb" ifdef="MX6Q">write device tree to sd card</CMD>
<!-- burn dtb
<CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/imx6dl-%board%.dtb" ifdef="MX6D">write device tree to sd card</CMD>
<CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/imx6sx-%sxdtb%.dtb" ifdef="MX6SX">write device tree to sd card</CMD>
<CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/imx7d-%7ddtb%.dtb" ifdef="MX7D">write device tree to sd card</CMD>
<CMD state="Updater" type="push" body="$ cp $FILE /mnt/mmcblk%mmc%p1/imx6ul-%6uldtb%.dtb" ifdef="MX6UL">write device tree to sd card</CMD>
-->


<CMD state="Updater" type="push" body="$ umount /mnt/mmcblk%mmc%p1">Unmounting vfat partition</CMD>


<!-- burn 
<CMD state="Updater" type="push" body="$ mkfs.ext3 -E nodiscard /dev/mmcblk%mmc%p2">Formatting rootfs partition</CMD>
<CMD state="Updater" type="push" body="$ mkdir -p /mnt/mmcblk%mmc%p2"/>
<CMD state="Updater" type="push" body="$ mount -t ext3 /dev/mmcblk%mmc%p2 /mnt/mmcblk%mmc%p2"/>
<CMD state="Updater" type="push" body="pipe tar -jxv -C /mnt/mmcblk%mmc%p2" file="IMAGE/rootfs.tar.bz2" ifdev="MX6SL MX6D MX6Q MX6SX">Sending and writting rootfs</CMD>
<CMD state="Updater" type="push" body="pipe tar -jxv -C /mnt/mmcblk%mmc%p2" file="files/rootfs_nogpu.tar.bz2" ifdev="MX6UL MX7D">Sending and writting rootfs</CMD>
<CMD state="Updater" type="push" body="frf">Finishing rootfs write</CMD>
<CMD state="Updater" type="push" body="$ umount /mnt/mmcblk%mmc%p2">Unmounting rootfs partition</CMD>
<CMD state="Updater" type="push" body="$ echo Update Complete!">Done</CMD>
rootfs -->
  </list>
  
  
  
  
    
  
  
  
  
  


  
  
    
  
  
  
  
  

  • 4
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值