Building and Flashing ROM for PandaBoard ES(详细记录版)

之前有写过一篇http://guoh.org/lifelog/2012/06/building-and-flashing-rom-for-pandaboard-es/
那篇只是记录主要的问题,没有把详细过程记录下来,因为我当初也是参考别人的出来了,所以就觉得没有必要把详细的东西记录下来。
很多同学看了那边文章还是弄不出来,于是我答应周末有空的时候再完整做一个这个过程供大家参考。
因为这个板子是裸板,没有什么窗口可以显示当前板子的状态,所以可能这个难住了一些同学。买一个板子配套的扩展板又太贵了,不划算。
所以我建议如果大家实在搞不出来,也不知道原因的话,可以买根Linux下可用的串口线(如果你用Mac OS的话自己酌情处理),结合PuTTY用着包你瞬间明白烧录ROM其实也不难。
下面开始正文:
一,Build ROM
编译需要X64的操作系统,官方也是这么说的
X32位机器出现如下错误
/lib64/ld-linux-x86-64.so.2: No such file or directory

关于所用源码
官方也说了,pandaboard只支持master的code,所以源码需要是master的

我这里是目前最新的代码,2012-09-08这天的代码

repo init -u https://android.googlesource.com/platform/manifest
repo sync
repo forall -c 'git checkout -b master aosp/master'

安装一个patch(源码不同这个patch就不同哦)
https://developers.google.com/android/nexus/drivers#panda
PandaBoard binaries for Android 4.0.4 (IMM76I to IMM76L)

在X64上开始编译

guohai@KNIGHT:~/dev/src/android/git/panda$ source build/envsetup.sh

including device/asus/grouper/vendorsetup.sh
including device/generic/armv7-a-neon/vendorsetup.sh
including device/generic/armv7-a/vendorsetup.sh
including device/moto/wingray/vendorsetup.sh
including device/samsung/crespo4g/vendorsetup.sh
including device/samsung/crespo/vendorsetup.sh
including device/samsung/maguro/vendorsetup.sh
including device/samsung/toro/vendorsetup.sh
including device/sony/lt26/vendorsetup.sh
including device/ti/panda/vendorsetup.sh
including sdk/bash_completion/adb.bash

guohai@KNIGHT:~/dev/src/android/git/panda$ lunch 

You’re building on Linux

Lunch menu… pick a combo:
1. full-eng
2. full_x86-eng
3. vbox_x86-eng
4. full_mips-eng
5. full_grouper-userdebug
6. mini_armv7a_neon-userdebug
7. mini_armv7a-userdebug
8. full_wingray-userdebug
9. full_crespo4g-userdebug
10. full_crespo-userdebug
11. full_maguro-userdebug
12. full_toro-userdebug
13. full_lt26-userdebug
14. full_panda-userdebug

在此我选择
full_panda-userdebug

Which would you like? [full-eng] full_panda-userdebug

============================================
PLATFORM_VERSION_CODENAME=AOSP
PLATFORM_VERSION=4.0.9.99.999.9999.99999
TARGET_PRODUCT=full_panda
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.0.0-25-generic-x86_64-with-Ubuntu-11.10-oneiric
HOST_BUILD_TYPE=release
BUILD_ID=OPENMASTER
OUT_DIR=out
============================================

我用

guohai@KNIGHT:~/dev/src/android/git/panda$ make -j16

编译花了2个多钟头,偶中途去了趟超市,做了顿饭,整个ROM才编译完成,千万不要傻傻的等哦,找点别的事情干干(当然啦,偶尔过来看看有没有什么意外情况出现build failure是可以的,我已经build很多遍了,所以机器上的编译环境一般没有什么问题,比较放心)

直到build完成,出现
Creating filesystem with parameters:
Size: 268435456
Block size: 4096
Blocks per group: 32768
Inodes per group: 8192
Inode size: 256
Journal blocks: 1024
Label:
Blocks: 65536
Block groups: 2
Reserved block group size: 15
Created filesystem with 970/16384 inodes and 41312/65536 blocks
+ ‘[‘ 0 -ne 0 ‘]’
Install system fs image: out/target/product/panda/system.img
out/target/product/panda/system.img+out/target/product/panda/obj/PACKAGING/recovery_patch_intermediates/recovery_from_boot.p maxsize=274053120 blocksize=4224 total=167387526 reserve=2770944
DroidDoc took 1181 sec. to write docs to out/target/common/docs/doc-comment-check

