need advice on howto access memory from fpga and cpu
Greetings, I need advice about a programming project I am doing at my university. The goal basically is to implement a framebuffer in RAM on a Zedboard SoC (www.zedboard.org). The problem is, that both the integrated FPGA and "the software" need to access the framebuffer, e.g. need access to the same memory region. I am not sure if I have to write a kernel driver for this at all, or if it's sufficient to do some mmap'ing on /dev/mem from userspace. Also, it would be really nice if I could reserve some memory (< 1MB), so that Linux will not touch it, and the framebuffer will always lie at the same address in RAM. Otherwise I would have to tell the FPGA the addresses. I don't really need direct memory access from userspace, I just have to get some images out of the vga port. So my plan currently is to tell Linux somehow to not touch the first X bytes of the RAM. Thus the memory region of the framebuffer is already known. Then I want to implement a kernel driver that's setting up a character device, say /dev/fb0, to receive frames from userspace. I already read this[1] post on Stackoverflow, which is going in the right direction, and started reading "Linux Device Drivers 3rd Edition", but I would really like to get some comment from the more experienced programmers, whether there's a better approach to this. [1] http://stackoverflow.com/questions/647783/direct-memory-access-in-linux -- Grüße, Kai "In a world without walls and fences, who needs Windows and Gates?"
On Wed, Oct 30, 2013 at 04:20:30PM +0530, srinivas bakki wrote:
But otherwise am wondering why would you need to tell the FPGA these kernel mapped addresses ? How is it connected to the memory module ?
The FPGA seems to have direct access to the memory. If I would allocate memory for the framebuffer dynamically, I would first have to find out the physical adress of this area, and then tell it to the FPGA, so it can read the frames from there. We are implementing a "GPU" on the FPGA here, or at least something that's reading frames from the RAM, to send it to the VGA port. -- Grüße, Kai "In a world without walls and fences, who needs Windows and Gates?"
If you don't want dynamic memory allocation for framebuffer and neither do you want it in the user space, All you need is to pass memmap = <size>$<start address> to the kernel and then write a kernel module module where you ioremap that physical address space. This is just like any other device driver where device registers are mapped. On Wed, Oct 30, 2013 at 7:56 PM, Kai <kai@kunfoo.org> wrote:
On Wed, Oct 30, 2013 at 04:20:30PM +0530, srinivas bakki wrote:
But otherwise am wondering why would you need to tell the FPGA these kernel mapped addresses ? How is it connected to the memory module ?
The FPGA seems to have direct access to the memory. If I would allocate memory for the framebuffer dynamically, I would first have to find out the physical adress of this area, and then tell it to the FPGA, so it can read the frames from there. We are implementing a "GPU" on the FPGA here, or at least something that's reading frames from the RAM, to send it to the VGA port. -- Grüße, Kai
"In a world without walls and fences, who needs Windows and Gates?"
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On Wed, Oct 30, 2013 at 08:15:08PM +0530, srinivas bakki wrote:
If you don't want dynamic memory allocation for framebuffer and neither do you want it in the user space, All you need is to pass memmap = <size>$<start address> to the kernel and then write a kernel module module where you ioremap that physical address space.
This is just like any other device driver where device registers are mapped.
Thanks for your answers, it sounds very straightforward. One more question: Currently I'm using the book Linux Device Drivers 3rd Edition (2005) as a reference, and it's discussing Kernel 2.6.10. Do you think that's still okay, or should I get/buy a more recent book on this topic, and which would you recommend? -- Grüße, Kai "In a world without walls and fences, who needs Windows and Gates?"
On Wed, 30 Oct 2013 17:17:44 +0100, Kai said:
One more question: Currently I'm using the book Linux Device Drivers 3rd Edition (2005) as a reference, and it's discussing Kernel 2.6.10. Do you think that's still okay, or should I get/buy a more recent book on this topic, and which would you recommend?
The concepts are all valid (when you need locking, stuff like that), but many of the APIs have been changed. Fortunately, it's kernel policy that when an API is changed, we change not only the semantics, but also the signature of the function (name, number of parameters, etc), so old code will throw a compile error rather than mysteriously bomb at runtime.
Thanks for your answers, it sounds very straightforward.
ofcourse it's straightforward. Believe me its not really difficult to write low level drivers in linux. You should be more comfortable with the hardware to write low level stuff. Beauty of linux is the framework it provides to make to it so easy ! On Wed, Oct 30, 2013 at 9:47 PM, Kai <kai@kunfoo.org> wrote:
On Wed, Oct 30, 2013 at 08:15:08PM +0530, srinivas bakki wrote:
If you don't want dynamic memory allocation for framebuffer and neither do you want it in the user space, All you need is to pass memmap = <size>$<start address> to the kernel and then write a kernel module module where you ioremap that physical address space.
This is just like any other device driver where device registers are mapped.
Thanks for your answers, it sounds very straightforward.
One more question: Currently I'm using the book Linux Device Drivers 3rd Edition (2005) as a reference, and it's discussing Kernel 2.6.10. Do you think that's still okay, or should I get/buy a more recent book on this topic, and which would you recommend? -- Grüße, Kai
"In a world without walls and fences, who needs Windows and Gates?"
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Thank you guys, you helped me a lot! -- Grüße, Kai "In a world without walls and fences, who needs Windows and Gates?"
participants (3)
-
Kai -
srinivas bakki -
Valdis.Kletnieks@vt.edu