www.久久久久|狼友网站av天堂|精品国产无码a片|一级av色欲av|91在线播放视频|亚洲无码主播在线|国产精品草久在线|明星AV网站在线|污污内射久久一区|婷婷综合视频网站

當(dāng)前位置:首頁(yè) > 公眾號(hào)精選 > 嵌入式云IOT技術(shù)圈
[導(dǎo)讀]Android系統(tǒng)里以*.rc為擴(kuò)展名為系統(tǒng)初始化腳本,腳本里就是使用安卓初始化語(yǔ)言。語(yǔ)句都是一行為一條語(yǔ)句,沒(méi)有符號(hào)分隔. 語(yǔ)句里的每個(gè)詞用空格隔開(kāi)。

微信公眾號(hào):楊源鑫
如果你覺(jué)得文章對(duì)你有幫助,歡迎在評(píng)論區(qū)交流討論

參考: android源碼目錄里的system/core/init/readme.txt.


Android系統(tǒng)里以*.rc為擴(kuò)展名為系統(tǒng)初始化腳本,腳本里就是使用安卓初始化語(yǔ)言.


語(yǔ)句都是一行為一條語(yǔ)句,沒(méi)有符號(hào)分隔. 語(yǔ)句里的每個(gè)詞用空格隔開(kāi).?

如: service ueventd /sbin/ueventd


備注語(yǔ)句以符號(hào)”#”作為注釋.


語(yǔ)言基本上分為4個(gè)塊: Actions Commands Services 和 Options.


每個(gè)Actions和Services關(guān)鍵詞開(kāi)始的語(yǔ)句作為一個(gè)新的區(qū)塊.?

Commands和Options就是屬于就近的Actions或Services塊.?

如:?

Actions的形式:

1on?<trigger>
2???<command>
3???<command>
4???<command>

Services的形式:

1service?<name>?<pathname>?[?<argument>?]*
2???<option>
3???<option>

rc文件里實(shí)例:

 1service?logd?/system/bin/logd
2????class?core
3????socket?logd?stream?0666?logd?logd
4????socket?logdr?seqpacket?0666?logd?logd
5????socket?logdw?dgram?0222?logd?logd
6????group?root?system
7?????writepid?/dev/cpuset/system-background/tasks
8
9service?healthd?/sbin/healthd
10????class?core
11????critical
12????seclabel?u:r:healthd:s0
13
14#?Actions
15#?on???????
16on?property:sys.powerctl=*
17????powerctl?${sys.powerctl}
18
19on?early-init
20????#?Set?init?and?its?forked?children's?oom_adj.
21????write?/proc/1/oom_score_adj?-1000
22????#?Set?the?security?context?of?/adb_keys?if?present.
23????restorecon?/adb_keys
24????start?ueventd

每個(gè)rc文件里又可以包含其它rc文件:

1import?/init.environ.rc
2import?/init.usb.rc
3import?/init.${ro.hardware}.rc
4import?/init.usb.configfs.rc
5import?/init.${ro.zygote}.rc
6import?/init.trace.rc

Actions里常用的trigger有:

 1on?early-init
2????
3
4on?init
5????
6
7on?late-init
8????
9
10on?post-fs
11???
12
13on?boot
14???
15
16on?property:sys.init_log_level=*??//在設(shè)置屬性值時(shí)觸發(fā)
17???
18
19on?charger
20???
21
22on?property:sys.powerctl=*
23???

常用的Commands有:?
//參考system/core/init/keywords.h

 1bootchart_init
