`
ykk81ykk
  • 浏览: 12065 次
社区版块
存档分类
最新评论

imx515 开发板Android源代码编译过程[开发日记]

 
阅读更多

  Android requires the following system packages: flex: This lexical analyzer generator is used to read a given input file for a description of a scanner to generate.
  bison: This is a general-purpose parser generator.
  gperf: This is a perfect hash function generator.
  libesd0-dev: This enlightened sound daemon (dev files) is used to mix digitized audio streams for playback by a single device.
  libwxgtk2.6-dev: This package provides GUI components and other facilities for many different platforms.
  build-essential: This package contains a list of packages considered fundamental to building Debian packages.
  tong_jiang@tj-laptop:/$sudo apt-get install flex bison gperf libesd0-dev libwxgtk2.6-dev zlib1g-dev build-essential安装好jdk 1.5.0,并在/etc/profile中设置好导出的环境变量
  # Begin set java environment
  export JAVA_HOME=/opt/java/jdk1.5.0_22
  export JRE_HOME=/opt/java/jdk1.5.0_22/jre
  export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPAT H
  export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH 
  # End set java environment
  After you setup a Linux PC, unpack the FSL i.MX Android Release Package using the following commands: 设置要导出的编译器相关的环境变量
  #Freescale CrossCompiler Env
  export ARCH=arm
  export CROSS_COMPILE=/opt/gcc-4.1.2-glibc-2.5-nptl-3/arm- none-linux-gnueabi/bin/arm-none-linux-gnueabi-
  export PATH=/opt/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linu x-gnueabi/bin:$PATH
  #
  Prebuilt Image for uboot : 下面开始repo代码打patch the Android source code is maintained as more than 100 gits in an Android repository (Visit GitWeb from browser).  To get the Android source code from Google repo , follow the steps:          Assume you had unzipped i.MX Android release package to /opt/imx-android-r8/.    $ cd ~    $ mkdirmyandroid    $ cdmyandroid    $ curl http://android.git.kernel.org/repo > ./repo    $ chmoda+x ./repo    $ ./repo init -u git://android.git.kernel.org/platform/manifest.git -b eclair    $ cp /opt/imx-android-r8/code/r8/default.xml .repo/manifests/default.xml        (To avoid loading unnecessary gits from Google repo , meanwhile load some gits from Google repo which is not included in default manifest)    $ ./repo sync 
  Get a clean kernel source code from kernel.org: 
  If you use uboot as your bootloader , then you need get a clean source code base from the original git :  
  Apply all i.MX Android patches using following steps:         Assume you had unzipped i.MX Android release package to /opt/imx-android-r8/.    $ cd ~/myandroid    $ . /opt/imx-android-r8/code/r8/and_patch.sh    $ help    Now you should see "c_patch " function is available for you     $ c_patch /opt/imx-android-r8/code/r8 imx_r8     Here "/opt/imx-android-r8/code/r8" is the location of the patches (i.e. directory created when you unzip release package)    "imx_r8" is the branch which will be created automatically for you to hold all patches (only in those existing Google gits ).     You can choose any branch name you like instead of "imx_r8".        If everything is OK, "c_patch " will generate the following output to indicate successful patch:    ************************************************** ************    Success: Now you can build android code for FSL i.MX platform    ************************************************** ************ 
  Note: The patch script (and_patch.sh) utalizes  some basic utilities like awk/sed . If they are not available on your LinuxPC , install them in advance.      $ cd ~/myandroid/bootable/bootloader/uboot-imx
  $ echo $ARCH && echo $CROSS_COMPILE
  Make sure you have those 2 environment variables set
  Command to build for i.MX51 BBG3 board is:
  $ make mx51_bbg_android_config
  $ make
  "u-boot.bin " is generated if you have a successful build.
  The above u-boot.bin has 1024KB padding at the head of file,for example first executable instruction is at the offset 1KB. If you want to generate a no-padding image, you need do below dd command in host.
  $ dd if=./u-boot.bin of=./u-boot-no-padding.binbs =1024 skip=1
  Usually this no-padding uboot image is used in the SD card, for example, program this no-padding uboot image into 1KB offset of SD card so that we do not overwrite the MBR (including partition table) within first 512B on the SD card.
  Note : Any image which must be loaded by uboot must have an unique image head, for example, some data must be added at the head of loaded image to tell uboot about the image (for example, it's a kernel, or ramfs , etc) and how to load the image (for example, load/execute address).
  Therefor before you can load any image into RAM by uboot , you need a tool to add this information to generate a new image which can be recognized by uboot . Fortunately, this tool is delivered together with uboot . After you make uboot using the above steps, you can find the tool (mkimage ) under tools/.
  Later the document will describe how to use mkimage to generate the image (for example kernel image, ramfs image) to be loaded by uboot .  To run Android using NFS or from SD, build the kernel with the default configuration  now as follows:       Assume you had already built uboot . mkimage was generated under myandroid//bootable/bootloader/uboot-imx/tools / and it's in your PATH
  $ cd ~/myandroid/kernel_imx
  $ echo $ARCH && echo $CROSS_COMPILE
  Make sure you have those 2 environment variables set
  $ make imx5_android_defconfig
  Generate ".config " according to default config file under arch/arm/configs .
  $ make uImage
  You can generate zImage too by "make zImage ", use following command to generate uImage from zImage . With a successful build in either of the above case, the generated kernel image is ~/myandroid/kernel_imx/arch/arm/boot/uImage. Generate uImage to be loaded by u-boot To generate uImage from the built zImage , generate a uImage based on the above zImage as follows:      $ cdmyandroid/kernel_imx/arch/arm/boot
  $ ~/myandroid/bootable/bootloader/uboot-imx/tools/mkim age -A arm -O linux -T kernel -C none -a 0x90008000 -e 0x90008000 -n "Android Linux Kernel" -d ./zImage ./uImage
  During boot, when uboot try to load above "uImage ", it will know to load it (without image head added by mkimage tool) into 0x90008000 (specified by "-a"), and then jump to 0x90008000 (specified by "-e") to execute it. "-C none" means no compression when generating "uImage ". This is because the original zImage is already a compressed one. After applying all i.MX patches and kernel image built out, build the Android image using following steps: For i.MX51 BBG build, the following outputs are generated as default under myandroid/out/target/product/imx51_BBG:  Generate uRamdisk to be loaded by uboot
  The following steps generate a RAMDISK image recognized by uboot : 编译完成,我们可以逐步将img文件烧写到SD卡中.
  上述过程简单,按步骤一步步进行即可,不抓图描述.
  Program Bootloader into SD using dd
  Insert the SD card/cardreader to the Linux PC (root privileges are needed for programming SD)
  Note : if the SD card had been previously formatted with a valid file system, usually it is automatic mounted when you insert the SD card to Linux PC. Check is the SD card has been mounted using mount (usually /dev/sdb *). Umount the SD card using sudoumount /dev/sdb *
  Program the bootloader into offset 1K (1024B) of the SD card    Make sure bootloader (uboot , for 3DS or BBG3) image is used. See "Prebuilt image for using uboot ".
  # dd if=your_bootloader_binfile of=/dev/sdbbs =1K seek=1
  In above example, you should use no-padding version bootloader since it will be programmed to 1KB offset ("bs =1K seek=1"). If you do want to use the normal version bootloader (with 1KB padding at the head of binfile ), you can do as below.
  # dd if=/dev/sdb of=./mbrbackupbs =512 count=1  [To backup MBR]
  # dd if=your_bootloader_binfile_withpadding of=/dev/sdb [To program bootloader into offset 0 on SD ]
  # dd if=./mbrbackup of=/dev/sdb   [To restore MBR] 由于我们生成了nopading的uboot,我们直接执行前者语句即可,烧写uboot后上电测试.
  进入uboot目录
  tong_jiang@tj-laptop:~$ cd workdir/freescale/android/bootable/bootloader/uboo t-imx/
  生成nopading的uboot
  tong_jiang@tj-laptop:~/workdir/freescale/android/b ootable/bootloader/uboot-imx$ sudo dd if=./u-boot.bin  of=./u-boot-no-padding.bin bs=1024 skip=1
  148+1 records in
  148+1 records out
  151952 bytes (152 kB) copied,0.000897465 秒,169 MB/秒
  该命令参数的含义
  skip = blocks 跳过读入缓冲区开头的ibs*blocks块。
  bs=bytes同时设置读写块的大小为 bytes ,可代替 ibs 和 obs 。
  烧写uboot
  tong_jiang@tj-laptop:~/workdir/freescale/android/b ootable/bootloader/uboot-imx$ sudo dd if=u-boot-no-padding.bin of=/dev/sdb bs=1K seek=1 
  148+1 records in
  148+1 records out
  151952 bytes (152 kB) copied,0.202129 秒,752 kB/秒
  seek=blocks   从输出文件开头跳过 blocks 个块后再开始复制。(通常只有当输出文件是磁盘或磁带时才有效)
  设置为uboot启动模式,并上电测试:
  Setup the correct boot DIP configuration.
  i.MX51 BBG3, load bootloader from SD:
  * 7/8 ON; all others off U-Boot 2009.08-00099-gc1a8812 ( 6月 22 2010 - 15:55:43) CPU: Freescale i.MX51 family 3.0V at 800 MHz mx51 pll1: 800MHz mx51 pll2: 665MHz mx51 pll3: 216MHz ipg clock : 66500000Hz ipg per clock : 665000000Hz uart clock : 66500000Hz cspi clock : 54000000Hz Board: MX51 BABBAGE 3.0 [POR] Boot Device: MMC DRAM: 512 MB MMC: FSL_ESDHC: 0 *** Warning - bad CRC or MMC, using default environment In: serial Out: serial Err: serial Press home + power to enter recovery mode ... Net: FEC0 [PRIME] Hit any key to stop autoboot: 0 Unknown command 'mmcinit' - try 'help' Wrong Image Format for bootm command ERROR: can't get kernel image! BBG U-Boot > 分别写入内核与文件系统到SD卡中,用dd或tftp均可. tong_jiang@tj-laptop:~/workdir/freescale/android/k ernel_imx$ sudo dd if=arch/arm/boot/uImage of=/dev/sdb bs=1M seek=1
  2+1 records in
  2+1 records out
  2352920 bytes (2.4 MB) copied,0.504715 秒,4.7 MB/秒 tong_jiang@tj-laptop:~/workdir/freescale/android$ sudo dd if=out/target/product/imx51_BBG/uramdisk.img of=/dev/sdb bs=4M seek=1
  0+1 records in
  0+1 records out
  207807 bytes (208 kB) copied,0.0672214 秒,3.1 MB/秒  tong_jiang@tj-laptop:~/workdir/freescale/android$ sudo dd if=out/target/product/imx51_BBG/system.img of=/dev/sdb2
  187536+0 records in
  187536+0 records out
  96018432 bytes (96 MB) copied,51.4244 秒,1.9 MB/秒 tong_jiang@tj-laptop:~/workdir/freescale/android$ sudo dd if=out/target/product/imx51_BBG/recovery.img of=/dev/sdb4
  9184+0 records in
  9184+0 records out
  4702208 bytes (4.7 MB) copied,4.43228 秒,1.1 MB/秒 Note: You can dduserdata.img if there are files to be added. Make sure data partition size is set correctly in session TARGET_USERIMAGES_BLOCKS : = 204800 of file vendor/fsl/imx51_BBG/BoardConfig.mk.  插入SD卡,启动设备,进入uboot命令行,执行: BBG U-Boot > setenvbootcmd 'run bootcmd_SD1 bootcmd_SD2' BBG U-Boot > setenv bootcmd_SD1 'run bootargs_basebootargs_androidbootargs_SD ' BBG U-Boot > setenv bootcmd_SD2 'mmc read 0 ${loadaddr } 0x800 0x1280;mmc read 0 ${rd_loadaddr } 0x2000 0x258;bootm ${loadaddr } ${rd_loadaddr }' BBG U-Boot > setenvbootargs_base 'setenvbootargs console=ttymxc0,115200' BBG U-Boot > setenvbootargs_SD 'setenvbootargs ${bootargs }' BBG U-Boot > setenvbootargs_android 'setenvbootargs ${bootargs } init=/init androidboot.console =ttymxc0 wvga calibration' BBG U-Boot > setenvloadaddr 0x90800000 BBG U-Boot > setenvrd_loadaddr 0x90B00000  BBG U-Boot > saveenv 第一次启动需要校准触摸屏,请认真设置,如果设置不准确用起来就麻烦了.
  对于在windows上使用adb工具,安装好对应驱动即可.
  在ubuntu linux上使用adb工具或adt工具连接物理设备,google的文档中有描述:    If you're developing on Ubuntu Linux, you need to add a rules file that contains a USB configuration for each type of device you want to use for development. Each device manufacturer uses a different vendor ID. The example rules files below show how to add an entry for a single vendor ID (the HTC vendor ID). In order to support more devices, you will need additional lines of the same format that provide a different value for the SYSFS{idVendor} property. For other IDs, see the table of USB Vendor IDs below.  Log in as root and create this file: /etc/udev/rules.d/51-android.rules .  For Gusty/Hardy, edit the file to read:
  SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666" For Dapper, edit the file to read:
  SUBSYSTEM=="usb_device", SYSFS{idVendor}=="0bb4", MODE="0666" 但是实际上的USB Vendor ID的表并不正确
  在这里我使用下面的方法解决
  1.插拔连接设备的USB线,并分别用lsusb打印usb信息.
  我们可以看到我们的vendor信息,High Tech Computer Corp.为我们的设备. 
  tong_jiang@tj-laptop:/$ lsusb
  Bus 002 Device 093: ID 0bb4:0c02 High Tech Computer Corp. 
  Bus 002 Device 082: ID 14cd:8123 Super Top 
  Bus 002 Device 075: ID 046d:c01f Logitech, Inc. 
  Bus 002 Device 028: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
  Bus 002 Device 004: ID 0c45:6450 Microdia 
  Bus 002 Device 002: ID 8087:0020  
  Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  Bus 001 Device 002: ID 8087:0020  
  Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hup. 将/etc/udev/rules.d/51-android.rules中vendor值修改为0bb4使用eclipse的adt工具连接,正常. 
  
  可以加载hello world测试.正常.
  加载歌曲到sd卡媒体分区中,播放歌曲,无声音,原因是codec没有编译进去,现在把codec加载并编译. $ tar xzvf imx-android-r8-codec-standard.tar.gz      $ cd imx-android-r8-codec-standard/  $ cp -rf codec_prebuilt/* ~/myandroid/prebuilt/android-arm/fsl_imx_codec/  $ cd ~/myandroid (or any other directory to be the android source code's root directory) $ . ./build/envsetup.sh  Change the below text entries in vendor/fsl/imx51_BBG/init.rc or vendor/fsl/imx51_3stack/init.rc through text editor. The properties of ro.FSL_AVI_PARSER, ro.FSL_AAC_PARSER, ro.FSL_ASF_PARSER, ro.FSL_MKV_PARSER, and ro.FSL_FLV_PARSER are used to control whether AVI file(*.avi),AAC file(*.aac),ASF file(*.wmv,*.wma,*.asf), MKV(*.mka,*mkv) file, and FLV(*.flv) playback features will be built in. And the properties of ro.media.enc.hprof.file.format, ro.media.enc.hprof.codec.vid, ro.media.enc.hprof.codec.aud are used to control whether MP4(H264&MP3) recording feature will be built in.  setprop ro.FSL_AVI_PARSER 0    setprop ro.FSL_AAC_PARSER 0    setprop ro.FSL_ASF_PARSER 0  setprop ro.FSL_MKV_PARSER 0 setprop ro.FSL_FLV_PARSER 0 setprop ro.media.enc.hprof.file.format 3gp setprop ro.media.enc.hprof.codec.vid h263 setprop ro.media.enc.hprof.vid.width 352 setprop ro.media.enc.hprof.vid.height 288 setprop ro.media.enc.hprof.vid.bps 360000 setprop ro.media.enc.hprof.codec.aud amrnb setprop ro.media.enc.hprof.aud.hz  8000 setprop ro.media.enc.hprof.aud.bps  23450 to the below value: setprop ro.FSL_AVI_PARSER 1    setprop ro.FSL_AAC_PARSER 1    setprop ro.FSL_ASF_PARSER 1  setprop ro.FSL_MKV_PARSER 1 setprop ro.FSL_FLV_PARSER 1 setprop ro.media.enc.hprof.file.format mp4 setprop ro.media.enc.hprof.codec.vid h264 setprop ro.media.enc.hprof.vid.width 720 setprop ro.media.enc.hprof.vid.height 576 setprop ro.media.enc.hprof.vid.bps 38400 setprop ro.media.enc.hprof.codec.aud mp3 setprop ro.media.enc.hprof.aud.hz  44100 setprop ro.media.enc.hprof.aud.bps  128000 $ make PRODUCT-imx51_BBG-eng  注意修改的时候小心没注意修改到了其他的值,会导致搜索不到某些nobody媒体文件和播放无声音等问题.
  RMVB的PARSER是需要付费的.
  现在可以放 mkv,3gp,mp4,asf,avi等文件测试了.
  放了个nobody上去,感觉不错,wma和mp3均可以正常播放.
  使用SD卡启动是正常,之后可以尝试使用tftp下载内核,用nfs挂载文件系统进行调试.
  设置好tftp需要设置的环境变量.
  Configure uboot to determine where and how to load the kernel. Power up the board and complete the following steps in uboot console: BBG U-Boot > setenvethaddr 00:04:9f:00:ea:d3 BBG U-Boot > setenvfec_addr 00:04:9f:00:ea:d3 BBG U-Boot > setenvbootcmd 'dhcp;runbootcmd_nfs ' BBG U-Boot > setenvbootcmd_nfs 'run bootargs_basebootargs_androidbootargs_nfs ; bootm ' BBG U-Boot > setenvbootargs_base 'setenvbootargs console=ttymxc0,115200' BBG U-Boot > setenvbootargs_nfs 'setenvbootargs ${bootargs } ip =dhcp root=/dev/nfsnfsroot =${serverip }:${nfsroot },v3,tcp' BBG U-Boot > setenvbootargs_android 'setenvbootargs ${bootargs } init=/init androidboot.console =ttymxc0 wvga calibration' BBG U-Boot > setenvloadaddr 0x90800000 BBG U-Boot > setenvbootfileuImage BBG U-Boot > setenvserverip  192.168.1.101  BBG U-Boot > setenvnfsroot /opt/nfs_root/android_bbg BBG U-Boot > saveenv
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics