Tuesday, December 8, 2009

android ndk 的makefile

在Application.mk裡可以指定APP_BUILD_SCRIPT
來指定你要的Android.mk

可是在mydroid 跟ndk裡的Android.mk
發現在LOCAL_SHARED_LIBRARIES的用法不太一樣
所以要分開來使用
也就是在mydroid build時要一個Android.mk 而用ndk build時則要另一個

但我在Application.mk中設定APP_BUILD_SCRIPT時
發現取別的名字的話  總是會有LOCAL_MAKEFILE not defined 的error msg

最後看了一下他build 的script
local-makefile = $(lastword $(filter %Android.mk,$(MAKEFILE_LIST))

在這用了makefile的 % character

所以只要把APP_BUILD_SCRIPT設定成 Android.mk結尾的就好了
例如NdkAndroid.mk

Saturday, November 28, 2009

android ndk 1.6

這星期用了ndk 1.6

首先要改這個script

http://groups.google.com/group/android-ndk/browse_thread/thread/2127fa52b6aa362c?pli=1

比較特別的是

在Application.mk裡
APP_PROJECT_PATH可以指到別的地方 不一定要在ndk/app底下

另外
LOCAL_SHARED_LIBS
跟LOCAL_LDLIBS的usage還不是很清楚
在mydroid裡LOCAL_SHARED_LIBS可以動
但ndk裡LOCAL_LDLIBS才可以

Monday, November 2, 2009

LOCAL_SDK_VERSION

在Android.mk裡
發現了一個
LOCAL_SDK_VERSION

這是在ApiDemos裡的Android.mk看到的
如果加了                 
LOCAL_SDK_VERSION := current
就會讓你用sdk的android.jar來編
也就是一些hide的api就不能用了

Wednesday, October 28, 2009

mydroid 找不到sdcard

今天發現我從mydroid build出來的emulator一直mount 不到sdcard

最後發現 我的 /etc/沒有 vold.conf這檔案

然後就把 mydroid/development/data/etc/vold.conf  copy 到
out/target/product/generic/system/etc下
然後make systemimage 

我可以mount到sdcard了!!!

~                                                                                                                                                           
~                                                                                                                                                           
~                                   

Tuesday, September 15, 2009

在Android emulator 上改userdata system 的image max size

之前被問到userdata image要如何改大小

花了很多時間才找到XD

首先從Android build system講起
在mydroid/build/core/definitions.mk裡
有個
define assert-max-file-size的 function
原本以為只要指定
BOARD_FLASH_BLOCK_SIZE 跟BOARD_USERDATAIMAGE_MAX_SIZE
就可以了
但發現他這只是作個檢查的動作而已

不過他這有講到 /proc/mtd的東西
然後看了其他的code
也都是去讀 /proc/mtd 來作partition

dev: size erasesize name
mtd0: 04000000 00020000 "system"
mtd1: 04000000 00020000 "userdata"
mtd2: 04000000 00020000 "cache

然後去checkout android linux kernel的code
下載完首先要switch 到有goldfish的branch
不然預設是msm 裡面沒有goldfish的driver 編kernel也會有error
會跳到linux kernel裡面看的原因是有的embedded linux
會把mtd 的size name 等的information寫在 /drivers/mtd/map下
一個叫mtd_parition的struct裡


在drivers/mtd/devices/goldfish_nand.c下 有看到設定size的code
但他也是從memory中讀值出來而已
static int goldfish_nand_init_device(struct goldfish_nand *nand, int id)
看mtd->size
但是其他的地方都找不到設定size的地方

後來又跳到emulator的source裡看(mydroid/external/qemu)
首先發現了qemu可以讓你指定nand
"-nand name[,readonly][,size=size][,pagesize=size][,extrasize=size][,erasepages=pages][,initfile=file][,file=file]"

然後發現
android在emulator的options裡有加讓你設定nand size的option
-partition-size system/data partition size in MBs


所以 結論就是
在emulator後面加上 -partition-size 就可以設定system userdata image的大小了

# cat /proc/mtd
dev: size erasesize name
mtd0: 07c20000 00020000 "system"
mtd1: 07c20000 00020000 "userdata"
mtd2: 04000000 00020000 "cache"

Thursday, September 3, 2009

Gold linker

Linker Part1
http://www.airs.com/blog/archives/38
妙的是 levine有留comment喔
可惜lan回 : I don’t actually have a copy to hand....

Linker Part2
http://www.airs.com/blog/archives/39
有點講歷史的感覺

Linker Part3
http://www.airs.com/blog/archives/40

Linker Part4
http://www.airs.com/blog/archives/41
講到了Procedure Linkage Table, Global Offset Table
ELF spec也有講到這東西
PLT:

GOT:
The program linker will create the dynamic relocations which the dynamic linker will use to initialize the GOT at runtime. Unlike the PLT, the dynamic linker always fully initializes the GOT when the program start


GOT會被存在%ebx裡

Linker Part5
http://www.airs.com/blog/archives/42
有介紹到 ELF symbol visibility
不過..... 在ELF spec 跟System V ABI都沒看到這個
原來 這是在System V ABI的update裡
http://www.sco.com/developers/gabi/2000-07-17/contents.html


Linker Part6
http://www.airs.com/blog/archives/43
講Relocation
in general a relocation has a type, a symbol, an offset into the contents, and an addend.
然後講linker怎麼把他轉成executable

Linker Part7
http://www.airs.com/blog/archives/44
Thread Local Storage
comment裡有提到幾個resource
http://dlc.sun.com/pdf/817-1984/817-1984.pdf
http://people.redhat.com/drepper/tls.pdf
http://www.lsd.ic.unicamp.br/~oliva/writeups/TLS/RFC-TLSDESC-x86.txt


Linker Part8
http://www.airs.com/blog/archives/45
ELF Segments

Linker Part9
http://www.airs.com/blog/archives/46
Symbol Versions

Linker Part10
http://www.airs.com/blog/archives/47
Parellel Linking

Linker Part11
http://www.airs.com/blog/archives/48
Archives

Linker Part12
http://www.airs.com/blog/archives/49
Symbol Resolution

Linker Part13
http://www.airs.com/blog/archives/50
Symbol Version Redux

Linker Part14
http://www.airs.com/blog/archives/51
Linking Time Optimization

Linker Part15
http://www.airs.com/blog/archives/52
COMDAT sections

Linker Part16
http://www.airs.com/blog/archives/53
C++ template instantiation

Linker Part17
http://www.airs.com/blog/archives/54
Warning Symbols

Linker Part18
http://www.airs.com/blog/archives/55
Incremental Linking

Linker Part19
http://www.airs.com/blog/archives/56
__start and __stop symbols

Linker Part20
http://www.airs.com/blog/archives/57
Gold linker update