2009-02-11 09:46:51 unable to do mmap to the video hardware
Maha lakshmi (INDIA)
Message: 69267
Hi,
The mmap function fails in the following program when I tried in BF527. Please tell me how to do it.
static unsigned char * frame_map = NULL;
// 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;
frame_map = (unsigned char *)mmap(NULL, screensize, PROT_READ|PROT_WRITE,MAP_SHARED, fbfd,0);
if (frame_map == (unsigned char *)-1) {
printf("Unable to memory map the video hardware\n");
frame_map = NULL;
exit(0);
}
Thanks,
Maha
QuoteReplyEditDelete
2009-02-11 10:03:26 Re: unable to do mmap to the video hardware
Michael Hennerich (GERMANY)
Message: 69268
Use MAP_PRIVATE
frame_map = (unsigned char *)mmap(NULL, screensize, PROT_READ|PROT_WRITE,MAP_PRIVATE, fbfd,0);
-Michael
QuoteReplyEditDelete
2009-02-11 23:45:20 Re: unable to do mmap to the video hardware
Maha lakshmi (INDIA)
Message: 69304
Hi,
I tried MAP_PRIVATE in the above program. I got following results.
The framebuffer device was opened successfully.
320x240, 24bpp
The framebuffer device was mapped to memory successfully.
Bus error
dmesg shows the following error messages once i run this program.
Data access misaligned address violation
- Attempted misaligned data memory or data cache access.
Defered Exception context
CURRENT PROCESS:
COMM=fb PID=237
TEXT = 0x03b39000-0x03b39d54 DATA = 0x00488d54-0x00488f18
BSS = 0x00488f18-0x004a0000 USER-STACK = 0x004bfe40
return address: [0x03b39b68]; contents of:
0x03b39b40: 5208 bbe0 b9e0 4f58 3008 b9d0 4f28 5601
0x03b39b50: 3008 b9c0 5601 e678 fffe b980 3008 b950
0x03b39b60: 5001 3210 e578 fffe [9710] b960 6408 bb60
0x03b39b70: b960 e121 012b 0908 1b5b b970 6408 bb70
SEQUENCER STATUS: Not tainted
SEQSTAT: 00000024 IPEND: 0030 SYSCFG: 0006
HWERRCAUSE: 0x0
EXCAUSE : 0x24
RETE: <0x00000000> /* Maybe null pointer? */
RETN: <0x00486000> /* unknown address */
RETX: <0x03b39b68> [ /home/fb + 0xb68 ]
RETS: <0x03b39a12> [ /home/fb + 0xa12 ]
PC : <0x03b39b68> [ /home/fb + 0xb68 ]
DCPLB_FAULT_ADDR: <0x004bfdc8> [ fb + 0x1fdc8 ]
ICPLB_FAULT_ADDR: <0x03b39b68> [ /home/fb + 0xb68 ]
PROCESSOR STATE:
R0 : fffff80a R1 : 0001782f R2 : 00000000 R3 : 00000000
R4 : 0043154c R5 : 00000001 R6 : 004bfe44 R7 : 004918a8
P0 : 00000004 P1 : 0049315c P2 : 0001782f P3 : 004918a8
P4 : 0043155c P5 : 00493a3c FP : 004bfdf0 SP : 00485f24
LB0: 001f21b1 LT0: 001f21a4 LC0: 00000000
LB1: 03bdce37 LT1: 03bdce36 LC1: 00000000
B0 : 00000000 L0 : 00000000 M0 : 00000000 I0 : 03b39d08
B1 : 00000000 L1 : 00000000 M1 : 00000000 I1 : 03bf5614
B2 : 00000000 L2 : 00000000 M2 : 00000000 I2 : 00000000
B3 : 00000000 L3 : 00000000 M3 : 00000000 I3 : 00000000
A0.w: 00000000 A0.x: 00000000 A1.w: 00000000 A1.x: 00000000
USP : 004bfcb8 ASTAT: 02002000
Hardware Trace:
0 Target : <0x0000491c> { _trap_c + 0x0 }
Source : <0xffa006ec> { _exception_to_level5 + 0xb4 }
1 Target : <0xffa00638> { _exception_to_level5 + 0x0 }
Source : <0xffa00590> { _ex_trap_c + 0x5c }
2 Target : <0xffa00534> { _ex_trap_c + 0x0 }
Source : <0xffa0078c> { _trap + 0x28 }
3 Target : <0xffa00764> { _trap + 0x0 }
Source : <0x03b39b64> [ /home/fb + 0xb64 ]
4 Target : <0x03b39b36> [ /home/fb + 0xb36 ]
Source : <0x03b39b2a> [ /home/fb + 0xb2a ]
5 Target : <0x03b39ae4> [ /home/fb + 0xae4 ]
Source : <0x03b39a5a> [ /home/fb + 0xa5a ]
6 Target : <0x03b39a2e> [ /home/fb + 0xa2e ]
Source : <0x03b39b78> [ /home/fb + 0xb78 ]
7 Target : <0x03b39b36> [ /home/fb + 0xb36 ]
Source : <0x03b39b2a> [ /home/fb + 0xb2a ]
8 Target : <0x03b39ae4> [ /home/fb + 0xae4 ]
Source : <0x03b39a5a> [ /home/fb + 0xa5a ]
9 Target : <0x03b39a2e> [ /home/fb + 0xa2e ]
Source : <0x03b39b78> [ /home/fb + 0xb78 ]
10 Target : <0x03b39b70> [ /home/fb + 0xb70 ]
Source : <0x03b39a2c> [ /home/fb + 0xa2c ]
11 Target : <0x03b39a26> [ /home/fb + 0xa26 ]
Source : <0x03b39b88> [ /home/fb + 0xb88 ]
12 Target : <0x03b39b80> [ /home/fb + 0xb80 ]
Source : <0x03b39a24> [ /home/fb + 0xa24 ]
13 Target : <0x03b39a12> [ /home/fb + 0xa12 ]
Source : <0x03bdac8a> [ /lib/libuClibc-0.9.29.so + 0x1ac8a ]
14 Target : <0x03bdac82> [ /lib/libuClibc-0.9.29.so + 0x1ac82 ]
Source : <0x03bdac74> [ /lib/libuClibc-0.9.29.so + 0x1ac74 ]
15 Target : <0x03bdac6c> [ /lib/libuClibc-0.9.29.so + 0x1ac6c ]
Source : <0x03bdeaaa> [ /lib/libuClibc-0.9.29.so + 0x1eaaa ]
Stack from 00485f04:
004918a8 ffa006f0 001d2568 001d2568 001d2564 00000000 0000003a 0009f600
03b39b68 00000030 00000024 00000000 00486000 03b39b68 03b39b68 03b39a12
fffff80a 02002000 03bdce37 001f21b1 03bdce36 001f21a4 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 03bf5614 03b39d08 004bfcb8 004bfdf0 00493a3c 0043155c
Call Trace:
[<0001782f>] _blocking_notifier_call_chain+0x7/0x18
[<0001782f>] _blocking_notifier_call_chain+0x7/0x18
Can you tell me a solution for this.
Thanks,
Maha
QuoteReplyEditDelete
2009-02-12 00:45:39 Re: unable to do mmap to the video hardware
Mike Frysinger (UNITED STATES)
Message: 69308
please read the documentation:
docs.blackfin.uclinux.org/doku.php?id=uclinux-dist:debugging_applications#analyzing_traces