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