如何让A20,android开机自动启动C程序
本帖最后由 jiangdou 于 2014-12-26 11:38 编辑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"
exit3,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,开机,,效果,,运行了两个hello
root@android:/ # ps | busybox grep hello
root 14091 652 108 c006bf0c 0001090c S /system/bin/hello
root 14111 652 108 c006bf0c 0001090c S hello
root@android:/ #
证明开机自动运行了
5, C代码内容,,,,编译$arm-linux-androideabi-gcc -ohello hello.c-static#include<stdio.h>
#include <signal.h>
int main(void)
{
int i;
signal(SIGCHLD, SIG_IGN);
daemon(0, 0);//fork 强制后台运行!
// for(i = 0; i < 10; i++)
while(1)
{
sleep(1);
printf("hello......by jiangdou\n");
}
return 0;
}
Mark给力
sunbeyond 发表于 2014-12-29 09:09 static/image/common/back.gif
Mark给力
:):):):):):):):):):):):):):)
页:
[1]