lbr023的个人空间 https://bbs.21ic.com/?674006 [收藏] [复制] [RSS]

日志

NXP6Q(MCIMX6Q-SDB)环境搭建、编译和烧录流程

已有 852 次阅读2019-2-18 16:55 |个人分类:笔记|系统分类:嵌入式系统

一、mfgtool烧录
1、官网选择要下载的软件版本对应的document,mfgtool和烧录image
        官网:https://www.nxp.com/support/developer-resources/software-development-tools/i.mx-developer-resources/i.mx-software-and-development-tool:IMX_SW?&&fsrch=1&sr=1&pageNum=1
2、将启动模式选择:拨码开关(SW6) 00001100 (from 1-8 bit)
3、需要烧录的软件copy到目录:android:Profiles\Linux\OS Firmware\files\android\sabresd\,     linux:Profiles\Linux\OS Firmware\files
4、上电后在设备管理器查看HID设备是否识别到
5、执行mfgtool可执行脚本:mfgtool2-yocto-mx-sabresd-emmc.vbs,执行后界面如果显示no device connected,解决办法:
        5.1、按板子reset后是否显示hid设备
        5.2、还是不能出现,更新此版本mfgtool:https://github.com/NXPmicro/mfgtools/releases?after=uuu_1.0.28,更新后如果执行以上脚本出现24错误,屏蔽掉Profiles\Linux\OS Firmware\ucl2.xml 其它板子的命令行,比如<STATE name="BootStrap" dev="MX6SX" vid="15A2" pid="0071"/>等
        以上操作基本都能解决!
        5.3、如果烧录的板子修改了硬件配置,DDR,则需要修改U-boot DDR参数:
         DDR 容量大小:\include\configs\mx6sabresd.h 文件中宏定义:PHYS_SDRAM_SIZE
         DDR 校准参数文件:board\freescale\mx6sabresd\mx6q_4x_mt41j128.cfg,根据校准tools校准值修改对应register的值
         重新编译uboot, 更新Profiles\Linux\OS Firmware\firmware\和Profiles\Linux\OS Firmware\files\下对应的uboot,然后再烧录
