不是裸机程序,是光盘里面的资料,源码如led.c下:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.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 < 0 || led_no > 3) {
fprintf(stderr, "Usage: leds led_no 0|1\n");
exit(1);
}
fd = open("/dev/leds", 0);
// if (fd < 0) {
// fd = open("/dev/leds", 0);
// }
// if (fd < 0) {
// perror("open device leds");
// exit(1);
// }
ioctl(fd, on, led_no);
close(fd);
return 0;
}
Makefile的源码:
# ----------------------------------------------------------------------------
# Makefile for building tapp
#
# Copyright 2010 FriendlyARM (
http://www.arm9.net/)
#
ifndef DESTDIR
DESTDIR ?= /tmp/FriendlyARM/mini6410/rootfs
endif
CFLAGS = -Wall -O2
CC = arm-linux-gcc
INSTALL = install
TARGET = led
all: $(TARGET)
led: led.c
$(CC) $(CFLAGS) $< -o $@
install: $(TARGET)
$(INSTALL) $^ $(DESTDIR)/usr/bin
clean distclean:
rm -rf *.o $(TARGET)
# ----------------------------------------------------------------------------
.PHONY: $(PHONY) install clean distclean
# End of file
# vim: syntax=make
我make之后得到的led可执行文件放到开发板不能用./led执行,报错就如/system/bin/sh:./led not found
谢谢版主热心回答