This article was reproduced from: http://blog.csdn.net/u011258134/article/details/50749174
How to let a20,android boot automatically start C program2014-12-26 11:32 557 people read comments (3) favorite reports Classification:C language Learning (Ten)Author of similar articlesX
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Xinit added: xinit/usr/local/bin/xfreerdp 192.168.1.196
1, modify Android/device/init.sun7i.rc
........ Slightly
#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
........ Slightly
2, in device/softwinner/sugar-cubieboard2/new dou.sh file, content:
#! /system/bin/sh
#hello是C编译的文件, is statically compiled, and placed in system/bin/
/system/bin/hello
#or
Hello
echo "Jiangdou"
Exit
3,vi DEVICE/SOFTWINNER/SUGAR-CUBIEBOARD2/SUGAR_CUBIEBOARD2.MK//purpose is to perform make-j48 copy to out/target/product/ sugar-cubieboard2/system/bin/
........ Slightly
#add by Jiangdou
Product_copy_files + = \
Device/softwinner/sugar-cubieboard2/hello:system/bin/hello \
device/softwinner/sugar-cubieboard2/dou.sh:system/bin/dou.sh
........ Slightly
4, boot,, effect
[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]:/#
Prove that the boot is running automatically.
5, C code content,,,, compiled $ arm-linux-androideabi-gcc-o Hello hello.c-static
[HTML] View plainCopy
- #include<stdio.h>
- #include <signal.h>
- int main (void)
- {
- int i;
- Signal (SIGCHLD, sig_ign);
- Daemon (0, 0);//fork Force background Run! Daemon See the following article
- for (i = 0; I < ; i++)
- while (1)
- {
- Sleep (1);
- printf ("Hello......by jiangdou\n");
- }
- return 0;
- }
[HTML]View PlainCopy
- #include<stdio.h>
- #include <signal.h>
- int main (void)
- {
- int i;
- Signal (SIGCHLD, sig_ign);
- Daemon (0, 0);//fork Force background Run!
- for (i = 0; I < ; 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
Original posts: http://blog.csdn.net/jiangdou88/article/details/42169263#comments
How to let a20,android boot automatically start C program "Go"