linux,Android基礎知識總結_第1頁
linux,Android基礎知識總結_第2頁
linux,Android基礎知識總結_第3頁
已閱讀5頁,還剩45頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、linux, android基礎知識總結1. android編譯系統(tǒng)分析2. 文件系統(tǒng)分析3. 制作交叉工具鏈4. 軟件編譯常識5. 設置模塊流程分析6. linux系統(tǒng)啟動流程分析7. linux下 svn 使用指南8. lfs相關9. linux內核的初步理解android 系統(tǒng)開發(fā)指南(常用環(huán)境的搭建和使用) 說明 :有的步驟會用到腳本簡化操作,腳本通過svn 服務器獲?。簊vn co svn:/48/smartphone/td0901/release/images/scripts用戶名為各位的姓名拼音,密碼與用戶名相同一編譯 android 源碼,制作文件系統(tǒng)二u

2、buntu 下燒錄內核和文件系統(tǒng)一編譯 android 源碼,制作文件系統(tǒng)1. 開發(fā)主線源碼位置:svn:/48/smartphone/td0901/trunk/cupcake-jianping/cupcake 源代碼svn:/48/smartphone/td0901/trunk/linux-2.6.28-a1/內核源代碼2. 打標的源代碼位置svn list svn:/48/smartphone/td0901/tag我們可以通過svn listsvn:/48/smartphone查看 svn 版本庫內核更

3、多信息請參卡以下文檔:48/svn/smartphone/48/svn/smartphone/ 智能平臺開發(fā)部資料管理手冊v1.0.doc 48/svn/smartphone/linux下 svn 操作指南及規(guī)范 .doc用戶名為各位的姓名拼音,密碼與用戶名相同3. 編譯源碼進入 cupcake 工作拷貝的頂層目錄,執(zhí)行:. ./make_image15.sh部分執(zhí)行結果:out/target/product/littleton/root/內核需要使用的initramfs out/target

4、/product/littleton/system文件系統(tǒng)的系統(tǒng)分區(qū)out/target/product/littleton/data/文件系統(tǒng)數據分區(qū)4. 編譯內核此處內核編譯主要針對驅動組之外的同事1> 設置工具鏈內核的 linux-2.6.28-a1/makefile中設定了:cross_compile?= arm-linux-所以設置 path 環(huán)境變量,保證能找到正確的工具鏈假設工具鏈位于:/usr/local/marvell-arm-linux-4.1.1/設置為:export path:=/usr/local/marvell-arm-linux-4.1.1/bin/:$pa

5、th2> 更改編譯選項(網絡啟動或者本機啟動) 內核頂層目錄執(zhí)行:make menuconfig general setup->* initial ram filesystem and ram disk (initramfs/initrd)support ()initramfs source file(s) (new)如果需要支持網絡啟動反選 initial ram filesystem and ram disk (initramfs/initrd)support如果需要支持本地啟動選中* initial ram filesystem and ram disk (initramfs

6、/initrd)support設置 ()initramfs source file(s) (new)為 root拷貝cupcake 編譯結果out/target/product/littleton/root/到內核頂層目錄3> 編譯內核頂層目錄執(zhí)行make zimage 編 譯 好 的 內 核 : arch/arm/boot/zimage5. 搭建網絡開發(fā)環(huán)境1>安裝 nfs 服務器sudo apt-get install nfs-kernel-server nfs-common2> 修改 nfs 服務器配置文件 /etc/exports ,確保有以下配置項/nfsroot/

7、rootfs *(rw,no_root_squash,sync)我們在內核中已經固定,手機通過網絡方式啟動,默認從/nfsroot/rootfs讀取文件系統(tǒng),修改配置項后需要重啟nfs 服務器:sudo /etc/init.d/nfs-kernel-serverrestart 3> 配置網絡根文件系統(tǒng)拷貝out/target/product/littleton/root/內容到/nfsroot/rootfs目錄拷貝out/target/product/littleton/system內容到/nfsroot/rootfs/system修改/nfsroot/rootfs/init.rc去掉幾

