Google Glass 笔记

来自Jack's Lab
跳转到: 导航, 搜索

目录

1 硬件

  • 处理器: TI OMAP4430
  • 内存: Elpida mobile DRAM 1GB (最新的为 2GB)
  • 闪存: SanDisk 16GB
  • 显示: Himax HX7309 LCOS(Liquid Crystal on Silicon,硅基液晶),Field Sequential Color display (FSC),640x360,控制器有可能是 Himax HX7812,通过MIPI (DSI)与OMAP4430连接
  • 摄像头: 500万像素
  • WiFi: WM-BN-BM-04-a,WLAN +BT+FM 三合一模块,WiFi与处理器的接口为SDIO/SPI
  • 蓝牙: WM-BN-BM-04-a,WLAN +BT+FM 三合一模块,BT与处理器的接口为UART(串口)
  • 触摸控制器: Synaptics T1320A
  • 加速度传感: ST LIS3
  • 耳机: 骨传导 (Bone Conduction Transducer)
  • 电源管理: TI TWL6030 (6030B107)
  • 锂电池: 2.1 Wh (570 mAh)

Omap4430-blockdiagram.png


参考拆解: http://www.catwig.com/google-glass-teardown/

2 内核

代码位于: https://android.googlesource.com/kernel/omap.git

最早的版本为 XRR02,现在最新的版本为 XRT73B。基于 Linux Kernel 3.0.31

$ git branch -a
  android-omap-tuna-3.0
* glass-omap-xrr02
  glass-omap-xrr88
  glass-omap-xrt73b
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/android-omap-3.0
  ......
  remotes/origin/glass-omap-xrr02
  remotes/origin/glass-omap-xrr35
  remotes/origin/glass-omap-xrr64b
  remotes/origin/glass-omap-xrr88
  remotes/origin/glass-omap-xrs36
  remotes/origin/glass-omap-xrs68
  remotes/origin/glass-omap-xrs92
  remotes/origin/glass-omap-xrt35
  remotes/origin/glass-omap-xrt73b
  remotes/origin/linux-omap-3.0
  remotes/origin/master
  remotes/origin/sph-l700-fh05

$ head Makefile 
VERSION = 3
PATCHLEVEL = 0
SUBLEVEL = 31
EXTRAVERSION =
NAME = Sneaky Weasel



3 ROM

Google Glass 的 ROM 官方获取地址:https://developers.google.com/glass/tools-downloads/system

comcat@jackslab:/work/glass/image$ ls -lht boot.img-XE12 glass_1-img-947604.zip 
-rw------- 1 comcat comcat 344M  3月 19 23:18 glass_1-img-947604.zip
-rw------- 1 comcat comcat 4.5M  3月 19 23:07 boot.img-XE12

# XE12 的 ROM 压缩包为 glass_1-img-947604.zip,解压后的内容如下:
comcat@jackslab:/work/glass/image$ cd glass_1-img-947604/
comcat@jackslab:/work/glass/image/glass_1-img-947604$ ls
android-info.txt  boot.img  recovery.img  system.img  userdata.img

comcat@jackslab:/work/glass/image/glass_1-img-947604$ ls *.img -lht
-rw------- 1 comcat comcat 134M 12月 13 07:04 userdata.img
-rw-r--r-- 1 comcat comcat 4.5M  1月  1  2009 boot.img
-rw-r--r-- 1 comcat comcat 5.3M  1月  1  2009 recovery.img
-rw-r--r-- 1 comcat comcat 477M  1月  1  2009 system.img

# boot.img 解开后的内容:
comcat@jackslab:/work/glass/image/glass_1-img-947604$ ls boot
boot.img-ramdisk.gz  kernel

# system.img 的内容:
comcat@jackslab:/work/glass/image/glass_1-img-947604$ ls system/x/
app  bin  build.prop  etc  fonts  framework  glass_fonts  lib  media  tts  usr  vendor  xbin
comcat@jackslab:/work/glass/image/glass_1-img-947604$ find system/x/app/
system/x/app/
system/x/app/ApplicationsProvider.apk
system/x/app/ApplicationsProvider.odex
system/x/app/BackupRestoreConfirmation.apk
system/x/app/BackupRestoreConfirmation.odex
system/x/app/CalendarProvider.apk
system/x/app/CalendarProvider.odex
system/x/app/CertInstaller.apk
system/x/app/CertInstaller.odex
system/x/app/ContactsProvider.apk
system/x/app/ContactsProvider.odex
system/x/app/DefaultContainerService.apk
system/x/app/DefaultContainerService.odex
system/x/app/DownloadProvider.apk
system/x/app/DownloadProvider.odex
system/x/app/FrameworkStubs.apk
system/x/app/FrameworkStubs.odex
system/x/app/GlassBluetooth.apk
system/x/app/GlassBoutique.apk
system/x/app/GlassBrowser.apk
system/x/app/GlassCamera.apk
system/x/app/GlassDeviceAdministration.apk
system/x/app/GlassGesture.apk
system/x/app/GlassHangouts.apk
system/x/app/GlassHome.apk
system/x/app/GlassLockRecovery.apk
system/x/app/GlassLogging.apk
system/x/app/GlassMaps.apk
system/x/app/GlassMusicPlayer.apk
system/x/app/GlassPhone.apk
system/x/app/GlassPhotosphere.apk
system/x/app/GlassSearch.apk
system/x/app/GlassSettings.apk
system/x/app/GlassSetup.apk
system/x/app/GlassSound.apk
system/x/app/GlassSystemUI.apk
system/x/app/GlassSystemUI.odex
system/x/app/GlassTutorial.apk
system/x/app/GlassUpdate.apk
system/x/app/GlassVideoPlayer.apk
system/x/app/GlassVoice.apk
......
......



