當前位置:首頁 » 安卓系統 » androidforlinux

androidforlinux

發布時間: 2023-06-07 14:05:28

『壹』 如何將android linux燒到Raspberry Pi及其調試

一.Raspberry Pi入門向導。

可以在以下地址下載Raspberry向導


2.構建android framework

命令如下:

cd <your_android_path>

source build/envsetup.sh

lunch


顯示lunch菜單如下:

You』re building on Linux


Lunch menu… pick a combo:

1. full-eng

2. full_x86-eng

3. simulator

4. full_rpi-eng

5. cyanogen_generic-eng

6. cyanogen_rpi-eng

選擇第6個菜單。

然後進行編譯

make -j8

等待編譯成功,這可能需要幾十分鍾。


編譯成功之後將」system」目錄復制到root目錄下,接下來我們可能會用到。

命令如下:

cd <your_android_path>

cp -r system out/target/proct/rpi/root


ps:編譯時如果jdk版本不對,可將其改成jdk1.6


五.如何在Raspberry Pi上跑android linux內核?


1.准備一張存儲空間2G以上的SD卡及相應讀卡器。


2.下載arch linux鏡像文件

用wget工具下載鏡像文件:

wget http://files.velocix.com/c1410/images/archlinuxarm/archlinux-hf-2012-09-18/archlinux-hf-2012-09-18.zip

解壓

unzip archlinux-hf-2012-09-18.zip

成功之後,你會在當前目錄下發現一個鏡像文件。


3.燒linux鏡像文件。

sudo dd bs=4M if=archlinux-hf-2012-09-18.img of=/dev/sdb

sudo sync

ps:/dev/sdb是SD卡在主機上的設備文件。不同的電腦可能不同。


4.用android linux內核代替這個內核。

做完上述步驟之後,當你把SD卡插在電腦上,你會發現有兩個分區:一個是引導區,另一個是文件系統區。

用android linux內核代替引導區的kernel.img。

cp -uv <your_android_linux_path>/arch/arm/boot/zImage <your_sdcard_boot_partition>/kernel.img


5.用android linux文件系統代替這個linux文件系統

rm -rf <your_sdcard_file_system_partition>