8、個 mount 命令為了使大家的過程,結果統(tǒng)一,可以使用腳本mkfs.cupcake 完成在執(zhí)行 mkfs.cupcake.nfs腳本前先到cupcake-jianping目錄下執(zhí)行 :. ./make_env15.sh 設置環(huán)境變量 ,獲取通過手動輸入android 源碼的位置,讓腳本來設置環(huán)境變量。二ubuntu 下燒錄內核和文件系統(tǒng)1. 硬件: 手機一臺usb 轉串口線一根usb 轉網卡線一根2. 軟件環(huán)境1> tftp服務器執(zhí)行腳本: setup_tftpd.sh 安裝和配置 tftp 服務器,我們默認以/tftpboot為 tftp 服務器的根目錄,需要下載的文件都放在該目錄下

9、。2> 獲取待燒錄的鏡像文件svn list svn:/48/smartphone/td0901/release/images查看服務器上的版本情況,通常我們下載最新的,例如,下載 9 月 18 號發(fā)布的版本:svn co svn:/48/smartphone/td0901/release/images/images200909183> 燒錄鏡像文件用以下文件為例,示范通過tftp 燒寫內核和文件系統(tǒng)內核zimage0917系統(tǒng)分區(qū): system0918.img數據分區(qū)data0918.img待燒寫的以上文件必須存在于tftp 服務器根

10、目錄 /tftpboot 下。具體步驟:首先連接好硬件設備進入blob 下載模式1> blob 起來后按任意鍵processing obm parameters.can't detect micco. set pmic as normal i2c mode.nandflash(manu=0x98 device=0xba) detected!slot 0 foundget relocation tablefound main bad block table at address 0x0f000000, version 0x01 found mirror bad block tabl

11、e at address 0x0efc0000, version 0x01consider yourself blobed!blob version 2.0.5-pre3 for marvell littletoncopyright (c) 1999 2000 2001 2002 2003 jan-derk bakker and erik mouwblob comes with absolutelyno warranty;read the gnu gpl for details.this is free software, and you are welcome to redistribute

12、 it under certain conditions; read the gnu gpl for details. length not align with page size, change to 0x0read flash from 0x60000, length 0x0doneautoboot (2 seconds) in progress, press any key to stop . autoboot abortedtype "help" to get a list of commands blob>2> 通過 tftp下載內核到 pc 內存

13、0x80800000地址處blob> tftp zimage0917 begin init ether usbnet!*plug-in usb cable & config usbdnet now * exit check_usb_connection:1tftping zimage0917*ok. received 6144 blocks (3145156 bytes)tftp_cmd: file 'zimage0917' loaded via tftp to address 0x80800000.3> 擦除原來的內核分區(qū),0x100000 為分區(qū)起始地址

14、, 0x300000 為分區(qū)長度blob> nanderase-z 0x100000 0x400000the current nandchip does not support block unlocking. erase 0x300000 length data from flash: 0x100000eraseflash from 0x100000, length 0x300000.done4> 燒寫內存 0x80800000開始 實際長度為3145156 的內核數據到起始地址為0x100000 的內核分區(qū)blob> nandwrite -z 0x80800000 0x1

15、00000 3145156the current nandchip does not support block unlocking.write 0x2ffdc4 length data from ram:0x80800000 to flash: 0x100000 write flash from 0x100000, length 0x2ffdc4eraseflash from 0x100000, length 0x300000.done.done5> 下載系統(tǒng)分區(qū)鏡像文件到pc 內存 0x80800000地址處blob> tftp system0918.imgtftping sy

16、stem0918.img*ok. received 113138 blocks (57925824 bytes)tftp_cmd: file 'system0918.img' loaded via tftp to address 0x80800000.6> 擦除原來的 flash 系統(tǒng)分區(qū)blob> nanderase-z 0x500000 0x4000000the current nandchip does not support block unlocking. erase 0x3e0f800 length data from flash: 0x400000er

