2007 2013 Kandroid
www.kandroid.org »
kandroid s/w fundamentals 교육 »
Android Open Source 
▶ HTC Android Kernel Open Source
▶ Samsung Android Kernel Open Source
▶ Motorola Android Kernel(+α) Open Source
▶ LGE Android Kernel(+α) Open Source
Neo 1973 phone
작성자 들풀
작성일 2008-11-06 (목) 02:45
ㆍ추천: 0  ㆍ조회: 3414      
IP: 125.xxx.181
첨부#1 android-armv4-20081028.tar (160KB) (Down:161)
 
 
참고 :
http://wiki.openmoko.org/wiki/User:Seanmcneil3
http://benno.id.au/blog/
 
 
So, my earlier post on this was a little premature; anyone who has tried out the code has
found out that it pretty much doesn’t work (hey I did warn you!). Now there are a range of
fun reasons why this didn’t work, most of which I’ve now solved.
 
Firstly, it turns out that EABI and ARMv4T are pretty much incompatible. (I’ll post separately
about that!). In short, thumb interworking doesn’t (can’t) work, so I’ve reverted back to plain
old ARMv4 architecture as my target (the only difference between ARMv4 and ARMv4T is
the thumb stuff, which we can’t use until the compiler / spec is fixed.). So I’ve updated the
linux-arm.mk to support ARMv4 for now as well.

Of course the next problem that this introduces is that the bx instruction doesn’t exist on
ARMv4, and GCC (helpfully) complains and stops the compilation. Now a BX without thumb
support is simply a mov pc, instruction, so I went through and provided a BX macro that
expands to either bx or mov pc,. This is a little bit nasty/invasive because it touches all the
system call bindings, thankfully these are generated anyway, but it makes the diff quite
large. (When I have time I’ll make it so that generation is part of the buid system, not a
manual process.)

The next problem is that the provided compiler’s libgcc library is build for ARMv5, and has
instructions that just don’t exist on ARMv4 (shc as clz), so I went and built a new compiler
targeted to ARMv4. There is no reason why this couldn’t be set up as a multi-lib compiler
that supports both, but I don’t have enough GCC wizardry in me to work that out right now.
So a new compiler.

This got things to a booting stage, but not able to mount /system or /data. Basically, Android
by default uses yet another flash file-system (YAFFS), but for some reasons, which I
couldn’t fully work out initially, the filesystem just didn’t seem to cleanly initialise and then
mount. So, without diving too deep, I figured I could just use jffs2 instead, which I know
works on the target. So I upgraded the Android build system to support allowing you to
choose which filesystem type to use, and providing jffs2 as an option. This was going
much better, and I got a lot further, far enough that I needed to recompile my kernel with
support for some of the Android specific drivers like ashmem, binder and logger. Unfortunately
I was getting a hang on an mmap call, for reasons that I couldn’t quite work out. After a lot of
tedious debugging (my serial console is broken, so I have to rely on graphics console,
which is really just an insane way to try and debug anything), anyway, it turns out that part
of what the Dalvik virtual machine does when optimising class files is to mmap the file as
writable memory. This was what was failing, with the totally useless error invalid argument.
Do you know how many unique paths along the mmap system call can set EINVAL?
Well it’s a lot. Anyway, long story short, it turns out that the jffs2 filesystem doesn’t support
writable mmaps! %&!#.

After I finished cursing, I decided to go back to using yaffs and working out what the real
problem is. After upgrading u-boot (in a pointless attempt to fix my serial console), I
noticed a new write yaffs[1] command. This wasn’t there in the old version. Ok, cool,
maybe this has something do to with the problem. But what is this the deal with yaffs
versus yaffs1? Well it turns out that NAND has different pagesize, 512 bytes, and 2k (or
multiples thereof, maybe??). And it turns out that YAFFS takes advantage of this and has
different file systems for different sized NAND pages, and of course, everything that can
go wrong will so, the filesystem image that the build system creates is YAFFS2 which is
for 2k pages not 512b pages. So, I again updated the build system to firstly build both the
mkyaffs2image and the mkyaffsimage tool, and then set off building a YAFFS file system.

