All of lore.kernel.org
 help / color / mirror / Atom feed
* need advice on howto access memory from fpga and cpu
@ 2013-10-30  8:58 Kai
  2013-10-30 14:26 ` Kai
  0 siblings, 1 reply; 7+ messages in thread
From: Kai @ 2013-10-30  8:58 UTC (permalink / raw)
  To: kernelnewbies

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@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?"

^ permalink raw reply	[flat|nested] 7+ messages in thread

* need advice on howto access memory from fpga and cpu
  2013-10-30  8:58 need advice on howto access memory from fpga and cpu Kai
@ 2013-10-30 14:26 ` Kai
  2013-10-30 14:45   ` srinivas bakki
  0 siblings, 1 reply; 7+ messages in thread
From: Kai @ 2013-10-30 14:26 UTC (permalink / raw)
  To: kernelnewbies

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?"

^ permalink raw reply	[flat|nested] 7+ messages in thread

* need advice on howto access memory from fpga and cpu
  2013-10-30 14:26 ` Kai
@ 2013-10-30 14:45   ` srinivas bakki
  2013-10-30 16:17     ` Kai
  0 siblings, 1 reply; 7+ messages in thread
From: srinivas bakki @ 2013-10-30 14:45 UTC (permalink / raw)
  To: kernelnewbies

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 at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20131030/fb593324/attachment.html 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* need advice on howto access memory from fpga and cpu
  2013-10-30 14:45   ` srinivas bakki
@ 2013-10-30 16:17     ` Kai
  2013-10-30 16:30       ` Valdis.Kletnieks at vt.edu
  2013-10-30 18:46       ` srinivas bakki
  0 siblings, 2 replies; 7+ messages in thread
From: Kai @ 2013-10-30 16:17 UTC (permalink / raw)
  To: 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?"

^ permalink raw reply	[flat|nested] 7+ messages in thread

* need advice on howto access memory from fpga and cpu
  2013-10-30 16:17     ` Kai
@ 2013-10-30 16:30       ` Valdis.Kletnieks at vt.edu
  2013-10-30 18:46       ` srinivas bakki
  1 sibling, 0 replies; 7+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2013-10-30 16:30 UTC (permalink / raw)
  To: kernelnewbies

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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20131030/765413a9/attachment.bin 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* need advice on howto access memory from fpga and cpu
  2013-10-30 16:17     ` Kai
  2013-10-30 16:30       ` Valdis.Kletnieks at vt.edu
@ 2013-10-30 18:46       ` srinivas bakki
  2013-10-31  9:39         ` Kai
  1 sibling, 1 reply; 7+ messages in thread
From: srinivas bakki @ 2013-10-30 18:46 UTC (permalink / raw)
  To: kernelnewbies

 >>>> 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 at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20131031/30b6f8d8/attachment.html 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* need advice on howto access memory from fpga and cpu
  2013-10-30 18:46       ` srinivas bakki
@ 2013-10-31  9:39         ` Kai
  0 siblings, 0 replies; 7+ messages in thread
From: Kai @ 2013-10-31  9:39 UTC (permalink / raw)
  To: kernelnewbies

Thank you guys, you helped me a lot!
-- 
Gr??e, Kai

"In a world without walls and fences, who needs Windows and Gates?"

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-10-31  9:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-30  8:58 need advice on howto access memory from fpga and cpu Kai
2013-10-30 14:26 ` Kai
2013-10-30 14:45   ` srinivas bakki
2013-10-30 16:17     ` Kai
2013-10-30 16:30       ` Valdis.Kletnieks at vt.edu
2013-10-30 18:46       ` srinivas bakki
2013-10-31  9:39         ` Kai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.