17、aseflash from 0x400000, length 0x3e0f800.done7> 燒寫數據到 flash 系統(tǒng)分區(qū)blob> nandwrite -y 0x80800000 0x500000 57925824the current nandchip does not support block unlocking.write 0x373e0c0 length data from ram:0x80800000 to flash: 0x400000 write flash from 0x400000, length 0x3591800eraseflash from 0x4

18、00000, length 0x3591800.done.done8> 下載數據分區(qū)鏡像文件到pc 內存 0x80800000地址處blob> tftp data0918.imgtftping data0918.img*ok. received 33992 blocks (17402880 bytes)tftp_cmd: file 'data0918.img' loaded via tftp to address 0x80800000. blob>9> 擦除原來的 flash 數據分區(qū)blob> nanderase-z 0x4500000 0xbb

19、00000the current nandchip does not support block unlocking. erase 0xa81f000 length data from flash: 0x4400000 eraseflash from 0x4400000, length 0xa81f000.done10> 燒寫數據鏡像到 flash 數據分區(qū)blob> nandwrite -y 0x80800000 0x4500000 17402880 the current nandchip does not support block unlocking.write 0x109

20、8c00 length data from ram: 0x80800000 to flash: 0x4400000write flash from 0x4400000, length 0x1018000 eraseflash from 0x4400000, length 0x1018000.done.doneblob>flash 分區(qū)圖:*blob*kernel*system *data* nanderase-z 0x100000 0x400000 tftp zimagenandwrite -z 0x80800000 0x100000 <zimage-actual-length&g

21、t;燒寫 system.img:nanderase-z 0x500000 0x4000000 tftp system.imgnandwrite -y 0x80800000 0x500000 <system.img actual length>燒 寫 userdata.img :nanderase-z 0x4500000 0xbb00000 tftp userdata.imgnandwrite -y 0x80800000 0x4500000 <userdata.img actual length>涉及的內容:svn 服務器的使用android 的編譯系統(tǒng),原理,工具鏈,輔

22、助工具,參數等,環(huán)境變量,怎樣單獨添加編譯一個單獨的模塊等。android 的編譯結果:文件系統(tǒng)分析文件系統(tǒng)的使用,啟動流程設置模塊流程分析1. android 編譯系統(tǒng)分析編譯腳本及系統(tǒng)變量build/envsetup.sh 腳本分析在編譯源代碼之前通常需要在android 源代碼頂層目錄執(zhí)行./build/envsetup.sh目的是為了使用腳本 envsetup.sh 里面定義了一些函數:function help()function get_abs_build_var() function get_build_var() function check_product() functio

23、n check_variant() function setpaths()function printconfig()function set_stuff_for_environment() function set_sequence_number() function settitle()function choosetype() function chooseproduct() function choosevariant() function tapas()function choosecombo() function print_lunch_menu() function lunch(

24、)function gettop function m()function findmakefile() function mm() function mmm() function croot() function pid()function gdbclient() function jgrep() function cgrep() function resgrep()function getprebuilt function tracedmdump() function runhat() function getbugreports()function startviewserver() f

25、unction stopviewserver()function isviewserverstarted() function smoketest()function runtest()function runtest_py() function godir ()choosecombo 命令分析:function choosecombo()choosesim $1 echoechochoosetype $2echo echochooseproduct $3echo echochoosevariant $4echo set_stuff_for_environment printconfig會依次

26、進行如下選擇:build for the simulator or the device?1. device2. simulatorwhich would you like? 1build type choices are:1. release2. debugwhich would you like? 1product choices are:1. emulator2. generic3. sim4. littletonyou can also type the name of a product if you know it. which would you like? littletonv

27、ariant choices are:1. user2. userdebug3. engwhich would you like? eng user 默 認 選 擇 以 后 會 出 現 : target_product=littleton target_build_variant=usertarget_simulator=falsetarget_build_type=release target_arch=arm host_arch=x86host_os=linux host_build_type=release build_id=function chooseproduct() 函數分析:c

