android开机启动c程序,如何让A20,android开机自动启动C程序【转】

///  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,开机,,效果

root@android:/ # ps | busybox grep hello

root      1409  1     652    108   c006bf0c 0001090c S /system/bin/hello

root      1411  1     652    108   c006bf0c 0001090c S hello

root@android:/ #

证明开机自动运行了

5, C代码内容,,,,编译$  arm-linux-androideabi-gcc -o  hello hello.c  -static

#include

#include 

int main(void)

{

int i;

signal(SIGCHLD, SIG_IGN);

daemon(0, 0);//fork 强制后台运行!    daemon祥见下面的文章

// for(i = 0; i 

while(1)

{

sleep(1);

printf("hello......by jiangdou\n");

}

return 0;

}

#include

#include 

int main(void)

{

int i;

signal(SIGCHLD, SIG_IGN);

daemon(0, 0);//fork 强制后台运行!

// for(i = 0; i 

while(1)

{

sleep(1);

printf("hello......by jiangdou\n");

}

return 0;

}

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值