Now, while u-boot supports yaffs filesystem, device firmware update doesn’t (appear to).
So this means I need to copy the image to memory first, then on the device copy it from
memory to flash. Now, the other fun thing is that dfu can only copy 2MB or so to RAM at
a time, and the system.img file is around 52MB or so, which means that it takes around 26
individual copies of 2MB sections.... very, very painful. But in the end this more or less
worked. So now I have a 56MB partition for the system, and a 4MB partition for the user
and things are looking good.

Good that is, right up until the point where dalvik starts up and writes out cached version
of class files to /data. You see, it needs more than 4MB, a lot more, so I’m kind of back to
square one. I mean, if I’d looked at the requirements I would have read 128MB of flash,
but meh, who reads requirements? The obvious option would be some type of MMC card,
but as it turns out the number of handy Fry’s stores on Boeing 747 from Sydney to LA
number in the zeroes.

So the /system partition is read-only, and since the only problem with jffs2 was when we
were writing to it, it seems that we could use jffs2 for the read-only system partition,
which has the advantage of jffs2 doing compression, and fitting in about 30MB, not about
50MB, leaving plenty of room for the user data partition, which is where the Dalvik cached
files belong. This also has the advantage of being able to use normal DFU commands to
install the image (yay!). So after more updates to the build system to now support
individually setting the system filesystem type and the user filesystem type things seem
a lot happier.

Currently, I have a system that boots init, starts up most of the system services, including
the Dalvik VM, runs a bunch of code, but bombs out with an out-of-memory error in the
pixelflinger code which I’m yet to have any luck tracing. Currently my serial console is fubar,
so I can’t get any useful logging, which makes things doubly painful. The next step is to
get adb working over USB so I have at least an output of the errors and warning, which
should give me half a chance of tracking down the problem.

So if you want to try and get up to this point, what are the steps? Well, firstly go and
download the android toolchain source code. and compile it for a v4 target. You use the
--target=armv4-android-eabi argument to configure if I remember correctly.
Once you have that done, grab my latest patch and apply it to the Android source code
base. (That is tar file with diffs for each individual project, apply these correctly is left as
an exercise for the reader). Then you want to compile it with the new toolchain. I use a
script like this:
#!/bin/sh

make TARGET_ARCH_VERSION=armv4 
     MKJFFS2_CMD="ssh nirvana -x "cd `pwd`; mkfs.jffs2""  
     SYSTEM_FSTYPE=jffs2 
     USERDATA_FSTYPE=yaffs 
     TARGET_TOOLS_PREFIX=/opt/benno/bin/armv4-android-eabi- $@