cp -r <your_android_source_code_path>/out/target/proct/rpi/root/* <your_sdcard_file_system_partition>


6.配置內核命令行cmdline.txt

Edit the <your_sdcard_boot_partition>/cmdling.txt, and replace 「init=/…」 with 「init=/init」


7.做完這些之後就可以在Raspberry Pi上跑這個android linux內核。


六.如何為Android linux做一張可引導的SD卡


1.刪除已有分區,如果沒有就不用刪了。

Command(m for help):p


Disk /dev/sdb: 15.7 GB, 15707668480 bytes

64 heads, 32 sectors/track, 14980 cylinders, total 30668085 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0×00000000


sudo fdisk/dev/sdb


Command(m for help):d

Partition number(1-4):1


Command(m for help):d

Selected partition 2


Command (m for help): p


Disk /dev/sdb: 15.7 GB, 15707668480 bytes

64 heads, 32 sectors/track, 14980 cylinders, total 30679040 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0×00000000

Device Boot Start End Blocks Id System


Command(m for help):w

ps:確定刪除之後,卸掉SD卡,然後再裝上。


以bytes問單位記下SD卡的大小。後面的步驟會用到。

然後進入」Expert mode」。


Command(m for help):x


將這個SD卡設置為255個磁面,63個扇區和磁柱數量(不同的SD/mmc卡有著不同的此柱數量)

Expert command (m for help): h

Number of heads (1-256, default 64): 255


Expert command (m for help): s

Number of sectors (1-63, default 32): 63


ps:在下一步開始前,先要計算磁柱數量,計算過程如下:

B:SD卡以bytes為單位的大小(前面已經記住了即:15707668480)

C:磁柱的數量

C=B/255/63/512


例如:我的SD卡大小是16G(15707668480)

C=15707668480/255/63/512=1909.68191721,約等於1909.


Expert command (m for help): c

Number of cylinders (1-1048576, default 14980): 1909

Expert command (m for help): r


2.新建分區

如果你的SD卡已經分區,請按照上述步驟刪除分區。接下來,我們將創建兩個分區,一個是引導區,用來存放內核鏡像等文件;另一個文件系統區存放android linux文件系統。


Command (m for help): n

Partition type:

p primary (0 primary, 0 extended, 4 free)

e extended

Select (default p): p

Partition number (1-4, default 1):

Using default value 1

First sector (2048-30679039, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-30679039, default 30679039): +128M

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): c

Changed system type of partition 1 to c (W95 FAT32 (LBA))

Command (m for help): a

Partition number (1-4): 1

Command (m for help): n

Partition type:

p primary (1 primary, 0 extended, 3 free)

e extended

Select (default p): p

Partition number (1-4, default 2):

Using default value 2

First sector (264192-30679039, default 264192):

Using default value 264192

Last sector, +sectors or +size{K,M,G} (264192-30679039, default 30679039):

Using default value 30679039

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x

partitions, please see the fdisk manual page for additional

information.

Syncing disks.


ok,分區成功,現在我們有兩個分區,接下我們對分區進行格式化。


3.格式化分區

對引導區進行格式化:


sudo mkfs.msdos -F 32 /dev/sdb1 -n BOOT

mkfs.msdos 3.0.12 (29 Oct 2011)


對文件系統區進行格式化:

sudo mkfs.ext3 /dev/sdb2 -L ROOTFS

mke2fs 1.42 (29-Nov-2011)

Filesystem label=ROOTFS

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

950976 inodes, 3801856 blocks

190092 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=3896508416

117 block groups

32768 blocks per group, 32768 fragments per group

8128 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done


4.設置引導區

引導區必須包含以下文件,你可以從官方鏡像里獲取(bootable/fat32 partition)也可以從書面步驟中復制過來:

bootcode.bin:第二階段的引導程序,

loader.bin:第三階段的引導程序,

start.elf:GPU二進制固件映像,

kernel.img操作系統的內核鏡像文件,

cmdline.txt:傳遞給內核的參數.


5.設置root文件系統分區

ROOTFS分區包含android文件系統,是從<your_android_framework_path>/out/target/proct/rpi/root復制過來的。

cp -r <your_android_framework_path>/out/target/proct/rpi/root/* /media/ROOTFS/


6.完成上述步驟之後,將其放在Raspberry Pi上跑。


七.如何在Raspberry Pi使用adb?


1.查看網路

當android linux在Raspberry Pi運行時,切換到控制台,執行以下命令:

ifconfig eth0

記下ip地址。

如果不能找到ip,可以輸入以下命令:/system/xbin/dhcp-eth0,來啟動網路連接程序。

ps:如果屏幕沒有顯示控制台,只要按CTRL+ALT+F2即可切換到控制台。如果你想要切換到Android界面,只要按CTRL+ALT+F7即可。


2.遠程連接adb伺服器

在主機上執行以下命令即可與同一區域網的Raspberry Pi相連

adb connect ip

連接成功後,你就可以用adb工具輸出日誌,執行shell命令等。


3.也可以用數據線連接主機,直接在主機上調試。

進入調試的命令為:

screen /dev/ttyUSB0 115200


名詞解釋:

交叉編譯(cross compile):交叉編譯呢,簡單地說,就是在一個平台上生成另一個平台上的可執行代碼。這里需要注意的是所謂 平台,實際上包含兩個概念:體系結構(Architecture)、操作系統(Operating System)。同一個體系結構可以運行不同的操作系統;同樣,同一個操作系統也可以在不同的體系結構上運行。舉例來說,我們常說的x86 Linux平台實際上是Intel x86體系結構和Linux for x86操作系統的統稱;而x86 WinNT平台實際上是Intel x86體系結構和Windows NT for x86操作系統的簡稱。

『貳』 安卓手機Linux模擬器。反正能夠用所有的Linux命令的模擬器有沒有全部都是一些太基礎的不要

沒什麼好辦法,下個cygwin模擬一個linux試試吧,建議最好用虛擬機加linux,比用cygwin好些,畢竟那是真實的linux,而cygwin是虛擬的

如果不想裝linux的話,有兩個方法:
1、安裝cygwin
2、下載putty,連接朋友提供的伺服器.或者到網上找一些學習性的系統.
參考資料中的目標是為研究、學習和使用各種版本的Unix和類Unix操作系統的教師、學生和工程技術人員提供一個體驗和測試各種版本的Unix和類Unix系統的軟硬體平台,缺點是不能使用一些管理員許可權。
所提供的操作系統包括AIX 5.3,Solaris 10,OpenSolaris 2009.06,Fedora Core 10,Ubuntu 8.04,FreeBSD 6.2,Debian Linux for MIPS。這些操作系統分別運行在IBM Power 5,Sun UltraSPARC T1,AMD Opteron,Intel Xeon,龍芯2E等不同構架的處理器上。
參考資料: http://www.unix-center.net/

『叄』 如何加快linux android 的編譯速度

項目越來越大,每次需要重新編譯整個項目都是一件很浪費時間的事情。Research了一下,找到以下可以幫助提高速度的方法,總結一下。
1. 使用tmpfs來代替部分IO讀寫
2.ccache,可以將ccache的緩存文件設置在tmpfs上,但是這樣的話,每次開機後,ccache的緩存文件會丟失
3.distcc,多機器編譯
4.將屏幕輸出列印到內存文件或者/dev/null中,避免終端設備(慢速設備)拖慢速度。

tmpfs
有人說在Windows下用了RAMDisk把一個項目編譯時間從4.5小時減少到了5分鍾,也許這個數字是有點誇張了,不過粗想想,把文件放到內存上做編譯應該是比在磁碟上快多了吧,尤其如果編譯器需要生成很多臨時文件的話。
這個做法的實現成本最低,在Linux中,直接mount一個tmpfs就可以了。而且對所編譯的工程沒有任何要求,也不用改動編譯環境。
mount -t tmpfs tmpfs ~/build -o size=1G
用2.6.32.2的Linux Kernel來測試一下編譯速度:
用物理磁碟:40分16秒
用tmpfs:39分56秒
呃……沒什麼變化。看來編譯慢很大程度上瓶頸並不在IO上面。但對於一個實際項目來說,編譯過程中可能還會有打包等IO密集的操作,所以只要可能,用tmpfs是有益無害的。當然對於大項目來說,你需要有足夠的內存才能負擔得起這個tmpfs的開銷。
make -j
既然IO不是瓶頸,那CPU就應該是一個影響編譯速度的重要因素了。
用make -j帶一個參數,可以把項目在進行並行編譯,比如在一台雙核的機器上,完全可以用make -j4,讓make最多允許4個編譯命令同時執行,這樣可以更有效的利用CPU資源。
還是用Kernel來測試:
用make: 40分16秒
用make -j4:23分16秒
用make -j8:22分59秒
由此看來,在多核CPU上,適當的進行並行編譯還是可以明顯提高編譯速度的。但並行的任務不宜太多,一般是以CPU的核心數目的兩倍為宜。
不過這個方案不是完全沒有cost的,如果項目的Makefile不規范,沒有正確的設置好依賴關系,並行編譯的結果就是編譯不能正常進行。如果依賴關系設置過於保守,則可能本身編譯的可並行度就下降了,也不能取得最佳的效果。
ccache
ccache工作原理:
ccache也是一個編譯器驅動器。第一趟編譯時ccache緩存了GCC的「-E」輸出、編譯選項以及.o文件到$HOME/.ccache。第二次編譯時盡量利用緩存,必要時更新緩存。所以即使"make clean; make"也能從中獲得好處。ccache是經過仔細編寫的,確保了與直接使用GCC獲得完全相同的輸出。

ccache用於把編譯的中間結果進行緩存,以便在再次編譯的時候可以節省時間。這對於玩Kernel來說實在是再好不過了,因為經常需要修改一些Kernel的代碼,然後再重新編譯,而這兩次編譯大部分東西可能都沒有發生變化。對於平時開發項目來說,也是一樣。為什麼不是直接用make所支持的增量編譯呢?還是因為現實中,因為Makefile的不規范,很可能這種「聰明」的方案根本不能正常工作,只有每次make clean再make才行。
安裝完ccache後,可以在/usr/local/bin下建立gcc,g++,c++,cc的symbolic link,鏈到/usr/bin/ccache上。總之確認系統在調用gcc等命令時會調用到ccache就可以了(通常情況下/usr/local /bin會在PATH中排在/usr/bin前面)。
安裝的另外一種方法:
vi ~/.bash_profile
把/usr/lib/ccache/bin路徑加到PATH下
PATH=/usr/lib/ccache/bin:$PATH:$HOME/bin
這樣每次啟動g++的時候都會啟動/usr/lib/ccache/bin/g++,而不會啟動/usr/bin/g++
效果跟使用命令行ccache g++效果一樣
這樣每次用戶登錄時,使用g++編譯器時會自動啟動ccache
繼續測試:
用ccache的第一次編譯(make -j4):23分38秒
用ccache的第二次編譯(make -j4):8分48秒
用ccache的第三次編譯(修改若干配置,make -j4):23分48秒

看來修改配置(我改了CPU類型...)對ccache的影響是很大的,因為基本頭文件發生變化後,就導致所有緩存數據都無效了,必須重頭來做。但如果只是修改一些.c文件的代碼,ccache的效果還是相當明顯的。而且使用ccache對項目沒有特別的依賴,布署成本很低,這在日常工作中很實用。
可以用ccache -s來查看cache的使用和命中情況:
cache directory /home/lifanxi/.ccachecache hit 7165cache miss 14283called for link 71not a C/C++ file 120no input file 3045files in cache 28566cache size 81.7 Mbytesmax cache size 976.6 Mbytes
可以看到,顯然只有第二編次譯時cache命中了,cache miss是第一次和第三次編譯帶來的。兩次cache佔用了81.7M的磁碟,還是完全可以接受的。
distcc
一台機器的能力有限,可以聯合多台電腦一起來編譯。這在公司的日常開發中也是可行的,因為可能每個開發人員都有自己的開發編譯環境,它們的編譯器版本一般是一致的,公司的網路也通常具有較好的性能。這時就是distcc大顯身手的時候了。
使用distcc,並不像想像中那樣要求每台電腦都具有完全一致的環境,它只要求源代碼可以用make -j並行編譯,並且參與分布式編譯的電腦系統中具有相同的編譯器。因為它的原理只是把預處理好的源文件分發到多台計算機上,預處理、編譯後的目標文件的鏈接和其它除編譯以外的工作仍然是在發起編譯的主控電腦上完成,所以只要求發起編譯的那台機器具備一套完整的編譯環境就可以了。
distcc安裝後,可以啟動一下它的服務:
/usr/bin/distccd --daemon --allow 10.64.0.0/16
默認的3632埠允許來自同一個網路的distcc連接。
然後設置一下DISTCC_HOSTS環境變數,設置可以參與編譯的機器列表。通常localhost也參與編譯,但如果可以參與編譯的機器很多,則可以把localhost從這個列表中去掉,這樣本機就完全只是進行預處理、分發和鏈接了,編譯都在別的機器上完成。因為機器很多時,localhost的處理負擔很重,所以它就不再「兼職」編譯了。
export DISTCC_HOSTS="localhost 10.64.25.1 10.64.25.2 10.64.25.3"
然後與ccache類似把g++,gcc等常用的命令鏈接到/usr/bin/distcc上就可以了。
在make的時候,也必須用-j參數,一般是參數可以用所有參用編譯的計算機CPU內核總數的兩倍做為並行的任務數。
同樣測試一下:
一台雙核計算機,make -j4:23分16秒
兩台雙核計算機,make -j4:16分40秒
兩台雙核計算機,make -j8:15分49秒
跟最開始用一台雙核時的23分鍾相比,還是快了不少的。如果有更多的計算機加入,也可以得到更好的效果。
在編譯過程中可以用distccmon-text來查看編譯任務的分配情況。distcc也可以與ccache同時使用,通過設置一個環境變數就可以做到,非常方便。
總結一下:
tmpfs: 解決IO瓶頸,充分利用本機內存資源
make -j: 充分利用本機計算資源
distcc: 利用多台計算機資源
ccache: 減少重復編譯相同代碼的時間
這些工具的好處都在於布署的成本相對較低,綜合利用這些工具,就可以輕輕鬆鬆的節省相當可觀的時間。上面介紹的都是這些工具最基本的用法,更多的用法可以參考它們各自的man page。
5.還有提速方法是把屏幕輸出重定向到內存文件或/dev/null,因對終端設備(慢速設備)的阻塞寫操作也會拖慢速度。推薦內存文件,這樣發生錯誤時,能夠查看。

『肆』 pkg install android-tools

Android-tools-adbDownloadforLinux(deb,pkg)。
可以下載這個工具或者直接在手機的文件中改變文件的後綴為.zip,手機即可識別文件進行安裝。
pkg文件也就是安裝包配置文件,是製作SymbianOS安裝程序的核心部分。搜索它包含了製作安裝文件所需要的全部信息,根據這個文件的內容,sis文件生成器(安裝程序的擴展名是.sis)製作生成應用程序的安裝程序,也就是.sis文件。

『伍』 如何用 Android 手機遠程式控制制 Linux 桌面 VLC 播放器

准備條件

Android 手機和桌面 Linux 位於同一無線網路,是否可以訪問互聯網不重要。
Android 手機上安裝免費開源的 Remote for VLC(Code 首頁)
已經在 Linux 桌面環境下安裝好 VLC 2.0 播放器。

下文將以 Fedora 17 為例介紹這一過程。
啟用 VLC http 遠程式控制制支持
啟動 VLC,在主界面上依次點擊「工具」-「首選項」-左下角選擇「全部」-左側列表中選擇「主界面」-在右側勾選「Web」。如下圖所示:




保存並關閉 VLC。
之後需要編輯 VLC 的 Lua 主機配置文件,允許可以訪問的網路段。比如可以用以下命令以 root 用戶身份打開配置文件:
su -c 'vim /usr/share/vlc/lua/http/.hosts'
一般正常的人會僅希望區域網內的 Android 手機可以訪問並控制桌面上的 VLC,於是取消 # private addresses下面幾行開頭的注釋即可。
保存更改並退出編輯器。
設置防火牆策略
找到系統設置中的防火牆,或者通過在終端輸入 system-config-firewall 的方式啟動。
VLC 的遠程式控制制默認通過 8080 埠實現,所以在左側選擇「其他埠」,然後通過右側依次添加 TCP/UDP 8080 埠。
(可選)Android 手機支持通過 Avahi 的方式自動尋找查找網路中的可用主機,如果需要這個功能的話在左側選擇「可信的服務」,然後在右側勾選「多點廣播 DNS (mDNS)」。如果不用啟用該項的話就需要在 Remote for VLC 手動輸入 IP 地址和埠。
完成之後點擊工具欄上的「應用」保存防火牆配置。
開始使用
再次啟動 VLC 播放器,在主界面上選擇「視圖」-「添加界面」-選擇「Web」。
在 Android 手機上啟動 Remote for VLC,稍等一下應該就會顯示在網路中找到的所有 VLC 實例,輕觸即可鏈接。
此時你就可以遠離鍵盤和滑鼠,坐在沙發上享受 VLC 帶來的影音體驗了:

支持音量、音軌、字幕軌、全屏模式的調整,顯示媒體信息。
支持創建播放列表。
支持瀏覽桌面 Linux 上的文件系統(知道為何不建議通過互聯網訪問了吧……)
試驗性的支持 DVD 菜單。
可以在有來電時自動暫停媒體播放。

『陸』 android kernel和標准linux kernel的區別

android kernel和標准linux kernel的區別

android kernel和標准linux kernel的區別
總的區別可以歸納如下:
ARCH -- 這是Android修改了arch/arm下面的一些檔案:
arch/arm:
Chg: arch/arm/kernel/entry-armv.S
Chg: arch/arm/kernel/mole.c
Chg: arch/arm/kernel/process.c
Chg: arch/arm/kernel/ptrace.c
Chg: arch/arm/kernel/setup.c
Chg: arch/arm/kernel/signal.c
Chg: arch/arm/kernel/traps.c
Chg: arch/arm/mm/cache-v6.S
Chg: arch/arm/vfp/entry.S
Chg: arch/arm/vfp/vfp.h
Chg: arch/arm/vfp/vfphw.S
Chg: arch/arm/vfp/vfpmole.c
Goldfish -- 這是Android為了模擬器所開發的一個虛擬硬體平台。Goldfish執行arm926T指令(在2.6.29中,goldfish也支援ATMv7指令),但是在實際的裝置中,該虛擬平台的檔案不會被編譯。
arch/arm/mach-goldfish:
New: arch/arm/mach-goldfish/audio.c
New: arch/arm/mach-goldfish/board-goldfish.c
New: arch/arm/mach-goldfish/pdev_bus.c
New: arch/arm/mach-goldfish/pm.c
New: arch/arm/mach-goldfish/switch.c
New: arch/arm/mach-goldfish/timer.c
YAFFS2 -- 和PC把檔案儲存在硬碟上不一樣, 移動裝置一般把Flash作為儲存裝數模鏈置。尤其是NAND flash應用非常廣泛(絕大多數手機用的都是NAND flash,三星的一些手機使用的是OneNAND)。NAND flash具有低成碼帶本和高密度的優點。
YAFFS2 是「Yet Another Flash File System, 2nd edition" 的簡稱。 它提供在Linux核心和NAND flash裝置 之前高效率的介面。 YAFFS2並沒薯孫有包含在標準的Linux核心中, Google把它新增到了Android的kernel
fs/yaffs2:
New: fs/yaffs2/devextras.h
New: fs/yaffs2/Kconfig
New: fs/yaffs2/Makefile
New: fs/yaffs2/moleconfig.h
New: fs/yaffs2/yaffs_checkptrw.c
New: fs/yaffs2/yaffs_checkptrw.h
New: fs/yaffs2/yaffs_e.c
New: fs/yaffs2/yaffs_e.h
New: fs/yaffs2/yaffs_fs.c
New: fs/yaffs2/yaffs_getblockinfo.h
New: fs/yaffs2/yaffs_guts.c
New: fs/yaffs2/yaffs_guts.h
New: fs/yaffs2/yaffsinterface.h
New: fs/yaffs2/yaffs_mtdif1.c
New: fs/yaffs2/yaffs_mtdif1.h
New: fs/yaffs2/yaffs_mtdif2.c
New: fs/yaffs2/yaffs_mtdif2.h
New: fs/yaffs2/yaffs_mtdif.c
New: fs/yaffs2/yaffs_mtdif.h
New: fs/yaffs2/yaffs_nand.c
New: fs/yaffs2/yaffs_nandemul2k.h
New: fs/yaffs2/yaffs_nand.h
New: fs/yaffs2/yaffs_packedtags1.c
New: fs/yaffs2/yaffs_packedtags1.h
New: fs/yaffs2/yaffs_packedtags2.c
New: fs/yaffs2/yaffs_packedtags2.h
New: fs/yaffs2/yaffs_qsort.c
New: fs/yaffs2/yaffs_qsort.h
New: fs/yaffs2/yaffs_tagspat.c
New: fs/yaffs2/yaffs_tagspat.h
New: fs/yaffs2/yaffs_tagsvalidity.c
New: fs/yaffs2/yaffs_tagsvalidity.h
New: fs/yaffs2/yportenv.h
Bluetooth -- Google為Bluetooth打上了patch,fix了一些Bluetooth的bug
drivers/bluetooth:
Chg: drivers/bluetooth/bfu *** .c
Chg: drivers/bluetooth/bt3c_cs.c
Chg: drivers/bluetooth/btu *** .c
Chg: drivers/bluetooth/hci_h4.c
Chg: drivers/bluetooth/hci_ll.c
Scheler -- 對於Scheler的改變非常小,我對它並沒有去研究。
Chg: kernel/sched.c

New Android Functionality -- 除了fix一些bug以及其他一些小的更改,Android增加了一些新的功能,介紹如下:
IPC Binder -- The IPC Binder is an Inter-Process Communication (IPC) mechani *** . It allows processes to provide services to other processes via a set of higher-level APIs than are available in standard Linux. An Inter search indicated that the Binder concept originated at Be, Inc., and then made its way into Palm's sofare, before Google wrote a new Binder for Android.
New: drivers/staging/android/binder.c
Low Memory Killer -- Android adds a low-memory killer that, each time it's called, scans the list of running Linux processes, and kills one. It was not clear in our cursory examination why Android adds a low-memory killer on of the already existing one in the standard Linux kernel.
New: drivers/staging/android/lowmemorykiller.c
Ashmem -- Ashmem is an Anonymous SHared MEMory system that adds interfaces so processes can share named blocks of memory. As an example, the system could use Ashmem to store icons, which multiple processes could then aess when drawing their UI. The advantage of Ashmem over traditional Linux shared memory is that it provides a means for the kernel to reclaim these shared memory blocks if they are not currently in use. If a process then tries to aess a shared memory block the kernel has freed, it will receive an error, and will then need to reallocate the block and reload the data.
New: mm/ashmem.c
RAM Console and Log Device -- To aid in debugging, Android adds the ability to store kernel log messages to a RAM buffer. Additionally, Android adds a separate logging mole so that user processes can read and write user log messages.
New: drivers/staging/android/ram_console.c
Android Debug Bridge -- Debugging embedded devices can best be described as challenging. To make debugging easier, Google created the Android Debug Bridge (ADB), which is a protocol that runs over a USB link beeen a hardware device running Android and a developer writing applications on a desk PC.
drivers/u *** /gadget:
New: drivers/u *** /gadget/android.c
Chg: drivers/u *** /gadget/posite.c
Chg: drivers/u *** /gadget/f_acm.c
New: drivers/u *** /gadget/f_acm.h
New: drivers/u *** /gadget/f_adb.c
New: drivers/u *** /gadget/f_adb.h
New: drivers/u *** /gadget/f_mass_storage.c
New: drivers/u *** /gadget/f_mass_storage.h
Android also adds a new real-time clock, switch support, and timed GPIO support. We list the impacted files for these new moles at the end of this document.
Power Management -- Power management is one of the most difficult pieces to get right in mobile devices, so we split it out into a group separate from the other pieces. It's interesting to note that Google added a new power management system to Linux, rather than reuse what already existed. We list the impacted files at the end of this document.
kernel/power:
New: kernel/power/consoleearlysuspend.c
New: kernel/power/earlysuspend.c
New: kernel/power/fbearlysuspend.c
Chg: kernel/power/main.c
Chg: kernel/power/power.h
Chg: kernel/power/process.c
New: kernel/power/userwakelock.c
New: kernel/power/wakelock.c
Miscellaneous Changes -- In addition to the above, we found a number of changes that could best be described as, 'Miscellaneous.' Among other things, these changes include additional debugging support, keypad light controls, and management of TCP neorking.
(freedom_asic)

Android kernel是從linux kernel 修改過來的,大部分的核心沒什麼變化。Android廠商會定製原始碼修改驅動 或者增加新的特性等。

『柒』 如何件android中的命令移植到linux開發板上,想使用android中的一些命令,方便開發,比如logcat命令

本文用《Android深度探索(卷1):HAL與驅動開發》的隨書源代碼為例詳細說明如何配置Android驅動開發和測試環境,並且如何使用源代碼中的build.sh腳本文件在各種平台(UbuntuLinux、Android模擬器和S3C6410開發板)上編譯、安裝和測試Linux驅動。
建議讀者使用UbuntuLinux12.04或更高版本實驗本文的方法。
最好用root賬號登錄Linux。
一、安裝交叉編譯器
如果只是在UbuntuLinux上測試Linux驅動就不需要安裝交叉編譯器了,但要在Android模擬器或S3C6410開發板上進行測試,就必須安裝交叉編譯器。
首先下載交叉編譯器(分卷壓縮
下載後解壓,會發現有兩個tgz文件,可以將這兩個文件放到/root/compilers目錄中,在Linux終端進入該目錄,執行如下命令安裝交叉編譯器。
[plain]viewplain
#tarzxvfarm-linux-gcc-4.3.2.tgz-C/
#tarjxvfarm-none-linux-gnueabi-arm-2008q3-72-for-linux.tar.bz2-C/
二、編譯和測試Linux內核
這里的Linux內核有兩個,一個是goldfish,也就是Android模擬器使用的Linux內核、另外一個是S3C6410開發板使用的Linux內核(Linux2.6.36)。
讀者首先要下載這兩個Linux內核。
Android模擬器用的Linux內核源代碼(分卷壓縮)
用於S3C6410開發板的Linux內核源代碼(分卷壓縮)
分卷1
分卷2
由於隨書代碼中的word_count驅動已經在goldfish和linux2.6.36中分別建立了符號鏈接,以便在編譯linux內核時同時也會編譯word_count驅動,所以linux內核與源代碼目錄應與作者機器上的目錄相同。
也就是兩個linux內核目錄與源代碼目錄如下:
linux內核目錄
/root/kernel/goldfish
/root/kernel/linux_kernel_2.6.36
源代碼目錄
/root/drivers
注意/root/drivers目錄下就直接是每一章的源代碼了,例如/root/drivers/ch
06、/root/drivers/ch07
現在需要將/usr/local/arm/arm-none-linux-gnueabi/bin路徑加到Linux的PATH環境變數中(不會加的上網查,這是Linux的基本功)
最後進入/root/compilers/goldfish目錄,執行make命令編譯linux內核,如果完全編譯,大概20分鍾左右。
編譯完成後,會在/root/kernel/goldfish/arch/arm/boot目錄中生成一個zImage文件,代碼1.7MB,這就是用於Android模擬器的Linux內核文件。
三、編譯Linux驅動
現在來編譯隨書光碟的驅動程序,這里以word_count驅動為例。
在Linux終端進入/root/drivers/ch06/word_count目錄。
先別忙著編譯。
首先要設置打開/root/drivers/common.sh文件,修改第一行UBUNTU_KERNEL_PATH變數值為自己機器上安裝的UbuntuLinux內核路徑,只要執行「ls/usr/src」命令即可查看當前機器可用的linux內核。

『捌』 嵌入式linux和嵌入式android系統有什麼區別和聯系

嵌入式android源碼架構:uboot+linux kernel+android(包含文件系統,虛擬機,UI)
嵌入式linux:這是大部分人認識的linux uboot+linux kernel+文件系統+QT(UI),
當然兩者的linux 內核因為上層UI的不同會稍有差別,不過還是非常接近的,做過linux的人可以無縫切換到android底層開發,所以大家說的學習android系統,其實最重要的就是學習linux驅動,再加一下android下的專門的HAL,JNI,java等等,不過大公司android相關部分也是專門的人做的了。

甚至連QT都不用了,因為linux很多設備都是沒有UI的,所以要來幹啥?直接無界面,照樣是嵌入式linux。

現在大家說的什麼嵌入式debian,ubuntu,其實也是站在linux巨人的肩膀上,其實都不算是linux的分支,只算是linux的延伸,小變化而已。看到這里大家知道嵌入式linux的強大了吧,反正是比wince 強大N倍啊。

O(∩_∩)O~,所以啊,學習嵌入式android,其實底下就是學習uboot,linux內核啊,不會搞這些就像搞應用一樣,所以大家以為android就是java,是非常片面的。

以前老的,說了一下區別,可以參考一下
ARCH -- 這是Android修改了arch/arm下面的一些文件:
arch/arm:
Chg: arch/arm/kernel/entry-armv.S
Chg: arch/arm/kernel/mole.c
Chg: arch/arm/kernel/process.c
Chg: arch/arm/kernel/ptrace.c
Chg: arch/arm/kernel/setup.c
Chg: arch/arm/kernel/signal.c
Chg: arch/arm/kernel/traps.c
Chg: arch/arm/mm/cache-v6.S
Chg: arch/arm/vfp/entry.S
Chg: arch/arm/vfp/vfp.h
Chg: arch/arm/vfp/vfphw.S
Chg: arch/arm/vfp/vfpmole.c
Goldfish -- 這是Android為了模擬器所開發的一個虛擬硬體平台。Goldfish執行arm926T指令(在2.6.29中,goldfish也支持ATMv7指令),但是在實際的設備中,該虛擬平台的文件不會被編譯。
arch/arm/mach-goldfish:
New: arch/arm/mach-goldfish/audio.c
New: arch/arm/mach-goldfish/board-goldfish.c
New: arch/arm/mach-goldfish/pdev_bus.c
New: arch/arm/mach-goldfish/pm.c
New: arch/arm/mach-goldfish/switch.c
New: arch/arm/mach-goldfish/timer.c
YAFFS2 -- 和PC把文件存儲在硬碟上不一樣, 移動設備一般把Flash作為存儲設備。尤其是NAND flash應用非常廣泛(絕大多數手機用的都是NAND flash,三星的一些手機使用的是OneNAND)。NAND flash具有低成本和高密度的優點。
YAFFS2 是「Yet Another Flash File System, 2nd edition" 的簡稱。 它提供在Linux內核和NAND flash設備 之前高效率的介面。 YAFFS2並沒有包含在標準的Linux內核中, Google把它添加到了Android的kernel
fs/yaffs2:
New: fs/yaffs2/devextras.h
New: fs/yaffs2/Kconfig
New: fs/yaffs2/Makefile
New: fs/yaffs2/moleconfig.h
New: fs/yaffs2/yaffs_checkptrw.c
New: fs/yaffs2/yaffs_checkptrw.h
New: fs/yaffs2/yaffs_ecc.c
New: fs/yaffs2/yaffs_ecc.h
New: fs/yaffs2/yaffs_fs.c
New: fs/yaffs2/yaffs_getblockinfo.h
New: fs/yaffs2/yaffs_guts.c
New: fs/yaffs2/yaffs_guts.h
New: fs/yaffs2/yaffsinterface.h
New: fs/yaffs2/yaffs_mtdif1.c
New: fs/yaffs2/yaffs_mtdif1.h
New: fs/yaffs2/yaffs_mtdif2.c
New: fs/yaffs2/yaffs_mtdif2.h
New: fs/yaffs2/yaffs_mtdif.c
New: fs/yaffs2/yaffs_mtdif.h
New: fs/yaffs2/yaffs_nand.c
New: fs/yaffs2/yaffs_nandemul2k.h
New: fs/yaffs2/yaffs_nand.h
New: fs/yaffs2/yaffs_packedtags1.c
New: fs/yaffs2/yaffs_packedtags1.h
New: fs/yaffs2/yaffs_packedtags2.c
New: fs/yaffs2/yaffs_packedtags2.h
New: fs/yaffs2/yaffs_qsort.c
New: fs/yaffs2/yaffs_qsort.h
New: fs/yaffs2/yaffs_tagscompat.c
New: fs/yaffs2/yaffs_tagscompat.h
New: fs/yaffs2/yaffs_tagsvalidity.c
New: fs/yaffs2/yaffs_tagsvalidity.h
New: fs/yaffs2/yportenv.h
Bluetooth -- Google為Bluetooth打上了patch,fix了一些Bluetooth的bug
drivers/bluetooth:
Chg: drivers/bluetooth/bfusb.c
Chg: drivers/bluetooth/bt3c_cs.c
Chg: drivers/bluetooth/btusb.c
Chg: drivers/bluetooth/hci_h4.c
Chg: drivers/bluetooth/hci_ll.c
Scheler -- 對於Scheler的改變非常小,我對它並沒有去研究。
Chg: kernel/sched.c
New Android Functionality -- 除了fix一些bug以及其他一些小的更改,Android增加了一些新的功能,介紹如下:
IPC Binder -- The IPC Binder is an Inter-Process Communication (IPC) mechanism. It allows processes to provide services to other processes via a set of higher-level APIs than are available in standard Linux. An Internet search indicated that the Binder concept originated at Be, Inc., and then made its way into Palm's software, before Google wrote a new Binder for Android.
New: drivers/staging/android/binder.c
Low Memory Killer -- Android adds a low-memory killer that, each time it's called, scans the list of running Linux processes, and kills one. It was not clear in our cursory examination why Android adds a low-memory killer on top of the already existing one in the standard Linux kernel.
New: drivers/staging/android/lowmemorykiller.c
Ashmem -- Ashmem is an Anonymous SHared MEMory system that adds interfaces so processes can share named blocks of memory. As an example, the system could use Ashmem to store icons, which multiple processes could then access when drawing their UI. The advantage of Ashmem over traditional Linux shared memory is that it provides a means for the kernel to reclaim these shared memory blocks if they are not currently in use. If a process then tries to access a shared memory block the kernel has freed, it will receive an error, and will then need to reallocate the block and reload the data.
New: mm/ashmem.c
RAM Console and Log Device -- To aid in debugging, Android adds the ability to store kernel log messages to a RAM buffer. Additionally, Android adds a separate logging mole so that user processes can read and write user log messages.
New: drivers/staging/android/ram_console.c
Android Debug Bridge -- Debugging embedded devices can best be described as challenging. To make debugging easier, Google created the Android Debug Bridge (ADB), which is a protocol that runs over a USB link between a hardware device running Android and a developer writing applications on a desktop PC.
drivers/usb/gadget:
New: drivers/usb/gadget/android.c
Chg: drivers/usb/gadget/composite.c
Chg: drivers/usb/gadget/f_acm.c
New: drivers/usb/gadget/f_acm.h
New: drivers/usb/gadget/f_adb.c
New: drivers/usb/gadget/f_adb.h
New: drivers/usb/gadget/f_mass_storage.c
New: drivers/usb/gadget/f_mass_storage.h

Android also adds a new real-time clock, switch support, and timed GPIO support. We list the impacted files for these new moles at the end of this document.

Power Management -- Power management is one of the most difficult pieces to get right in mobile devices, so we split it out into a group separate from the other pieces. It's interesting to note that Google added a new power management system to Linux, rather than reuse what already existed. We list the impacted files at the end of this document.
kernel/power:
New: kernel/power/consoleearlysuspend.c
New: kernel/power/earlysuspend.c
New: kernel/power/fbearlysuspend.c
Chg: kernel/power/main.c
Chg: kernel/power/power.h
Chg: kernel/power/process.c
New: kernel/power/userwakelock.c
New: kernel/power/wakelock.c
Miscellaneous Changes -- In addition to the above, we found a number of changes that could best be described as, 'Miscellaneous.' Among other things, these changes include additional debugging support, keypad light controls, and management of TCP networking
http://www.linuxfordevices.com/c ... id-to-a-new-device/
http://hi..com/smallbigwang/item/95c99ebcb0e9544cba0e1281

『玖』 android之SELinux小記

SELinux是安全增強型 Linux(Security-Enhanced Linux)簡稱 SELinux。它是一個 Linux 內核模塊,也是 Linux 的一個安全子系統。

SELinux 主要由美國國家安全局開發。2.6 及以上版本的 Linux 內核都已經集成了 SELinux 模塊。

SELinux 的結構及配置非常復雜,而且有大量概念性的東西,要學精難度較大。很多 Linux 系統管理員嫌麻煩都把 SELinux 關閉了。

SELinux目的在於明確的指明某個進程可以訪問哪些資源(文件、網路埠等)。強制訪問控制系統的用途在於增強系統抵禦 0-Day 攻擊(利用尚未公開的漏洞實現的攻擊行為)的能力。

在目前的大多數發行版中,已經默認在內核集成了SELinux。

舉例來說,系統上的 Apache 被發現存在一個漏洞,使得某遠程用戶可以訪問系統上的敏感文件(比如 /etc/passwd 來獲得系統已存在用戶) ,而修復該安全漏洞的 Apache 更新補丁尚未釋出。此時 SELinux 可以起到彌補該漏洞的緩和方案。因為 /etc/passwd 不具有 Apache 的 訪問標簽,所以 Apache 對於 /etc/passwd 的訪問會被 SELinux 阻止。

相比其他強制性訪問控制系統,SELinux 有如下優勢:

SELinux for Android在架構和機制上與SELinux完全一樣,考慮到移動設備的特點,所以移植到Android上的只是SELinux的一個子集。SELinux for Android的安全檢查幾乎覆蓋了所有重要的系統資源,包括 域轉換,類型轉換,進程、內核、文件、目錄、設備,App,網路及IPC相關的操作

Android分為 寬容模式 (僅記錄但不強制執行 SELinux 安全政策 )和 強制模式 (強制執行並記錄安全政策。如果失敗,則顯示為 EPERM 錯誤。 );在選擇強制執行級別時只能二擇其一。

您的選擇將決定您的政策是採取操作,還是僅允許您收集潛在的失敗事件。寬容模式在實現過程中尤其有用。

DAC是傳統的Linux的訪問控制方式,DAC可以對文件、文件夾、共享資源等進行訪問控制。

在DAC這種模型中,文件客體的所有者(或者管理員)負責管理訪問控制。

DAC使用了ACL(Access Control List,訪問控制列表)來給非管理者用戶提供不同的許可權,而root用戶對文件系統有完全自由的控制權。

MAC是任何進程想在SELinux系統中干任何事情,都必須先在安全策略配置文件中賦予許可權。

凡是沒有出現在安全策略配置文件中的許可權,進程就沒有該許可權。

這個機制相當於一個白名單,這個白名單上配置了所有進程的許可權,進程只能做白名單上許可權內的事情,一旦它想做一個不屬於它許可權的操作就會被拒絕。

這就需要使用到配置文件和其對應的te語法。

語法解析:

指定一個「域」(domain),一般用於描述進程,該域內的的進程,受該條TE語句的限制。

用 type 關鍵字,把一個自定義的域與原有的域相關聯,最簡單地定義一個新域的方式為:

意思為賦予shell給domain屬性,同時,shell與屬於domain這個集合里。

例如:有一個allow domain xxxxx 的語句,同樣地也給了shell xxxxx的屬性。

進程需要操作的客體(文件,文件夾等)類型(安全上下文),同樣是用type與一些已有的類型,屬性相關聯。

type有兩個作用,定義(聲明)並關聯某個屬性。

可以把這兩個作用分開,type定義,typeattribute進行關聯。

class定義在文件 system/sepolicy/private/security_classes 中.

定義在 system/sepolicy/private/access_vectors 。有兩種定義方法。

SELinux中,每種東西都會被賦予一個安全屬性,它就是SecurityContext(Security Context以下簡稱SContext,安全上下文或安全屬性)是一個字元串,主要由三部分組成。

例如在 SELinux for Android中,進程的SContext可以通過PS-Z命令查看,如下:

其中:

1. kernel/msm-3.18/security/selinux/
2. external/selinux/
3. 用BOARD_SEPOLICY_DIRS添加的各te文件和安全配置文件,主要包括device/<oem_name>/sepolicy/<proct_name>/和system/sepolicy/,以及其他功能模塊添加的配置文件。

一文徹底明白linux中的selinux到底是什麼
SELinux之一:SELinux基本概念及基本配置
Android selinux配置和用法
詳解 SEAndroid 以及 Hack 其規則(sepolicy)
SELinux/SEAndroid 實例簡述(二) TE語言規則

『拾』 android 中linux 命令pm常見用法(安裝卸載app)

27種用法格式 :

用法說明

1、 pm list packages : prints all packages, optionally only those whose package name contains the text in FILTER. Options:

例子:列出系統中所有packages

2、 pm list permission-groups : prints all known permission groups.

例子:

3、 pm list permissions : prints all known permissions, optionally only those in GROUP. Options:

例子:列出系統所有許可

4、 pm list instrumentation : use to list all test packages; optionally supply to list the test packages for a particular application. Options:

-f: list the .apk file for the test package.

5、 pm list features : prints all features of the system.

例子:列出所有手機特性

6、 pm list users : prints all users on the system.

例子:

7、 pm path : print the path to the .apk of the given PACKAGE.

例子:按包名查找apk文件所在路徑

8、 pm mp : print system state associated with the given PACKAGE.

9、 pm install : installs a package to the system. Options:

例子:

10、 pm uninstall : removes a package from the system. Options:

-k: keep the data and cache directories around after package removal. 保留數據

例子:

11、 pm clear : deletes all data associated with a package..

例子:只刪除數據

12、 pm enable, disable, disable-user, disable-until-used : these commands change the enabled state of a given package or component (written as "package/class").

13、 pm grant, revoke : these commands either grant or revoke permissions to applications. Only optional permissions the application has declared can be granted or revoked.

14、 pm get-install-location : returns the current install location.

15、 pm set-install-location : changes the default install location.

NOTE: this is only intended for debugging; using this can cause applications to break and other undersireable behavior.

16、 pm trim-caches : trim cache files to reach the given free space.

17、 pm create-user : create a new user with the given USER_NAME, printing the new user identifier of the user. 創建新用戶

18、 pm remove-user : remove the user with the given USER_IDENTIFIER, deleting all data associated with that user 。 按用戶ID刪除用戶

熱點內容
筆記本電腦一般存儲空間 發布:2025-02-08 23:51:15 瀏覽:835
php網站優化 發布:2025-02-08 23:49:41 瀏覽:455
php網頁列印 發布:2025-02-08 23:40:02 瀏覽:820
windowssmb無法訪問 發布:2025-02-08 23:33:28 瀏覽:467
python27編譯器 發布:2025-02-08 23:29:20 瀏覽:339
如何運行python代碼 發布:2025-02-08 23:28:15 瀏覽:692
新箱子密碼鎖怎麼設置 發布:2025-02-08 23:26:50 瀏覽:148
安卓如何可以看見被撤回的消息 發布:2025-02-08 23:19:17 瀏覽:798
火影忍者競技場腳本 發布:2025-02-08 23:10:18 瀏覽:935
英國訪問學者簽證費用 發布:2025-02-08 23:04:46 瀏覽:927