本帖最后由 諫山黄泉 于 2013-3-16 14:22 编辑
/**
* [渣翻] xda: http://forum.xda-developers.com/showthread.php?t=2010338
*
* 转载请注明出处: http://bbs.gfan.com/android-5576468-1-1.html
*
* 略长, 懒得翻请自行Crtl+F
* 不定时更新...
*
* 科普向教程第二部分: http://bbs.gfan.com/android-5795118-1-1.html
*/
FAQ:
1, 什么是android?
Android(读音:['ændrɔid],中文俗称安卓)是一个以Linux为基础的半开源操作系统,主要用于移动设备,由Google成立的Open Handset Alliance(OHA,开放手持设备联盟)持续领导与开发中。
wiki: http://zh.wikipedia.org/wiki/Android
2, 什么是SDK, 我必须安装吗?
SDK = "software development kit" , 除非你是开发者, 不然这东西完全是浪费空间, 你所需要的只是SDK中提供的有关FASTBOOT与ADB的几个文件和驱动而已.
3, 什么是驱动, 我为什么要安装呢...?
知道什么是驱动就知道为什么了, wiki: http://zh.wikipedia.org/wiki/%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F
4, 我从哪儿能搞到驱动?
这个: http://forum.xda-developers.com/showthread.php?t=1992345
或者这个: http://forum.xda-developers.com/showthread.php?t=1996051
作者推荐第二个
5, 为什么要安装两次驱动?
android和PC有两种主要的通信方式: FASTBOOT和ADB, 两种接入方式的驱动是不同的, 所以需要安装两次. 以FASTBOOT方式( bootloader) 启动手机, 链接电脑后安装一次驱动; 而ADB模式需要android内核的支持, 所以正常启动手机( 或者某些自制recovery, 例如CWM) , 打开USB调试( USB debugging) , 然后连接电脑, 安装ADB驱动.
6, 怎么进入bootloader (FASTBOOT模式) ?
关掉手机, 摁住音量-键, 然后再摁住电源键, 直到开机.
7, 什么是命令行?
Windows下的命令行( Linux/MacOS下的终端), 是在图形用户界面得到普及之前使用最为广泛的用户界面,它通常不支持鼠标,用户通过键盘输入指令,计算机接收到指令后,予以执行。
wiki: http://zh.wikipedia.org/wiki/%E5%91%BD%E4%BB%A4%E8%A1%8C
TIPS: 在文件夹里, 摁住SHIFT键, 然后右键, 会看到: 在此处打开命令行窗口的选项
8, 什么是bootloader?
Bootloader(引导加载程序)是系统加电后运行的第一段代码, 一般运行的时间非常短, 但是对于嵌入式系统来说, 这段代码非常重要. 在我们的台式电脑当中, 引导加载程序由BIOS(固件程序)和位于硬盘MBR中的操作系统引导加载程序(比如NTLOADER,GRUB和LILO)一起组成.
在一般的典型系统中,整个系统的加载启动任务全由bootloader来完成. 在ARM中,系统上电或复位时通常从地址0x00000000处开始执行,而在这个位置,通常安排的就是系统的bootloader。通过这小段程序可以初始化硬件设备、建立内存空间映射图,从而将系统的软硬件环境设置到一个合适的状态!以为最终调用操作系统内核准备好正确的环境.
9, bootloader 有锁/解锁( locked/unlocked)?
你从厂家得到的设备大多是处于有锁状态. 出于安全考虑, 锁定的bootloader只能刷写拥有官方签名的镜像, 这意味着你很难改变或者修改操作系统. 解锁bootloader并不会增加设备的功能, 但是解锁后你可以随心所欲的刷写自制镜像与程序, 方便折腾...
10, 什么是root?
root本质上来说就是你获得了对系统文件与分区的root权限, 类似于Windows的管理员权限. root跟bootloader没半毛钱关系, root的是系统本身.
11, 怎么root?
root的实现过程是: 向系统目录下写入 一个叫做 su的可执行文件(功能为获得root权限), 并安装一个控制该权限开启与关闭的APP.
( PS: 每个命令都有对应的二进制可执行文件, 执行命令, 就是执行相应的二进制文件的过程, 而%PATH%保存的就是这些执行文件所在的目录...比方说常见的: cd, ls, cp, ifconfig 这几个命令的执行文件保存在 /system/bin下; su, 和busybox的命令, 习惯上, 安装在 /system/xbin 下...)
N4可用的是Chainfire的SuperSU: http://forum.xda-developers.com/showthread.php?t=1538053
非常详细的, 刷工厂镜像, root, 解锁教程: http://bbs.gfan.com/android-5795118-1-1.html
12, 解锁bootloader和root是一个意思吗?
不是, 解锁bootloader的作用是方便刷写; root的作用是获得最高权限, 可以随意操作系统文件.
13, 解锁bootloader之后必须root吗?
No.
14, 解锁bootloader后必须刷自制ROM吗?
No.
15, root之后才能刷ROM吗?
No.
16, 什么是ROM?
这里指android刷机包.
17, 不同版本android的区别是什么? 4.2 和 JOP40C有什么区别?
看这个: http://source.android.com/source/build-numbers.html
18, 原生镜像和自制镜像的区别是什么?
由Google开发编译的镜像为原生镜像( stock ROM), 其他的都是自制镜像.
19, 总听到AOSP这个词, 啥意思?
AOSP = Android Open Source Project, 他们负责android的源码编写与修改, 详情点击这里: http://source.android.com/
20, 什么是FASTBOOT?
三个意思 : 1, 用来设备和PC间通信的一个命令行工具 2, fastboot.exe 3, 设备的一种启动模式.
FASTBOOT是一个特殊的工程模式, 通过fastboot界面, 连接电脑后, 我们可以在电脑端通过特殊的指令来操作手机.
使用FASTBOOT命令, 需要PC上要安装有FASTBOOT驱动, 当前目录下必须存在fastboot.exe, 手机需要以FASTBOOT模式启动, 然后连接电脑.
22, FASTBOOT命令
在fastboot.exe所在的文件夹下打开命令行, 输入fastboot, 可以看到fastboot的命令格式.
- fastboot
- usage: fastboot [ <option> ] <command>
- commands:
- update <filename> reflash device from update.zip
- flashall flash boot + recovery + system
- flash <partition> [ <filename> ] write a file to a flash partition
- erase <partition> erase a flash partition
- format <partition> format a flash partition
- getvar <variable> display a bootloader variable
- boot <kernel> [ <ramdisk> ] download and boot kernel
- flash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash it
- devices list all connected devices
- continue continue with autoboot
- reboot reboot device normally
- reboot-bootloader reboot device into bootloader
- help show this help message
- options:
- -w erase userdata and cache
- -s <serial number> specify device serial number
- -p <product> specify product name
- -c <cmdline> override kernel commandline
- -i <vendor id> specify a custom USB vendor id
- -b <base_addr> specify a custom kernel base address
- -n <page size> specify the nand page size. default: 2048
复制代码
除去上面那些, 还有一个oem命令.
这些命令, 在FASTBOOT模式下, 不管有没有解锁bootloader都可以使用:
oem: 用来解锁或者锁定bootloader, 例如: fastboot oem unlock 是解锁bootloader的命令, fastboot oem lock, 是重新锁定bootloader的命令.
devices: 这命令用来检查设备是否已经正确的以FASTBOOT模式连接电脑, 例如: fastboot devices
reboot: 重启命令, 例如: fastboot reboot
reboot-bootloader: 这命令将会让你的设备重启到bootloader模式, 例如: fastboot reboot-bootloader
下面这些命令只有在解锁bootloader后才有效:
flash: 用来刷写镜像, 不能用来刷写来路不明的文件或者zip, 例如, 刷写系统区块的命令: fastboot flash system system.img
boot: 用来让核心从设备储存外的某镜像启动, 比方说你文件夹里的CMW RECOVERY镜像叫做: recovery.img, 输入: fastboot boot recovery.img, 便可让设备由recovery.img启动, 而不用将CWM刷写到设备flash之后启动.
erase: 用来擦除某些指定的区块, 例如: fastboot erase cache
以上就是会常常用到的fastboot命令啦.
23, 什么是ADB?
ADB = Android Debug Bridge, 用来设备和PC间通信的另一个工具. 使用ADB命令, 需要手机要启动到recovery模式, 或者正常启动. 一般来说, 正常启动的话, 需要打开USB调试. 当前目录下必须存在ADB相关的几个文件, PC上也必须安装有ADB驱动.
24, ADB命令.
在adb.exe所在的目录下打开命令行, 输入adb可以查看adb的命令格式.
- Android Debug Bridge version 1.0.29
- -d - directs command to the only connected USB device
- returns an error if more than one USB device is present.
- -e - directs command to the only running emulator.
- returns an error if more than one emulator is running.
- -s <serial number> - directs command to the USB device or emulator with
- the given serial number. Overrides ANDROID_SERIAL
- environment variable.
- -p <product name or path> - simple product name like 'sooner', or
- a relative/absolute path to a product
- out directory like 'out/target/product/sooner'.
- If -p is not specified, the ANDROID_PRODUCT_OUT
- environment variable is used, which must
- be an absolute path.
- devices - list all connected devices
- connect <host>[:<port>] - connect to a device via TCP/IP
- Port 5555 is used by default if no port number is specified.
- disconnect [<host>[:<port>]] - disconnect from a TCP/IP device.
- Port 5555 is used by default if no port number is specified.
- Using this command with no additional arguments
- will disconnect from all connected TCP/IP devices.
- device commands:
- adb push <local> <remote> - copy file/dir to device
- adb pull <remote> [<local>] - copy file/dir from device
- adb sync [ <directory> ] - copy host->device only if changed
- (-l means list but don't copy)
- (see 'adb help all')
- adb shell - run remote shell interactively
- adb shell <command> - run remote shell command
- adb emu <command> - run emulator console command
- adb logcat [ <filter-spec> ] - View device log
- adb forward <local> <remote> - forward socket connections
- forward specs are one of:
- tcp:<port>
- localabstract:<unix domain socket name>
- localreserved:<unix domain socket name>
- localfilesystem:<unix domain socket name>
- dev:<character device name>
- jdwp:<process pid> (remote only)
- adb jdwp - list PIDs of processes hosting a JDWP transport
- adb install [-l] [-r] [-s] <file> - push this package file to the device and install it
- ('-l' means forward-lock the app)
- ('-r' means reinstall the app, keeping its data)
- ('-s' means install on SD card instead of internal storage)
- adb uninstall [-k] <package> - remove this app package from the device
- ('-k' means keep the data and cache directories)
- adb bugreport - return all information from the device
- that should be included in a bug report.
- adb backup [-f <file>] [-apk|-noapk] [-shared|-noshared] [-all] [-system|-nosystem] [<packages...>]
- - write an archive of the device's data to <file>.
- If no -f option is supplied then the data is written
- to "backup.ab" in the current directory.
- (-apk|-noapk enable/disable backup of the .apks themselves
- in the archive; the default is noapk.)
- (-shared|-noshared enable/disable backup of the device's
- shared storage / SD card contents; the default is noshared.)
- (-all means to back up all installed applications)
- (-system|-nosystem toggles whether -all automatically includes
- system applications; the default is to include system apps)
- (<packages...> is the list of applications to be backed up. If
- the -all or -shared flags are passed, then the package
- list is optional. Applications explicitly given on the
- command line will be included even if -nosystem would
- ordinarily cause them to be omitted.)
- adb restore <file> - restore device contents from the <file> backup archive
- adb help - show this help message
- adb version - show version num
- scripting:
- adb wait-for-device - block until device is online
- adb start-server - ensure that there is a server running
- adb kill-server - kill the server if it is running
- adb get-state - prints: offline | bootloader | device
- adb get-serialno - prints: <serial-number>
- adb status-window - continuously print device status for a specified device
- adb remount - remounts the /system partition on the device read-write
- adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program
- adb reboot-bootloader - reboots the device into the bootloader
- adb root - restarts the adbd daemon with root permissions
- adb usb - restarts the adbd daemon listening on USB
- adb tcpip <port> - restarts the adbd daemon listening on TCP on the specified port
- networking:
- adb ppp <tty> [parameters] - Run PPP over USB.
- Note: you should not automatically start a PPP connection.
- <tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
- [parameters] - Eg. defaultroute debug dump local notty usepeerdns
- adb sync notes: adb sync [ <directory> ]
- <localdir> can be interpreted in several ways:
- - If <directory> is not specified, both /system and /data partitions will be updated.
- - If it is "system" or "data", only the corresponding partition
- is updated.
复制代码
有关 backup 和 restore 命令请看这篇非常给力的帖子: http://forum.xda-developers.com/showthread.php?t=1420351
devices: 这命令用来检查设备是否已经正确的以adb模式连接, 例如: adb devices
reboot: 用来重启设备, 例如: adb reboot
reboot-bootloader: 重启设备到bootloader模式, 例如: adb reboot bootloader
push: 用来向设备复制文件, 比如将c:\junk.jpg 拷贝到手机 /sdcard文件夹: adb push c:\junk.jpg /sdcard/ ( 执行前, 确保/sdcard已经挂载)
shell: 打开一个一个可以直接向android系统发送命令的终端, 命令: adb shell, 你会发现提示符变成了 $ ( 基本都是常见的Linux shell 命令)
25, N4的区块.
- /dev/block/platform/msm_sdcc.1/by-name:
- lrwxrwxrwx root root 2012-11-13 19:02 DDR -> /dev/block/mmcblk0p24
- lrwxrwxrwx root root 2012-11-13 19:02 aboot -> /dev/block/mmcblk0p12
- lrwxrwxrwx root root 2012-11-13 19:02 abootb -> /dev/block/mmcblk0p15
- lrwxrwxrwx root root 2012-11-13 19:02 boot -> /dev/block/mmcblk0p6
- lrwxrwxrwx root root 2012-11-13 19:02 cache -> /dev/block/mmcblk0p22
- lrwxrwxrwx root root 2012-11-13 19:02 grow -> /dev/block/mmcblk0p25
- lrwxrwxrwx root root 2012-11-13 19:02 m9kefs1 -> /dev/block/mmcblk0p8
- lrwxrwxrwx root root 2012-11-13 19:02 m9kefs2 -> /dev/block/mmcblk0p9
- lrwxrwxrwx root root 2012-11-13 19:02 m9kefs3 -> /dev/block/mmcblk0p10
- lrwxrwxrwx root root 2012-11-13 19:02 metadata -> /dev/block/mmcblk0p18
- lrwxrwxrwx root root 2012-11-13 19:02 misc -> /dev/block/mmcblk0p19
- lrwxrwxrwx root root 2012-11-13 19:02 modem -> /dev/block/mmcblk0p1
- lrwxrwxrwx root root 2012-11-13 19:02 persist -> /dev/block/mmcblk0p20
- lrwxrwxrwx root root 2012-11-13 19:02 recovery -> /dev/block/mmcblk0p7
- lrwxrwxrwx root root 2012-11-13 19:02 rpm -> /dev/block/mmcblk0p11
- lrwxrwxrwx root root 2012-11-13 19:02 rpmb -> /dev/block/mmcblk0p16
- lrwxrwxrwx root root 2012-11-13 19:02 sbl1 -> /dev/block/mmcblk0p2
- lrwxrwxrwx root root 2012-11-13 19:02 sbl2 -> /dev/block/mmcblk0p3
- lrwxrwxrwx root root 2012-11-13 19:02 sbl2b -> /dev/block/mmcblk0p13
- lrwxrwxrwx root root 2012-11-13 19:02 sbl3 -> /dev/block/mmcblk0p4
- lrwxrwxrwx root root 2012-11-13 19:02 sbl3b -> /dev/block/mmcblk0p14
- lrwxrwxrwx root root 2012-11-13 19:02 system -> /dev/block/mmcblk0p21
- lrwxrwxrwx root root 2012-11-13 19:02 tz -> /dev/block/mmcblk0p5
- lrwxrwxrwx root root 2012-11-13 19:02 tzb -> /dev/block/mmcblk0p17
- lrwxrwxrwx root root 2012-11-13 19:02 userdata -> /dev/block/mmcblk0p23
复制代码
来自这里: http://forum.xda-developers.com/showthread.php?t=1993036
嵌入式系统, 区块的大小与配置基本都是固定的...
比方说: lrwxrwxrwx root root 2012-11-13 19:02 system -> /dev/block/mmcblk0p21, 你会发现: /system 下挂载的是 mmcblc0p21这个区块...
recovery -> /dev/block/mmcblk0p7
userdata -> /dev/block/mmcblk0p23
cache -> /dev/block/mmcblk0p22
boot -> /dev/block/mmcblk0p6
26, 挂载.
这东西自己理解吧, Linux的目录结构和Windows不同, Windows是先有分区, 然后在分区上再产生目录, Linux下是先有目录结构, 将某分区挂载到某目录下, 那么该目录就指向这个分区, 目录可以理解成指针嘛...
27, 什么是recovery?
recovery是一个特殊的启动模式, 它提供向设备刷写文件, 升级, 或者备份等等功能. 原装recovery功能稀少坑爹, 但我们有两个非常给力的自制recovery: CMW和TWRP.
28, 我为什么在recovery模式下会看到一个仰面朝天的小绿人?
这是原版recovery, 按下电源键, 再按音量+ 来打开recovery菜单.
29, 我刚刷了CMW, 但是每次我想要启动CMW都会发现原版recovery阴魂不散, 怎么回事?
有两个文件会在你每次载入recovery时重新刷写recovery:
/system/etc/install-recovery.sh
/system/recovery-from-boot.p
PS: 这两个文件只有在OTA升级之后才会出现
删除或者将它们重命名, 然后重新刷写CMW, 就能固定CMW了.
这帖子提供了一个 recovery disabler : http://forum.xda-developers.com/showthread.php?t=1995440
传送门: http://bbs.gfan.com/android-5795118-1-1.html
>>> 长帖的坏处就是: 看到最后, 就没有力气回帖了...
>>> 觉着有用, 记得 回帖, 加分, 收藏...
|