Things you will need to change it the tools prefix, and the mkjffs2 command. 
The evil-hackery above is to run it on my linux virtual machine (I’m
compiling the rest under OS X, and I can’t get mkfs.jffs2 to compile under
it yet.)
After some time passes you should end up with a ramdisk.img, userdata.img
and system.img files. The next step is to get a usable kernel.
I’m using the OpenMoko stable kernel, which is 2.6.24 based. I’ve patched
this with bits of the Android kernel (enough, I think, to make it run).
Make sure you configure support for yaffs, binder, logger and ashmem. Here
is the kernel config I’m currently using.
At this stage it is important you have a version of u-boot supporting the
yaffs write commands, if you don’t your next step is to install that. After
this the next step is to re-partition your flash device. In case it isn’t
obvious this will trash your current OS. The useful parts from my uboot
environment are:
mtdids=nand0=neo1973-nand
bootdelay=-1
mtdparts=mtdparts=neo1973-nand:256k(uboot)ro,16k(uboot-env),752k(ramdisk),
2m(kernel),36m(system),24m(userdata) rdaddr=0x35000000 kaddr=0x32000000 bootcmd=setenv bootargs ${bootargs_base} ${mtdparts} initrd=${rdaddr},${rdsize};
nand read.e ${kaddr} kernel; nand read.e ${rdaddr} ramdisk; bootm ${kaddr} bootargs_base=root=/dev/ram rw console=tty0 loglevel=8
Note the mtdparts which defines the partitions, and the bootcmd. (I’m not entirely happy with
the boot command, mostly because when I install new RAM image I need to manually update
$rdsize, which is a pain).
With this in place you are ready to start. The first image to move across is your userdata
image. Now to make this happen we first copy it into memory using dfu-util:
sudo dfu-util -a 0 -R -D source/out/target/product/generic/userdata.img  -R
Then you need to use the nand write.yaffs1 command to copy it to the data partition. Note,
at this stage I get weird behaviour, I’m not convinced that the yaffs support truly works yet!
Afterwards I get some messed up data in other parts of the flash (which is why we are
doing it first). After you have copied it in, I suggest reseting the device, and you may find
you need to reinitialise u-boot (using dyngen, and resetting up the environment as above.

After this you are good to use dfu-util to copy accross the kernel, system.img and
ramdisk.img. After copying the ramdisk.img across update the rdsize variable with the
size of the ramdisk.

Once all this is done, you are good to boot, I wish you luck! If you have a working serial
console you can probably try the logcat command to see why graphics aren’t working.
If you get this far please email me the results!
 
 
이름아이콘 인베인
2008-11-06 06:59
It ain’t exactly running fast yet, and not everything it working 100%, but I think most of the tricky bits are done.
베로노의 글에 잠 제대로 자지도 못하고 진한 삽질의 모습이 베어나옵니다. 지금 arm계열 대세가 armv7으로 가는 시점에서 그냥 폰을 좀 좋은걸로 바꾸징...ㅎㅎ 아드로이드 툴체인(바이너리) 분석하면서 "The next problem is that the provided compiler’s libgcc library is build for ARMv5" 이 부분이 아직 기술적으로 제가   방법론을 이해하지 못하고 있는 부분입니다. 베로너 얘 컴파일러 뭐썼을까요? 안드로이드 툴체인으로 안되었을텐데...그건 그렇고, 위의 neo1973폰에 올려진 안드로이드 1.0의 Speed 동영상좀 보면 좋겠는데...
   
이름아이콘 인베인
2008-11-06 12:13
헐 알고 계셨어요? http://android.git.kernel.org/pub/android-toolchain-20081019.tar.bz2 의 구성이 바이너리(기존) ---> 소스로 바뀌었네요... (이전에 제가 질문했던내용입니다.)
   
이름아이콘 들풀
2008-11-06 13:06
네..알고 있었습니다..안의 페이지에 있자나여..~ㅎㅎ
   
이름아이콘 인베인
2008-11-06 13:45
안의 페이지에 설명되어 있기는 하지만,
저희가 안드로이드 오픈소스 공개된 후에
맨처엄 접속할때는 동일한 저 파일명(android-toolchain-20081019.tar.bz2 )이 바이너리였기때문에,
벤이 위에 작성한거 오타인줄 알았었거던요..
그래서, 얘는 어디서 안드로이드 툴체인 관련 소스를 get하였을까 궁금했었는데.
결론인즉 소스를 올려야 하는에 해당 구글 직원인 바이너리를 올려서 다시 소스로 올린걸로
해석된느거 맞는거죠???
   
이름아이콘 들풀
2008-11-06 14:45
그 구글직원.....정말 실수 했다면 웃긴거죠..~ㅎㅎㅎ
   
이름아이콘 인베인
2008-11-06 14:55
들풀님~ 질문 하나드립니다.  http://www.kandroid.org/s4/devtools/android-toolchain-20081019.tar.bz2 이 바이너리 파일을 어디서 받으신거에요? ^^
   
이름아이콘 들풀
2008-11-06 14:58
그것 다운로드 받았던 거 아닙니다. 안드로이드 소스 package내에 있는 설명문 보고.
제가 바이너리로 묶었던 겁입니다.
   
이름아이콘 인베인
2008-11-06 15:09
흐악 들풀님 미워여..ㅜㅜ  파일명이 똑같길래, 위주소에서 직접 바이너리 받으신거인줄 알고 그걸 사용해서 안에 왜 C library가 없는데 사용가능할까 계속 오늘까지 고민중인데....ㅡ.ㅡ;; 파일명을 좀 unique하게 사용해주세요.. 플리즈ㅡ...  android-toolchain-20081019.bin.tar.bz2 이렇게요..
   
이름아이콘 들풀
2008-11-06 15:10
네.... ㅎㅎㅎ..알겠습니다..~ㅎㅎㅎ 미워하지 마세요..!
   
 
덧글 쓰기 0
32000
※ 회원등급 레벨 0 이상 읽기가 가능한 게시판입니다.
    N     분류     제목    글쓴이 작성일 조회
65 9회 kandroid 컨퍼런스를 기다리며~ [10]+8 행복아 2012-02-01 2425
64 안드로이드 전체소스의 맵(OS+플랫폼) [8]+7 인베인 2012-01-19 6019
63 안드로이드 그래픽스와 9회 kandroid 컨퍼런스 들풀 2012-01-04 2424
62 ICS4.0 (Prelink와 ASLR)와 9회 kandroid 컨퍼런스 [2]+3 들풀 2012-01-04 3004
61 [완결] 안드로이드 커널피쳐가 리눅스 메인라인에 들어오다... [4]+3 인베인 2011-12-20 2781
60 새로운 안드로이드버젼(ICS)의 공식 git 저장소 [3]+4 인베인 2011-12-19 9015
59 Gif파일 만들기 [2] 별찌 2011-12-05 1760
58 [덧글필독]안드로이드 system_server 디버깅 기법 [2]+8 들풀 2011-10-23 5844
57 ICS버젼 쓰레드의 TLS 동작구조(ver 0.3) [6]+10 인베인 2011-10-18 4284
56 [Android-MMF] 안드로이드 미디어 프레임워크의 개요 - 04.. [4]+1 소오강호 2011-05-29 8329
55 [Android-MMF] 안드로이드 미디어 프레임워크의 개요 - 03.. [2] 소오강호 2011-05-29 7509
54 [Android-MMF] 안드로이드 미디어 프레임워크의 개요 - 02.. [4] 소오강호 2011-05-14 7405
53 [Android-MMF] 안드로이드 미디어 프레임워크의 개요 - 01.. [9]+1 소오강호 2011-05-10 13084
52 안드로이드 Gingerbread Source Open 및 Build [6]+3 lesmin 2010-12-20 9679
51 Optimus-Q 리눅스 커널 오픈소스 URL [1] onjo 2010-10-01 4628
50 Galaxy-S 리눅스 커널 오픈소스 URL [2] 들풀 2010-07-21 9803
49 안드로이드 Froyo Source Open [5]+1 lesmin 2010-06-24 11796
48 안드로이드 내장 APKs 개발방법(초안) [28]+20 들풀 2010-03-05 33721
47 모토로이 소스 공개 [7]+3 Beto 2010-03-01 14870
46 안드로이드 2.1 Source Open [3]+2 자하랑 2010-01-21 12550
45 Android 1.6 브랜치 업데이트(1.3->1.4) [2]+1 인베인 2009-10-24 3766
44 SH4 CPU 아키텍쳐 지원을 위한 Android [2]+1 인베인 2009-09-17 4596
43 Samsung Galaxy 안드로이드 커널 빌드 [7]+14 들풀 2009-09-15 10927
42 Online PDK(Platform Dev. Kit) - donut [2]+1 들풀 2009-09-01 4782
41 MIPS용 안드로이드 소스코드 릴리즈 및 빌드방법.. [4]+6 인베인 2009-08-11 8857
40 iPAQ HX4700 PDA에 안드로이드를 포팅하자 [9] 좋은이 2009-08-10 8094
39 CENTOS 5.5에서 Android PDK설치방법 (Froyo브랜치) [1] 인베인 2009-07-27 13072
38 Ubuntu 9.04 + Android 1.5 Build [4] bluedisk 2009-05-06 8529
37 Android Porting on x86 PC [10]+1 SPARC 2009-04-29 10424
36    Re.. 질문이요. VBoxManage convertfromraw 문제 [8] coojin 2009-05-15 10272
35 Create AVDs for SDK 1.5 [1] 이광우 2009-04-28 10320
34 [빙고]1.5 SDK Win & Linux 링크입니다 참고하세요 [13]+10 와이드오픈 2009-03-10 5108
33 ADT 0.9 Cupcake 용 [5] 자하랑 2009-02-10 3619
32    Re..No resource identifier found for attribute... [2] Leone 2009-02-18 4862
31 X86용으로 안드로이드 포팅하기(on Virtualbox) [7]+2 인베인 2009-02-09 10241
30 REAL TARGET BOARD 없이 안드로이드 포팅기술 익히기.. [17]+15 좋은이 2009-01-30 14945
29    Re..REAL TARGET BOARD 없이 안드로이드 포팅기술 익히기.. [4]+2 NPain 2009-03-21 5437
28    Re..REAL TARGET BOARD 없이 안드로이드 포팅기술 익히기.. [5] 딱신 2009-03-18 3834
27 Dalvik JNI 를 이용한 cpp 함수 추가 및 SDK 에서 사용하기.. [9] unbiari 2008-12-26 8403
26 안드로이드 전체소스 빌드(For X86) - Fedora 사용자.. [3] 인베인 2008-12-24 17536
25    Re..ASUS/EEE LapTop PC의 플랫폼 드라이버 코드 [2] 인베인 2009-02-09 2656
24    Re..안드로이드 전체소스 빌드(For X86) - Fedora 사용자.. 인베인 2008-12-29 3057
23 안드로이드 전체소스 빌드(For X86) - Ubuntu사용자.. [14] 인베인 2008-12-24 11776
22 안드로이드 Native Development Kit(NDK) 사용법 [18]+3 들풀 2008-12-11 16755
21    Android NDK r3 공식 릴리즈 [3]+1 들풀 2010-03-09 4235
20    Re..android-ndk-1.6_r1 미리보기 [3]+1 들풀 2009-09-20 3698
19    Re.. android-ndk-1.5_r1 사용법 [windows] [7]+3 들풀 2009-06-29 8955
18 안드로이드 SDK Build 방법 [5] 들풀 2008-12-09 12022
17 Android Porting Guide for TI OMAP Zoom [1] 들풀 2008-12-07 4881
16 Git Community Book [3] 들풀 2008-12-07 3372
15 android build system [8]+2 베이징숀 2008-11-19 8226
14 Android Telephony for CDMA [1] 들풀 2008-11-28 4478
13 안드로이드 PDK (Platform Development Kit) [1] 들풀 2008-10-28 7947
12 Mac OS에서 Android 소스 받기 및 빌드 [10]+5 ratharn 2008-10-27 8857
11 Android 전체소스 빌드 방법(For ARM) on Fedora 배포판 -2008.. [8]+1 invain 2008-10-26 10689
10    Re.. Fedora배포판에서 Cupcake빌드시의 TroubleShooting.. 인베인 2010-03-18 3511
9 [Samsung SC32442]용 Android 소스 빌드 [7] 들풀 2008-10-26 7336
8    Re.. sc32442 안드로이드 탑재 screen shot [15]+5 들풀 2009-01-12 3626
7    Neo 1973 phone [9] 들풀 2008-11-06 3414
6 안드로이드 전체 소스 코드 빌드 방법 [54]+7 들풀 2008-10-24 45551
5    HTC_DREAM Build (Donut) [6]+1 불타는주작 2009-08-04 3649
4    안드로이드 cupcake 빌드방법 [5]+5 들풀 2009-01-28 6360
3    안드로이드 플랫폼 개발을 위해 Eclipse 사용하기.. 들풀 2008-12-07 8317
2    안드로이드 소스 코드 빌드 테스트 [8]+1 들풀 2008-10-27 8513
1 안드로이드 오픈 소스 [7] 들풀 2008-10-22 12976
1