这样我们需要的ROM就准备好了

二,Flash ROM
1、未插入电源的状态下,拔掉SD卡

插入USB线,串口线(可选)

连接电源

2、执行

guohai@KNIGHT:~/dev/src/android/git/panda/device/ti/panda$ ./usbboot2 ./bootloader.bin 

using built-in 2ndstage.bin
waiting for OMAP44xx device…
reading ASIC ID
CHIP: 4440
IDEN: 0000000000000000000000000000000000000000
MPKH: 0000000000000000000000000000000000000000000000000000000000000000
CRC0: 229e85ba
CRC1: 00000000
sending 2ndstage to target… f0030002
waiting for 2ndstage response…
sending image to target…
looks everything is ok…

注:最后这一句”look everything is ok…”是我自己加在omap4boot源码里的,这里使用的usbboot2就是omap4boot编译出来的

Putty会给出如下反馈
见图01-usbboot.png
01-usbboot

最后一句是Fastboot entered…
就表明板子已经进入了fastboot mode

3、插入SD Card

执行

guohai@KNIGHT:~/dev/src/android/git/panda/device/ti/panda$ fastboot oem format


OKAY [ 0.656s]
finished. total time: 0.656s

Putty会给出如下反馈
见图02-fastboot-oem-format.png
02-fastboot-oem-format

guohai@KNIGHT:~/dev/src/android/git/panda/device/ti/panda$ fastboot flash xloader ./xloader.bin

sending ‘xloader’ (23 KB)…
OKAY [ 0.007s]
writing ‘xloader’…
OKAY [ 0.321s]
finished. total time: 0.328s

见图03-fastboot-flash-xloader.png
03-fastboot-flash-xloader

guohai@KNIGHT:~/dev/src/android/git/panda/device/ti/panda$ fastboot flash bootloader ./bootloader.bin

sending ‘bootloader’ (161 KB)…
OKAY [ 0.015s]
writing ‘bootloader’…
OKAY [ 0.384s]
finished. total time: 0.399s

见图04-fastboot-flash-bootloader.png
04-fastboot-flash-bootloader

验证板子目前是否处于fastboot mode

guohai@KNIGHT:~/dev/src/android/git/panda/device/ti/panda$ fastboot devices

7024000200000001 fastboot

guohai@KNIGHT:~/dev/src/android/git/panda/device/ti/panda$ fastboot erase cache

erasing ‘cache’…
OKAY [103.063s]
finished. total time: 103.063s

guohai@KNIGHT:~/dev/src/android/git/panda/device/ti/panda$ fastboot flash userdata

sending ‘userdata’ (10428 KB)…
OKAY [ 0.585s]
writing ‘userdata’…
OKAY [ 4.786s]
finished. total time: 5.372s

见图05fastboot-erase-cache_flash-userdata.png
05-fastboot-erase-cache_flash-userdata

guohai@KNIGHT:~/dev/src/android/git/panda/device/ti/panda$ fastboot flashall

——————————————–
Bootloader Version…: U-Boot 1.1.4-gedeced79
Baseband Version…..:
Serial Number……..: 7024000200000001
——————————————–
checking product…
OKAY [ 0.001s]
sending ‘boot’ (3750 KB)…
OKAY [ 0.224s]
writing ‘boot’…
OKAY [ 1.993s]
sending ‘recovery’ (4096 KB)…
OKAY [ 0.237s]
writing ‘recovery’…
OKAY [ 2.113s]
sending ‘system’ (163150 KB)…
OKAY [ 9.107s]
writing ‘system’…
OKAY [ 58.941s]
rebooting…

finished. total time: 72.623s

见图06-flash-all.png 07-flash-all-done.png
06-flash-all
07-flash-all-done

到此完成,板子自动重启
稍等一会儿就出现ANDROID的Logo啦

另外据说PLATFORM_VERSION=4.0.9.99.999.9999.99999
就是Jelly Bean,进去之后发现真的就是Jelly Bean