4 Flush ROM

先在这下载官方的 'Factory System Image': https://developers.google.com/glass/tools-downloads/system

进入 Glass,打开 'Debug mode',USB 线连接 PC:

$ adb reboot bootloader                     # enter fastboot mode
$ fastboot devices                          # verify device is in fastboot, should see its serial no.
$ fastboot flash boot boot.img              # flash partitions with factory images
$ fastboot flash system system.img
$ fastboot flash recovery recovery.img
$ fastboot erase cache                      # optional, erase the cache and userdata partitition
$ fastboot erase userdata
$ fastboot oem lock                         # optional, only if you want to re-lock the bootloader.



5 Root

先在这下载官方的 Rooted bootloader: https://developers.google.com/glass/tools-downloads/system

进入 Glass,打开 'Debug mode',USB 线连接 PC:

$ adb reboot bootloader           # enter fastboot mode, takes 10-15 seconds
$ fastboot devices                # verify device is in fastboot, should see its serial #
$ fastboot oem unlock             # unlocking erases all data, you are prompted to run this command twice to be sure
$ fastboot flash boot boot.img    # gain root shell access with the rooted bootloader
$ fastboot reboot                 # reboot the device
$ adb root                        # start adb as root
$ adb shell                       # access the shell as root



6 编译测试环境

http://www.gradle.org 下载 gradle-1.11-bin.zip ,这是 android app 的命令行编译框架

解压到 /work/glass/gradle/gradle-1.11

用 Android SDK Manager 安装 Android 4.0.3 (API 15) SDK 和 Glass Development Kit Sneak Peek,以及 Android Build Tools 19.0.3,Android SDK 目录位于:/work/android/sdk/android-sdk-linux

~/.bashrc 中导出环境变量:

# gradle for build android/glass
export PATH=/work/glass/gradle/gradle-1.11/bin:$PATH
export ANDROID_HOME=/work/android/sdk/android-sdk-linux


建立工作目录,clone GDK的例子代码:

$ mkdir glass && cd glass
$ echo "include ':compass'" > settings.gradle

$ git clone https://github.com/googleglass/apk-compass-sample.git compass
$ cd compass


建一个如下名为 build.gradle 文件,放在 compass/ 目录下:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
	classpath 'com.android.tools.build:gradle:0.9.1'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion "Google Inc.:Glass Development Kit Sneak Peek:15"
    buildToolsVersion "19.0.3"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 15
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
        instrumentTest.setRoot('tests')
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
    signingConfigs {
        debug {
            storeFile file(System.getenv("DEBUG_KEYSTORE"))
            storePassword 'android'                           # ------> 与 keytool 生成密钥对的密码一致
            keyAlias 'mykey'
            keyPassword 'android'
        }
    }
    buildTypes {
        debug {
            // Using release config...
            signingConfig signingConfigs.debug
        }
    }
}


keytool 生成一个 key 文件,生成时所有的密码都为 android,cp 为 /home/comcat/.android/my-debug.keystore

$ keytool --genkeypair
Enter keystore password:  
Re-enter new password: 
What is your first and last name?
  [Unknown]:  Jack Tan
What is the name of your organizational unit?
  [Unknown]:  Jack's Lab
What is the name of your organization?
  [Unknown]:  Jack's Lab
What is the name of your City or Locality?
  [Unknown]:  Beijing
What is the name of your State or Province?
  [Unknown]:  Beijing
What is the two-letter country code for this unit?
  [Unknown]:  CN
Is CN=Jack Tan, OU=Jack's Lab, O=Jack's Lab, L=Beijing, ST=Beijing, C=CN correct?
  [no]:  yes

Enter key password for <mykey>
	(RETURN if same as keystore password):  
Re-enter new password: 

$ cp ~/.keystore ~/.android/my-debug.keystore

~/.bashrc 中导出环境变量:

 export DEBUG_KEYSTORE=/home/comcat/.android/my-debug.keystore

在 glass/ 目录下执行:

 $ gradle build


运行,google glass 没有模拟器,只能push到实体硬件上去测试:


要让adb发现glass,得打开glass的调试模式:

进入 Settings card ---> 'Device Info' card ---> 'Turn on debug'
$ adb devices
List of devices attached 
0256E86EE2500E920	device


安装:

$ adb install -r compass/build/apk/compass-debug.apk
$ adb shell am start -n com.google.glass.samples.compass/.CompassActivity


查看安装的APP:

$ adb shell pm list packages | grep jacks
package:com.jackslab.helloworld


卸载:

$ adb uninstall com.jackslab.helloworld
Success




7 Hello World

Write Your First Glassware

代码位于: https://github.com/comcat/glassware/tree/master/helloworld



8 参考















个人工具
名字空间

变换
操作
导航
工具箱