I have an SSD 1306 OLED display on my Beaglebone that is configured as a
framebuffer in LInux (3.8.13).
I want to use mmap to get its framebuffer so I can draw on it. The mmap
call does return a pointer, but subsequent operations will segfault.
This is the C code:
#include <stdio.h>
> #include <sys/mman.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <unistd.h>
> #include <linux/fb.h>
> #include <sys/ioctl.h>
> #include <wakkomononormalh.h>
> #include <string.h>
> #include <time.h>
>
> static char b[1024]; /* Local image buffer */
> static struct timespec displaydelay;
>
>
> int main()
> {
> struct fb_fix_screeninfo fb_fixed_info; /* Framebuffer information */
>
> int fbfd = 0;
> char *fbp = 0;
>
> //Open the file for reading and writing
> fbfd = open("/dev/fb0", O_RDWR);
>
> //Map the device to memory
>
> fbp = (char *)mmap(0, fb_fixed_info.smem_len, PROT_READ |
> PROT_WRITE,MAP_SHARED
> ,
> fbfd, 0);
>
> if ((int)fbp == -1) { printf("Error: failed to map framebuffer device
> to memory./n");
> return 4;
> }
>
> printf("The framebuffer device was mapped to memory successfully./n");
>
>
> // Clear screen
>
> memset(b,0,fb_fixed_info.smem_len);
> memcpy(fbp,b,screensize);
>
> The code fails at memcpy. I knew I would have a learning curve, but I
> have been in circles on this. I thought I dodged a bullet not having to
> write kernel drivers for my project, but...
>
Thanks.
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.