以前编译ICS也是这一样的步骤,只是代码不同,打的patch不同
要参观多图(非高清),请移步http://www.flickr.com/photos/46848122@N08/sets/72157631476114706/

读AOSP的Camera源码之录影中拍摄

写Camera这一系列之前,先把Camera主要的概况介绍下(上一篇没有写,这基本都会是一些比较简单而简短的文字记录)

参照 http://developer.android.com/reference/android/hardware/Camera.html

整个拍照的过程Docs上也有写的很清楚
1. open camera
2. get/set parameters
3. set display orientation
4. set surface
5. start preview
6. take picture
7. 拍照之后preview display会自动停止,如果还想继续拍摄就需要再次执行step 5
8. stop preview
9. release camera

这当中有些是必须的,有些不是

学习Camera最好熟悉几块重要的部分代码,这样比较容易理解,因为这是一个硬件和软件结合比较紧密的话题。
大多数时候我们只需要熟悉各个参数,然后将他们通过set parameter传递给hardware层就能完成我们需要的大部分功能。

$ANDROID_SRC_HOME/frameworks/base/core/java/android/hardware/Camera.java

$ANDROID_SRC_HOME/frameworks/base/core/jni/android_hardware_Camera.cpp

$ANDROID_SRC_HOME/frameworks/base/include/camera/Camera.h
$ANDROID_SRC_HOME/frameworks/base/libs/camera/Camera.cpp

这几个文件已经基本可以让我们从APP的层面了解Camera了

Camera最重要的任务就是拍摄出最好的照片,APP的parameter设置下去,发现出来的片子不是我们想要的,这时就要分析是我们参数下错了,还是底层出错了。
这都是我们APP这层需要考虑的。

对于用户来说,最理想的状态就是什么都不用设置,按下拍摄,就能出来最好的片子,这就是为什么卡片机被发明出来,而且还这么受到欢迎,虽然卡片机还是无法做到什么都不设置,就能出来最佳效果的片子。

概况介绍就到这里,很简单。
下面接着说今天的主题,录影中拍摄

如今Samsung和HTC都打出边录边拍的功能,对于APP来说实现这种功能不难,只要机器的芯片支持这个功能,对于APP来说就比较简单了。

这个功能的学名叫做Video Snapshot

Android有这么一个API

    /**
     * Returns true if video snapshot is supported. That is, applications
     * can call {@link #takePicture(Camera.ShutterCallback,
     * Camera.PictureCallback, Camera.PictureCallback, Camera.PictureCallback)}
     * during recording. Applications do not need to call {@link
     * #startPreview()} after taking a picture. The preview will be still
     * active. Other than that, taking a picture during recording is
     * identical to taking a picture normally. All settings and methods
     * related to takePicture work identically. Ex: {@link
     * #getPictureSize()}, {@link #getSupportedPictureSizes()}, {@link
     * #setJpegQuality(int)}, {@link #setRotation(int)}, and etc. The
     * picture will have an EXIF header. {@link #FLASH_MODE_AUTO} and {@link
     * #FLASH_MODE_ON} also still work, but the video will record the flash.
     *
     * Applications can set shutter callback as null to avoid the shutter
     * sound. It is also recommended to set raw picture and post view
     * callbacks to null to avoid the interrupt of preview display.
     *
     * Field-of-view of the recorded video may be different from that of the
     * captured pictures.
     *
     * @return true if video snapshot is supported.
     */
android.hardware.Camera.Parameters.isVideoSnapshotSupported()

这个API的注释把使用过程都说的很清楚,跟普通拍摄没什么两样,需要注意的就是在做Video Snapshot的时候不需要start preview就可以拍摄,因为录影的过程中,整个preview一直是活跃的。不会像普通的拍摄一样,每拍摄一次preview就会停止,需要我们再次start preview。

这项功能的关键在于厂商的芯片的好坏,比如能否在录影过程中的拍摄也支持full resolution等等。

AOSP的Camera当中就通过这行代码来实现这个功能

Log.v(TAG, "Video snapshot start");
mCameraDevice.takePicture(null, null, null, new JpegPictureCallback(loc));

更多可以参见

$ANDROID_SRC_HOME/framework/packages/apps/Camera/src/com/android/camera/VideoCamera.java

很简单不是?