28、hoices=(/bin/ls build/target/board/*/boardconfig.mkvendor/*/*/boardconfig.mk2> /dev/null)讀取 build/target/board/*目錄下的板配置文件:boardconfig.mk讀取 vendor/*/*/ 目錄下的板配置文件:boardconfig.mk choices 的 值 為 : build/target/board/emulator/boardconfig.mk build/target/board/generic/boardconfig.mk build/target/board/s

29、im/boardconfig.mk vendor/marvell/littleton/boardconfig.mk經過:for choice in $choices do# the product name is the name of the directory containing # the makefile we found, dlist=($prodlistdirname $choice| xargs basename)done的處理, prodlist 的值為: emulator generic sim littleton 所以選擇菜單為:product choi

30、ces are:1. emulator2. generic3. sim4. littleton如果選擇4,那么 target_product被賦值為: littleton 。board_config_mk :=$(strip $(wildcard$(src_target_dir)/board/$(target_device)/boardconfig.mk vendor/*/$(target_device)/boardconfig.mk)怎樣添加一個模塊local_path:=$(call my-dir) #編譯靜態(tài)庫include $(clear_vars)local_module= libh

31、ellos local_cflags= $(l_cflags)local_src_files= hellos.clocal_c_includes= $(includes)local_shared_libraries:= libcutilslocal_copy_headers_to:= libhellos local_copy_headers:= hellos.h include $(build_static_library)#編譯動態(tài)庫include $(clear_vars) local_module= libhellod local_cflags= $(l_cflags)local_src

32、_files= hellod.c local_c_includes= $(includes)local_shared_libraries:= libcutils local_copy_headers_to:= libhellod local_copy_headers:= hellod.h include $(build_shared_library)build_test=trueifeq ($(build_test),true) #使用靜態(tài)庫include $(clear_vars) local_module:= hellos local_static_libraries:= libhello

33、slocal_shared_libraries:= local_ldlibs+= -ldl local_cflags:= $(l_cflags)local_src_files:= mains.c local_c_includes:= $(includes)include $(build_executable)#使用動態(tài)庫include $(clear_vars) local_module:= hellod local_module_tags:= debuglocal_shared_libraries:= libc libcutils libhellod local_ldlibs+= -ldll

34、ocal_cflags:= $(l_cflags)local_src_files:= maind.c local_c_includes:= $(includes)include $(build_executable)endif # ifeq ($(wpa_build_supplicant),true)#local_target_dir := $(target_out)/etc/wifi #include $(clear_vars) #local_module:= wpa_supplicant.conf #local_module_tags:= user #local_module_class:

35、= etc#local_module_path:= $(local_target_dir) #local_src_files:= $(local_module)#include $(build_prebuilt) #系統(tǒng)變量解析local_module 編譯的目標對象local_src_files 編譯的源文件local_c_includes 需要包含的頭文件目錄local_shared_libraries 鏈接時需要的外部庫local_prelink_module 是否需要 prelink 處理build_shared_library 指明要編譯成動態(tài)庫local_path- 編譯時的目錄$

36、(call 目錄,目錄 .) 目錄引入操作符如該目錄下有個文件夾名稱src,則可以這樣寫$(call src),那么就會得到src 目錄的完整路徑include $(clear_vars)-清除之前的一些系統(tǒng)變量clear_vars:=$(build_system)/clear_vars.mk在 build/core/config.mk定義 clear_vars:=$(build_system)/clear_vars.mk通過 include包含自定義的 .mk 文件(即是自定義編譯規(guī)則)或是引用系統(tǒng)其他的.mk 文件(系統(tǒng)定義的編譯規(guī)則)。local_src_files 編譯的源文件可以是

37、.c, .cpp, .java, .s(匯編文件)或是.aidl 等格式不同的文件用空格隔開。如果編譯目錄子目錄,采用相對路徑,如子目錄/文件名。也可以通過$(call目錄),指明編譯某目錄下所有 .c/.cpp/.java/.s/ .aidl 文件 .追加文件local_src_files+= 文件local_c_includes 需要包含的頭文件目錄可以是系統(tǒng)定義路徑,也可以是相對路徑. 如該編譯目錄下有個include 目錄,寫法是include/*.hlocal_shared_libraries 鏈接時需要的外部共享庫local_static_libraries 鏈接時需要的外部外部靜

38、態(tài)local_java_libraries加入 jar 包local_module 編譯的目標對象module 是指系統(tǒng)的 native code,通常針對 c,c+代碼./system/core/sh/android.mk:32:local_module:=sh./system/core/libcutils/android.mk:71:local_module:= libcutils./system/core/cpio/android.mk:9:local_module:= mkbootfs./system/core/mkbootimg/android.mk:8:local_module:=

39、 mkbootimg./system/core/toolbox/android.mk:61:local_module:=toolbox./system/core/logcat/android.mk:10:local_module:=logcat./system/core/adb/android.mk:65:local_module:= adb./system/core/adb/android.mk:125:local_module:= adbd./system/core/init/android.mk:20:local_module:=init./system/core/vold/androi

40、d.mk:24:local_module:=vold./system/core/mountd/android.mk:13:local_module:=mountdlocal_package_namejava 應用程序的名字用該變量定義./packages/apps/music/android.mk:9:local_package_name:= music./packages/apps/browser/android.mk:14:local_package_name:= browser./packages/apps/settings/android.mk:8:local_package_name

41、:= settings./packages/apps/stk/android.mk:10:local_package_name:= stk./packages/apps/contacts/android.mk:10:local_package_name:= contacts./packages/apps/mms/android.mk:8:local_package_name:= mms./packages/apps/camera/android.mk:8:local_package_name:= camera./packages/apps/phone/android.mk:11:local_p

42、ackage_name:= phone./packages/apps/voicedialer/android.mk:8:local_package_name:= voicedialerbuild_shared_library 指明要編譯成動態(tài)庫。編譯的目標,用 include操作符uild_static_library來指明要編譯成靜態(tài)庫。如果是 java 文件的話,會用到系統(tǒng)的編譯腳本host_java_library.mk ,用 build_package來指明。三個編譯include $(build_static_library)build_static_library:=$(build

43、_system)/static_library.mkinclude $(build_shared_library)./build/core/config.mk:50:build_shared_library:=$(build_system)/shared_library.mkinclude $(build_host_shared_library)build_host_shared_library:=$(build_system)/host_shared_library.mkinclude $(build_executable)build/core/config.mk:51:build_exec

44、utable:=$(build_system)/executable.mkinclude $(build_host_executable)./build/core/config.mk:53:build_host_executable:=$(build_system)/host_executable.mkbuild_host_java_library:=$(build_system)/host_java_library.mkbuild_java_library./build/core/config.mk:58:build_java_library:=$(build_system)/java_li

45、brary.mkbuild_static_java_library編譯靜態(tài) java 庫./build/core/config.mk:59:build_static_java_library:=$(build_system)/static_java_library.mkbuild_host_java_library編譯本機用的 java庫./build/core/config.mk:60:build_host_java_library:=$(build_system)/host_java_library.mkbuild_host_static_library:=$(build_system)/

46、host_static_library.mk build_host_shared_library:=$(build_system)/host_shared_library.mk build_static_library:=$(build_system)/static_library.mk build_raw_static_library:= $(build_system)/raw_static_library.mk build_shared_library:=$(build_system)/shared_library.mk build_executable:=$(build_system)/

47、executable.mkbuild_raw_executable:=$(build_system)/raw_executable.mk build_host_executable:=$(build_system)/host_executable.mk build_package:=$(build_system)/package.mk build_host_prebuilt:=$(build_system)/host_prebuilt.mk build_prebuilt:=$(build_system)/prebuilt.mk build_multi_prebuilt:=$(build_system)/multi_prebuilt.mk build_java_library:=$(build_system)/java_library.mk build_static_java_library:=$(build_system)/static_java_library.mk build_host_java_library:=$(build_system)/host_java_library.mk build_droiddoc:=$(build_system)/droiddoc.mk build_copy_headers:= $(build_s

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論