2???Start?bootcharting?if?configured?(see?below).
3???This?is?included?in?the?default?init.rc.
4
5chmod?mode>?<path>
6???Change?file?access?permissions.
7
8chown??<group>?<path>
9???Change?file?owner?and?group.
10
11class_start?
12???Start?all?services?of?the?specified?class?if?they?are
13???not?already?running.
14
15class_stop?
16???Stop?and?disable?all?services?of?the?specified?class?if?they?are
17???currently?running.
18
19class_reset?
20???Stop?all?services?of?the?specified?class?if?they?are
21???currently?running,?without?disabling?them.?They?can?be?restarted
22???later?using?class_start.
23
24copy??
25???Copies?a?file.?Similar?to?write,?but?useful?for?binary/large
26???amounts?of?data.
27
28domainname?<name>
29???Set?the?domain?name.
30
31enable?
32???Turns?a?disabled?service?into?an?enabled?one?as?if?the?service?did?not
33???specify?disabled.
34???If?the?service?is?supposed?to?be?running,?it?will?be?started?now.
35???Typically?used?when?the?bootloader?sets?a?variable?that?indicates?a?specific
36???service?should?be?started?when?needed.?E.g.
37?????on?property:ro.boot.myfancyhardware=1
38????????enable?my_fancy_service_for_my_fancy_hardware
39
40exec?[??[?<user>?[?<group>?]*?]?]?--??[??]*
41???Fork?and?execute?command?with?the?given?arguments.?The?command?starts
42???after?"--"?so?that?an?optional?security?context,?user,?and?supplementary
43???groups?can?be?provided.?No?other?commands?will?be?run?until?this?one
44???finishes.??can?be?a?-?to?denote?default.
45
46export?<name>?<value>
47???Set?the?environment?variable?<name>?equal?to?<value>?in?the
48???global?environment?(which?will?be?inherited?by?all?processes
49???started?after?this?command?is?executed)
50
51hostname?<name>
52???Set?the?host?name.
53
54ifup?<interface>
55???Bring?the?network?interface?<interface>?online.
56
57import?
58???Parse?an?init?config?file,?extending?the?current?configuration.
59
60insmod?<path>
61???Install?the?module?at?<path>
62
63load_all_props
64???Loads?properties?from?/system,?/vendor,?et?cetera.
65???This?is?included?in?the?default?init.rc.
66
67load_persist_props
68???Loads?persistent?properties?when?/data?has?been?decrypted.
69???This?is?included?in?the?default?init.rc.
70
71loglevel?<level>
72???Sets?the?kernel?log?level?to?level.?Properties?are?expanded?within?<level>.
73
74mkdir?<path>?[mode]?[owner]?[group]
75???Create?a?directory?at?<path>,?optionally?with?the?given?mode,?owner,?and
76???group.?If?not?provided,?the?directory?is?created?with?permissions?755?and
77???owned?by?the?root?user?and?root?group.?If?provided,?the?mode,?owner?and?group
78???will?be?updated?if?the?directory?exists?already.
79
80mount_all?
81???Calls?fs_mgr_mount_all?on?the?given?fs_mgr-format?fstab.
82
83mount?<type>??
?[??]*?[]
84???Attempt?to?mount?the?named?device?at?the?directory?

85????may?be?of?the?form?mtd@name?to?specify?a?mtd?block
86???device?by?name.
87???s?include?"ro",?"rw",?"remount",?"noatime",?...
88????include?"barrier=1",?"noauto_da_alloc",?"discard",?...?as
89???a?comma?separated?string,?eg:?barrier=1,noauto_da_alloc
90
91powerctl
92???Internal?implementation?detail?used?to?respond?to?changes?to?the
93???"sys.powerctl"?system?property,?used?to?implement?rebooting.
94
95restart?
96???Like?stop,?but?doesn't?disable?the?service.
97
98restorecon??[??]*
99???Restore?the?file?named?by??to?the?security?context?specified
100???in?the?file_contexts?configuration.
101???Not?required?for?directories?created?by?the?init.rc?as?these?are
102???automatically?labeled?correctly?by?init.
103
104restorecon_recursive??[??]*
105???Recursively?restore?the?directory?tree?named?by??to?the
106???security?contexts?specified?in?the?file_contexts?configuration.
107
108rm?
109???Calls?unlink(2)?on?the?given?path.?You?might?want?to
110???use?"exec?--?rm?..."?instead?(provided?the?system?partition?is
111???already?mounted).
112
113rmdir?
114???Calls?rmdir(2)?on?the?given?path.
115
116setprop??
117???Set?system?property??to?.?Properties?are?expanded
118???within?.
119
120setrlimit???
121???Set?the?rlimit?for?a?resource.
122
123start?
124???Start?a?service?running?if?it?is?not?already?running.
125
126stop?
127???Stop?a?service?from?running?if?it?is?currently?running.
128
129swapon_all?
130???Calls?fs_mgr_swapon_all?on?the?given?fstab?file.
131
132symlink??
133???Create?a?symbolic?link?at??with?the?value?
134
135sysclktz?
136???Set?the?system?clock?base?(0?if?system?clock?ticks?in?GMT)
137
138trigger?
139???Trigger?an?event.??Used?to?queue?an?action?from?another
140???action.
141
142verity_load_state
143???Internal?implementation?detail?used?to?load?dm-verity?state.
144
145verity_update_state?
146???Internal?implementation?detail?used?to?update?dm-verity?state?and
147???set?the?partition..verified?properties?used?by?adb?remount
148???because?fs_mgr?can'
t?set?them?directly?itself.
149
150wait?<path>?[?<timeout>?]
151???Poll?for?the?existence?of?the?given?file?and?return?when?found,
152???or?the?timeout?has?been?reached.?If?timeout?is?not?specified?it
153???currently?defaults?to?five?seconds.
154
155write?<path>?<content>
156???Open?the?file?at?<path>?and?write?a?string?to?it?with?write(2).
157???If?the?file?does?not?exist,?it?will?be?created.?If?it?does?exist,
158???it?will?be?truncated.?Properties?are?expanded?within?<content>.

