Forum Discussion
Altera_Forum
Honored Contributor
11 years ago --- Quote Start --- Sounds good, but how do you get the physical address of something in Linux. ie if I allocate some memory in Linux I get a pointer that's eg 0x65223000. Now I only have 1GB of Ram attached, so it's clearly not mapped from 0->3FFFFFFF. I assume there is some memory management going on, but how do I translate 0x65223000 to the actual address on the SDRAM? --- Quote End --- That's correct, if you malloc in Linux you'll get a virtual address back so if you want to pass that address to the FPGA for something in there to access the same data you'll need to convert the virtual address to a physical address. The other thing to keep in mind is that a large buffer in memory that gets allocated may get mapped to multiple physical addresses because memory is paged. The size of these pages is determined by the MMU settings. On top of that pages can potentially move to new physical locations as well which requires "pinning" to ensure that they don't move around. Unfortantely I'm a hardware guy so I don't know which API you should use so what I recommend doing is looking at examples that have FPGA logic accessing locations in the HPS to see how those drivers handle this. Most of those should be up on rocketboards: http://rocketboards.org/ Another recommendation I have is to create a new post in the Linux section of the SoC forum since they'll know what you should do.