Android/CyanogenMod 发烧笔记

来自Jack's Lab
2013年12月12日 (四) 18:44Comcat (讨论 | 贡献)的版本

跳转到: 导航, 搜索

目录

1 缘起

手上的三星 Android 机 T959 用了快三年了,一直用原生系统,挺好用,一直没有分析的动力。

最近刷了 MIUI V5,内置了一堆的吸流量、浪费系统资源的应用,苦不堪言,该好好来解析一下手机 Android 系统了



2 探索你的手机系统

正常的系统里,您用“文件管理器”是看不到你整天用的手机系统的是个啥样的(类似看不到window 下的 C:\windows 文件夹的内容)。


要想看到、甚至精简你的系统,有两种主要方法:


1. ROOT 获取系统管理员权限,然后使用 Root Explorer 这个APP去访问根目录、去 /system/app 下去删除你在正常系统里删不了流氓APP,比如 “米币”,“系统更新” 等等

2. 使用调试工具 ADB,ADB 是Android官方提供给开发者的一种调试工具,很容易使用,可以随心所欲地控制、修改你的手机系统。Android 的好处就是,人人都能通过简单的学习,自由地修改你的系统。武装好自己的大脑,任他什么互联网流氓应用都控制不了你。


2.1 ROOT



2.2 ADB

ADB 本是Android SDK(APP 开发环境)内置的调试工具,可以通过 USB/WiFi 连接手机,获取ROOT权限,执行 shell 命令,上传下载数据等。ADB 功能强大,是骨灰级发烧友杀人越货之必备良器

Google 有独立的包,1MB 左右,根据你的平台选用相应的包即可。

http://dl.google.com/android/repository/platform-tools_r19-linux.zip
http://dl.google.com/android/repository/platform-tools_r19-windows.zip
http://dl.google.com/android/repository/platform-tools_r19-macosx.zip

比如 WINDOWS 下,解压 zip 包后,把 adb.exe AdbWinApi.dll AdbWinUsbApi.dll 拷贝到 C:\WINDOWS 下 (省得改环境变量)

然后打开“运行”,输入cmd,回车,开启一个命令行窗口,输入 adb devices,如果你安装了手机的 USB 驱动,在手机里 “设置” --> “开发者选项” --> “USB调试模式” 打开的话,你就能看到

adb devices
List of devices attached 
32334071DA1D00EC	device

表明 adb 已经发现手机设备了


运行 adb shell 则会获得一个 shell,你就可以像在 Linux 中一样了

adb shell

root@android:/ # id
uid=0(root) gid=0(root)

root@android:/ # cat /proc/version                                             
Linux version 3.0.52-Semaphore_JB_2.6.1sv (stratosk@semaphore.gr) (gcc version 4.7.3 20121001 (prerelease) (crosstool-NG linaro-1.13.1-4.7-2012.10-20121022 - Linaro GCC 2012.10) ) #313 PREEMPT Sun Nov 25 20:47:09 EET 2012

root@android:/ # cat /proc/cpuinfo                                             
Processor	: ARMv7 Processor rev 2 (v7l)
BogoMIPS	: 99.26
Features	: swp half thumb fastmult vfp edsp thumbee neon vfpv3 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x2
CPU part	: 0xc08
CPU revision	: 2

Hardware	: aries
Revision	: 0030
Serial		: 32334071da1d00ec

root@android:/ # free -m                                                       
             total         used         free       shared      buffers
Mem:        401084       395532         5552            0         1648
-/+ buffers:             393884         7200
Swap:            0            0            0

更多信息输出,可参考 MIUI V5 在老机三星 T959 上的第一眼




3 Android 系统结构

Android 实际 Linux 内核 + Java虚拟机(google自己实现的虚拟机Dalvik)+ 类Java应用(图形环境,手机桌面,应用程序等等)的混合体