Services里常用的options有:

 1critical
2??This?is?a?device-critical?service.?If?it?exits?more?than?four?times?in
3??four?minutes,?the?device?will?reboot?into?recovery?mode.
4
5disabled
6??This?service?will?not?automatically?start?with?its?class.
7??It?must?be?explicitly?started?by?name.
8
9setenv??
10??Set?the?environment?variable??to??in?the?launched?process.
11
12socket????[??[?<group>?[??]?]?]
13??Create?a?unix?domain?socket?named?/dev/socket/?and?pass
14??its?fd?to?the?launched?process.???must?be?"dgram",?"stream"?or?"seqpacket".
15??User?and?group?default?to?0.
16??'seclabel'?is?the?SELinux?security?context?for?the?socket.
17??It?defaults?to?the?service?security?context,?as?specified?by?seclabel?or
18??computed?based?on?the?service?executable?file?security?context.
19
20user?
21??Change?to?username?before?exec'ing?this?service.
22??Currently?defaults?to?root.??(????probably?should?default?to?nobody)
23??Currently,?if?your?process?requires?linux?capabilities?then?you?cannot?use
24??this?command.?You?must?instead?request?the?capabilities?in-process?while
25??still?root,?and?then?drop?to?your?desired?uid.
26
27group??[??]*
28??Change?to?groupname?before?exec'ing?this?service.??Additional
29??groupnames?beyond?the?(required)?first?one?are?used?to?set?the
30??supplemental?groups?of?the?process?(via?setgroups()).
31??Currently?defaults?to?root.??(????probably?should?default?to?nobody)
32
33seclabel?
34??Change?to?'seclabel'?before?exec'ing?this?service.
35??Primarily?for?use?by?services?run?from?the?rootfs,?e.g.?ueventd,?adbd.
36??Services?on?the?system?partition?can?instead?use?policy-defined?transitions
37??based?on?their?file?security?context.
38??If?not?specified?and?no?transition?is?defined?in?policy,?defaults?to?the?init?context.
39
40oneshot
41??Do?not?restart?the?service?when?it?exits.
42
43class?
44??Specify?a?class?name?for?the?service.??All?services?in?a
45??named?class?may?be?started?or?stopped?together.??A?service
46??is?in?the?class?"default"?if?one?is?not?specified?via?the
47??class?option.
48
49onrestart
50??Execute?a?Command?(see?below)?when?service?restarts.
51
52writepid?
53??Write?the?child's?pid?to?the?given?files?when?it?forks.?Meant?for
54??cgroup/cpuset?usage.

實(shí)現(xiàn)直接使用root用戶進(jìn)入終端, 修改android/out/target/product/tulip-p1/root/init.rc :

1service?console?/system/bin/sh
2?????class?core
3?????console
4?????disabled
5?#????user?shell
6?#????group?shell?log
7?#????seclabel?u:r:shell:s0

//備注使用shell用戶進(jìn)入終端. 會(huì)默認(rèn)使用root用戶操作

實(shí)現(xiàn)系統(tǒng)進(jìn)入后執(zhí)行自定義的腳本 :?
修改android/out/target/product/tulip-p1/root/init.rc , 增加內(nèi)容:

1service?start_mytest?/system/bin/mytest.sh????
2????oneshot
3????on?property:sys.boot_completed=1
4????start?start_mytest

在android/out/target/product/tulip-p1/system/bin目錄下,增加mytest.sh, 內(nèi)容:

1#!/system/bin/sh
2

3echo?"mytest?...!"?>?/dev/ttyS0
4echo?"mytest?...!"?>?/dev/ttyS0
5echo?"mytest?...!"?>?/dev/ttyS0
6echo?"mytest?...!"?>?/dev/ttyS0
7echo?"mytest?...!"?>?/dev/ttyS0
8echo?"mytest?...!"?>?/dev/ttyS0
9echo?"mytest?...!"?>?/dev/ttyS0