二、Linux 版本
        1、下载对应版本的yocto project源码步骤:
        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 u-boot-tools
        1.2. Create a bin folder in the home directory.
                $ 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
        1.3. Add the following line to the .bashrc file to ensure that the ~/bin folder is in your PATH variable.
                export PATH=~/bin:$PATH(you need to modify the path of bin according you work folder)
        1.4. Set up you git
                $ git config --global user.name "Your Name"
                $ git config --global user.email "Your Email"
                $ git config --list
        1.5. download linux source code
                $ mkdir fsl-release-bsp
                $ cd fsl-release-bsp
                $ repo init -u git://git.freescale.com/imx/fsl-arm-yocto-bsp.git -b imx-4.1-krogoth
                $ repo sync
        1.6. compile source code
                1.6.1. DISTRO=fsl-imx-fb MACHINE=imx6qsabresd source fsl-setup-release.sh –b build-fb
                        DISTRO可选择:fsl-imx-x11,fsl-imx-wayland,fsl-imx-xwayland或fsl-imx-fb
                        MACHINE可选择:imx6qsabresd,imx6qpsabreauto等可支持的板子类型, -b build-fb是指定编译目录
                1.6.2. bitbake fsl-image-qt5
                      之后又是漫长的等待了,在yocto的编译过程中,是一边编译一边下载的,所以首次编译的时间会很长
                      如果在编译中看到类似 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,直到编译成功为止。
        如果编译过程中无意关掉了终端,那么重新打开终端进入fsl-release-bsp目录后只需要执行以下命令就可以重新进入编译环境:
               $ source setup-environment build
                  1.6.3. 编译后代码的位置
                          1、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/ 
                          2、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看到的。
                1.6.4. 编译出来的image的位置
                          编译出来的image在 fsl-releases-bsp/imx6q-x11/tmp/deploy/images/目录下,包括的u-boot zImage rootfs
                1.6.5. 编译的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目录下。
                1.6.6. 如何单独编译kernel和u-boot
                          我们修改了kernel或者u-boot的源代码,直接运行bitbake fsl-image-qt5是不会编译我们修改的源代码的。所以就需要我们单独编译源代码。
                          编译kernel
                          配置menuconfig:bitbake -c menuconfig -v linux-imx 
                        1、单独编译kernel
                          bitbake -c compile -f -v linux-imx 
                          bitbake linux-imx -c compile_kernelmodules -f -v    
                          bitbake -c deploy -f -v linux-imx  
                          需要重新生成rootfs,再执行命令:bitbake fsl-image-qt5
                          实际上我们修改了内核,往往不需要更新rootfs的,而我们 执行bitbake fsl-image-qt5时会重新生成rootfs,这个操作会耗费很长的时间。所以可只执行前三个命令
                                 编译出来的zImage和设备树在fsl-releases-bsp/imx6q-x11/tmp/work/imx6qsabresd-poky-linux-gnueabi/linux-imx/3.14.52-r0/deploy-linux-imx/目录下。
                        2、单独编译u-boot
                          bitbake -c compile -f -v u-boot-imx
                          bitbake -c deploy -f -v u-boot-imx
                          同样需要重新生成rootfs,再执行命令:bitbake fsl-image-qt5
                             实际上我们修改了uboot,往往不需要更新rootfs的,而我们 执行bitbake fsl-image-qt5时会重新生成rootfs,这个操作会耗费很长的时间。所以可只执行前两个命令
                          编译出来的u-boot在fsl-releases-bsp/imx6q-x11/tmp/work/imx6qsabresd-poky-linux-gnueabi/u-boot-imx/2015.04-r0/deploy-u-boot-imx/目录下。

                        3、单独强制编译应用程序
                                bitbake -c compile -f -v xxx
                                bitbake -b xxx_1.2.bb

                        4、qt交叉编译环境搭建与开发,参考以下地址:
                        如果出现编译错误,请从下面地址下载linux-arm-poky-qnueabi-g++,配置qmake spec
                        https://www.jianshu.com/p/4fd72797861d

                        5、运行qt软件;
                        5.1、export DISPLAY=:0.0
                        5.2、export QT_QPA_PLATFORM=eglfs
                        5.3、copy编译的软件(hello)到imx6q平台
                        5.4、./hello -platform eglfs -plugin evdevtouch:/dev/input/event0
三、android版本
                1、Setting up your computer
                        $ sudo apt-get install uuid uuid-dev 
                        $ sudo apt-get install zlib1g-dev liblz-dev 
                        $ sudo apt-get install liblzo2-2 liblzo2-dev 
                        $ sudo apt-get install lzop 
                        $ sudo apt-get install git-core curl 
                        $ sudo apt-get install u-boot-tools 
                        $ sudo apt-get install mtd-utils 
                        $ sudo apt-get install android-tools-fsutils 
                        $ sudo apt-get install openjdk-8-jdk
                        Note:If you have trouble installing the JDK in Ubuntu, see How to install misc JDK in Ubuntu
