Android核心的編譯和除錯
一、Android核心原始碼的選擇
Android手機裝置核心原始碼的除錯需要外部硬體裝置的支援,除錯步驟比較麻煩。相對來說,Android模擬器核心原始碼的除錯就比較簡單了,這裡以Android模擬器核心原始碼的除錯為例。首先建立一個Android API 19(Android 4.4.x版本)的Android模擬器,然後執行該Android模擬器。在 ubuntu 14.04.5系統或者 Windows 系統上開啟命令列終端,執行下面的命令,獲取移動裝置使用的晶片即獲取移動裝置核心原始碼的版本資訊。
windows系統上執行的結果如下圖:$ adb shell # 檢視裝置使用的晶片 $ ls /dev/block/platform
二、Android核心原始碼的下載
根據 ls /dev/block/platform 獲取到的Android裝置的晶片平臺為 goldfish ,然後查閱google官方提供的Android核心原始碼的編譯文件,執行下面的命令進行Android核心原始碼和Android核心原始碼交叉編譯工具鏈的下載。
$ git clone https://android.googlesource.com/kernel/goldfish.git $ cd goldfish/ # 檢視可以下載的Linux核心原始碼的版本 $ git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/android-3.10 remotes/origin/android-3.18 remotes/origin/android-goldfish-2.6.29 remotes/origin/android-goldfish-3.10 remotes/origin/android-goldfish-3.10-l-mr1-dev remotes/origin/android-goldfish-3.10-m-dev remotes/origin/android-goldfish-3.10-n-dev remotes/origin/android-goldfish-3.18 remotes/origin/android-goldfish-3.18-dev remotes/origin/android-goldfish-3.4 remotes/origin/android-goldfish-3.4-l-mr1-dev remotes/origin/android-goldfish-4.4-dev remotes/origin/heads/for/android-goldfish-3.18-dev remotes/origin/linux-goldfish-3.0-wip remotes/origin/master # 選擇下載android-goldfish-3.4的核心原始碼 $ git checkout remotes/origin/android-goldfish-3.4 # 或 $ git checkout -t remotes/origin/android-goldfish-3.4 -b goldfish3.4 # 下載編譯工具鏈 $ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7/
三、Android核心原始碼的配置和編譯
設定環境變數,匯出Android核心交叉編譯工具的路徑,生成核心編譯時使用的配置檔案。可以將配置的相關命令列儲存為指令碼檔案run_make_config.sh 。有關Android核心原始碼的編譯環境的配置可以參考google官方的文件:https://source.android.com/source/building-kernels#building。
賦予指令碼檔案 run_make_config.sh 以可執行許可權,然後執行該指令碼生成Android核心編譯的配置檔案 .config 。export CROSS_COMPILE=$(pwd)/arm-eabi-4.7/bin/arm-eabi- export ARCH=arm export SUBARCH=arm # 生成編譯配置檔案 make goldfish_armv7_defconfig
$ chmod +x run_make_config.sh
$ source run_make_config.sh
提示:
1.根據《Android安全攻防權威指南》中文版第251頁的提示瞭解到,在編譯Android核心時,要使用 arm-eabi 編譯器,而不是 arm-linux-androideabi 編譯器。使用不正確的 EABI 會導致編譯失敗。
2.在生成Android核心編譯的配置檔案 .config 時,make 命令的選擇既可以參考google官方的文件:https://source.android.com/source/building-kernels#building,也可以參考Android核心原始碼下幫助檔案,這裡是 /goldfish/README 檔案,關於make命令生成編譯配置檔案的說明如下:
在當前Android核心原始碼的根目錄下,執行 make help 命令,獲取到Android核心編譯配置命令的資訊。
$ make help
Cleaning targets:
clean - Remove most generated files but keep the config and
enough build support to build external modules
mrproper - Remove all generated files + config + various backup files
distclean - mrproper + remove editor backup and patch files
Configuration targets:
config - Update current config utilising a line-oriented program
nconfig - Update current config utilising a ncurses menu based program
menuconfig - Update current config utilising a menu based program
xconfig - Update current config utilising a QT based front-end
gconfig - Update current config utilising a GTK based front-end
oldconfig - Update current config utilising a provided .config as base
localmodconfig - Update current config disabling modules not loaded
localyesconfig - Update current config converting local mods to core
silentoldconfig - Same as oldconfig, but quietly, additionally update deps
defconfig - New config with default from ARCH supplied defconfig
savedefconfig - Save current config as ./defconfig (minimal config)
allnoconfig - New config where all options are answered with no
allyesconfig - New config where all options are accepted with yes
allmodconfig - New config selecting modules when possible
alldefconfig - New config with all symbols set to default
randconfig - New config with random answer to all options
listnewconfig - List new options
oldnoconfig - Same as silentoldconfig but set new symbols to n (unset)
Other generic targets:
all - Build all targets marked with [*]
* vmlinux - Build the bare kernel
* modules - Build all modules
modules_install - Install all modules to INSTALL_MOD_PATH (default: /)
firmware_install- Install all firmware to INSTALL_FW_PATH
(default: $(INSTALL_MOD_PATH)/lib/firmware)
dir/ - Build all files in dir and below
dir/file.[oisS] - Build specified target only
dir/file.lst - Build specified mixed source/assembly target only
(requires a recent binutils and recent build (System.map))
dir/file.ko - Build module including final link
modules_prepare - Set up for building external modules
tags/TAGS - Generate tags file for editors
cscope - Generate cscope index
gtags - Generate GNU GLOBAL index
kernelrelease - Output the release version string
kernelversion - Output the version stored in Makefile
headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH
(default: /home/fly2016/Android4.4.4r1/goldfish-kernel-3.4/goldfish/usr)
Static analysers
checkstack - Generate a list of stack hogs
namespacecheck - Name space analysis on compiled kernel
versioncheck - Sanity check on version.h usage
includecheck - Check for duplicate included header files
export_report - List the usages of all exported symbols
headers_check - Sanity check on exported headers
headerdep - Detect inclusion cycles in headers
coccicheck - Check with Coccinelle.
Kernel packaging:
rpm-pkg - Build both source and binary RPM kernel packages
binrpm-pkg - Build only the binary kernel package
deb-pkg - Build the kernel as a deb package
tar-pkg - Build the kernel as an uncompressed tarball
targz-pkg - Build the kernel as a gzip compressed tarball
tarbz2-pkg - Build the kernel as a bzip2 compressed tarball
tarxz-pkg - Build the kernel as a xz compressed tarball
perf-tar-src-pkg - Build perf-3.4.67.tar source tarball
perf-targz-src-pkg - Build perf-3.4.67.tar.gz source tarball
perf-tarbz2-src-pkg - Build perf-3.4.67.tar.bz2 source tarball
perf-tarxz-src-pkg - Build perf-3.4.67.tar.xz source tarball
Documentation targets:
Linux kernel internal documentation in different formats:
htmldocs - HTML
pdfdocs - PDF
psdocs - Postscript
xmldocs - XML DocBook
mandocs - man pages
installmandocs - install man pages generated by mandocs
cleandocs - clean all generated DocBook files
Architecture specific targets (arm):
* zImage - Compressed kernel image (arch/arm/boot/zImage)
Image - Uncompressed kernel image (arch/arm/boot/Image)
* xipImage - XIP kernel image, if configured (arch/arm/boot/xipImage)
uImage - U-Boot wrapped zImage
bootpImage - Combined zImage and initial RAM disk
(supply initrd image via make variable INITRD=<path>)
dtbs - Build device tree blobs for enabled boards
install - Install uncompressed kernel
zinstall - Install compressed kernel
uinstall - Install U-Boot wrapped compressed kernel
Install using (your) ~/bin/installkernel or
(distribution) /sbin/installkernel or
install to $(INSTALL_PATH) and run lilo
acs5k_defconfig - Build for acs5k
acs5k_tiny_defconfig - Build for acs5k_tiny
afeb9260_defconfig - Build for afeb9260
ag5evm_defconfig - Build for ag5evm
am200epdkit_defconfig - Build for am200epdkit
ap4evb_defconfig - Build for ap4evb
assabet_defconfig - Build for assabet
at91rm9200_defconfig - Build for at91rm9200
at91sam9260_defconfig - Build for at91sam9260
at91sam9261_defconfig - Build for at91sam9261
at91sam9263_defconfig - Build for at91sam9263
at91sam9g20_defconfig - Build for at91sam9g20
at91sam9g45_defconfig - Build for at91sam9g45
at91sam9rl_defconfig - Build for at91sam9rl
at91x40_defconfig - Build for at91x40
badge4_defconfig - Build for badge4
bcmring_defconfig - Build for bcmring
bonito_defconfig - Build for bonito
cam60_defconfig - Build for cam60
cerfcube_defconfig - Build for cerfcube
cm_x2xx_defconfig - Build for cm_x2xx
cm_x300_defconfig - Build for cm_x300
cns3420vb_defconfig - Build for cns3420vb
colibri_pxa270_defconfig - Build for colibri_pxa270
colibri_pxa300_defconfig - Build for colibri_pxa300
collie_defconfig - Build for collie
corgi_defconfig - Build for corgi
cpu9260_defconfig - Build for cpu9260
cpu9g20_defconfig - Build for cpu9g20
da8xx_omapl_defconfig - Build for da8xx_omapl
davinci_all_defconfig - Build for davinci_all
dove_defconfig - Build for dove
ebsa110_defconfig - Build for ebsa110
edb7211_defconfig - Build for edb7211
em_x270_defconfig - Build for em_x270
ep93xx_defconfig - Build for ep93xx
eseries_pxa_defconfig - Build for eseries_pxa
exynos4_defconfig - Build for exynos4
ezx_defconfig - Build for ezx
footbridge_defconfig - Build for footbridge
fortunet_defconfig - Build for fortunet
g3evm_defconfig - Build for g3evm
g4evm_defconfig - Build for g4evm
goldfish_armv7_defconfig - Build for goldfish_armv7
goldfish_defconfig - Build for goldfish
h3600_defconfig - Build for h3600
h5000_defconfig - Build for h5000
h7201_defconfig - Build for h7201
h7202_defconfig - Build for h7202
hackkit_defconfig - Build for hackkit
imote2_defconfig - Build for imote2
imx_v4_v5_defconfig - Build for imx_v4_v5
imx_v6_v7_defconfig - Build for imx_v6_v7
integrator_defconfig - Build for integrator
iop13xx_defconfig - Build for iop13xx
iop32x_defconfig - Build for iop32x
iop33x_defconfig - Build for iop33x
ixp2000_defconfig - Build for ixp2000
ixp23xx_defconfig - Build for ixp23xx
ixp4xx_defconfig - Build for ixp4xx
jornada720_defconfig - Build for jornada720
kirkwood_defconfig - Build for kirkwood
kota2_defconfig - Build for kota2
ks8695_defconfig - Build for ks8695
lart_defconfig - Build for lart
lpc32xx_defconfig - Build for lpc32xx
lpd270_defconfig - Build for lpd270
lubbock_defconfig - Build for lubbock
mackerel_defconfig - Build for mackerel
magician_defconfig - Build for magician
mainstone_defconfig - Build for mainstone
marzen_defconfig - Build for marzen
mini2440_defconfig - Build for mini2440
mmp2_defconfig - Build for mmp2
msm_defconfig - Build for msm
mv78xx0_defconfig - Build for mv78xx0
mxs_defconfig - Build for mxs
neponset_defconfig - Build for neponset
netwinder_defconfig - Build for netwinder
netx_defconfig - Build for netx
nhk8815_defconfig - Build for nhk8815
nuc910_defconfig - Build for nuc910
nuc950_defconfig - Build for nuc950
nuc960_defconfig - Build for nuc960
omap1_defconfig - Build for omap1
omap2plus_defconfig - Build for omap2plus
orion5x_defconfig - Build for orion5x
palmz72_defconfig - Build for palmz72
pcm027_defconfig - Build for pcm027
pleb_defconfig - Build for pleb
pnx4008_defconfig - Build for pnx4008
pxa168_defconfig - Build for pxa168
pxa255-idp_defconfig - Build for pxa255-idp
pxa3xx_defconfig - Build for pxa3xx
pxa910_defconfig - Build for pxa910
qil-a9260_defconfig - Build for qil-a9260
raumfeld_defconfig - Build for raumfeld
realview_defconfig - Build for realview
realview-smp_defconfig - Build for realview-smp
rpc_defconfig - Build for rpc
s3c2410_defconfig - Build for s3c2410
s3c6400_defconfig - Build for s3c6400
s5p64x0_defconfig - Build for s5p64x0
s5pc100_defconfig - Build for s5pc100
s5pv210_defconfig - Build for s5pv210
sam9_l9260_defconfig - Build for sam9_l9260
shannon_defconfig - Build for shannon
shark_defconfig - Build for shark
simpad_defconfig - Build for simpad
spear3xx_defconfig - Build for spear3xx
spear6xx_defconfig - Build for spear6xx
spitz_defconfig - Build for spitz
stamp9g20_defconfig - Build for stamp9g20
tct_hammer_defconfig - Build for tct_hammer
tegra_defconfig - Build for tegra
trizeps4_defconfig - Build for trizeps4
u300_defconfig - Build for u300
u8500_defconfig - Build for u8500
usb-a9260_defconfig - Build for usb-a9260
versatile_defconfig - Build for versatile
vexpress_defconfig - Build for vexpress
viper_defconfig - Build for viper
xcep_defconfig - Build for xcep
zeus_defconfig - Build for zeus
make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build
make V=2 [targets] 2 => give reason for rebuild of target
make O=dir [targets] Locate all output files in "dir", including .config
make C=1 [targets] Check all c source with $CHECK (sparse by default)
make C=2 [targets] Force check of all c source with $CHECK
make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections
make W=n [targets] Enable extra gcc checks, n=1,2,3 where
1: warnings which may be relevant and do not occur too often
2: warnings which occur quite often but may still be relevant
3: more obscure warnings, can most likely be ignored
Multiple levels can be combined with W=12 or W=123
Execute "make" or "make all" to build all targets marked with [*]
For further info see the ./README file
當前Android核心原始碼的幫助檔案 README 的全部內容資訊:
Linux kernel release 3.x <http://kernel.org/>
These are the release notes for Linux version 3. Read them carefully,
as they tell you what this is all about, explain how to install the
kernel, and what to do if something goes wrong.
WHAT IS LINUX?
Linux is a clone of the operating system Unix, written from scratch by
Linus Torvalds with assistance from a loosely-knit team of hackers across
the Net. It aims towards POSIX and Single UNIX Specification compliance.
It has all the features you would expect in a modern fully-fledged Unix,
including true multitasking, virtual memory, shared libraries, demand
loading, shared copy-on-write executables, proper memory management,
and multistack networking including IPv4 and IPv6.
It is distributed under the GNU General Public License - see the
accompanying COPYING file for more details.
ON WHAT HARDWARE DOES IT RUN?
Although originally developed first for 32-bit x86-based PCs (386 or higher),
today Linux also runs on (at least) the Compaq Alpha AXP, Sun SPARC and
UltraSPARC, Motorola 68000, PowerPC, PowerPC64, ARM, Hitachi SuperH, Cell,
IBM S/390, MIPS, HP PA-RISC, Intel IA-64, DEC VAX, AMD x86-64, AXIS CRIS,
Xtensa, Tilera TILE, AVR32 and Renesas M32R architectures.
Linux is easily portable to most general-purpose 32- or 64-bit architectures
as long as they have a paged memory management unit (PMMU) and a port of the
GNU C compiler (gcc) (part of The GNU Compiler Collection, GCC). Linux has
also been ported to a number of architectures without a PMMU, although
functionality is then obviously somewhat limited.
Linux has also been ported to itself. You can now run the kernel as a
userspace application - this is called UserMode Linux (UML).
DOCUMENTATION:
- There is a lot of documentation available both in electronic form on
the Internet and in books, both Linux-specific and pertaining to
general UNIX questions. I'd recommend looking into the documentation
subdirectories on any Linux FTP site for the LDP (Linux Documentation
Project) books. This README is not meant to be documentation on the
system: there are much better sources available.
- There are various README files in the Documentation/ subdirectory:
these typically contain kernel-specific installation notes for some
drivers for example. See Documentation/00-INDEX for a list of what
is contained in each file. Please read the Changes file, as it
contains information about the problems, which may result by upgrading
your kernel.
- The Documentation/DocBook/ subdirectory contains several guides for
kernel developers and users. These guides can be rendered in a
number of formats: PostScript (.ps), PDF, HTML, & man-pages, among others.
After installation, "make psdocs", "make pdfdocs", "make htmldocs",
or "make mandocs" will render the documentation in the requested format.
INSTALLING the kernel source:
- If you install the full sources, put the kernel tarball in a
directory where you have permissions (eg. your home directory) and
unpack it:
gzip -cd linux-3.X.tar.gz | tar xvf -
or
bzip2 -dc linux-3.X.tar.bz2 | tar xvf -
Replace "XX" with the version number of the latest kernel.
Do NOT use the /usr/src/linux area! This area has a (usually
incomplete) set of kernel headers that are used by the library header
files. They should match the library, and not get messed up by
whatever the kernel-du-jour happens to be.
- You can also upgrade between 3.x releases by patching. Patches are
distributed in the traditional gzip and the newer bzip2 format. To
install by patching, get all the newer patch files, enter the
top level directory of the kernel source (linux-3.x) and execute:
gzip -cd ../patch-3.x.gz | patch -p1
or
bzip2 -dc ../patch-3.x.bz2 | patch -p1
(repeat xx for all versions bigger than the version of your current
source tree, _in_order_) and you should be ok. You may want to remove
the backup files (xxx~ or xxx.orig), and make sure that there are no
failed patches (xxx# or xxx.rej). If there are, either you or me has
made a mistake.
Unlike patches for the 3.x kernels, patches for the 3.x.y kernels
(also known as the -stable kernels) are not incremental but instead apply
directly to the base 3.x kernel. Please read
Documentation/applying-patches.txt for more information.
Alternatively, the script patch-kernel can be used to automate this
process. It determines the current kernel version and applies any
patches found.
linux/scripts/patch-kernel linux
The first argument in the command above is the location of the
kernel source. Patches are applied from the current directory, but
an alternative directory can be specified as the second argument.
- If you are upgrading between releases using the stable series patches
(for example, patch-3.x.y), note that these "dot-releases" are
not incremental and must be applied to the 3.x base tree. For
example, if your base kernel is 3.0 and you want to apply the
3.0.3 patch, you do not and indeed must not first apply the
3.0.1 and 3.0.2 patches. Similarly, if you are running kernel
version 3.0.2 and want to jump to 3.0.3, you must first
reverse the 3.0.2 patch (that is, patch -R) _before_ applying
the 3.0.3 patch.
You can read more on this in Documentation/applying-patches.txt
- Make sure you have no stale .o files and dependencies lying around:
cd linux
make mrproper
You should now have the sources correctly installed.
SOFTWARE REQUIREMENTS
Compiling and running the 3.x kernels requires up-to-date
versions of various software packages. Consult
Documentation/Changes for the minimum version numbers required
and how to get updates for these packages. Beware that using
excessively old versions of these packages can cause indirect
errors that are very difficult to track down, so don't assume that
you can just update packages when obvious problems arise during
build or operation.
BUILD directory for the kernel:
When compiling the kernel all output files will per default be
stored together with the kernel source code.
Using the option "make O=output/dir" allow you to specify an alternate
place for the output files (including .config).
Example:
kernel source code: /usr/src/linux-3.N
build directory: /home/name/build/kernel
To configure and build the kernel use:
cd /usr/src/linux-3.N
make O=/home/name/build/kernel menuconfig
make O=/home/name/build/kernel
sudo make O=/home/name/build/kernel modules_install install
Please note: If the 'O=output/dir' option is used then it must be
used for all invocations of make.
CONFIGURING the kernel:
Do not skip this step even if you are only upgrading one minor
version. New configuration options are added in each release, and
odd problems will turn up if the configuration files are not set up
as expected. If you want to carry your existing configuration to a
new version with minimal work, use "make oldconfig", which will
only ask you for the answers to new questions.
- Alternate configuration commands are:
"make config" Plain text interface.
"make menuconfig" Text based color menus, radiolists & dialogs.
"make nconfig" Enhanced text based color menus.
"make xconfig" X windows (Qt) based configuration tool.
"make gconfig" X windows (Gtk) based configuration tool.
"make oldconfig" Default all questions based on the contents of
your existing ./.config file and asking about
new config symbols.
"make silentoldconfig"
Like above, but avoids cluttering the screen
with questions already answered.
Additionally updates the dependencies.
"make defconfig" Create a ./.config file by using the default
symbol values from either arch/$ARCH/defconfig
or arch/$ARCH/configs/${PLATFORM}_defconfig,
depending on the architecture.
"make ${PLATFORM}_defconfig"
Create a ./.config file by using the default
symbol values from
arch/$ARCH/configs/${PLATFORM}_defconfig.
Use "make help" to get a list of all available
platforms of your architecture.
"make allyesconfig"
Create a ./.config file by setting symbol
values to 'y' as much as possible.
"make allmodconfig"
Create a ./.config file by setting symbol
values to 'm' as much as possible.
"make allnoconfig" Create a ./.config file by setting symbol
values to 'n' as much as possible.
"make randconfig" Create a ./.config file by setting symbol
values to random values.
You can find more information on using the Linux kernel config tools
in Documentation/kbuild/kconfig.txt.
NOTES on "make config":
- having unnecessary drivers will make the kernel bigger, and can
under some circumstances lead to problems: probing for a
nonexistent controller card may confuse your other controllers
- compiling the kernel with "Processor type" set higher than 386
will result in a kernel that does NOT work on a 386. The
kernel will detect this on bootup, and give up.
- A kernel with math-emulation compiled in will still use the
coprocessor if one is present: the math emulation will just
never get used in that case. The kernel will be slightly larger,
but will work on different machines regardless of whether they
have a math coprocessor or not.
- the "kernel hacking" configuration details usually result in a
bigger or slower kernel (or both), and can even make the kernel
less stable by configuring some routines to actively try to
break bad code to find kernel problems (kmalloc()). Thus you
should probably answer 'n' to the questions for
"development", "experimental", or "debugging" features.
COMPILING the kernel:
- Make sure you have at least gcc 3.2 available.
For more information, refer to Documentation/Changes.
Please note that you can still run a.out user programs with this kernel.
- Do a "make" to create a compressed kernel image. It is also
possible to do "make install" if you have lilo installed to suit the
kernel makefiles, but you may want to check your particular lilo setup first.
To do the actual install you have to be root, but none of the normal
build should require that. Don't take the name of root in vain.
- If you configured any of the parts of the kernel as `modules', you
will also have to do "make modules_install".
- Verbose kernel compile/build output:
Normally the kernel build system runs in a fairly quiet mode (but not
totally silent). However, sometimes you or other kernel developers need
to see compile, link, or other commands exactly as they are executed.
For this, use "verbose" build mode. This is done by inserting
"V=1" in the "make" command. E.g.:
make V=1 all
To have the build system also tell the reason for the rebuild of each
target, use "V=2". The default is "V=0".
- Keep a backup kernel handy in case something goes wrong. This is
especially true for the development releases, since each new release
contains new code which has not been debugged. Make sure you keep a
backup of the modules corresponding to that kernel, as well. If you
are installing a new kernel with the same version number as your
working kernel, make a backup of your modules directory before you
do a "make modules_install".
Alternatively, before compiling, use the kernel config option
"LOCALVERSION" to append a unique suffix to the regular kernel version.
LOCALVERSION can be set in the "General Setup" menu.
- In order to boot your new kernel, you'll need to copy the kernel
image (e.g. .../linux/arch/i386/boot/bzImage after compilation)
to the place where your regular bootable kernel is found.
- Booting a kernel directly from a floppy without the assistance of a
bootloader such as LILO, is no longer supported.
If you boot Linux from the hard drive, chances are you use LILO which
uses the kernel image as specified in the file /etc/lilo.conf. The
kernel image file is usually /vmlinuz, /boot/vmlinuz, /bzImage or
/boot/bzImage. To use the new kernel, save a copy of the old image
and copy the new image over the old one. Then, you MUST RERUN LILO
to update the loading map!! If you don't, you won't be able to boot
the new kernel image.
Reinstalling LILO is usually a matter of running /sbin/lilo.
You may wish to edit /etc/lilo.conf to specify an entry for your
old kernel image (say, /vmlinux.old) in case the new one does not
work. See the LILO docs for more information.
After reinstalling LILO, you should be all set. Shutdown the system,
reboot, and enjoy!
If you ever need to change the default root device, video mode,
ramdisk size, etc. in the kernel image, use the 'rdev' program (or
alternatively the LILO boot options when appropriate). No need to
recompile the kernel to change these parameters.
- Reboot with the new kernel and enjoy.
IF SOMETHING GOES WRONG:
- If you have problems that seem to be due to kernel bugs, please check
the file MAINTAINERS to see if there is a particular person associated
with the part of the kernel that you are having trouble with. If there
isn't anyone listed there, then the second best thing is to mail
them to me ([email protected]), and possibly to any other
relevant mailing-list or to the newsgroup.
- In all bug-reports, *please* tell what kernel you are talking about,
how to duplicate the problem, and what your setup is (use your common
sense). If the problem is new, tell me so, and if the problem is
old, please try to tell me when you first noticed it.
- If the bug results in a message like
unable to handle kernel paging request at address C0000010
Oops: 0002
EIP: 0010:XXXXXXXX
eax: xxxxxxxx ebx: xxxxxxxx ecx: xxxxxxxx edx: xxxxxxxx
esi: xxxxxxxx edi: xxxxxxxx ebp: xxxxxxxx
ds: xxxx es: xxxx fs: xxxx gs: xxxx
Pid: xx, process nr: xx
xx xx xx xx xx xx xx xx xx xx
or similar kernel debugging information on your screen or in your
system log, please duplicate it *exactly*. The dump may look
incomprehensible to you, but it does contain information that may
help debugging the problem. The text above the dump is also
important: it tells something about why the kernel dumped code (in
the above example it's due to a bad kernel pointer). More information
on making sense of the dump is in Documentation/oops-tracing.txt
- If you compiled the kernel with CONFIG_KALLSYMS you can send the dump
as is, otherwise you will have to use the "ksymoops" program to make
sense of the dump (but compiling with CONFIG_KALLSYMS is usually preferred).
This utility can be downloaded from
ftp://ftp.<country>.kernel.org/pub/linux/utils/kernel/ksymoops/ .
Alternately you can do the dump lookup by hand:
- In debugging dumps like the above, it helps enormously if you can
look up what the EIP value means. The hex value as such doesn't help
me or anybody else very much: it will depend on your particular
kernel setup. What you should do is take the hex value from the EIP
line (ignore the "0010:"), and look it up in the kernel namelist to
see which kernel function contains the offending address.
To find out the kernel function name, you'll need to find the system
binary associated with the kernel that exhibited the symptom. This is
the file 'linux/vmlinux'. To extract the namelist and match it against
the EIP from the kernel crash, do:
nm vmlinux | sort | less
This will give you a list of kernel addresses sorted in ascending
order, from which it is simple to find the function that contains the
offending address. Note that the address given by the kernel
debugging messages will not necessarily match exactly with the
function addresses (in fact, that is very unlikely), so you can't
just 'grep' the list: the list will, however, give you the starting
point of each kernel function, so by looking for the function that
has a starting address lower than the one you are searching for but
is followed by a function with a higher address you will find the one
you want. In fact, it may be a good idea to include a bit of
"context" in your problem report, giving a few lines around the
interesting one.
If you for some reason cannot do the above (you have a pre-compiled
kernel image or similar), telling me as much about your setup as
possible will help. Please read the REPORTING-BUGS document for details.
- Alternately, you can use gdb on a running kernel. (read-only; i.e. you
cannot change values or set break points.) To do this, first compile the
kernel with -g; edit arch/i386/Makefile appropriately, then do a "make
clean". You'll also need to enable CONFIG_PROC_FS (via "make config").
After you've rebooted with the new kernel, do "gdb vmlinux /proc/kcore".
You can now use all the usual gdb commands. The command to look up the
point where your system crashed is "l *0xXXXXXXXX". (Replace the XXXes
with the EIP value.)
gdb'ing a non-running kernel currently fails because gdb (wrongly)
disregards the starting offset for which the kernel is compiled.
修改生成的Android核心編譯配置檔案.config,增加Android核心編譯的config選項。預設的 make goldfish_armv7_defconfig 配置沒有開啟除錯選項,也沒有使用HIGHMEM等選項,因此為了使用 kgdb 除錯Android核心必須增加這些選項。這裡手動開啟goldfish/.config檔案,增加除錯相關的選項配置。
# 開啟Android核心編譯的配置檔案
$ gedit .config
增加的編譯配置選項:
# 設定模擬器的執行記憶體-可選引數
CONFIG_HIGHMEM=y
CONFIG_DEBUG_KERNEL=y
CONFIG_KGDB=y
CONFIG_DEBUG_INFO=y
# 真機裝置除錯需要設定這一項,模擬器不需要
#CONFIG_KGDB_SERIAL_CONSOLE=y
# 可以是直接在配置檔案中去掉這一項
CONFIG_DEBUG_RODATA=n
具體每一個配置選項的作用,可以參考這篇博文《用 kGDB 除錯 Linux 核心》,簡單的描述如下圖,其中開啟 CONFIG_HIGHMEM=y 這個選項後,啟動模擬器時 emulator -memory 引數才能發揮作用即可以設定Android模擬器啟動時的執行記憶體的大小,是一個可選的引數,因為可以直接使用
Adt-bundle-x86_64 或者 Android Studio 提供的建立Andorid模擬器的工具設定,不需要手動新增 -memory引數 進行修改。
執行修改Android核心編譯配置檔案.config的結果如下圖所示:
Android核心編譯配置檔案的修改也可以通過執行 make menuconfig 命令進行修改,只不過麻煩一下。上面修改.config完成以後,儲存和關閉.config檔案,然後執行下面的命令進行Android核心原始碼的編譯。由於前面修改Android核心編譯配置時,增加了幾個配置,因此編譯一開始會有提示讓選擇配置選項,記得相關的配置全部選 y 就可以了。Android核心編譯完成後,goldfish/arch/arm/boot/zImage檔案出現,這個檔案就是Android核心檔案了。
$ make -j4
Android核心原始碼編譯成功後的結果截圖如下:
四、Android核心的除錯
1.使用 Adt-bundle-x86_64 或者 Android Studio 開發Android程式時搭建的環境中的Android模擬器 emulator 來載入上面編譯成功的Android核心映象檔案。根據Android核心原始碼 android-goldfish-3.4 支援的Android系統的版本,來建立Android 模擬器命名為 Debug_Kernel 。這裡根據實際情況建立Android 4.4.4 API 19 版本的Android模擬器。首先使用Android綜合開發工具 Android Studio 建立名稱為 Debug_Kernel 的Android模擬器,設引數置如下圖,後面用建立的這個模擬器來載入上面編譯成功的Android核心映象檔案 goldfish/arch/arm/boot/zImage,進行Android核心的除錯。
提示:
1.在進行後面的實踐中,需要新增Android SDK到系統的環境變數中,否則執行 emulator 命令時需要使用全路徑比較麻煩,下面是新增 Android SDK 到環境變數中的操作命令:
# 編輯環境變數配置檔案
$ sudo gedit /etc/profile
# 新增到環境變數配置檔案/etc/profile中的內容
# Android SDK
export ANDROID_SDK=/home/fly2016/Android/Sdk
export PATH=$PATH:${ANDROID_SDK}/platform-tools:${ANDROID_SDK}/tools
# Android NDK(順便新增)
export ANDROID_NDK=/home/fly2016/Android/Sdk/ndk-bundle
export PATH=$PATH:${ANDROID_NDK}
# 更新系統環境變數
$ source /etc/profile
# 測試Android SDK是否配置成功的命令
$ adb verison
$ emulator -help
# 測試Android NDK是否配置成功的命令
$ ndk-build
2.這裡是用Android Studio的工具建立的Android虛擬機器 Debug_Kernel,當然使用 Adt-bundle-x86_64的工具建立Android 虛擬機器 Debug_Kernel 是可以的,甚至是使用 android create avd 命令進行Android模擬器的建立也是可以的。有關 android
create avd 命令建立Android 虛擬機器的使用幫助如下:
$ android create avd
Error: The parameters --name, --target must be defined for action 'create avd'
Usage:
android [global options] create avd [action options]
Global options:
-h --help : Help on a specific command.
-v --verbose : Verbose mode, shows errors, warnings and all messages.
--clear-cache: Clear the SDK Manager repository manifest cache.
-s --silent : Silent mode, shows errors only.
Action "create avd":
Creates a new Android Virtual Device.
Options:
-g --tag : The sys-img tag to use for the AVD. The default is to
auto-select if the platform has only one tag for its system
images.
-c --sdcard : Path to a shared SD card image, or size of a new sdcard for
the new AVD.
-n --name : Name of the new AVD. [required]
-a --snapshot: Place a snapshots file in the AVD, to enable persistence.
-p --path : Directory where the new AVD will be created.
-f --force : Forces creation (overwrites an existing AVD)
-s --skin : Skin for the new AVD.
-t --target : Target ID of the new AVD. [required]
-b --abi : The ABI to use for the AVD. The default is to auto-select the
ABI if the platform has only one ABI for its system images.
-d --device : The optional device definition to use. Can be a device index
or id.
使用 android create avd 命令,建立Android模擬器Debug_Kernel的示例,如下:
# 檢視本地下載的Android SDK
$ android list targets
# 建立Android模擬器 Debug_Kernel
$ android create avd -n Debug_Kernel -t android-19 -b default/armeabi-v7a -s HVGA
Android API 19的Android模擬器 Debug_Kernel 建立成功以後,使用下面的命令檢查新建立的Android模擬器 Debug_Kernel 能否正常啟動成功。
# 檢視已經建立的Android模擬器
$ emulator -list-avds
# 啟動執行建立的Android模擬器Debug_Kernel
$ emulator -avd Debug_Kernel -gpu mesa
Android模擬器 Debug_Kernel 啟動成功,說明準備工作已經做好了。現在可以在
Android核心原始碼的根目錄下 執行下面的命令,以 -kernel引數 指定載入前面編譯成功的Android核心映象檔案 goldfish/arch/arm/boot/zImage ,並以等待除錯模式啟動Android模擬器 Debug_Kernel 。$ emulator -avd Debug_Kernel -verbose -netfast -show-kernel -kernel ./arch/arm/boot/zImage -gpu mesa -qemu -s -S
除錯核心一般不需要顯示圖形介面和聲音,因此增加啟動選項 -no-window, no-audio ,增加 -verbose -show-kernel 選項 可以看到核心的詳細輸出資訊,-kernel 選項 指定載入的核心映象檔案為前面編譯的Android核心映象檔案,增加 -qemu -s -S 選項 啟動除錯監聽即Android核心啟動以後會監聽埠 1234 ,暫停等待除錯,這時需要開啟另一個命令終端執行 gdb 程式,對Android核心進行除錯,還可以增加 -memory 2048 選項 設定執行的記憶體大小,增加執行記憶體使除錯執行更流暢。
執行結果輸出資訊,如下所示:
[email protected]:~/Desktop/Android4.4.4r1/goldfish-kernel-3.4/goldfish$ emulator -avd Debug_Kernel -verbose -netfast -show-kernel -kernel ./arch/arm/boot/zImage -gpu mesa -qemu -s -S
emulator:Found AVD name 'Debug_Kernel'
emulator:Found AVD target architecture: arm
emulator: Found directory: /home/fly2016/Android/Sdk/system-images/android-19/default/armeabi-v7a/
emulator:Probing for /home/fly2016/Android/Sdk/system-images/android-19/default/armeabi-v7a//kernel-ranchu: file missing
emulator:Auto-config: -engine classic (based on configuration)
emulator: Found directory: /home/fly2016/Android/Sdk/system-images/android-19/default/armeabi-v7a/
emulator:Looking for emulator-arm to emulate 'arm' CPU
emulator:Probing program: /home/fly2016/Android/Sdk/tools/emulator64-arm
emulator:return result: /home/fly2016/Android/Sdk/tools/emulator64-arm
emulator:Found target-specific 64-bit emulator binary: /home/fly2016/Android/Sdk/tools/emulator64-arm
emulator:Adding library search path: '/home/fly2016/Android/Sdk/tools/lib64'
emulator:Adding library search path: '/home/fly2016/Android/Sdk/tools/lib64/libstdc++'
emulator: Found directory: /home/fly2016/Android/Sdk/system-images/android-19/default/armeabi-v7a/
emulator: Found directory: /home/fly2016/Android/Sdk/system-images/android-19/default/armeabi-v7a/
emulator:GPU emulation enabled using 'mesa' mode
WARNING: The Mesa software renderer is deprecated. Use Swiftshader (-gpu swiftshader) for software rendering.
emulator: Adding library search path for Qt: '/home/fly2016/Android/Sdk/tools/lib64/qt/lib'
emulator: Setting Qt plugin search path: QT_QPA_PLATFORM_PLUGIN_PATH=/home/fly2016/Android/Sdk/tools/lib64/qt/plugins
emulator: Running :/home/fly2016/Android/Sdk/tools/emulator64-arm
emulator: qemu backend: argv[00] = "/home/fly2016/Android/Sdk/tools/emulator64-arm"
emulator: qemu backend: argv[01] = "-avd"
emulator: qemu backend: argv[02] = "Debug_Kernel"
emulator: qemu backend: argv[03] = "-verbose"
emulator: qemu backend: argv[04] = "-netfast"
emulator: qemu backend: argv[05] = "-show-kernel"
emulator: qemu backend: argv[06] = "-kernel"
emulator: qemu backend: argv[07] = "./arch/arm/boot/zImage"
emulator: qemu backend: argv[08] = "-gpu"
emulator: qemu backend: argv[09] = "mesa"
emulator: qemu backend: argv[10] = "-qemu"
emulator: qemu backend: argv[11] = "-s"
emulator: qemu backend: argv[12] = "-S"
emulator: Concatenated backend parameters:
/home/fly2016/Android/Sdk/tools/emulator64-arm -avd Debug_Kernel -verbose -netfast -show-kernel -kernel ./arch/arm/boot/zImage -gpu mesa -qemu -s -S
emulator: Android virtual device file at: /home/fly2016/.android/avd/Debug_Kernel.ini
emulator: virtual device content at /home/fly2016/.android/avd/Debug_Kernel.avd
emulator: virtual device config file: /home/fly2016/.android/avd/Debug_Kernel.avd/config.ini
emulator: using core hw config path: /home/fly2016/.android/avd/Debug_Kernel.avd/hardware-qemu.ini
emulator: Found AVD target API level: 19
emulator: Read property file at /home/fly2016/Android/Sdk/system-images/android-19/default/armeabi-v7a//build.prop
emulator: No boot.prop property file found.
emulator: found skin 'nexus_5' in directory: /opt/android-studio/plugins/android/lib/device-art-resources/
emulator: autoconfig: -skin nexus_5
emulator: autoconfig: -skindir /opt/android-studio/plugins/android/lib/device-art-resources/
emulator: Auto-detect: Kernel image requires legacy device naming scheme.
emulator: Auto-detect: Kernel does support YAFFS2 partitions.
emulator: autoconfig: -ramdisk /home/fly2016/Android/Sdk/system-images/android-19/default/armeabi-v7a//ramdisk.img
emulator: Using initial system image: /home/fly2016/Android/Sdk/system-images/android-19/default/armeabi-v7a//system.img
emulator: autoconfig: -initdata /home/fly2016/.android/avd/Debug_Kernel.avd/userdata.img
emulator: autoconfig: -cache /home/fly2016/.android/avd/Debug_Kernel.avd/cache.img
emulator: autoconfig: -sdcard /home/fly2016/.android/avd/Debug_Kernel.avd/sdcard.img
emulator: Physical RAM size: 1536MB
emulator: VM heap size 64MB is below hardware specified minimum of 384MB,setting it to that value
emulator: System image is read only
emulator: GPU emulation enabled using 'mesa' mode
emulator: Found 1 DNS servers: 192.168.170.2
emulator: trying to load skin file '/opt/android-studio/plugins/android/lib/device-art-resources//nexus_5/layout'
emulator: Found 1 DNS servers: 192.168.170.2
emulator: WARNING: Classic qemu does not support SMP. The hw.cpu.ncore option from your config file is ignored.
Content of hardware configuration file:
hw.cpu.arch = arm
hw.cpu.model = cortex-a8
hw.cpu.ncore = 2
hw.ramSize = 1536
hw.screen = touch
hw.mainKeys = false
hw.trackBall = false
hw.keyboard = true
hw.keyboard.lid = false
hw.keyboard.charmap = qwerty2
hw.dPad = false
hw.gsmModem = true
hw.gps = true
hw.battery = true
hw.accelerometer = true
hw.audioInput = true
hw.audioOutput = true
hw.sdCard = true
hw.sdCard.path = /home/fly2016/.android/avd/Debug_Kernel.avd/sdcard.img
disk.cachePartition = true
disk.cachePartition.path = /home/fly2016/.android/avd/Debug_Kernel.avd/cache.img
disk.cachePartition.size = 66m
hw.lcd.width = 1080
hw.lcd.height = 1920
hw.lcd.depth = 16
hw.lcd.density = 480
hw.lcd.backlight = true
hw.gpu.enabled = true
hw.gpu.mode = mesa
hw.gpu.blacklisted = no
hw.initialOrientation = portrait
hw.camera.back = none
hw.camera.front = none
vm.heapSize = 384
hw.sensors.light = true
hw.sensors.pressure = true
hw.sensors.humidity = true
hw.sensors.proximity = true
hw.sensors.magnetic_field = true
hw.sensors.orientation = true
hw.sensors.temperature = true
hw.useext4 = true
kernel.path = ./arch/arm/boot/zImage
kernel.newDeviceNaming = no
kernel.supportsYaffs2 = yes
disk.ramdisk.path = /home/fly2016/Android/Sdk/system-images/android-19/default/armeabi-v7a//ramdisk.img
disk.systemPartition.initPath = /home/fly2016/Android/Sdk/system-images/android-19/default/armeabi-v7a//system.img
disk.systemPartition.size = 550m
disk.dataPartition.path = /home/fly2016/.android/avd/Debug_Kernel.avd/userdata-qemu.img
disk.dataPartition.initPath = /home/fly2016/.android/avd/Debug_Kernel.avd/userdata.img
disk.dataPartition.size = 550m
avd.name = Debug_Kernel
.
emulator: WARNING: CPU acceleration only works with x86/x86_64 system images.
QEMU options list:
emulator: argv[00] = "/home/fly2016/Android/Sdk/tools/emulator64-arm"
emulator: argv[01] = "-netfast"
emulator: argv[02] = "-dns-server"
emulator: argv[03] = "192.168.170.2"
emulator: argv[04] = "-serial"
emulator: argv[05] = "android-kmsg"
emulator: argv[06] = "-serial"
emulator: argv[07] = "null"
emulator: argv[08] = "-android-hw"
emulator: argv[09] = "/home/fly2016/.android/avd/Debug_Kernel.avd/hardware-qemu.ini"
emulator: argv[10] = "-s"
emulator: argv[11] = "-S"
emulator: argv[12] = "-append"
emulator: argv[13] = "qemu=1 androidboot.hardware=goldfish console=ttyS0 android.qemud=1 android.checkjni=1 qemu.gles=1"
Concatenated QEMU options:
/home/fly2016/Android/Sdk/tools/emulator64-arm -netfast -dns-server 192.168.170.2 -serial android-kmsg -serial null -android-hw /home/fly2016/.android/avd/Debug_Kernel.avd/hardware-qemu.ini -s -S -append 'qemu=1 androidboot.hardware=goldfish console=ttyS0 android.qemud=1 android.checkjni=1 qemu.gles=1'
emulator: Starting QEMU main loop
emulator: registered 'boot-properties' qemud service
emulator: Using kernel serial device prefix: ttyS
emulator: AVD Name: Debug_Kernel
emulator: Ramdisk image contains fstab.goldfish file
emulator: Found format of system partition: 'ext4'
emulator: Found format of userdata partition: 'ext4'
emulator: Found format of cache partition: 'ext4'
emulator: system partition format: ext4
emulator: nand_add_dev: system,size=0x22600000,file=/home/fly2016/Android/Sdk/system-images/android-19/default/armeabi-v7a//system.img,pagesize=512,extrasize=0,readonly
emulator: userdata partition format: ext4
emulator: nand_add_dev: userdata,size=0x22600000,file=/home/fly2016/.android/avd/Debug_Kernel.avd/userdata-qemu.img,pagesize=512,extrasize=0
emulator: cache partition format: ext4
emulator: Creating empty cache partition image at: /home/fly2016/.android/avd/Debug_Kernel.avd/cache.img
Creating filesystem with parameters:
Size: 69206016
Block size: 4096
Blocks per group: 32768
Inodes per group: 4224
Inode size: 256
Journal blocks: 1024
Label:
Blocks: 16896
Block groups: 1
Reserved block group size: 7
Created filesystem with 11/4224 inodes and 1302/16896 blocks
emulator: nand_add_dev: cache,size=0x4200000,file=/home/fly2016/.android/avd/Debug_Kernel.avd/cache.img,pagesize=512,extrasize=0
emulator: Adding boot property: 'dalvik.vm.heapsize' = '384m'
emulator: Adding boot property: 'qemu.sf.lcd_density' = '480'
emulator: Adding boot property: 'qemu.hw.mainkeys' = '0'
emulator: Adding boot property: 'qemu.sf.fake_camera' = 'none'
emulator: Found 1 DNS servers: 192.168.170.2
emulator: Adding boot property: 'ro.opengles.version' = '131072'
emulator: Initializing hardware OpenGLES emulation support
emulator: Kernel parameters: qemu=1 androidboot.hardware=goldfish console=ttyS0 android.qemud=1 android.checkjni=1 qemu.gles=1
emulator: ro.adb.qemud invalid or not found, API >= 16, defaulting ro.adb.qemud = 0
emulator: (setup_console_and_adb_ports) trying console port 5554, adb port 5555 (legacy: true)
emulator: (android_console_start) initializing on port 5554
bind: Transport endpoint is not connected
emulator: (setup_console_and_adb_ports) trying console port 5556, adb port 5557 (legacy: true)
emulator: (android_console_start) initializing on port 5556
emulator: control console listening on port 5556, ADB on port 5557
emulator: sent '0012host:emulator:5557' to ADB server
emulator: Listening for console connections on port: 5556
emulator: Serial number of this emulator (for ADB): emulator-5556
emulator: android_hw_fingerprint_init: fingerprint qemud listen service initialized
emulator: Skipping metrics reporting: No user opt-in.
Android模擬器 emulator 命令的使用幫助說明如下,上面Android模擬器的各個啟動引數的意思,可以參考下面命令幫助。
$ emulator -help
sh: 1: glxinfo: not found
Android Emulator usage: emulator [options] [-qemu args]
options:
-list-avds list available AVDs
-sysdir <dir> search for system disk images in <dir>
-system <file> read initial system image from <file>
-writable-system make system image writable after 'adb remount'
-datadir <dir> write user data into <dir>
-kernel <file> use specific emulated kernel
-ramdisk <file> ramdisk image (default <system>/ramdisk.img
-image <file> obsolete, use -system <file> instead
-initdata <file> same as '-init-data <file>'
-data <file> data image (default <datadir>/userdata-qemu.img
-partition-size <size> system/data partition size in MBs
-cache <file> cache partition image (default is temporary file)
-cache-size <size> cache partition size in MBs
-no-cache disable the cache partition
-nocache same as -no-cache
-sdcard <file> SD card image (default <datadir>/sdcard.img
-snapstorage <file> file that contains all state snapshots (default <datadir>/snapshots.img)
-no-snapstorage do not mount a snapshot storage file (this disables all snapshot functionality)
-snapshot <name> name of snapshot within storage file for auto-start and auto-save (default 'default-boot')
-no-snapshot perform a full boot and do not do not auto-save, but qemu vmload and vmsave operate on snapstorage
-no-snapshot-save do not auto-save to snapshot on exit: abandon changed state
-no-snapshot-load do not auto-start from snapshot: perform a full boot
-snapshot-list show a list of available snapshots
-no-snapshot-update-time do not do try to correct snapshot time on restore
-wipe-data reset the user data image (copy it from initdata)
-avd <name> use a specific android virtual device
-skindir <dir> search skins in <dir> (default <system>/skins)
-skin <name> select a given skin
-no-skin deprecated: create an AVD with no skin instead
-noskin same as -no-skin
-memory <size> physical RAM size in MBs
-accel <mode> Configure emulation acceleration
-no-accel Same as '-accel off'
-ranchu Use new emulator backend instead of the classic one
-engine <engine> Select engine. auto|classic|qemu2
-netspeed <speed> maximum network download/upload speeds
-netdelay <delay> network latency emulation
-netfast disable network shaping
-code-profile <name> enable code profiling
-show-kernel display kernel messages
-shell enable root shell on current terminal
-no-jni disable JNI checks in the Dalvik runtime
-nojni same as -no-jni
-logcat <tags> enable logcat output with given tags
-use-system-libs Use system libstdc++ instead of bundled one
-no-audio disable audio support
-noaudio same as -no-audio
-audio <backend> use specific audio backend
-raw-keys disable Unicode keyboard reverse-mapping (deprecated)
-radio <device> redirect radio modem interface to character device
-port <port> TCP port that will be used for the console
-ports <consoleport>,<adbport> TCP ports used for the console and adb bridge
-onion <image> use overlay PNG image over screen
-onion-alpha <%age> specify onion-skin translucency
-onion-rotation 0|1|2|3 specify onion-skin rotation
-dpi-device <dpi> specify device's resolution in dpi (default 165)
-scale <scale> scale emulator window (deprecated)
-http-proxy <proxy> make TCP connections through a HTTP/HTTPS proxy
-timezone <timezone> use this timezone instead of the host's default
-dns-server <servers> use this DNS server(s) in the emulated system
-cpu-delay <cpudelay> throttle CPU emulation
-no-boot-anim disable animation for faster boot
-no-window disable graphical window display
-version display emulator version number
-report-console <socket> report console port to remote socket
-gps <device> redirect NMEA GPS to character device
-keyset <name> specify keyset file name
-shell-serial <device> specific character device for root shell
-tcpdump <file> capture network packets to file
-bootchart <timeout> enable bootcharting
-charmap <file> use specific key character map
-prop <name>=<value> set system property on boot
-shared-net-id <number> join the shared network, using IP address 10.1.2.<number>
-nand-limits <nlimits> enforce NAND/Flash read/write thresholds
-gpu <mode> set hardware OpenGLES emulation mode
-camera-back <mode> set emulation mode for a camera facing back
-camera-front <mode> set emulation mode for a camera facing front
-webcam-list lists web cameras available for emulation
-screen <mode> set emulated screen mode
-force-32bit always use 32-bit emulator
-selinux <disabled|permissive> Set SELinux to either disabled or permissive mode
-unix-pipe <path> Add <path> to the list of allowed Unix pipes
-fixed-scale Use fixed 1:1 scale for the initial emulator window.
-qemu args... pass arguments to qemu
-qemu -h display qemu help
-verbose same as '-debug-init'
-debug <tags> enable/disable debug messages
-debug-<tag> enable specific debug messages
-debug-no-<tag> disable specific debug messages
-help print this help
-help-<option> print option-specific help
-help-disk-images about disk images
-help-keys supported key bindings
-help-debug-tags debug tags for -debug <tags>
-help-char-devices character <device> specification
-help-environment environment variables
-help-keyset-file key bindings configuration file
-help-virtual-device virtual device management
-help-sdk-images about disk images when using the SDK
-help-build-images about disk images when building Android
-help-all prints all help content
其實Android模擬器 emulator 就是
基於qemu虛擬機器 開發的,因此Android模擬器 emulator 在執行的時候也支援qemu虛擬機器的命令,在上面以 除錯模式啟動 Android虛擬機器 Debug_Kernel 時使用的啟動選項 -qemu -s -S的作用,可以參考命令列的幫助,如下圖:
Android模擬器 emulator 使用qemu虛擬機器命令列引數 的詳細幫助參考如下:
[email protected]:~$ emulator -qemu -h
sh: 1: glxinfo: not found
QEMU emulator version 2.2.0 , Copyright (c) 2003-2008 Fabrice Bellard
usage: qemu-system-i386 [options] [disk_image]
'disk_image' is a raw hard disk image for IDE hard disk 0
Standard options:
-h or -help display this help and exit
-version display version information and exit
-machine [type=]name[,prop[=value][,...]]
selects emulated machine ('-machine help' for list)
property accel=accel1[:accel2[:...]] selects accelerator
supported accelerators are kvm, xen, tcg (default: tcg)
kernel_irqchip=on|off controls accelerated irqchip support
vmport=on|off|auto controls emulation of vmport (default: auto)
kvm_shadow_mem=size of KVM shadow MMU
dump-guest-core=on|off include guest memory in a core dump (default=on)
mem-merge=on|off controls memory merge support (default: on)
iommu=on|off controls emulated Intel IOMMU (VT-d) support (default=off)
-cpu cpu select CPU ('-cpu help' for list)
-smp [cpus=]n[,maxcpus=cpus][,cores=cores][,threads=threads][,sockets=sockets]
set the number of CPUs to 'n' [default=1]
maxcpus= maximum number of total cpus, inclu