免責(zé)聲明:本文內(nèi)容由21ic獲得授權(quán)后發(fā)布,版權(quán)歸原作者所有,本平臺(tái)僅提供信息存儲(chǔ)服務(wù)。文章僅代表作者個(gè)人觀點(diǎn),不代表本平臺(tái)立場(chǎng),如有問(wèn)題,請(qǐng)聯(lián)系我們,謝謝!

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除。
換一批
延伸閱讀

9月2日消息,不造車的華為或?qū)⒋呱龈蟮莫?dú)角獸公司,隨著阿維塔和賽力斯的入局,華為引望愈發(fā)顯得引人矚目。

關(guān)鍵字: 阿維塔 塞力斯 華為

倫敦2024年8月29日 /美通社/ -- 英國(guó)汽車技術(shù)公司SODA.Auto推出其旗艦產(chǎn)品SODA V,這是全球首款涵蓋汽車工程師從創(chuàng)意到認(rèn)證的所有需求的工具,可用于創(chuàng)建軟件定義汽車。 SODA V工具的開(kāi)發(fā)耗時(shí)1.5...

關(guān)鍵字: 汽車 人工智能 智能驅(qū)動(dòng) BSP

北京2024年8月28日 /美通社/ -- 越來(lái)越多用戶希望企業(yè)業(yè)務(wù)能7×24不間斷運(yùn)行,同時(shí)企業(yè)卻面臨越來(lái)越多業(yè)務(wù)中斷的風(fēng)險(xiǎn),如企業(yè)系統(tǒng)復(fù)雜性的增加,頻繁的功能更新和發(fā)布等。如何確保業(yè)務(wù)連續(xù)性,提升韌性,成...

關(guān)鍵字: 亞馬遜 解密 控制平面 BSP

8月30日消息,據(jù)媒體報(bào)道,騰訊和網(wǎng)易近期正在縮減他們對(duì)日本游戲市場(chǎng)的投資。

關(guān)鍵字: 騰訊 編碼器 CPU

8月28日消息,今天上午,2024中國(guó)國(guó)際大數(shù)據(jù)產(chǎn)業(yè)博覽會(huì)開(kāi)幕式在貴陽(yáng)舉行,華為董事、質(zhì)量流程IT總裁陶景文發(fā)表了演講。

關(guān)鍵字: 華為 12nm EDA 半導(dǎo)體

8月28日消息,在2024中國(guó)國(guó)際大數(shù)據(jù)產(chǎn)業(yè)博覽會(huì)上,華為常務(wù)董事、華為云CEO張平安發(fā)表演講稱,數(shù)字世界的話語(yǔ)權(quán)最終是由生態(tài)的繁榮決定的。

關(guān)鍵字: 華為 12nm 手機(jī) 衛(wèi)星通信

要點(diǎn): 有效應(yīng)對(duì)環(huán)境變化,經(jīng)營(yíng)業(yè)績(jī)穩(wěn)中有升 落實(shí)提質(zhì)增效舉措,毛利潤(rùn)率延續(xù)升勢(shì) 戰(zhàn)略布局成效顯著,戰(zhàn)新業(yè)務(wù)引領(lǐng)增長(zhǎng) 以科技創(chuàng)新為引領(lǐng),提升企業(yè)核心競(jìng)爭(zhēng)力 堅(jiān)持高質(zhì)量發(fā)展策略,塑強(qiáng)核心競(jìng)爭(zhēng)優(yōu)勢(shì)...

關(guān)鍵字: 通信 BSP 電信運(yùn)營(yíng)商 數(shù)字經(jīng)濟(jì)

北京2024年8月27日 /美通社/ -- 8月21日,由中央廣播電視總臺(tái)與中國(guó)電影電視技術(shù)學(xué)會(huì)聯(lián)合牽頭組建的NVI技術(shù)創(chuàng)新聯(lián)盟在BIRTV2024超高清全產(chǎn)業(yè)鏈發(fā)展研討會(huì)上宣布正式成立。 活動(dòng)現(xiàn)場(chǎng) NVI技術(shù)創(chuàng)新聯(lián)...

關(guān)鍵字: VI 傳輸協(xié)議 音頻 BSP

北京2024年8月27日 /美通社/ -- 在8月23日舉辦的2024年長(zhǎng)三角生態(tài)綠色一體化發(fā)展示范區(qū)聯(lián)合招商會(huì)上,軟通動(dòng)力信息技術(shù)(集團(tuán))股份有限公司(以下簡(jiǎn)稱"軟通動(dòng)力")與長(zhǎng)三角投資(上海)有限...

關(guān)鍵字: BSP 信息技術(shù)
關(guān)閉
關(guān)閉