2014年11月2日星期日

imx6 user guide

Freescale Semiconductor
Document Number: AUG
Rev kk4.4.2_1.0.0-ga, 07/2014
Android User's Guide
Contents
1 Overview 1 Overview....................................................................1
This document explains how to use the Android release
package. 2 Preparation................................ ................................ 1
3 Building Android for i.MX................ ....................... 5
It describes how to set up the environment, how to apply i.MX
Android patches, and how to build the Android system. It also
describes how to download prebuilt images to a target storage
device and set up the correct hardware/software boot
configurations to boot the system. In addition, it provides the
information on how to get Android source from Google, and
what the device storage usage and boot options are. For more
information, see source.android.com/source/building.html. 4 Downloading Images..................... ......................... 12
5 Booting................................ ................................... 16
2 Preparation
2.1 Setting up your computer
To build the Android source files, you will need to use a Linux
computer.
You also need to use the 10.10 or 11.04 64 bit version of
Ubuntu which are the most tested OS for the Android kk4.4.2
build.
© 2014 Freescale Semiconductor, Inc.Preparation
After installing the Linux computer, you need to check whether you have all the necessary packages installed for an Android
build. See "Setting up your machine" on the Android website source.android.com/source/initializing.html.
In addition to the packages requested on the Android website, the following packages are also needed:
$
$
$
$
$
$
$
sudo
sudo
sudo
sudo
sudo
sudo
sudo
apt-get install uuid uuid-dev
apt-get install zlib1g-dev liblz-dev
apt-get install liblzo2-2 liblzo2-dev
add-apt-repository ppa:git-core/ppa
apt-get update
apt-get install git-core curl
apt-get install uboot-mkimage
NOTE
If you have trouble in installing the Sun's JDK in Ubuntu, refer to
2.2 Unpacking Android release package
After you have set up a Linux computer, unpack the Android release package.
After you have setup a Linux computer, unpack the Android release package by using the following commands:
# cd /opt (or any other directory where you placed the android_kk4.4.2_1.0.0-
ga_core_source.tar.gz file)
$ tar xzvf android_kk4.4.2_1.0.0-ga_source.tar.gz
$ cd android_kk4.4.2_1.0.0-ga_core_source/code/
$ tar xzvf kk4.4.2_1.0.0-ga.tar.gz
2.3 Running Android with a prebuilt image
To test Android before building any code, use the prebuilt images from the following packages and go to "Download Images"
and "Boot".
Table 1. Image packages
Image package
Description
android_kk4.4.2_1.0.0-ga_core_image_6qsabresd.tar.gz The table below shows the prebuilt image for i.MX 6Dual/
6Quad SABRE-SD board and platform and i.MX 6Solo/
6DualLite SABRE-SD platform, which has basic Android
features.
android_kk4.4.2_1.0.0-ga_core_image_6qsabreauto.tar.gz The table below shows the prebuilt image for i.MX 6Dual/
6Quad and i.MX 6Solo/6DualLite SABRE-AI platform, which
has basic Android features.
android_kk4.4.2_1.0.0-ga_core_image_6slevk.tar.gz The table below shows the prebuilt image for the i.MX
6SoloLite EVK board, which has basic Android features.
android_kk4.4.2_1.0.0-ga_full_image_6qsabresd.tar.gz The table below shows the prebuilt image for i.MX 6Dual/
Quad and i.MX 6DualLite SABRE-SD board, which includes
Freescale extended features.
For more information and details about the Freescale
Extended Multimedia Feature Package available for this
release, refer to the Android Release Notes.
Table continues on the next page...
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
2
Freescale Semiconductor, Inc.Preparation
Table 1. Image packages (continued)
android_kk4.4.2_1.0.0-ga_full_image_6qsabreauto.tar.gz
The table below shows the prebuilt image for i.MX 6Dual/
Quad and i.MX 6DualLite/Solo SabreAI board, which includes
Freescale extended features.
For more information and details about the Freescale
Extended Multimedia Feature Package available for this
release, refer to the Android Release Notes.
The following tables list the detailed contents of android_kk4.4.2_1.0.0-ga_core_image_6qsabresd.tar.gz and
android_kk4.4.2_1.0.0-ga_full_image_6qsabresd.tar.gz image packages.
The table below shows the prebuilt images to support the system boot from eMMC on i.MX 6Dual/6Quad SABRE-SD board
and platform and i.MX 6Solo/6DualLite SABRE-SD platform.
Table 2. Images for SABRE-SD board and platform eMMC boot
SABRE-SD eMMC image
Description
u-boot-6q.bin The bootloader (with padding) for i.MX 6Dual/6Quad SABRE-
SD board and platform
u-boot-6dl.bin The bootloader (with padding) for i.MX 6Solo/6DualLite
SABRE-SD platform
eMMC/boot.img Boot Image for eMMC
eMMC/system.img System Boot Image
eMMC/recovery.img Recovery Image
The table below shows the prebuilt images to support the system boot from SD on i.MX 6Dual/6Quad and i.MX 6Solo/
6DualLite SABRE-SD boards.
Table 3. Images for SABRE-SD SD
SABRE-SD SD image
Description
u-boot-6q.bin The bootloader (with padding) for i.MX 6Dual/6Quad SABRE-
SD board and platform
u-boot-6dl.bin The bootloader (with padding) for i.MX 6Solo/6DualLite
SABRE-SD platform
SD/boot.img Boot Image for SD
SD/system.img System Boot Image
SD/recovery.img Recovery Image
The table below shows the prebuilt images to support the system boot from TFTP server and NFS rootfs on i.MX 6Dual/
6Quad and i.MX 6Solo/6DualLite SABRE-SD boards.
Table 4. Images for SABRE-SD TFTP and NFS
SABRE-SD TFTP/NFS image
u-boot-6q.bin
Description
The bootloader (with padding) for i.MX 6Dual/6Quad SABRE-
SD board and platform
Table continues on the next page...
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
Freescale Semiconductor, Inc.
3Preparation
Table 4. Images for SABRE-SD TFTP and NFS (continued)
u-boot-6dl.bin The bootloader (with padding) for i.MX 6Solo/6DualLite
SABRE-SD platform
NFS/android_fs.tar.gz NFS rootfs
NFS/uImage Kernel image for TFTP
The following tables list the detailed contents of android_kk4.4.2_1.0.0-ga_core_image_6qsabreauto.tar.gz and
android_kk4.4.2_1.0.0-ga_full_image_6qsabreauto.tar.gz image packages:
The table below shows the prebuilt images to support the system boot from SD on i.MX 6Dual/6Quad and i.MX 6Solo/
6DualLite SABRE-AI boards.
Table 5. Images for SABRE-AI SD boot
SABRE-AI SD image
Description
u-boot-mx6q.bin The bootloader (with padding) for i.MX 6Dual/6Quad SABRE-
AI SD boot
u-boot-mx6dl.bin The bootloader (with padding) for i.MX 6DualLite SABRE-AI
SD boot
u-boot-mx6solo.bin The bootloader (with padding) for i.MX 6Solo SABRE-AI SD
boot
SD/boot.img Boot Image for SD
SD/system.img System Boot Image
SD/recovery.img Recovery Image
The table below shows the prebuilt images to support the system boot from NAND on i.MX 6 series SABRE-AI boards.
Table 6. Images for SABRE-AI NAND boot
SABRE-AI NAND image
Description
u-boot-mx6q-nand.bin The bootloader (with padding) for i.MX 6Dual/6Quad SABRE-
AI NAND boot
u-boot-mx6dl-nand.bin The bootloader (with padding) for i.MX 6DualLite SABRE-AI
NAND boot
u-boot-mx6solo-nand.bin The bootloader (with padding) for i.MX 6Solo SABRE-AI
NAND boot
NAND/boot.img Boot Image for NAND
NAND/android_root.img System Boot Image
NAND/recovery.img Recovery Image
The table below shows the prebuilt images to support the system boot from TFTP server and NFS rootfs on i.MX 6 series
SABRE-AI boards.
Table 7. Images for SABRE-AI TFTP and NFS
SABRE-AI TFTP/NFS image
Description
Table continues on the next page...
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
4
Freescale Semiconductor, Inc.Building Android for i.MX
Table 7. Images for SABRE-AI TFTP and NFS (continued)
u-boot-mx6q.bin The bootloader (with padding) for i.MX 6Dual/6Quad SABRE-
AI SD boot
u-boot-mx6dl.bin The bootloader (with padding) for i.MX 6DualLite SABRE-AI
boot
u-boot-mx6solo.bin The bootloader (with padding) for i.MX 6Solo SABRE-AI SD
boot
NFS/android_fs.tar.gz NFS rootfs
NFS/uImage Kernel image for TFTP
The following tables list the detailed contents of android_kk4.4.2_1.0.0-ga_core_image_6slevk.tar.gz image package.
The table below shows the prebuilt images to support the system boot from SD on i.MX 6SoloLite EVK boards.
Table 8. Images for EVK SD
EVK SD image Description
u-boot-mx6sl.bin Bootloader (with padding) for the i.MX 6SoloLite EVK board
SD/boot.img Boot image for SD
SD/system.img System boot image
SD/recovery.img Recovery image
The table below shows the prebuilt images to support the system boot from TFTP server and NFS rootfs on i.MX 6SoloLite
EVK boards.
Table 9. Images for EVK TFTP and NFS
EVK TFTP/NFS images Description
u-boot-mx6sl.bin Bootloader (with padding) for the i.MX 6SoloLite EVK board
NFS/android_fs.tar.gz NFS rootfs
NFS/uImage Kernel image for TFTP
NOTE
boot.img is an Android image that stores zImage and ramdisk together. It also stores
other information such as the kernel boot command line, machine name, e.g. This
information can be configured in corresponding board's BoardConfig.mk. If you use
boot.img, you do not need uImage and uramdisk.img.
3 Building Android for i.MX
3.1 Getting Android source code (Android/kernel/U-Boot)
The Android source code is maintained as more than 100 gits in the Android repository (android.googlesource.com).
To get the Android source code from Google repo, follow the steps below:
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
Freescale Semiconductor, Inc.
5Building Android for i.MX
$ cd ~
$ mkdir myandroid
$ mkdir bin
$ cd myandroid
$ chmod a+x ~/bin/repo
$ ~/bin/repo init -u https://android.googlesource.com/platform/manifest -b android-4.4.2_r1
$ ~/bin/repo sync # this command loads most needed repos. Therefore, it can take several
hours to load.
Get kk4.4.2_1.0.0-ga kernel source code from Freescale open source git:
$ cd myandroid
$ git clone git://git.freescale.com/imx/linux-2.6-imx.git kernel_imx # the kernel repo is
heavy. Therefore, this process can take a while.
$ cd kernel_imx
$ git checkout kk4.4.2_1.0.0-ga
NOTE
If you are behind a proxy, use socksify to set socks proxy for git protocol.
If you use U-Boot as your bootloader, then you can clone the U-Boot git repository from Freescale open source git:
$
$
$
$
cd myandroid/bootable/bootloader
git clone git://git.freescale.com/imx/uboot-imx.git uboot-imx
cd uboot-imx
git checkout kk4.4.2_1.0.0-ga
3.2 Patch code for i.MX
The patch script (and_patch.sh) requires some basic utilities like awk/sed.
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_kk4.4.2_1.0.0-ga_source .
$ cd ~/myandroid
$ source /opt/android_kk4.4.2_1.0.0-ga_core_source/code/kk4.4.2_1.0.0-ga/and_patch.sh
$ help
2. You should see that the "c_patch" function is available.
$ c_patch /opt/android_kk4.4.2_1.0.0-ga_core_source/code/kk4.4.2_1.0.0-ga
imx_kk4.4.2_1.0.0-ga
Here, "/opt/android_kk4.4.2_1.0.0-ga_source/code/kk4.4.2_1.0.0-ga" is the location of the patches, which is the
directory created when you unzip the release package.
"imx_kk4.4.2_1.0.0-ga" 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 instead of "imx_kk4.4.2_1.0.0-ga".
3. If everything is OK, "c_patch" will generate the following output to indicate the successful patch:
**************************************************************
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
6
Freescale Semiconductor, Inc.Building Android for i.MX
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 your Linux computer, install them first.
3.3 Building Android images
After applying all i.MX patches, build the U-Boot, kernel, and Android image.
After applying all i.MX patches, build the U-Boot, kernel, and Android images by using the steps below:
$ cd ~/myandroid
$ source build/envsetup.sh
$ lunch sabresd_6dq-user
$ make 2>&1 | tee build_sabresd_6dq_android.log
"sabresd_6dq" is the product name (see ~/myandroid/device/fsl/product)
After build, check build_*_android.log to make sure no build error.
#Build Android images for i.MX 6 SABRE-SD boards
$ lunch sabresd_6dq-user
$ make 2>&1 | tee build_sabresd_6dq_android.log
#Build Android images for i.MX 6 SABRE-AI boards
$ lunch sabreauto_6dq-user
$ make 2>&1 | tee build_sabreauto_6dq_android.log
#Build Android images for i.MX 6SoloLite EVK boards
$ lunch evk_6sl-user
$ make 2>&1 | tee build_evk_6sl_android.log
For BUILD_ID & BUILD_NUMBER, add a buildspec.mk in your ~/myandroid directory. For details, see the Android
Frequently Asked Questions document.
For i.MX 6Dual/6Quad SABRE-SD and i.MX 6DualLite SABRE-SD boards, we use the same build configuration. The two
boards share the same kernel/system/recovery images with the exception of the U-Boot image. The following outputs are
generated by default in myandroid/out/target/product/sabresd_6dq:
root/ is a root file system (including init, init.rc, etc). Mounted at /
system/ is an Android system binary/libraries. Mounted at /system.
data/ is an Android data area. Mounted at /data.
recovery/ is a root file system when booting in "recovery" mode. Not used directly.
boot.img is a composite image which includes the kernel zImage, ramdisk, and boot parameters.
ramdisk.img is a ramdisk image generated from "root/". Not used directly.
system.img is an EXT4 image generated from "system/". It can be programmed to "SYSTEM" partition on SD/eMMC
card with "dd".
• recovery.img is an EXT4 image generated from "recovery/". It can be programmed to "RECOVERY" partition on SD/
eMMC card with "dd".
• u-boot-6q.bin is an U-Boot image with padding for i.MX 6Dual/6Quad SABRE-SD.
• u-boot-6dl.bin is an U-Boot image with padding for i.MX 6DualLite SABRE-SD.
NOTE
Make sure the mkimage is a valid command in your build machine. If not, use the
command below to have it installed:
$sudo apt-get install uboot-mkimage
• To build the U-Boot image separately, see Building U-Boot images.
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
Freescale Semiconductor, Inc.
7Building Android for i.MX
• To build the kernel uImage separately, see Building kernel image.
• To build boot.img, see Building boot.img.
3.3.1 User build mode
For a production release, the Android image should be built in the user mode.
When compared to eng mode, it will have the following differences:
• It will have limited access due to security reasons, and it will lack certain debug tools.
• It will install modules tagged with user, and APKs& tools according to product definition files, which are in
PRODUCT_PACKAGES in device/fsl/imx6/imx6.mk.
If you need to add your customized package, add the package MODULE_NAME or PACKAGE_NAME to this list.
• Set ro.secure=1, and ro.debuggable=0. adb is disabled by default.
# Build images for i.MX 6 SABRE-SD board
$ make PRODUCT-sabresd_6dq-user 2>&1 | tee build_sabresd_6dq_android.log
# Build Images for i.MX 6 SABRE-AI board
$ make PRODUCT-sabreauto_6q-user 2>&1 | tee build_sabreauto_6dq_android.log
# Build Images for i.MX SoloLite EVK board
$ make PRODUCTevk_6sluser 2>&1 | tee build_evk_6sl_android.log
Or you can use the following commands:
#
$
$
$
$ Build images for i.MX 6 SABRE-SD board
source build/envsetup.sh
lunch sabresd_6dq-user
make
make dist # you can generate ota package with this command.
#
$
$
$
$ Build images for i.MX 6 SABRE-AI board
source build/envsetup.sh
lunch sabreauto_6q-user
make
make dist # you can generate ota package with this command.
#
$
$
$
$ Build images for i.MX 6SoloLite EVK board
source build/envsetup.sh
lunch evk_6sluser
make
make dist # you can generate ota package with this command.
For more Android building information, see source.android.com/source/building.html.
3.3.2 Building Android images for the SD card on the SABRE-SD
board
The default configuration in the source code package takes internal eMMC as the boot storage for i.MX 6Dual/6Quad and
i.MX 6Solo/6DualLite SABRE-SD boards.
The default setting can be changed to make the SD card in SD Slot 3 be the boot storage as shown below:
1. Change the fstab.freescale configure files in device/fsl.git by the following patch, which make sure partitions are
mounted for SD:
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
8
Freescale Semiconductor, Inc.Building Android for i.MX
diff git a/sabresd_6dq/fstab.freescale b/sabresd_6dq/fstab.freescale
index c2b737a..d2e59a3 100644
--- a/sabresd_6dq/fstab.freescale
+++ b/sabresd_6dq/fstab.freescale
@@ 3,12 +3,12 @@
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
-/devices/platform/sdhciesdhcimx.2/mmc_host/mmc1 /mnt/media_rw/extsd vfat defaults
voldmanaged=extsd:auto
+/devices/platform/sdhciesdhcimx.1/mmc_host/mmc2 /mnt/media_rw/extsd vfat defaults
voldmanaged=extsd:auto
/devices/platform/fslehci/mnt/udisk vfat defaults voldmanaged=sdcard:auto
-/dev/block/mmcblk0p5
/system
ext4
ro
wait
-/dev/block/mmcblk0p4
/data
ext4
nosuid,nodev,nodiratime,noatime,nomblk_io_submit,noauto_da_alloc,errors=pa
nic
wait,encryptable=footer
-/dev/block/mmcblk0p6
/cache
ext4
nosuid,nodev,nomblk_io_submit
wait
-/dev/block/mmcblk0p7 /device
ext4
ro,nosuid,nodev
wait
-/dev/block/mmcblk0p1 /boot
emmc
defaults
defaults
-/dev/block/mmcblk0p2 /recovery
emmc
defaults
defaults
-/dev/block/mmcblk0p8 /misc
emmc
defaults
defaults
+/dev/block/mmcblk1p5 /system
ext4
ro
wait
+/dev/block/mmcblk1p4 /data
ext4
nosuid,nodev,nodiratime,noatime,nomblk_io_submit,noauto_da_alloc,errors=pa
nic
wait,encryptable=footer
+/dev/block/mmcblk1p6 /cache
ext4
nosuid,nodev,nomblk_io_submit
wait
+/dev/block/mmcblk1p7 /device
ext4
ro,nosuid,nodev
wait
+/dev/block/mmcblk1p1 /boot
emmc
defaults
defaults
+/dev/block/mmcblk1p2 /recovery emmc defaults
defaults
+/dev/block/mmcblk1p8 /misc
emmc
defaults
defaults
2. Follow the 3.3.1 to build the images.
3.3.3 Building Android images for NAND on the SABRE-AI board
The default configuration in the source code package takes SD card as the boot storage for i.MX 6 series SABRE-AI boards.
The default setting can be changed to make the NAND Flash in U19 be the boot storage as shown below:
make PRODUCT-sabreauto_6q-user BUILD_TARGET_FS=ubifs
NOTE
Make sure the uuid-dev is installed in your build machine (/usr/lib/x86_64-linux-gnu/
uuid.so). If not, please follow the command below to have it installed:
$sudo apt-get install uuid-dev
$sudo apt-get install liblzo2-dev
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
Freescale Semiconductor, Inc.
9Building Android for i.MX
3.4 Building U-Boot images
After you set up U-Boot using the steps outlined above, you can find the tool (mkimage) under tools/.
$ cd ~/myandroid/bootable/bootloader/uboot-imx
$ export ARCH=arm
$ export CROSS_COMPILE=~/myandroid/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
For i.MX 6Quad SABRE-SD:
$ make mx6q_sabresd_android_config
$ make
For i.MX 6DualLite SABRE-SD:
$ make mx6dl_sabresd_android_config
$ make
Command to build for i.MX 6Quad/DualLite/Solo SABRE-AI board is:
$ make distclean
For i.MX 6Quad SABRE-AI SD:
$ make mx6q_sabreauto_android_config
$ make
For i.MX 6Quad SABRE-AI NAND:
$ make mx6q_sabreauto_nand_android_config
$ make
For i.MX 6DualLite SABRE-AI SD:
$ make mx6dl_sabreauto_android_config
$ make
For i.MX 6DualLite SABRE-AI NAND:
$ make mx6dl_sabreauto_nand_android_config
$ make
For i.MX 6Solo SABRE-AI SD:
$ make mx6solo_sabreauto_android_config
$ make
For i.MX 6SoloLite EVK SD:
$ make mx6sl_evk_android_config
$ make
"u-boot.bin" is generated if you have a successful build. The above u-boot.bin has 1KB padding at the head of the file, for
example: first executable instruction is at the offset 1KB. If you want to generate a no-padding image, you need to implement
the dd command specified below in host.
$ sudo dd if=./u-boot.bin of=./u-boot-no-padding.bin bs=1024 skip=1; sync
Usually the no-padding U-Boot image is used in the SD card, for example, program the no-padding U-Boot image into 1KB
offset of SD card so that you do not overwrite the MBR (including partition table) within first 512B on the SD card.
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
10
Freescale Semiconductor, Inc.Building Android for i.MX
NOTE
Any image that should be loaded by U-Boot must have an unique image head. For
example, data must be added at the head of the loaded image to tell U-Boot about the
image (i.e., it's a kernel, or ramfs, etc) and how to load the image (i.e., load/execute
address). Before you can load any image into RAM by U-Boot, you need a tool to add
this information and generate a new image which can be recognized by U-Boot. The tool
is delivered together with U-Boot. After you set up U-Boot using the steps outlined
above, you can find the tool (mkimage) under tools/. The process of using mkimage to
generate an image (for example, kernel image and ramfs image), which is to be loaded by
U-Boot, is outlined in the subsequent sections of this document.
3.5 Building kernel image
Kernel image will be built out while building the Android root file system.
If you do not need to build the kernel image, you can skip this section.
To run Android using NFS, or from SD, build the kernel with the default configuration as described below:
Assume you had already built U-Boot. mkimage was generated under myandroid/bootable/bootloader/uboot-imx/tools/ and it
is in your PATH.
$ export PATH=~/myandroid/bootable/bootloader/uboot-imx/tools:$PATH
$ cd ~/myandroid/kernel_imx
$ echo $ARCH && echo $CROSS_COMPILE
Make sure you have those two environment variables set. If the two variables are not set, set them as:
$
$
#
#
$
#
$
$
export ARCH=arm
export CROSS_COMPILE=~/myandroid/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
Generate ".config" according to default config file under arch/arm/configs.
to build the kernel image for i.MX6DQ, DL, and Solo
make imx6_android_defconfig
to build the kernel image for i.MX6SoloLite
make imx6s_android_defconfig
make uImage
With a successful build in either of the above case, the generated kernel image is ~/myandroid/kernel_imx/arch/arm/boot/
uImage.
3.6 Building boot.img
boot.img and booti are default booting commands.
As outlined in Running Android with a prebuilt image, we use boot.img and booti as default commands to boot, not the
uramdisk and uImage we used before.
You can use this command to generate boot.img under Android environment:
#
$
$
$
$ Boot image for SABRE-SD board
cd ~/myandroid
source build/envsetup.sh
lunch sabresd_6dq-user
make bootimage
#
$
$
$ Boot image for SABRE-AI board
source build/envsetup.sh
lunch sabreauto_6q-user
make bootimage
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
Freescale Semiconductor, Inc.
11Downloading Images
#
$
$
$
Boot image for i.MX6SoloLite EVK board
source build/envsetup.sh
lunch evk_6sl-user
make bootimage
4 Downloading Images
i.MX Android can be booted up from MMC/SD and NFS (networking).
i.MX Android can be booted up in the following ways:
1. Boot from MMC/SD
2. Boot from NFS (networking)
3. Boot from NAND for SABRE-AI board
Before boot, you should program the bootloader, kernel, ramdisk, and rootfs images into the main storage device (MMC/SD,
TF or NAND), or unpack the NFS root filesystem into the NFS server root.
The following download methods are supported for i.MX 6Dual/6Quad SABRE-SD and i.MX 6Solo/6DualLite SABRE-SD
boards:
• MFGTool to download all images to MMC/SD card.
• Using dd command to download all images to MMC/SD card.
4.1 System on MMC/SD
The images needed to create and Android system on MMC/SD can either be obtained from the release package or they can be
built out.
The images needed to create an Android system on MMC/SD are listed below:
U-Boot image: u-boot.bin or u-boot-no-padding.bin
boot image: boot.img
Android system root image: system.img
Recovery root image: recovery.img
The images can either be obtained from the release package or they can be built out.
4.1.1 Storage partitions
To create storage partitions, you can use MFGTool as described in the Android Quick Start Guide, or you can use format
tools in prebuild dir.
The layout of the MMC/SD/TF card for Android system is shown below:
• [Partition type/index] is which defined in the MBR.
• [Name] is only meaningful in Android. You can ignore it when creating these partitions.
• [Start Offset] shows where partition is started, unit in MB.
The SYSTEM partition is used to put the built out Android system image. The DATA is used to put applications' unpacked
codes/data, system configuration database, etc. In normal boot mode, the root file system is mounted from uramdisk. In
recovery mode, the root file system is mounted from the RECOVERY partition.
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
12
Freescale Semiconductor, Inc.Downloading Images
Partition type/index
Name
Start offset
Size
File system
Content
N/A BOOT Loader 1 KB 1 MB N/A bootloader
Primary 1 Boot 8 MB 8 MB boot.img format,
kernel + ramdisk boot.img
Primary 2 Recovery Follow Boot 8MB boot.img format,
kernel + ramdisk recovery.img
Logic 5 (Extended 3) SYSTEM Follow
Recovery 512 MB EXT4. Mount as /
system Android system files under /
system/ dir.
Logic 6 (Extended 3) CACHE Follow
SYSTEM. 512 MB EXT4. Mount as /
cache. Android cache for image
store of OTA.
Logic 7 Device follow CACHE 8 MB Ext4. To Store MAC address files.
(Extended 3)
Logic 8
Mount at /vender.
Misc
(Extended 3)
Primary 4
Follow
4M N/A For recovery store
bootloader message,
reserve.
Total - Other
images EXT4. Mount at /
data. Application data storage for
the system application and
for internal media partition
in /mnt/sdcard/ dir.
Device
DATA
Follow Misc.
There is a shell script mksdcard.sh.tar in MFGTool-Dir\Profiles\MX6DL Linux Update\OS Firmware.
The script below can be used to partition a SD card as shown in the partition table above:
$ cd ~/myandroid/
$ sudo chmod +x ./device/fsl/common/tools/fsl-sdcard-partition.sh
$ sudo ./device/fsl/common/tools/fsl-sdcard-partition.sh /dev/sdX
NOTE
• The minimum size of SD card is 2GB.
• /dev/sdxN, the x is the disk index from 'a' to 'z'. That may be different on each
Linux computer.
• The default images and source code in this release only support boot from eMMC
device for i.MX 6Dual/6Quad SABRE-SD and i.MX 6Solo/6DualLite SABRE-SD.
If you want to boot it from the external SD card, see Section 3.3.2 "Building
Android images for the SD card on the SABRE-SD board".
• Unmount all the SD card partitions before running the script.
4.1.2 Downloading images with MFGTool
MFGTool can be used to download all images into a target device.
It is a quick and easy tool for downloading images. See Android Quick Start Guide for detailed description of MFGTool.
4.1.3 Downloading images with dd utility
The Linux utility "dd" on Linux computer can be used to download the images into the MMC/SD/TF card.
Before downloading, ensure that your MMC/SD/TF card partitions are created as described in Storage partitions.
All partitions can be recognized by the Linux computer. To download all images into the card, use the commands below:
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
Freescale Semiconductor, Inc.
13Downloading Images
Download the U-Boot image:
# sudo dd if=u-boot.bin of=/dev/sdx bs=1K skip=1 seek=1; sync
Or If you're using no padding uboot image:
# sudo dd if=u-boot-no-padding.bin of=/dev/sdx bs=1K seek=1; sync
Download the boot image:
# sudo dd if=boot.img of=/dev/sdx1; sync
Download the android system root image:
# sudo dd if=system.img of=/dev/sdx5; sync
Download the android recovery image:
# sudo dd if=recovery.img of=/dev/sdx2; sync
4.2 System on NFS
Android support runs the system on NFS root file system.
We can put the entire Android root system in NFS, and we can load kernel image from TFTP server.
You must have a computer that has NFS and TFTP server, with their root directory set up correctly, for example, /opt/tftproot
for TFTP root, and /opt/nfsroot for NFS root.
4.2.1 Setting up the TFTP and NFS root
After you set up the TFTP/NFS server, put the kernel image into the TFTP server root directory and the Android file system
files into the NFS server root directory.
For kernel image, use uImage instead of zImage.
• If you are using a prebuilt image, ensure that you pick up the correct uImage (see "Prebuilt image for using U-Boot").
• If you are building your own image, ensure that you have generated a uImage (see "Generate uImage to be loaded by
U-Boot").
Copy uImage to the TFTP server root directory. For example:
$ cp your_uImage /opt/tftproot/
Set up the Android file system (take i.MX 6Dual/6Quad SABRE-SD or i.MX 6Solo/6DualLite SABRE-SD as an example):
• If you are using a prebuilt image, unzip the Android zip file (see "Prebuilt image for using U-Boot") to the NFS server
root. For example:
$ cd /opt/android_kk4.4.2_1.0.0-ga_image_6qsabresd/NFS
$ tar xzvf ./android_fs.tar.gz
$ cd android_fs
$ rm -rf /opt/nfsroot/*
$ cp -r * /opt/nfsroot/*
• If you built out your own Android image, copy the generated Android files to the NFS root manually. For example:
$
$
$
$
cd
rm
cp
cp
~/myandroid
-rf /opt/nfsroot/*
-r out/target/product/sabresd_6dq/root/* /opt/nfsroot/
-r out/target/product/sabresd_6dq/system/* /opt/nfsroot/system/
NOTE
Since the NFS uses system, data, and cache folders under /opt/nfsroot/, we have to
change some settings and command sequence in /opt/nfsroot/init.rc and /opt/nfsroot/
init.freescale.rc. Since the framework will clear ethernet's IP when suspended, which
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
14
Freescale Semiconductor, Inc.Downloading Images
causes resume failure, the system property ethernet.clear.ip should be set to "no" in /opt/
nfsroot/init.rc. For example:
--- a/opt/nfsroot/init.rc
+++ b/opt/nfsroot/init.rc
@@ -144,7 +144,6 @@ loglevel 3
on post-fs
# once everything is setup, no need to modify /
-mount rootfs rootfs / ro remount
# We chown/chmod /cache again so because mount is run as root + defaults
chown system cache /cache
chmod 0770 /cache
@@ -370,6 +369,7 @@ on boot
class_start core
class_start main
+class_start late_start
on property:sys.boot_completed=1
# Set default CPU frequency governor
@@ -400,8 +400,6 @@ on property:sys.interactive="active"
chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/input_boost
-on nonencrypted
-class_start late_start
on charger
class_start charger
--- a/opt/nfsroot/init.freescale.rc
+++ b/opt/nfsroot/init.freescale.rc
@@ -93,6 +93,7 @@ on boot
# No bluetooth hardware present
setprop hw.bluetooth 0
setprop wlan.interface wlan0
+setprop ro.nfs.mode yes
# mount the debugfs
mount debugfs none /sys/kernel/debug/
@@ -126,6 +127,6 @@ service iprenew_wlan0 /system/bin/dhcpcd -n
disabled
oneshot
-on fs
+#on fs
# mount ext4 partitions
-mount_all /fstab.freescale
+#mount_all /fstab.freescale
4.3 System on NAND for the SABRE-AI board
The images needed to create an Android system on NAND are listed below:
U-Boot image: u-boot-mx6q-nand.bin, u-boot-mx6dl-nand.bin, u-boot-mx6solo-nand.bin
Boot image: boot.img
Android system root image: android_root.img
Recovery root image: recovery.img
The images can either be obtained from the release package or they can be built out.
4.3.1 Storage partitions on NAND
The layout of the NAND for Android system is shown below:
• [Partition type/index] is which defined in the MBR.
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
Freescale Semiconductor, Inc.
15Booting
• [Name] is only meaningful in Android. You can ignore it when creating these partitions.
• [Start Offset] shows where partition is started, unit in MB.
The SYSTEM partition is used to put the built out Android system image. The DATA is used to put the application's
unpacked codes/data, system configuration database, etc. In normal boot mode, the root file system is mounted from
uramdisk. In recovery mode, the root file system is mounted from the RECOVERY partition.
Partition type/index
Name
Start offset
Size
File system
Content
MTD0 BOOT Loader 0 16MB N/A bootloader
MTD1 Boot 16M 16MB boot.img format,
kernel + ramdisk boot.img
MTD2 Recovery Follow Boot 128MB boot.img format,
kernel + ramdisk recovery.img
MTD3(ubi0:system) SYSTEM Follow
Recovery 300MB ubifs. Mount as /
system Android system files under /
system/ dir.
MTD3(ubi0:cache) CACHE Follow
SYSTEM. 200MB ubifs. Mount as /
cache Android cache for image
store of OTA.
MTD3(ubi0:device) Vendor Follow
CACHE. 10 MB ubifs. Mount at /
vender For Store MAC address files.
MTD3(ubi0:data) Data follow Vendor 300MB ubifs Application data storage for
system application. And for
internal media partition,
in /mnt/sdcard/ dir.
Mount at /vender.
To create storage partitions, you can use MFGTool as described in the Android Quick Start Guide.
4.3.2 Downloading images with MFGTool for NAND
MFGTool can be used to download all images into a target device.
It is a quick and easy tool for downloading images. See Android Quick Start Guide for detailed description of MFGTool for
NAND.
5 Booting
This chapter describes booting from MMC/SD, NAND, TFTP and NFS.
5.1 Booting from MMC/SD
This section describes booting from MMC/SD on the SABRE-SD board, on the SABRE-AI board, and on the EVK board.
5.1.1 Booting from MMC/SD on the SABRE-SD board
This section contains boot switch information and steps needed to bootup from MMC/SD.
The following table lists the boot switch settings for different boot methods:
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
16
Freescale Semiconductor, Inc.Booting
download Mode(MFGTool mode) (SW6) 00001100 (from 1-8 bit)
eMMC 4-bit (MMC3) boot (SW6) 11100110 (from 1-8 bit)
eMMC 8-bit (MMC3) boot (SW6) 11010110 (from 1-8 bit)
MMC4 (SD2) boot (SW6) 10000010 (from 1-8 bit)
MMC2 (SD3) boot (SW6) 01000010 (from 1-8 bit)
Boot from eMMC
Change the board boot switch to eMMC 4-bit mode and make (SW6) 11100110 (from 1-8 bit). Or change (SW6) 11100110
(from 1-8 bit) for 8-bit boot mode.
The default environment in boot.img is booting from eMMC. If you want to use the default environment in boot.img, you can
use the following command:
U-Boot > setenv bootargs
To clear the bootargs env, you can use the following commands:
U-Boot > setenv fastboot_dev mmc3 [eMMC as fastboot deivce]
U-Boot > setenv bootcmd booti mmc3
[Load the boot.img from eMMC]
U-Boot > setenv bootargs console=ttymxc0,115200 init=/init video=mxcfb0:dev=ldb,bpp=32
video=mxcfb1:off video=mxcfb2:off fbmem=10M fb0base=0x27b00000 vmalloc=400M
androidboot.console=ttymxc0 androidboot.hardware=freescale #[Optional]
U-Boot > saveenv
#[Save the environments]
NOTE
The mmcX value changes depending on the boot mode. These are the correct values:
• eMMC --> mmc3
• MMC4 (SD2) --> mmc1
• MMC2 (SD3) --> mmc2
bootargs env is an optional setting for booti. The boot.img includes a default bootargs,
which will be used if there is no definition of the bootargs env.
Some SoCs on SABRE-SD boards do not have MAC address fused.
Therefore, if you want to use FEC in U-Boot, set the following environment:
U-Boot > setenv ethaddr 00:04:9f:00:ea:d3
MAC address]
U-Boot > setenv fec_addr 00:04:9f:00:ea:d3
MAC address]
#[setup the
$[setup the
Boot from SD card
Change the board boot switch to MMC2 (SD3) boot: (SW6) 01000010 (from 1-8 bit). To clear the bootargs env and set up
the booting from SD card in SD slot 3, you can use the following command:
U-Boot > setenv fastboot_dev mmc2 [eMMC as fastboot deivce]
U-Boot > setenv bootcmd booti mmc2
[Load the boot.img from SD card]
U-Boot > setenv bootargs console=ttymxc0,115200 init=/init video=mxcfb0:dev=ldb,bpp=32
video=mxcfb1:off video=mxcfb2:off fbmem=10M fb0base=0x27b00000 vmalloc=400M
androidboot.console=ttymxc0 androidboot.hardware=freescale #[Optional]
U-Boot > saveenv
#[Save the environments]
NOTE
bootargs env is an optional setting for booti. The boot.img includes a default bootargs,
which will be used if there is no definition of the bootargs env.
Some SoCs on SABRE-SD boards do not have MAC address fused.
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
Freescale Semiconductor, Inc.
17Booting
Therefore, if you want to use FEC in U-Boot, set the following environment:
U-Boot > setenv ethaddr 00:04:9f:00:ea:d3
U-Boot > setenv fec_addr 00:04:9f:00:ea:d3
#[setup the MAC address]
$[setup the MAC address]
5.1.2 Booting from MMC/SD on the SABRE-AI board
This section contains boot switch information and steps needed to bootup from MMC/SD.
The following table lists the boot switch settings for different boot methods on i.MX 6 series SABRE-AI boards.
download Mode(MFGTool mode) (S3) 0101 (from 1-4 bit)
SD on CPU Board (S1) 0100100000 (from 1-10 bit)
(S2) 0010 (from 1-4 bit)
(S3) 0010 (from 1-4 bit)
Boot from SD
Chang the board boot switch to (S3, S2, S1) 0010, 0010,0100100000 (from 1 bit).
The default environment in boot.img is booting from SD. If you want to use the default environment in boot.img, you can use
the following command:
U-Boot > setenv bootargs
To clear the bootargs env, you can use the following commands:
U-Boot > setenv bootcmd booti mmc2
#[Load the boot.img from SD]
U-Boot > setenv bootargs console=ttymxc3,115200 init=/init video=mxcfb0:dev=ldb,bpp=32
video=mxcfb1:off video=mxcfb2:off fbmem=10M vmalloc=400M androidboot.console=ttymxc3
androidboot.hardware=freescale #[Optional]
U-Boot > saveenv
#[Save the environments]
NOTE
bootargs env is an optional setting for booti. The boot.img includes a default bootargs,
which will be used if there is no definition of the bootargs env.
Some SoCs on SABRE-AI boards do not have MAC address fused.
Therefore, if you want to use FEC in U-Boot, set the following environment:
U-Boot > setenv ethaddr 00:04:9f:00:ea:d3
MAC address]
U-Boot > setenv fec_addr 00:04:9f:00:ea:d3
MAC address]
#[setup the
$[setup the
5.1.3 Booting from SD on the i.MX6SoloLite EVK board
Below are the Boot Switch settings to control the boot storage:
download Mode(MFGTool mode) SW3: 01000000(from 1-8 bit) SW4: 00101100(from 1-8 bit)
SW5: 00000000(from 1-8 bit) Boot_Mode: 10(from 1-2bit)
SD boot SW3: 01000000(from 1-8 bit) SW4: 00101100(from 1-8 bit)
SW5: 00000000(from 1-8 bit) Boot_Mode: 01(from 1-2bit)
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
18
Freescale Semiconductor, Inc.Booting
Boot from SD
Chang the board Boot_Mode switch to 01(from 1-2bit) and (SW3,4,5) 01000000 0010110000000000(from 1-8 bit).
The default environment in boot.img is booting from SD. If you want to use default enviroment in boot.img, you can use the
following command:
UBoot > setenv bootargs
To clear the bootargs env, you can use the following command:
UBoot > setenv bootcmd booti mmc1
UBoot > setenv bootargs console=ttymxc0,115200 init=/init
androidboot.console=ttymxc0 video=mxc_elcdif_fb:bpp=32
androidboot.hardware=freescale csi
[Optional]
UBoot > saveenv
[Save the environments]
5.2 Booting from NAND
This section contains boot switch information and steps needed to bootup from MMC/SD.
The following table lists the boot switch settings for NAND boot on i.MX 6 series SABRE-AI boards.
download Mode (MFGTool mode) (S3) 0101 (from 1-4 bit)
NAND (Micro 29F8G08ABABA) (S3) 0010 (from 1-4 bit)
(S2) 0001 (from 1-4bit)
(S1) 0001000000 (from 1-10 bit)
Boot from NAND
Change the board boot switch to (S3, S2,S1) 0010, 0001,0001000000 (from 1bit) on an i.MX 6 series SABRE-AI board.
The default environment in boot.img is booting from NAND. If you want to use the default environment in boot.img, you can
use the following command:
U-Boot > setenv bootargs
To clear the bootargs env, you can use the following commands:
U-Boot > setenv bootcmd nand read 0x12800000 0x1000000 0x800000;booti 0x12800000
#[Load the boot.img from NAND]
U-Boot > setenv bootargs console=ttymxc3,115200 init=/init video=mxcfb0:dev=ldb,bpp=32
video=mxcfb1:off video=mxcfb2:off fbmem=10M vmalloc=400M androidboot.console=ttymxc3
androidboot.hardware=freescale mtdparts=gmi-nand:16m(bootloader),16m(bootimg),
128m(recovery),-(root) ubi.mtd3 #[Optional]
U-Boot > saveenv
$[Save the environments]
NOTE
bootargs env is an optional setting for booti. The boot.img includes a default bootargs,
which will be used if there is no definition of the bootargs env.
Some SoCs on SABRE-AI boards do not have MAC address fused.
Therefore, if you want to use FEC in U-Boot, set the following environment:
U-Boot > setenv ethaddr 00:04:9f:00:ea:d3
MAC address]
#[setup the
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
Freescale Semiconductor, Inc.
19Booting
U-Boot > setenv fec_addr 00:04:9f:00:ea:d3
MAC address]
$[setup the
5.3 Booting from TFTP and NFS
Set up the U-Boot environment for loading kernel from TFTP and mounting NFS as root file system after the U-Boot shell.
5.3.1 i.MX 6Quad and i.MX 6DualLite SABRE-SD platforms
U-Boot > setenv loadaddr 0x10800000
U-Boot > setenv bootfile uImage
U-Boot > setenv serverip <your server ip>
#[Your TFTP/NFS server ip]
U-Boot > setenv nfsroot <your rootfs>
#[Your rootfs]
U-Boot > setenv bootcmd 'dhcp;bootm'
#[load kernel from TFTP and boot]
U-Boot > setenv bootargs console=ttymxc0,115200 init=/init ip=dhcp nfsroot=${serverip}:/$
{nfsroot} video=mxcfb0:dev=ldb,bpp=32 video=mxcfb1:off video=mxcfb2:off fbmem=10M
fb0base=0x27b00000 vmalloc=400M androidboot.console=ttymxc0 androidboot.hardware=freescale
U-Boot > saveenv
#[Save the environments]
After you have configured these settings, reboot the board, and let U-Boot run the bootcmd environment to load and run the
kernel.
For the first-time boot, it takes some time to finish and get to the Android UI.
5.3.2 i.MX 6Quad and i.MX 6DualLite SABRE-AI platforms
U-Boot > setenv loadaddr 0x10800000
U-Boot > setenv bootfile uImage
U-Boot > setenv serverip <your server ip>
#[Your TFTP/NFS server ip]
U-Boot > setenv nfsroot <your rootfs>
#[Your rootfs]
U-Boot > setenv bootcmd 'dhcp;bootm'
#[load kernel from TFTP and boot]
U-Boot > setenv bootargs console=ttymxc3,115200 init=/init ip=dhcp nfsroot=${serverip}:/$
{nfsroot} video=mxcfb0:dev=ldb,bpp=32 video=mxcfb1:off video=mxcfb2:off fbmem=10M
fb0base=0x27b00000 vmalloc=400M androidboot.console=ttymxc3 androidboot.hardware=freescale
U-Boot > saveenv
#[Save the environments]
After you configure these settings, reboot the board, and let u-boot run the bootcmd environment to load and run the kernel.
For the first-time boot, it takes some time to finish and get to the Android UI.
5.3.3 i.MX 6SoloLite EVK platform
UBoot > setenv loadaddr 0x80800000
UBoot > setenv bootfile uImage
UBoot > setenv serverip <your server ip>
#[Your TFTP/NFS server ip]
UBoot > setenv nfsroot <your rootfs>
#[Your rootfs]
UBoot > setenv bootcmd 'dhcp;bootm'
#[load kernel from TFTP and boot]
UBoot > setenv bootargs console=ttymxc0,115200 init=/init rw nfsroot=${serverip}:/${nfsroot}
androidboot.console=ttymxc0 csi
UBoot > saveenv
After you configure these settings, reboot the board, and let u-boot run the bootcmd environment to load and run the kernel.
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
20
Freescale Semiconductor, Inc.Booting
For the first-time boot, it takes some time to finish and get to the Android UI.
5.4 Boot-up configurations
This section explains the common U-Boot environments used for NFS, MMC/SD boot, and kernel command line.
5.4.1 U-Boot environment
If you do not define the bootargs environment, it will use the default bootargs inside the image.
ethaddr/fec_addr is a MAC address of the board.
serverip is an IP address of the TFTP/NFS server.
loadaddr/rd_loadaddr is the kernel/initramfs image load address in memory.
bootfile is the name of the image file loaded by "dhcp" command, when you are using TFTP to load kernel.
bootcmd is the first variable to run after U-Boot boot.
bootargs is the kernel command line, which the bootloader passes to the kernel. As described in Kernel command line
(bootargs), bootargs env is optional for booti. boot.img already has bootargs. If you do not define the bootargs env, it
will use the default bootargs inside the image. If you have the env, it will be used.
If you want to use default env in boot.img, you can use the following command to clear the bootargs env.
> setenv bootargs
• dhcp: get ip address by BOOTP protocol, and load the kernel image ($bootfile env) from TFTP server.
• booti:
booti command will parse the boot.img header to get the zImage and ramdisk. It will also pass the bootargs as needed
(it will only pass bootargs in boot.img when it can't find "bootargs" var in your U-Boot env). To boot from mmcX, you
need to do the following:
> booti mmcX
To read the boot partition (the partition store boot.img, in this case, mmcblk0p1), the X was the MMC bus number,
which is the hardware MMC bus number, in i.MX 6Dual/6Quad SABRE-SD and i.MX 6Solo/6DualLite SABRE-SD
boards. eMMC is mmc3.
You can also add partition ID after mmcX.
> booti mmcX boot
#
> booti mmcX recovery
boot is default
# boot from the recovery partition
If you have read the boot.img into memory, you can use this command to boot from
> booti 0xXXXXXXXX
• bootm (only works in for the NFS) starts running the kernel. For other cases, use booti command.
• splashimage is the virtual or physical address of bmp file in memory. If MMU is enabled in board configuration file,
the address is virtual. Otherwise, it is physical. See README in U-Boot code root tree for details.
• splashpos sets the splash image to a free position, 'x,y', on the screen. x and y should be a positive number, which is
used as number of pixel from the left/top. Note that the left and top should not make the image exceed the screen size.
You can specify 'm,m' for centering the image. Usually, for example, '10,20', '20,m', 'm,m' are all valid settings. See
README in U-Boot code root tree for details.
• lvds_num chooses which LVDS interface, 0 or 1, is used to show the splash image. Note that we only support boot
splash on LVDS panel. We do not support HDMI or any other display device.
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
Freescale Semiconductor, Inc.
21Booting
5.4.2 Kernel command line (bootargs)
Depending on the different booting/usage scenarios, you may need different kernel boot parameters set for bootargs.
Kernel parameter
Description
Typical value
console=ttymxc0,115200
Used when
console Where to output
kernel log by
printk. init Tells kernel where init=/init
the init file is
located. All cases. "init" in Android is located in "/"
instead of in "/sbin".
ip Tells kernel how/
whether to get an
IP address. "ip=dhcp" or "ip=static_ip_address" is
mandatory in "boot from TFTP/NFS".
ip=none
or
All cases.
ip=dhcp
or
ip=static_ip_address
nfsroot Where the NFS
rootfs=ip_address:/opt/
server/directory is nfsroot,v3,tcp
located. Used in "boot from tftp/NFS" together with
"root=/dev/nfs".
root Indicates the
root=/dev/nfs
location of the root
or
file system.
root=/dev/mmcblk0p2 Used in "boot from tftp/NFS" (i.e. root=/dev/
nfs).
Tells kernel/driver
which resolution/
depth and refresh
rate should be
used, or tells
kernel/driver not to
register a
framebuffer device
for a display
device. To specify a display framebuffer with:
video
video=mxcfb0:dev=ldb,LDB-
XGA,if=RGB666,bpp=32
or
Used in "boot from SD" (i.e. root=/dev/
mmcblk0p2) if no ramdisk is used for root
fs.
video=mxcfb<0,1,2>:dev=<ldb,hdmi>,<LDB
-XGA,xres x
yresM@fps>,if=<RGB666,RGB24>,bpp=<1
6,32>
video=mxcfb1:dev=hdmi,
1920x1080M@60,if=RGB24,bp
p=32
or
or
video=mxcfb2:off
To disable a display device's framebuffer
register with:
video=mxcfb<0,1,2>:off
fbmem framebuffer
reservation size
configuration fbmem=5M,10M fbmem=<fb0 size>,<fb2 size>,<fb4
size>,<fb5 size>
vmalloc vmalloc virtual
range size for
kernel vmalloc=400M vmalloc=<size>
enable_wait_mode Enables or disable enable_wait_mode=on
the i.MX 6 WAIT
mode. enable_wait_mode=<on/off>
Lets CPU work at
special
frequency(MHz). If you want to specify CPU working
frequency
arm_freq
arm_freq=800
Wait mode is enabled by default for this
release.
Table continues on the next page...
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
22
Freescale Semiconductor, Inc.Booting
Kernel parameter
Description
Typical value
Used when
androidboot.console The Android shell
console. It should
be the same as
console=. androidboot.console=ttymxc0 If you want to use the default shell job
control, such as Ctrl+C to terminate a
running process, you must set this for the
kernel.
fec_mac Sets up the FEC
MAC address. fec_mac=00:04:9f:00:ea:d3 On SABRE-SD board, the SoC does not
have MAC address fused in. If you want to
use FEC, assign this parameter to the
kernel.
fb0base Tells kernel the
fb0base=0x27b00000
framebuffer base
address that
bootloader uses
for splashscreen.
Kernel will use the
address for
framebuffer. This is only for Hannstar XGA LVDS panel.
To choose to support smooth UI transition
from bootloader to Kernel, you need to set
this. When this is set, you have to set
'fbmem' for fb0 to reserve fb memory as
well.
gpumem Sets up the
reserved memory
size for GPU
driver gpumem=192 M It is 192 M by default on the SABRE-SD
platform. This kernel parameter can only be
used when limiting GPU/VPU usage.
ldo_active Enable or disable
LDO bypass. ldo_active=off By defaut, LDO bypass is enabled. If you
want to use internal LDO, specify
"ldo_active=on" to the kernel command
line. LDO bypass can only be enabled on
the board that mounted with external PMIC
to supply VDDARM_IN/VDDSOC_IN power
rail
caam Enable/disable
CAAM module. caam By default, CAAM is disabled. If you want
to use CAAM module, specify "caam" to the
kernel command line. CAAM uses ALT7
mode of pad GPIO_0, which conflicts with
any other module that using pad GPIO_0
on the board. On an i.MX 6 series SABRE-
SD board, CAAM conflicts with audio codec
(WM8962) and camera(ov5642) module.
bluetooth Tells kernel to
enable bluetooth. bluetooth This is only for SABRE-SD Rev C board. It
uses UART 5 to enable the BT support.
csi Enable CSI
camera device csi This is only valid for i.MX6SoloLite EVK
board.
ldo_active=on
Android User's Guide, Rev kk4.4.2_1.0.0-ga, 07/2014
Freescale Semiconductor, Inc.
23How to Reach Us: Information in this document is provided solely to enable system and software
Home Page:
freescale.com implementers to use Freescale products. There are no express or implied copyright
Web Support:
freescale.com/support information in this document.
licenses granted hereunder to design or fabricate any integrated circuits based on the
Freescale reserves the right to make changes without further notice to any products
herein. Freescale makes no warranty, representation, or guarantee regarding the
suitability of its products for any particular purpose, nor does Freescale assume any
liability arising out of the application or use of any product or circuit, and specifically
disclaims any and all liability, including without limitation consequential or incidental
damages. "Typical" parameters that may be provided in Freescale data sheets and/or
specifications can and do vary in different applications, and actual performance may
vary over time. All operating parameters, including "typicals," must be validated for
each customer application by customer's technical experts. Freescale does not convey
any license under its patent rights nor the rights of others. Freescale sells products
pursuant to standard terms and conditions of sale, which can be found at the following
Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc.,
Reg. U.S. Pat. & Tm. Off. All other product or service names are the property of their
respective owners. ARM and ARM Cortex-A9 are registered trademarks of ARM
Limited.
© 2014 Freescale Semiconductor, Inc.
Document Number: AUG
Rev. kk4.4.2_1.0.0-ga
07/2014

《Android repo 魔法》

Android repo 魔法

Android 为企业提供一个新的市场,无论大企业,小企业都是处于同一个起跑线上。研究 Android 尤其是 Android 系统核心或者是驱动的开发,首先需要做的就是本地克隆建立一套 Android 版本库管理机制。 Android 使用 Git 作为代码管理工具,开发了 Gerrit 进行代码审核以便更好的对代码进行集中式管理,还开发了 Repo 命令行工具,对 Git 部分命令封装,将 百多个 Git 库有效的进行组织。要想克隆和管理这百多个 Git 库,还真不是一件简单的事情。 在研究 Repo 的过程中,发现很多文档在 Google Group 上,非"翻墙"不可看。非法的事情咱不干,直接阅读 repo 的代码吧。

创建本地 Android 版本库镜像的思路

如果了解了 Repo 的实现,参考 《Using Repo and Git》 , 建立一个本地的 android 版本库镜像还是不难的:
  • 下载 repo bootstrap 脚本
    $ curl http://android.git.kernel.org/repo >~/bin/repo  $ chmod a+x ~/bin/repo  $ export PATH=$PATH:~/bin
  • 提供 --mirror 参数调用 repo init ,建立 git 版本库克隆
    $ repo init -u git://android.git.kernel.org/platform/manifest.git --mirror
    • 使用 --morror 则下一步和源同步的时候,本地按照源的版本库组织方式进行组织,否则会按照 manifest.xml 指定的方式重新组织并检出到本地
  • 开始和源同步
    $ repo sync
  • 修改 manifest ,修改 git 库地址,指向本地的 git 服务器
    • 修改 platform/manifest.git 库中现有的 xml 文件,或者创建一个新的 xml 文件
    • 将 git 的地址改为本地地址,提交并 push
  • 本地 repo 镜像建立完毕之后,就可以在执行 repo init 时,使用本地更改后的 manifest 库,之后执行 repo sync 就是基于本地版本库进行同步了。
  • 也可以改造 repo,使得不必为 repo 工具初始化,也在本地网络完成操作...

Repo init 干了些什么?

实际上,得到客户使用 repo 的信息后,首先下载 repo 执行脚本开始研究。
curl http://android.git.kernel.org/repo >~/bin/repo
难道只有 600 行的 python 代码么?要是这样应该很简单的呀。可以看下来,却发现远非如此。

Shell script or python?

首先 repo 脚本使用了一个魔法:从脚本第一行的 shebang 来看应该是 shell 脚本,但是满眼却都是 python 语法,怎么回事?
 1 #!/bin/sh   2   3 ## repo default configuration   4 ##   5 REPO_URL='git://android.git.kernel.org/tools/repo.git'   6 REPO_REV='stable'   7   8 # Copyright (C) 2008 Google Inc.     ...    22 magic='--calling-python-from-/bin/sh--'  23 """exec" python -E "$0" "$@" """#$magic"  24 if __name__ == '__main__':  25   import sys  26   if sys.argv[-1] == '#%s' % magic:  27     del sys.argv[-1]  28 del magic
魔法就在第 23 行,巧妙的通过 python 三引号字串写出了一个能被 python 和 shell script 都能理解的代码,以此为界,代码由 Shell 脚本进入了 Python 的世界。

Bootstrap 和真正的 repo

通过 curl 下载的的 repo 并非完整的 repo 脚本,只是一个 bootstrap。当 repo 执行时,会负责下载完整的 repo 代码,并将控制权转移给真正的 repo。 通过 main 函数,可以看到 repo 运行的开始,就试图发现本地真正的完整的 repo 代码,以便移交控制权:
544 def main(orig_args):  545   main, dir = _FindRepo()    586   try:  587     os.execv(main, me)
其中 545 行的 _FindRepo() 会在当前目录开始向上递归查找 ".repo/repo/main.py",如果找到则移交控制权(587行)。

Repo bootstrap 脚本调用 init 只完成第一阶段的初始化

Repo 的 bootstrap 脚本只支持两个命令 help 和 init,而 init 也只完成 repo 版本库克隆(即安装 repo 完整工具),之后就转移控制权。 在 Repo bootstrap 执行 init 可以提供很多参数,但实际上第一阶段初始化,只用到两个参数(而且都有默认值)
  • 参数:--repo-url=URL repo 工具本身的 git 库地址。缺省为:git://android.git.kernel.org/tools/repo.git
  • 参数:--repo-branch=REVISION 使用 repo 的版本库,即 repo git 库的分支或者里程碑名称。缺省为 stable

第二阶段的 repo init

执行第二阶段的 repo init,控制权已经移交给刚刚克隆出来的 repo git 库的脚本。 Repo git 库被克隆/检出到执行 repo init 命令当前目录下的 .repo/repo 子目录中,主要的执行脚本为 .repo/repo/main.py。main.py 接着执行 repo init 命令。 Repo 的代码组织的非常好,在 .repo/repo/subcmds/ 子目录下,是各个 repo 命令的处理脚本。repo init 的第二阶段脚本正是由 .repo/repo/subcmds/init.py 负责执行的。第二阶段主要完成:
  • 克隆由 -u 参数提供的 manifest Git 库,如克隆 android 库时:
    $ repo init -u git://android.git.kernel.org/platform/manifest.git
  • 如果不提供 -b REVISION 或者 --manifest-branch=REVISION参数,则检出 manifest Git 库的 master 分支
  • 如果不提供 -m NAME.xml 或者 --manifest-name=NAME.xml 参数,则使用缺省值 default.xml
  • 如果提供 --mirror 参数,则后续同步操作会有相应的体现

Repo start 干了些什么?

Android 源码网站在介绍 repo 的使用模型中,有一个图片: http://source.android.com/images/git-repo-1.png , 介绍了 repo 的使用流程。其中 "repo start" 是紧接着 "repo sync" 后的第一个动作。那么这个动作是干什么的呢? 得益于 repo 对 git 操作的封装,"repo start" 命令的处理代码只有区区 68 行。
 37   def Execute(self, opt, args):     41     nb = args[0]     47     projects = []   48     if not opt.all:   49       projects = args[1:]     54     all = self.GetProjects(projects)     57     for project in all:     59       if not project.StartBranch(nb):   60         err.append(project)
看到第 59 行了么,就是对 repo 同步下来的项目的多个 Git 版本库,逐一执行 project.StartBranch 操作。 nb 是 repo start 的第一个参数,即分支名称。 关于 StartBranch 的代码,在 project.py 中:
 857   def StartBranch(self, name):   858     """Create a new branch off the manifest's revision.   859     """     894     if GitCommand(self,   895                   ['checkout', '-b', branch.name, revid],   896                   capture_stdout = True,   897                   capture_stderr = True).Wait() == 0:   898       branch.Save()   899       return True
原来如此, repo start <branch_name> 就是逐一为各个版本库创建工作分支,以便在此分支下进行工作。 读者可以按图索骥,找到 repo 各个命令的实现,破解心中的疑惑。

Repo——另一个Git协同模型 git和repo的关系

Git 的神奇之处在于,你可以用很多不同的方式来使用它,而不像 Subversion,只有集中式一种方式。 最近又发现了一个 Git 新的协同模型 —— Repo,这个协同模型对于一个项目用到了多个Git版本库的协同开发非常有效。 实际上,这是上周在给一个团队做 "Git培训" 时,发现该团队在 Android 开发中,需要使用 Repo 这个工具来维护 Android 代码。于是花了些时间研究,补充了新的一章到讲义中...  Repo 是 Google Android 项目的附属工具,用于维护 Android 超级复杂的 Git 库(150多个独立的Git库)。虽然 repo 属于 android 项目,但 repo 本身可以独立使用,可以作为独立的工具,被任何项目使用。 用一句话概括 Repo: Repo 让分散的各自独立的 Git 版本库整合为一个整体。 不是有 git submodule 么?为什么还会出现一个 repo 呢?主要的原因,我认为有:
  • 子模组不能指向Git库的某一分支,只是指向某个 commit
    • 这对于项目发布没有问题,子模组指向 commit,即相当于固定于某个版本(里程碑)
    • 但是对于开发非常不方便 。子模组固定于某个 commit,相当于处于 detached HEAD 状态,必须切换到分支才能更改。但是子模组对应于git库的哪一个分支,子模组的实现不能给出答案
  • 主版本库和各个子版本库各自独立操作,不能整体的查看状态,查看differ
Repo 的实现很有趣,通过 repo 可以将本来各自独立的 Git 库在形式上整合为一个整体,可以用 repo 的命令进行整体操作。
  • 通过一个 manifests git 库,维护一个 XML 文件:manifest.xml
    • 这个文件相当于 submodule 的 .gitmodules 文件
    • 记录着版本库的源地址,以及本地检出的路径
    • 该XML文件超越 .gitmodules 之处在于,XML文件可以记录分支名,即检出版本库的哪一个分支到对应的目录中
  • Repo 包含了一些和 git 相近的子命令,实际上是对 git 相应命令的封装以便提供多版本库支持
    • branches 命令,可以显示各个分支名称在各个 git 版本库中的分布统计
    • diff 命令,可以显示各个 git 库的代码差异
    • start 命令,对所有版本库创建功能分支并切换分支
    • 还有 rebase, stage, status, sync 等命令

基于Repo和Git的关系版本管理

涉及Android源代码的工作需要用到的Git和Repo工具。多数情况下我们可以用Git工具代替Repo,或者两者混用组合成更复杂的命令。而Repo工具可以使Android的网络操作更加简洁。

     Git是一个开源版本管理系统,旨在处理各种知识库发布的大型项目。一般来说,我们可以使用Git进行本地操作,比如本地分支化、提交、对比和编辑。Android项目中一个挑战是如何支持外部的群体(爱好者社区以及大型OEM厂商)。如果想让组件可替代、延长生命周期,我们必须选择一个发布式版本管理系统,所有我们选择Git工具。
     Repo是基于Git工具的知识库管理系统工具,该工具可以统一管理Git知识库并提交源码到版本管理系统,使得Android项目的开发流程自动化。Repo并不意味着替代Git工具,它仅使得工作更加简单。Repo命令是Python脚本,可以放到任何路径下。涉及到网络操作时可以使用该工具,比如使用单个Repo命令可以下载多个知识库到本地。
     Gerrit是给予web的代码review系统,集中支持了Git众多的应用。该系统允许授权用户提交代码更改,通过review后自动merge到版本管理系统。Gerrit支持差异展现和在线评论,使review比较简单。
一、版本管理基本流程
     与知识库交互的基本流程如下:
     1、建立新的分支——repo start
     2、编辑代码文件
     3、stage文件更改——git add
     4、提交更改——git commit
     5、提交更改到review服务器——repo upload

                                            
二、任务处理
     下面详细介绍了如何使用Repo和Git命令。
     1、同步本地客户端
      同步所有的工程文件——repo sync
      同步特定的工程文件——repo sync PROJECT0 PROJECT1 PROJECT2 ...
     2、创建分支
     每当开始编辑文件比如开始修改bug和添加新的功能,需要在本地创建特定的分支。分支并不是原始文件的拷贝,它作为特定提交的标示,该标示创建本地分支并在分支间进行轻量级切换,分支可以隔绝一个方面的更改。
     创建分支——repo start BRANCH_NAME
     验证新分支的有效性——repo status
    3、分支使用
     分配分支到特定工程——repo start BRANCH_NAME PROJECT
     本地环境中切换分支——git checkout BRANCH_NAME
     列出所有分支——git branch or repo branches
   4、staging文件
     默认情况下,git工具提示但并不跟踪工程的更改,为了通知git保存代码的变化,我们必须commit代码,即"staging"。
    stage文件更改——git add
    该命令可以接受任何文件和工程目录,git添加文件到git知识库,并且stage文件更改、删除的记录。
   5、浏览客户端状态
    展示文件状态——repo status
    展示未提交的文件编辑——repo diff
   6、提交更改
    git中commit是版本管理的基本单元,包含了工程的目录结构和文件内容。
    创建commit——git commit
    执行该命令后editor中弹出commit提示信息,最好能够提供有益的帮助信息。如果没有添加log信息,该次commit提交会被遗弃。
   7、提交更改到Gerrit
    upload之前更新最新的版本——repo sync
    接着提交代码——repo upload
    之后呈现我们提交的更改,并提示我们选择分支。
   8、处理代码冲突
    提交代码时如果遇到冲突,需要执行以下操作:进入相关的工程目录,针对冲突的文件运行git add和git commit命令,恢复更改。如下:
     git add .
     git commit 
     git rebase --continue
    恢复更改后再次重复整个更新:
     repo sync PROJECT0 PROJECT1 ... PROJECTN
    如果本地又对刚刚提交的代码进行了修改,提交时可以直接覆盖上次的提交,执行如下命令:
    git add files
    git commit  --amend
    repo upload
   9、清除客户端文件
    merge代码到Gerrit之后,更新本地的工作目录:
    repo sync
   安全清除陈旧的分支执行以下命令:
    repo prune
   想恢复代码到以前的分支,可以执行以下命令:
    git log
    git reset hard
  10、删除客户端代码
   由于代码所有的代码信息存储在本地,我们仅需要删除目录即可完成:
    rm -rf WORKING_DIRECTORY
   删除本地代码后将会永久的删除所有提交的更改。
三、Git和Repo流程表

流程命令表

原文参考:http://source.android.com/source/version-control.html

Repo和Git 版本管理常用命令

转载一则:

Git命令快速参考

Git Command Quick Reference
本附录为Git常见命令快速参考。每节介绍一种操作类型。
这里会列出很多命令,而相应的解释却不多。对于还不熟悉Git的读者,可回头翻阅第1章"Git的版本控制之道"(第3页)。

A.1安装和初始化
Setup and Initialization

在使用Git之前,须要先进行配置。在使用一个新的版本库之前,须要先初始化。本节介绍与Git设置和初始化相关的命令。

配置全局用户名和电子邮件地址
prompt> git config --global user.name "Your Name"
prompt> git config --global user.email "wuhua0904@126.com"
为特定的版本库配置用户名和电子邮件地址

注意:你可以为每个版本库单独设置用户名和邮件地址。这使得用户可在不同项目中使用不同的用户名和/或不同的邮件地址。

prompt> cd /path/to/repo
prompt> git config user.name "Your Name"
prompt> git config user.email wuhua0904@126.com

在命令行中使用不同颜色显示不同内容
prompt> git config --global color.ui "auto"

初始化新版本库
prompt> mkdir /path/to/repo:
prompt> cd /path/to/repo
prompt> git init
Initialized empty Git repository in /path/to/repo/.git/
prompt>
... create file(s) for first commit ...
prompt> git add 
prompt> git commit -m 'initial import'
Created initial commit bdebe5c: initial import. 

1 files changed, 1 insertions(+), 0 deletions(-)

create mode 100644 <some file>

克隆版本库
prompt> git clone <repository url
Initialize repo/.git
Initialized empty Git repository in /work/<remote repository>/.git/

将目录中的内容纳入Git版本控制
prompt> cd /path/to/existing/directory
prompt> git init
Initialized empty Git repository in /path/to/existing/directory/.git
prompt> git add .
prompt> git commit -m "initial import of some project"

在本地版本库中设置远程版本库的别名
... from within the repository directory ...
prompt> git remote add <remote repository> <repository url>


A.2 日常操作
Normal Usage

本节列出Git日常操作命令,对应于第4章"添加与提交:Git基础"(第41页)。

添加新文件或暂存已有文件上的改动,然后提交
prompt> git add <some file>
prompt> git commit -m "<some message>"

暂存已有文件上的部分修改
注意:[...]表示可选参数。

prompt> git add -p [<some file> [<some file> [and so on]]]
选择要提交的文本块……

使用交互方式添加文件
prompt> git add -i

暂存已纳入Git版本控制之下的文件的修改
prompt> git add -u [<some path> [<some path>]]

提交已纳入Git版本控制之下的文件的所有修改# s"
prompt> git commit -m "<some message>" -a

清除工作目录树中的修改
prompt> git checkout HEAD <some file> [<some file>]

取消已暂存但尚未提交的修改的暂存标识
prompt> git reset HEAD <some file> [<some file>]

修复上一次提交中的问题

改动相关文件,并暂存……
prompt> git commit -m "<some message>" --amend

修复上一次提交中的问题,并复用上次的提交注释
prompt> git commit -C HEAD --amend


A.3 分支
Branches
分支是Git的强项之一。本节介绍关于分支的各个命令。详细内容见第5章"理解和使用分支"(第55页)。

列出本地分支
prompt> git branch
列出远程分支
prompt> git branch -r

列出所有分支
prompt> git branch -a

基于当前分支(的末梢)创建新分支
prompt> git branch <new branch>

检出另一条分支
prompt> git checkout <some branch>

基于当前分支创建新分支,同时检出该分支
prompt> git checkout -b <new branch

基于另一个起点,创建新分支
你可以从版本库中的任何一个版本开始创建新分支。这个起始点可以用一条已有的分支名称、一个提交名称,或者一个标签名称来表
prompt> git branch <new branch> <start point>

创建同名新分支,覆盖已有分支
prompt> git branch -f <some existing branch> [<start point>]

移动或重命名分支
只有当<new branch>不存在时
prompt> git checkout -m <existing branch name> <new branch name>

如果<new branch>已存在,就覆盖它
prompt> git checkout -M <existing branch name> <new branch name>

把另一条分支合并到当前分支
prompt> git merge <some branch>

合并,但不提交
prompt> git merge --no-commit <some branch>

拣选合并,并且提交
prompt> git cherry-pick <commit name>

拣选合并,但不提交
prompt> git cherry-pick -n <commit name>

把一条分支上的内容压合到另一条分支(上的一个提交)
prompt> git merge --squash <some branch>

删除分支
仅当欲删除的分支已合并到当前分支时
prompt> git branch -d <branch to delete>

不论欲删除的分支是否已合并到当前分支
prompt> git branch -D <branch to delete>


A.4 历史
History

这些命令用来显示版本库的历史信息,包括代码曾在哪里、谁在何时做了什么、修改的内容及其统计信息。详见第6章"查询Git历史记录"(第71页)。
显示全部历史记录
prompt> git log

显示版本历史,以及版本间的内容差异
prompt> git log -p

只显示最近一个提交
prompt> git log -1

显示最近的20个提交,以及版本间的内容差异
prompt> git log -20 -p

显示最近6小时的提交
prompt> git log --since="6 hours"

显示两天之前的提交
prompt> git log --before="2 days"

显示比HEAD(当前检出分支的末梢)早3个提交的那个提交
prompt> git log -1 HEAD
或者……
prompt> git log -1 HEAD
或者……
prompt> git log -1 HEAD

显示两个版本之间的提交
下面命令中的<start point>和<end point>可以是一个提交名称、分支名称、标签名称,或者它们的混合。
prompt> git log <start point>...<end point>

显示历史,每个提交显示一行,包括提交注释的第一行
prompt> git log --pretty=oneline

显示改动行数统计
prompt> git log --stat

显示改动文件的名称和状态
prompt> git log --name-status

显示当前工作目录树和暂存区间的差别
prompt> git diff

显示暂存区和版本库间的差别
prompt> git diff --cached

显示工作目录树和版本库间的差别
prompt> git diff HEAD

显示工作目录树与版本库中某次提交版本之间的差别
<start point>可以是一个提交名称、分支名称或标签名称。
prompt> git diff <start point>

显示版本库中两个版本之间的差别
prompt> git diff <start point> <end point>

显示差别的相关统计
prompt> git diff --stat <start point> [<end point>]

显示文件中各个部分的修改者及相关提交信息
prompt> git blame <some file>

显示文件中各个部分的修改者及相关提交信息,包括在该文件中复制、粘贴和移动内容等方面的情况。
prompt> git blame -M <some file>

显示文件中各部分的修改者及相关提交信息,包括在文件间移动内容方面的情况
prompt> git blame -C -C <some file>

显示历史时,显示复制和粘贴信息
prompt> git log -C -C -p -1 <some point>



A.5 远程版本库
Remote Repositories

开发人员之间通过远程版本库来共享工作成果,相互协作。本节介绍关于这些操作的命令,详见第7章"与远程版本库协作"(第91页)。

克隆远程版本库
prompt> git clone <some repository>

克隆远程版本库,但只下载其中最近200个提交的历史记录
prompt> git clone --depth 200 <some repository>

在本地版本库中设置远程版本库的别名
prompt> git remote add <remote repository> <repository url>

显示远程分支
prompt> git branch -r

基于远程分支创建本地分支
prompt> git branch <new branch> <remote branch>

基于远程标签创建本地分支
prompt> git branch <new branch> <remote tag>

从别名为"origin"的远程版本库中取来修改变化,但不合并到本地分支
prompt> git fetch

从任意的远程版本库中取来修改变化,但不合并到本地分支
prompt> git fetch <remote repository>

从任意的远程版本库中取来修改变化,并合并到当前检出的本地分支
prompt> git pull <remote repository>

从别名为"origin"的远程版本库中取来修改变化,并合并到当前检出的本地分支
prompt> git pull

把修改变化从本地分支推入远程版本库
prompt> git push <remote repository> <local branch>:<remote branch>

把修改变化从本地分支推入远程版本库中同名分支
prompt> git push <remote repository> <local branch>

把修改变化从本地新建分支推入远程版本库
prompt> git push <remote repository> <local branch>

把修改变化推入别名为"origin"的远程版本库
当远程版本库中已有同名分支时,这个命令会推入本地分支到远程版本库对应的分支中。如果远程版本库中尚无同名分支,则须使用git push <repository name> <local branch>。
prompt> git push

在远程版本库中删除分支
prompt> git push <remote repository> :<remote branch>

在本地版本库中删除所有远程版本库中已不存在的分支
prompt> git remote prune <remote repository>

在本地版本库中删除某个远程版本库的简称,以及该远程版本库相关的分支
prompt> git remote rm <remote repository>

A.6 连接Git和SVN
Git to SVN Bridge

Git可以读取Subversion版本库中的数据,并把本地修改发送回Subversion版本库。这是Git区别于其他版本控制工具的必杀技之一。相关详细介绍请参见第10章"迁移到Git"(第131页)。
克隆SVN版本库的全部内容
prompt> git svn clone <svn repository>

克隆具有标准结构的SVN版本库
下面命令适用于克隆标准结构的SVN数据库,也就是说,主干命名为trunk,其他分支都存放于branches目录下,标签都存放于tags目录下。
prompt> git svn clone -s <svn repository>

克隆非标准结构的SVN版本库
prompt> git svn clone -T <trunk path> \
2 ]! W9 t7 X4 N) D; H# n( g4 I/ H
-b <branch path> \

+ q- e& |5 k& n$ C1 }1 e
-t <tag path> \

7 v. |9 `& `9 g, _* a

< svn repository>

克隆具有标准结构的SVN版本库中的某个版本(比如第2321版)
prompt> git svn clone -s -r 2321

克隆具有标准结构的SVN版本库,并对SVN中的分支添加前缀
prompt> git svn clone -s --prefix svn/ <svn repository>

从上游SVN版本库中获得更新的内容,并依此在本地Git版本库中变基本地分支
prompt> git svn rebase

把修改变化推回上游SVN版本库
prompt> git svn dcommit

列出所有将推入上游SVN版本库的提交
prompt> git svn dcommit -n

显示SVN历史记录
prompt> git svn log

显示文件中各个部分的SVN的修改者及相关提交信息
prompt> git svn blame <some file>

 

 

转载二则:

1. 服务器版本下载:

repo init -u git@192.168.1.11:i700t_60501010/platform/manifest.git -b froyo_almond -m M76XXTSNCJNLYA60501010.xml

repo sync

repo forall -c git checkout --track origin/i700t_60501010 -b [你的本地分支]

或者:

git clone git@192.168.1.11:6120_gingerbread/Arm9-6120.git

git checkout --track origin/arm9_6120 -b [你的本地分支名]

 

2. 服务器新加仓库同步:

请按如下步骤取得Lanucher_wpon的代码:

1:~> cd I700T/.repo/manifest

2: I700T/.repo/manifest> git pull --rebase

3: I700T/.repo/manifest> cd ../..

4: I700T> repo sync platform/packages/apps/Launcher_wpon

5:I700T> cd packages/apps/Launcher_wpon

6:I700T/packages/apps/Launcher_wpon> 

7:git checkout --track origin/froyo_almond -b [你的本地分支]

 

3. 上传本地修改到服务器

repo forall -c git pull --rebase        和服务器同步(要上传代码前,一般先进行此操作)

git add .    或git add 文件名            添加当前仓库修改的文件

git commit -m "..."                       在引号中添加你的修改记录

git push origin  本地分支名:froyo_almond       上传本地修改的代码

 

4. 设置一些默认的全局变量,对所有工程代码有效

git config --global user.name yourmail

git config --global user.email yourmail

git config --global push.default tracking     这样后续git push 后面不用带参数

 

5.查看修改记录

git log                       本地仓库修改记录

repo forall -c git log --since="2011-04-19" --until="2011-04-21"   按条件查看工程所有仓库修改记录

repo status                查看工程中所有仓库的修改状态(包括文件位置)

git status                   查看仓库修改状态

 

6. 分支相关

git branch                 查看本地branch

git branch -r              查看远程branch

git branch -a              查看所有branch

git branch -D  (-d)  (branch name)    删除branch

cat .git/config      可以查看本地branch一些信息

 

7. 修改恢复相关

git checkout filename1  filename2  ...           取消本地修改,和服务器同步

git stash  

git stash apply          先stash本地修改,然后执行git pull --rebase同步,最后再APPLY恢复自己的修改

git reset --soft head_commit  恢复到最后一次commit,保持代码修改

git reset --hard commit    恢复到指定一次commit,放弃之前所有修改

#回退a.py这个文件的版本到上一个版本  

git reset HEAD^ a.py 

git reset commitNO filename

 

8. 本地某仓库出问题了,不好闹腾时,删除之,并重新同步跟踪

project_folder/vendor/qcom$ rm -rf proprietary/                         进到相应目录,删除之

project_folde$ repo sync platform/vendor/qcom/proprietary       重新repo sync,后面路径名称可查看:

                                                                                                 gedit .repo/manifest.xml

git branch -a    ----列举所有BRANCH

git branch -D 700_arm11_server

git branch -D 700_arm11_server_wifi  --删掉所有本地branch

git checkout --track origin/froyo_almond -b 700_arm11_server   然后track远程branch,重新创建本地分支

 

9.tag的使用

git tag [tag_name] [version],在对应版本上(一般用change的SHA1),创建tag 

git tag -l 列出当前tag 

git tag -d [tag_name] 删除tag 

有了tag以后,可以使用git checkout [tag_name] -b [branch_name]来检出对应tag时刻的代码。也可以用tag name来实现diff等功能。 

 

10. patch的使用

git diff filename1 filename2 ...                  修改位置对比,查看源码

git diff > xxx.patch                                  将修改的地方打成一个patch

git apply xxx.patch                                  将patch打上

 

11. 后续有用到的命令继续添加

git revert 是撤销某次提交。git reset –hard,才是退回到以前的版本

git reset --soft commitNum      保存代码修改的reset,但这个时候无法使用git diff 进行比较修改的文件,必须:

git reset filename filename     这样就可以git diff查看

git diff ffd98b291e0caa6c33575c1ef465eae661ce40c9 b8e7b00c02b95b320f14b625663fdecf2d63e74c 查看某两个版本之间的差异

git diff ffd98b291e0caa6c33575c1ef465eae661ce40c9:filename b8e7b00c02b95b320f14b625663fdecf2d63e74c:filename 查看某两个版本的某个文件之间的差异

  Git 命令别名

$ git config –global alias.co checkout // co将会成为checkout的别名

$ git config –global alias.br branch

$ git config –global alias.ci commit

$ git config –global alias.st status

$ git config –global user.name "username"

$ git config –global user.email username@mail.com

 

转载三则:

  1. 下载 repo 的地址: http://android.git.kernel.org/repo ,可以用 wgethttp://android.git.kernel.org/repo 或者 curl http://android.git.kernel.org/repo >~/bin/repo  来下载 repo , chmod a+x ~/bin/repo 
  2. 用repo sync 在抓去 android source code 的时候,会经常出现一些错误导致 repo sync 中断,每次都要手动开始。 可以用如下的命令,来自动重复:   $?=1;   while [ $? -ne 0 ] ; do  repo sync ; done
  3.  repo help [ command ] , 显示command 的详细的帮助信息内容
  4. repo init -u URL ,  在当前目录安装 repository ,会在当前目录创建一个目录 ".repo"  -u 参数指定一个URL, 从这个URL 中取得repository 的 manifest 文件。   repo init -u git://android.git.kernel.org/platform/manifest.git

               可以用 -m 参数来选择 repository 中的某一个特定的 manifest 文件,如果不具体指定,那么表示为默认的 namifest 文件 (default.xml)    repo init -u git://android.git.kernel.org/platform/manifest.git -m dalvik-plus.xml

              可以用 -b 参数来指定某个manifest 分支。

               repo init -u git://android.git.kernel.org/platform/manifest.git -b release-1.0

              可以用命令: repo help init 来获取 repo init 的其他用法

        4. repo sync [project-list]

            下载最新本地工作文件,更新成功,这本地文件和repository 中的代码是一样的。 可以指定需要更新的project , 如果不指定任何参数,会同步整个所有的项目。

           如果是第一次运行 repo sync , 则这个命令相当于 git clone ,会把 repository 中的所有内容都拷贝到本地。 如果不是第一次运行 repo sync , 则相当于 git remote update ;  git rebase origin/branch .  repo sync 会更新 .repo 下面的文件。 如果在merge 的过程中出现冲突, 这需要手动运行  git  rebase --continue

      5. repo update[ project-list ]

      上传修改的代码 ,如果你本地的代码有所修改,那么在运行 repo sync 的时候,会提示你上传修改的代码,所有修改的代码分支会上传到 Gerrit (基于web 的代码review 系统), Gerrit 受到上传的代码,会转换为一个个变更,从而可以让人们来review 修改的代码。

       6. repo diff [ project-list ]

        显示提交的代码和当前工作目录代码之间的差异。

       7. repo download  target revision

        下载特定的修改版本到本地, 例如:  repo download pltform/frameworks/base 1241 下载修改版本为 1241 的代码

       8. repo start newbranchname

        创建新的branch分支。 "." 代表当前工作的branch 分支。

       9.  repo prune [project list]

        删除已经merge 的 project

      10. repo foreach [ project-lists] -c command

       对每一个 project 运行 command 命令

      11. repo status

       显示 project 的状态