手机硬件之上跑的是 Linux 内核(http://www.kernel.org/ ),掌控所有软硬件资源,类似触摸屏、GPS、摄像头、传感器等硬件外设的驱动都实现为 Linux Kernel 的一个模块

上层应用如要访问硬件外设,已不是传统的 GNU/Linux 访问设备方式(比如通过打开 /dev/radio 设备文件,调用 read/write/ioctl 函数与设备交互),Android 把对设备的访问都封装成了一个个的共享库(位于 /system/lib/hw/ 下),比如 camera.aries.so 封装有手机相机的操作,sensors.aries.so 封装有所有传感器访问的操作等,上层应用通过 libhardware.so 这个统一的入口(提供 id 参数,区分具体设备),调用具体设备的封装共享库



4 T959 硬件结构

AP: SANSUNG Exynos S5PC111 (S5PC110) -- ARM Cortex A8 1GHz + PowerVR SGX540 显示核心 --- Android 的系统实际是跑在这个处理器上

CP: Infineon 8824 - Infineon X-GOLD 61x Baseband processor --- 处理 2G/3G射频前端送来的数字信号,主要是 2G/3G 的通信协议处理 --- 刷机包中的 modem.bin 是个基带固件(一个实时OS + 协议处理进程),其是跑在这个处理器上的,内部一般就是一个 ARM 核心加一个 DSP 核心


Infineon 5703 --- 2G/3G射频前端 + 模拟基带处理 --- 把天线过来的射频信号降频(down-conversion),模拟信号处理,模数转换后,输出数字信号

Triquint TQM676021 --- Handset Tritium III PAD (power amplifier/duplexer) module for UMTS band I (IMT2100 band) --- 3G 射频功放,2100MHz 频段

Triquint TQM666022 --- Handset Tritium III PAD (power amplifier/duplexer) module for UMTS Band II --- 3G 射频功放,1900MHz 频段

Triquint TQM656024 --- Handset Tritium III PAD (power amplifier/duplexer) module for UMTS band IV --- 3G 射频功放,1800MHz 频段


Samsung KB100D00WM - KFG8GH6Q4M 8Gb OneNAND , K4X2G323PB, K4X1G323PB and another 1G package

Samsung KLM8G4DEDD - 8G of MoviNAND


Maxim MAX8998 – Power management IC

Broadcom BCM4751 - single-chip GPS Receiver Solution

Broadcom BCM4329 – 802.11n with Bluetooth 2.1 + EDR and FM receiver

NEC MC-10170 – Elpida Memory + Camera processor

Atmel MXT224 - a 224-node highly configurable touchscreen controller which is part of Atmel's maXTouch product platform


http://www.techinsights.com/teardowns/samsung-galaxy-s-teardown/

http://www.evolife.cn/html/2011/57854.html

http://forum.xda-developers.com/showthread.php?t=1372365


小米3拆解:http://en.miui.com/thread-7633-1-1.html



5 刷机

5.1 概述



5.2 工具

Samsung 官方提供给维修中心的刷机工具 Odin

开源的 heimdall

Odin is an internal Samsung tool used for flashing firmware to their devices (via Download mode, bypassing recovery etc.). Importantly, it also has the ability to repartition the device storage based on a .pit file, which can save you from softbricking (when flashing goes wrong and recovery/the bootloader fail). It is not open source and to my knowledge they have not intentionally released it — a few versions have been leaked. For what it's worth, I have used the version posted here without issue.

Heimdall, however, is open source and duplicates the functionality of Odin. It claims to be more reliable as well, in addition to being cross-platform (Odin is Windows-only).

Both tools appear to work best with Galaxy S devices, so if you're using another device you probably want to ensure someone else has tried it and succeeded. Another note is that they use .tar packages layed out differently than the normal update.zip format used by recovery and OTAs, so you need to get the proper package for it to work.

5.3 heimdall

Then turn off your phone, enter Download mode, connect the USB to phone. Next I used command like this to do the flashing itself

 sudo heimdall flash --MDM modem.bin --verbose --no-reboot

Also to you can use to diagnose more with these, in case of issues

heimdall --version
sudo heimdall detect
sudo heimdall download-pit --output I9505.pit --verbose --no-reboot



6 基带固件

原生系统基带版本:T959UVKB1



7 编译APP



8 开发APP























个人工具
名字空间

变换
操作
导航
工具箱