如何讓A20,android開機自動啟動C程式【轉】

來源:互聯網
上載者:User

標籤:targe   收藏   運行   lin   man   int   data   增加   csdn   

本文轉載自:http://blog.csdn.net/u011258134/article/details/50749174

如何讓A20,android開機自動啟動C程式2014-12-26 11:32 557人閱讀 評論(3)收藏 舉報 分類:C語言學習(10) 作者同類文章X

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

///  xinit  增加:  xinit    /usr/local/bin/xfreerdp  192.168.1.196

 

 

1,修改 android/device/    init.sun7i.rc

 

........(略)

#add by jiangdou
    chmod 777 /system/bin/hello
    chmod 777 /system/bin/dou.sh
service init-setup /system/bin/dou.sh
    class main
    user root
    group root
    oneshot

........(略)

 

2,在device/softwinner/sugar-cubieboard2/建立dou.sh  檔案,內容:

#! /system/bin/sh

#hello是C編譯的檔案,是靜態編譯,,放在system/bin/
/system/bin/hello     

#or

hello

echo "jiangdou"

exit

 

3,vi device/softwinner/sugar-cubieboard2/sugar_cubieboard2.mk   ///目的是執行make -j48  複製到out/target/product/sugar-cubieboard2/system/bin/

 

........(略)

#add by jiangdou 
PRODUCT_COPY_FILES += \
        device/softwinner/sugar-cubieboard2/hello:system/bin/hello \
        device/softwinner/sugar-cubieboard2/dou.sh:system/bin/dou.sh

........(略)

 

 

4,開機,,效果

[email protected]:/ # ps | busybox grep hello
root      1409  1     652    108   c006bf0c 0001090c S /system/bin/hello
root      1411  1     652    108   c006bf0c 0001090c S hello
[email protected]:/ # 

 

證明開機自動運行了

 

 

5, C代碼內容,,,,編譯$  arm-linux-androideabi-gcc -o  hello hello.c  -static

 

[html] view plain copy  
  1. #include<stdio.h>  
  2. #include <signal.h>  
  3. int main(void)  
  4. {  
  5.   
  6.    int i;  
  7.     signal(SIGCHLD, SIG_IGN);  
  8.   
  9.     daemon(0, 0);//fork 強制後台運行!    daemon祥見下面的文章
  10.    // for(i = 0; i < 10; i++)  
  11.    while(1)  
  12.     {  
  13.      sleep(1);  
  14.      printf("hello......by jiangdou\n");  
  15.     }  
  16.  return 0;  
  17. }  
[html] view plain copy 
  1. #include<stdio.h>  
  2. #include <signal.h>  
  3. int main(void)  
  4. {  
  5.   
  6.    int i;  
  7.     signal(SIGCHLD, SIG_IGN);  
  8.   
  9.     daemon(0, 0);//fork 強制後台運行!  
  10.    // for(i = 0; i < 10; i++)  
  11.    while(1)  
  12.     {  
  13.      sleep(1);  
  14.      printf("hello......by jiangdou\n");  
  15.     }  
  16.  return 0;  
  17. }  


 

 


adb  push xxx   /system  ---->ERROR    "Readonly-----file   system"  

 

adb  shell   && mount -o remount -o rw /system

 

原帖:http://blog.csdn.net/jiangdou88/article/details/42169263#comments

如何讓A20,android開機自動啟動C程式【轉】

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.