TQ-lkp 发表于 2013-1-18 08:49
1编绎器是否正确
2代码是否有bug,最简单的调试方法,打印输出
为了排除其他情况,我烧写了TQ提供的2.6.30.4的内核和文件系统,然后把开机启动的中开启流水等的命令屏蔽了,具体是这样#/etc/rc.d/init.d/leds start。 接着重启板子,讲开机流水灯取消。
接着编译 TQ的控制led代码,如下
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
int main(int argc, char **argv)
{
int on;
int led_no;
int fd;
if (argc != 3 || sscanf(argv[1], "%d", &led_no) != 1 || sscanf(argv[2],"%d", &on) != 1 ||
on < 0 || on > 1 || led_no < 1 || led_no > 4) {
fprintf(stderr, "Usage: leds led_no 0|1\n");
exit(1);
}
fd = open("/dev/GPIO-Control", 0);
if (fd < 0) {
perror("open device leds");
exit(1);
}
ioctl(fd, on, (led_no-1));
close(fd);
return 0;
}
Makefile文件也未做修改,
CROSS=arm-linux-
all: leds
leds:leds.c
$(CROSS)gcc -o leds leds.c
$(CROSS)strip leds
clean:
@rm -vf leds *.o *~
使用的是4.3.3的交叉编译器,编译情况如下:
arm-linux-gcc -o leds leds.c
arm-linux-strip leds
编译成功,讲生成的执行文件,扔到板子中去执行,执行情况如下:
[root@EmbedSky /mnt]# ls
leds
[root@EmbedSky /mnt]# chmod 777 leds
[root@EmbedSky /mnt]# ls
leds
[root@EmbedSky /mnt]# ./leds
Segmentation fault
如果是用TQ提供apps中已经编译好的leds,执行情况如下
[root@EmbedSky test]# ./leds
Usage: leds led_no 0|1
使用文件系统中自带的,执行如下:
[root@EmbedSky init.d]# ./leds
[root@EmbedSky init.d]#
没有指示信息,
请问这是怎么回事啊,急急急
|