for Android build. 
                        Configure git before use. Set the name and email as follows:
                         • git config --global user.name "First Last" 
                         • git config --global user.email "first.last@company.com"
                2、Unpacking the Android release package
                        cd /opt (or any other directory where the android_N7.1.2_2.0.0_source.tar.gz file is
placed) 
                        $ tar xzvf android_N7.1.2_2.0.0_source.tar.gz
                3、Get source code
                        3.1、Getting Android source code (Android/kernel/U-Boot)
                                3.1.1. get android source code from google server
                                               $ cd ~
                                        $ mkdir myandroid
                                        $ mkdir bin 
                                        $ cd myandroid 
                                        $ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo 
                                               $ chmod a+x ~/bin/repo 
                                        $ ~/bin/repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.2_r9
                                        $ ~/bin/repo sync 
                                        # This command loads most needed repos. Therefore, it can take several hours to load.
                                        # clone bpt.git from google repo, and checkout to the
                                        $ cd ~/myandroid/system/tools 
                                        $ git clone https://android.googlesource.com/platform/system/tools/bpt 
                                        $ cd bpt
                                        $ git checkout -b n7.1.2_2.0.0-ga b7c3059e5d8c408f60222edc898ef1c229d8fc2d
                                3.1.2. if cann't connect to google server, instead of tinghua server
                                        $ curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo 
                                        $ chmod +x repo 
                                               $ export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/' 
                                        $ ../bin/repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-7.1.2_r9 
                                        $../bin/repo sync
                        3.2、Get the N7.1.2_2.0.0 kernel source code from Freescale open source git:
                                $ cd ~/myandroid 
                                $ git clone git://git.freescale.com/imx/linux-imx.git kernel_imx # the kernel repo is large. Therefore, this process can take a while. 
                                $ cd kernel_imx 
                                $ git checkout n7.1.2_2.0.0-ga
                        3.3、If you use U-Boot as your bootloader, clone the U-Boot git repository from the open source git:
                                $ cd ~/myandroid/bootable
                                $ mkdir bootloader
                                $ cd bootloader
                                $ git clone git://git.freescale.com/imx/uboot-imx.git uboot-imx
                                $ cd uboot-imx
                                $ git checkout n7.1.2_2.0.0-ga
                        3.4、Patch standard features code package
                                Apply all the i.MX Android patches by performing the following steps: 
                                1. Assume you have unzipped the i.MX Android release package to /opt/android_N7.1.2_2.0.0_source. 
                                        $ cd ~/myandroid 
                                        $ source /opt/android_N7.1.2_2.0.0_source/code/N7.1.2_2.0.0/and_patch.sh 
                                        $ help 
                                2. You should see that the "c_patch" function is available. 
                                        $ c_patch /opt/android_N7.1.2_2.0.0_source/code/N7.1.2_2.0.0/ imx_N7.1.2_2.0.0-ga 
                                        Here, "/opt/android_N7.1.2_2.0.0_source/code/N7.1.2_2.0.0" is the location of the patches, which is the directory created when you unzip the release package.
                                        "imx_N7.1.2_2.0.0" is the branch which is created automatically to hold all patches (only in those existing Google gits). 
                                        Choose any branch name instead of "imx_N7.1.2_2.0.0".3. 
                                        If everything is OK, "c_patch" generates the following output to indicate the successful patch: 
                                        ***************************************************************** 
                                        Success: Now you can build the Android code for FSL i.MX platform
                                        ***************************************************************** 
                                        NOTE:The patch script (and_patch.sh) requires some basic utilities like awk/sed. If they are not available on the computer running Linux OS, install them first.
                4、Android build steps are as follows:
                        4.1. Change to the top level build directory.
                                $ cd ~/myandroid
                        4.2. Set up the environment for building. This only configures the current terminal.
                                $ source build/envsetup.sh
                        4.3. Execute the Android lunch command. In this example, the setup is for the production image of i.MX 6DualQuad SABRE Board/Platform device with user type.
                                $ lunch sabresd_6dq-user
                        4.4. Execute the make command to generate the image.
                                $ make 2>&1 | tee build-log.txt
                5、设置环境变量,显示屏设置:
                        Linux mipi dsi显示:setenv mmcargs 'setenv bootargs ${bootargs} console=${console},${baudrate} ${smp} root=/dev/mmcblk3p2 rootwait rw video=mxcfb0:dev=mipi_dsi,TRULY-WVGA,if=RGB24'
                        Android mipi dsi显示:setenv bootargs console=ttymxc0,115200 androidboot.console=ttymxc0 consoleblank=0 vmalloc=128M init=/init video=mxcfb0:dev=mipi_dsi,TRULY-WVGA,if=RGB24 video=mxcfb1:off video=mxcfb2:off video=mxcfb3:off androidboot.hardware=freescale cma=448M
                        Linux hdmi 显示:setenv mmcargs 'setenv bootargs ${bootargs} console=${console},${baudrate} ${smp} root=/dev/mmcblk3p2 rootwait rw video=mxcfb0:dev=hdmi,1920x1080M@60,if=RGB24'
                        Android hdmi 显示:setenv bootargs console=ttymxc0,115200 androidboot.console=ttymxc0 consoleblank=0 vmalloc=128M init=/init video=mxcfb0:dev=hdmi,1920x1080M@60,bpp=32 video=mxcfb1:off video=mxcfb2:off video=mxcfb3:off androidboot.hardware=freescale cma=448M

路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)