Forum Discussion
Altera_Forum
Honored Contributor
16 years agono mmu problem
I builde the zImage on uClinux use the web_server sopc hardware project on the NEEK board.
I have selected the frame buffer driver, the jpegview application and mygui application. Use the jpegview or mygui application once is OK. But twice or more times is failure. The application hint "nommu bug" error. My result: ..... /bin> mygui r Use: mygui R G B (digital) display one color and auto exit. mygui R/G/B/Y (word) display 256 color(R/G/B/Gray) and auto exit. mygui R G B display gray color, Red color, Green color and Blue color once. 800 480 800 480 0 0 32 0 -1 -1 framebase = 0x80a00000 err=0 /bin> mygui g Use: mygui R G B (digital) display one color and auto exit. mygui R/G/B/Y (word) display 256 color(R/G/B/Gray) and auto exit. mygui R G B display gray color, Red color, Green color and Blue color once. 800 480 800 480 0 0 32 0 -1 -1 framebase = 0x80a00000 err=0 /bin> mygui b Use: mBUG: failure at /home/nios2-linux/linux-2.6/mm/nommu.c:530/add_nommu_region()! Kernel panic - not syncing: BUG! ygui R G B (digital) display one color and auto exit. mygui R/G/B/Y (word) display 256 color(R/G/B/Gray) and auto exit. mygui R G B display gray color, Red color, Green color and Blue color once. 800 480 800 480 0 0 32 0 -1 -1 Here the system stop. The error information: mBUG: failure at /home/nios2-linux/linux-2.6/mm/nommu.c:530/add_nommu_region()! Kernel panic - not syncing: BUG! I compare mygui and jpegview application. I think it is mmap function error. Hi, all: Who have solved it?10 Replies
- Altera_Forum
Honored Contributor
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 - Altera_Forum
Honored Contributor
<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:
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!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__); } - Altera_Forum
Honored Contributor
Dear Hippo I have meet the same errors . BUG: failure at /home/nios2-linux/linux-2.6/mm/nommu.c:530/add_nommu_region()! I update the uClinux for NEEK board . So Pls hlpe us to reslove the problem . thanks ! Alex - Altera_Forum
Honored Contributor
I will check the kernel when I got some spare time.
- Hippo - Altera_Forum
Honored Contributor
I tried running the code listed above on a NIOSII processor. I got the following results.
set_fb Start: 34 set_fb fbcon engine: Error when reading screen info: 42. cannot open /dev/fb0 TestMyGUI InitMyGUI OK 85. set_fb Start: 34 set_fb Continue: 47 cannot open /dev/fb0 TestMyGUI TestMyGUI OK 101. I then tried running the following code on the NIOSII. I had success running this same code on a PC running Linux.
I get the following result. The framebuffer device was opened successfully. 640x480, 16bpp Error: failed to map framebuffer device to memory. Does anybody have an idea why mmap doesn't seem to work?# include <unistd.h># include <stdio.h># include <fcntl.h># include <linux/fb.h># include <sys/mman.h> int main() { int fbfd = 0; struct fb_var_screeninfo vinfo; struct fb_fix_screeninfo finfo; long int screensize = 0; char *fbp = 0; int x = 0, y = 0; long int location = 0; // Open the file for reading and writing fbfd = open("/dev/fb0", O_RDWR); if (!fbfd) { printf("Error: cannot open framebuffer device.\n"); exit(1); } printf("The framebuffer device was opened successfully.\n"); // Get fixed screen information if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) { printf("Error reading fixed information.\n"); exit(2); } // Get variable screen information if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) { printf("Error reading variable information.\n"); exit(3); } printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel ); // Figure out the size of the screen in bytes screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; // Map the device to memory fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0); if ((int)fbp == -1) { printf("Error: failed to map framebuffer device to memory.\n"); exit(4); } printf("The framebuffer device was mapped to memory successfully.\n"); x = 100; y = 100; // Where we are going to put the pixel // Figure out where in memory to put the pixel for ( y = 100; y < 300; y++ ) for ( x = 100; x < 300; x++ ) { location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) + (y+vinfo.yoffset) * finfo.line_length; if ( vinfo.bits_per_pixel == 32 ) { *(fbp + location) = 100; // Some blue *(fbp + location + 1) = 15+(x-100)/2; // A little green *(fbp + location + 2) = 200-(y-100)/5; // A lot of red *(fbp + location + 3) = 0; // No transparency } else { //assume 16bpp int b = 10; int g = (x-100)/6; // A little green int r = 31-(y-100)/16; // A lot of red unsigned short int t = r<<11 | g << 5 | b; *((unsigned short int*)(fbp + location)) = t; } } munmap(fbp, screensize); close(fbfd); return 0; } - Altera_Forum
Honored Contributor
Hi All,
I just updated to the latest kernel download (this week) and I get the same error when exiting our app. The version of our app I ported has not been changed for quite some time (june this year). BUG: failure at /home/chris/nios2-linux/linux-2.6/mm/nommu.c:530/add_nommu_region()! Kernel panic - not syncing: BUG! Is this a new problem? I last updated the kernel about 2 months ago on a clean test machine, but I don't recall seeing this problem. We normally don't exit our app, but do so for development and debugging, and we have been doing most of our development on a much earlier kernel version (early last year some time). Good Huntin' cb - Altera_Forum
Honored Contributor
I found it was introduced since v2.6.29-rc1.
With v2.6.28, it worked fine. You can checkout for testing, cd linux-2.6 git checkout 3cd22ca7c7 I think it was a MM issue. Please help to debug this. Cheer, Hippo - Altera_Forum
Honored Contributor
This issue was resolved. Please pull the updates, clean and rebuild.
cd uClinux-dist make user/microwin_clean make - Hippo - Altera_Forum
Honored Contributor
--- Quote Start --- This issue was resolved. Please pull the updates, clean and rebuild. cd uClinux-dist make user/microwin_clean make - Hippo --- Quote End --- Hi,Hippo I'm a newbie and I get the same problem: BUG: failure at /aaa/nios2-linux/linux-2.6/mm/nommu.c:530/add_nommu_region()! Kernel panic - not syncing: BUG! But I don't know how to "pull the updates".Could you please explain it for me?Thank you. - Altera_Forum
Honored Contributor
please follow step4,5 in nios2-linux/README.
- Hippo