本人新手要做一个6410开发板上的LCD开机图片,用的是U-BOOT做的文件系统,写啦个开机图片C程序的代码,但是在板子上运行屏幕黑屏,编译用的ARM-LINUX-GCC,图片是自己用图片编辑器编辑好的480*272的图片,程序如下看看到底那里的问题
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <string.h>
int main(void)
{
unsigned int *v;
int fd;
int pic;
unsigned int *p;
fd = open("/dev/fb0", O_RDWR);
if(fd < 0){
perror("open /dev/fb0");
exit(1);
}
v = mmap(0, 480 * 272 * 4, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if(v == MAP_FAILED){
perror("mmap /dev/fb0");
exit(1);
}
pic = open("/desk.ini", O_RDONLY);
if(pic < 0){
perror("open /desk.ini");
exit(1);
}
p = mmap(0, 480 * 272* 4, PROT_READ, MAP_SHARED, pic, 0);
if(p == MAP_FAILED){
perror("mmap /desk.ini");
exit(1);
}
memcpy(v, p, 480 * 272 * 4);
munmap(p, 480 * 272 * 4);
munmap(v, 480 * 272 * 4);
close(pic);
close(fd);
return 0;
} |