编写最简单的应用程序
#include <stdio.h>
void main(int argc, char *argv[])
{
int i = 0,j = 0;
for(i=0;i<10;i++)
{
printf("hello world..............\r\n");
for(j=0;j<100000;j++)
{};
}
}
然后编译
arm-linux-gcc -o tst tst.c -static
生成tst文件,拷贝到PC端的adb文件夹下
然后打开adb,连接上安卓开发板
使用命令
adb push tst /system/
会将tst文件传到linux内核系统的system文件夹下,如果出现
failed to copy 'tst' to '/system/' : Read-only file system
先退出adb,再remount,即
adb remount
看到remount succeeded后
再执行adb push tst /system/即可成功
通过串口打印窗口进入内核的system文件夹下,可以看到tst文件,chmod 777 tst修改权限
然后运行./tst
即可看到打印
hello world..............
hello world..............
hello world..............
hello world..............
hello world..............
hello world..............
hello world..............
hello world..............
hello world..............
hello world..............