<div class='quotetop'>QUOTE (hippo @ Aug 26 2009, 10:17 PM) <{post_snapback}> (index.php?act=findpost&pid=23617)</div>
--- Quote Start ---
Please check the mmap call in your code. This is what used in microwin scr_fb.c,
psd->addr = mmap(NULL, psd->size, PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FILE,fb,0);
- Hippo[/b]
--- Quote End ---
My code:
int open_fb(void)
{
fb_fp = open("/dev/fb0", O_RDWR);
if(fb_fp <= 0)
{
printf("cannot open /dev/fb0\n");
return -1;
}
return fb_fp;
}
int set_fb(void)
{
//usleep(100000); // Wait 100 ms
printf("%s Start: %d \n", __FUNCTION__, __LINE__);
//usleep(10000); // Wait 10 ms
struct fb_var_screeninfo fb_var;
struct fb_fix_screeninfo fb_fix;
if(ioctl(fb_fp, FBIOGET_FSCREENINFO, &fb_fix) == -1 ||
ioctl(fb_fp, FBIOGET_VSCREENINFO, &fb_var) == -1) {
printf("%s fbcon engine: Error when reading screen info: %d.\n", __FUNCTION__, __LINE__);
return -1;
}
usleep(100000); // Wait 100 ms
printf("%s Continue: %d \n", __FUNCTION__, __LINE__);
usleep(100000); // Wait 100 ms
color_bits = (fb_var.bits_per_pixel+ 7)/ 8;
screen_width = fb_var.xres;
screen_height = fb_var.yres;
// frame_base = mmap(0, fb_var.xres * fb_var.yres* fb_var.bits_per_pixel/ 8, PROT_READ|PROT_WRITE, MAP_PRIVATE, fb_fp, 0);
frame_base = mmap(NULL, fb_var.xres * fb_var.yres* color_bits, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FILE, fb_fp, 0);
if(MAP_FAILED == frame_base)
{
printf("Error mmap frame buffer.\n");
return -1;
}
return 0;
}
void close_fb(void)
{
munmap(frame_base, screen_width* screen_height* color_bits);
close(fb_fp);
}
void TestMyGUI(void)
{
int i;
for(i=0; i<10; i++)
{
if(open_fb() > 0)
{
set_fb();
usleep(10000);
close_fb();
}
else break;
}
printf("%s InitMyGUI OK %d. \n", __FUNCTION__, __LINE__);
for(i=0; i<10; i++)
{
if(open_fb() > 0)
{
set_fb();
// SetGUIBackColor((i*8)%256, (i*10)%256, (i*12)%256);
// GUIFillRect(0, 0, screen_width-1, screen_height-1);
// GUIFillRect(10, 10, 100, 100);
*(((int *)frame_base)+ 16101) = (((i*8)%256)<<16) | (((i*10)%256) <<8) | ((i*12)%256);
usleep(10000);
close_fb();
}
else break;
}
printf("%s TestMyGUI OK %d. \n", __FUNCTION__, __LINE__);
}
The first times is OK. But twice or more times error:
set_fb Start: 64
set_fb Continue: 81
set_fb Start: 64
set_fb Continue: 81
TestMyGUI TestMyGUI OK 153.
/> mygui
set_fb Start: 64
set_fb Continue: 81
BUG: failure at /home/nios2-linux/linux-2.6/mm/nommu.c:530/add_nommu_region()!
Kernel panic - not syncing: BUG!