<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Expanding shared memory on the BBB</title><link>https://community.element14.com/products/devtools/single-board-computers/f/forum/21217/expanding-shared-memory-on-the-bbb</link><description>Since the PRU is great for interfacing hardware, I&amp;#39;d like to transfer more that 8kbyte at a time between the Linux hosted application and the PRU application. I know this is possible in theory, because the PRU can access the entire memory map. However</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><lastBuildDate>Sun, 09 Mar 2014 15:37:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://community.element14.com/products/devtools/single-board-computers/f/forum/21217/expanding-shared-memory-on-the-bbb" /><item><title>RE: Expanding shared memory on the BBB</title><link>https://community.element14.com/thread/47274?ContentTypeID=1</link><pubDate>Sun, 09 Mar 2014 15:37:22 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:f3405d4e-6f4e-41a7-98ff-9da9c921644c</guid><dc:creator>shabaz</dc:creator><description>&lt;p style="margin:0;"&gt;These topics mentioned will be useful:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;a class="jive-link-blog-small" href="https://community.element14.com/products/devtools/single-board-computers/next-genbeaglebone/b/blog/posts/bbb---high-speed-data-acquisition-and-web-based-ui"&gt;BBB - High speed data acquisition and web-based UI&lt;/a&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;In that topic and the current topic, the following URLs were discussed:&lt;/p&gt;&lt;p style="margin:0;"&gt;Allocating memory using modprobe uio_pruss:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;a class="jive-link-external-small" href="https://groups.google.com/forum/m/#!topic/beagleboard/Gb6xL7V7Z00" rel="nofollow ugc noopener" target="_blank" title="https://groups.google.com/forum/m/#!topic/beagleboard/Gb6xL7V7Z00"&gt;https://groups.google.com/forum/m/#!topic/beagleboard/Gb6xL7V7Z00&lt;/a&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;and this URL shows how to retrieve the address:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;a class="jive-link-external-small" href="http://hipstercircuits.com/beaglebone-pru-ddr-memory-access-the-right-way/" rel="nofollow ugc noopener" target="_blank" title="http://hipstercircuits.com/beaglebone-pru-ddr-memory-access-the-right-way/"&gt;http://hipstercircuits.com/beaglebone-pru-ddr-memory-access-the-right-way/&lt;/a&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;This method avoids the need of any other driver (but is not necessarily the best way for reasons described in the topics).&lt;/p&gt;&lt;p style="margin:0;"&gt;I noticed what looks like the same method is used here too:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;a class="jive-link-external-small" href="https://bitbucket.org/intelligentagent/pypruss/src/f48e3d553687205d3f62420a95039a0d16dbee4d/pypruss/pypruss.c" rel="nofollow ugc noopener" target="_blank" title="https://bitbucket.org/intelligentagent/pypruss/src/f48e3d553687205d3f62420a95039a0d16dbee4d/pypruss/pypruss.c"&gt;https://bitbucket.org/intelligentagent/pypruss/src/f48e3d553687205d3f62420a95039a0d16dbee4d/pypruss/pypruss.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expanding shared memory on the BBB</title><link>https://community.element14.com/thread/179786?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2013 17:48:50 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:09aad2a3-ff7b-483b-8006-b6e276504aed</guid><dc:creator>Former Member</dc:creator><description>&lt;p style="margin:0;"&gt;So I found the old driver, unfortunately it&amp;#39;s for a 2.4.x kernel.&amp;nbsp; On a brighter note, it&amp;#39;s only 168 lines and I&amp;#39;m guessing that 30% of that is comments, so I&amp;#39;ll see if I can get it cleaned up and compiling on a recent kernel.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expanding shared memory on the BBB</title><link>https://community.element14.com/thread/179785?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2013 16:35:43 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:bd0e80ff-9b7c-4759-be8e-de1b68810710</guid><dc:creator>Former Member</dc:creator><description>&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;shabaz wrote:&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;Regarding drivers, I had found &lt;a class="jive-link-external-small" href="http://www.freesoftwaremagazine.com/articles/drivers_linux" rel="nofollow" target="_blank"&gt;this link&lt;/a&gt; in the past and had bookmarked it to learn how to write drivers, so I&amp;#39;ll read up and also browse some existing drivers to see how they work, and perhaps copy one to use as a base. &lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;"&gt;&lt;a class="jive-link-external-small" href="http://oreilly.com/openbook/linuxdrive3/book/index.html" rel="nofollow ugc noopener" target="_blank" title="http://oreilly.com/openbook/linuxdrive3/book/index.html"&gt;http://oreilly.com/openbook/linuxdrive3/book/index.html&lt;/a&gt; used to be available as a single pdf but I don&amp;#39;t see it now, this is the closest &lt;a class="jive-link-external-small" href="http://lwn.net/Kernel/LDD3/" rel="nofollow ugc noopener" target="_blank" title="http://lwn.net/Kernel/LDD3/"&gt;http://lwn.net/Kernel/LDD3/&lt;/a&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;while it&amp;#39;s obviously dated now it&amp;#39;s still a good intro to a lot of the concepts.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;I&amp;#39;m searching for the driver I had to do this sort of thing from 6-7 years ago. It probably won&amp;#39;t build against a current kernel, but may be able to be cleaned up and reused to some degree - assuming I can find it !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expanding shared memory on the BBB</title><link>https://community.element14.com/thread/157264?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2013 16:17:20 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:03721a4f-2cc3-4679-9811-c512b440f648</guid><dc:creator>shabaz</dc:creator><description>&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;selsinork wrote:&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;thinking about that further, while you may need to describe the size of the buffer in the dts somehow, you probably need to tell uBoot to load the kernel higher. I didn&amp;#39;t dig too deeply, but possibly that can be done in the uEnv.txt that lives in /dev/mmcblk0p1 but if not then you likely need to rebuild uBoot just to change the kernel&amp;#39;s load address in the script.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;A driver will be the better way and it&amp;#39;s not really all that complicated as essentially all it needs to do is kmalloc a contiguous buffer and let you mmap that from userspace. You could always add features by using ioctl&amp;#39;s on a /dev entry or something in /sys to allow you to configure the buffer size at runtime if a simple fixed buffer of say 256k isn&amp;#39;t enough.&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;"&gt;I see, thank you for the excellent pointers. I&amp;#39;ll check out uEnv.txt and the .dts tonight.&lt;/p&gt;&lt;p style="margin:0;"&gt;Regarding drivers, I had found &lt;a class="jive-link-external-small" href="http://www.freesoftwaremagazine.com/articles/drivers_linux" rel="nofollow ugc noopener" target="_blank"&gt;this link&lt;/a&gt; in the past and had bookmarked it to learn how to write drivers, so I&amp;#39;ll read up and also browse some existing drivers to see how they work, and perhaps copy one to use as a base. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expanding shared memory on the BBB</title><link>https://community.element14.com/thread/157262?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2013 16:00:59 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:7fba936f-df9b-46b9-9635-0c2cd9787b42</guid><dc:creator>Former Member</dc:creator><description>&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;shabaz wrote:&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;They just mmap the huge 256MB amount, but don&amp;#39;t expect the user to try to access all that.&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;"&gt;Sure, but the problem is that you&amp;#39;re mmap&amp;#39;ing an area that includes kernel code and data, there&amp;#39;s no actual reservation or proper allocation here, everything is a wing and a prayer &lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/16x16/__key/communityserver-discussions-components-files/88/1586.contentimage_5F00_403.png"&gt;&lt;img alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/discussions/components/files/88/1586.contentimage_403.png-16x16.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=%2BKJ8XKhR9ySxrm6zniOvMcdRohzfyYWO2J7QmN2Xug8%3D&amp;amp;se=2026-04-11T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=BykzUr9N61FlLp1kyayPTQ==" style="max-height: 16px;max-width: 16px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;padding:0px;"&gt;I&amp;#39;ll check out the dts tonight, in case that contains it. If it doesn&amp;#39;t, maybe I should request that the memory in future builds is allocated a bit more than 8kbyte, but others may not want that. &lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;"&gt;thinking about that further, while you may need to describe the size of the buffer in the dts somehow, you probably need to tell uBoot to load the kernel higher. I didn&amp;#39;t dig too deeply, but possibly that can be done in the uEnv.txt that lives in /dev/mmcblk0p1 but if not then you likely need to rebuild uBoot just to change the kernel&amp;#39;s load address in the script.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;A driver will be the better way and it&amp;#39;s not really all that complicated as essentially all it needs to do is kmalloc a contiguous buffer and let you mmap that from userspace. You could always add features by using ioctl&amp;#39;s on a /dev entry or something in /sys to allow you to configure the buffer size at runtime if a simple fixed buffer of say 256k isn&amp;#39;t enough.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expanding shared memory on the BBB</title><link>https://community.element14.com/thread/157261?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2013 14:31:45 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:f8090b96-01a0-4cb7-858b-40a198e4bf61</guid><dc:creator>shabaz</dc:creator><description>&lt;p style="margin:0;"&gt;Ah, I should have pasted a bit more of that code:&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;static int mem_fd;&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;mem_fd = open(&amp;quot;/dev/mem&amp;quot;, O_RDWR);&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (mem_fd &amp;lt; 0) {&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&amp;quot;Failed to open /dev/mem (%s)\n&amp;quot;, strerror(errno));&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return -1;&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;and then they follow it with the ddrMem = mmap(.... portion pasted earlier.&lt;/p&gt;&lt;p style="margin:0;"&gt;They just mmap the huge 256MB amount, but don&amp;#39;t expect the user to try to access all that.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;I&amp;#39;ll check out the dts tonight, in case that contains it. If it doesn&amp;#39;t, maybe I should request that the memory in future builds is allocated a bit more than 8kbyte, but others may not want that. A driver or dts would be pretty neat, I wonder if that is planned by anyone if the functionality doesn&amp;#39;t exist today. I&amp;#39;ll try and query from Jonathan Bailey who is working on the GSoC PRU JTAG project, in case he needs to transfer more than 8kbyte too (although he could probably do it in chunks, which I can&amp;#39;t with my use-case).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expanding shared memory on the BBB</title><link>https://community.element14.com/thread/157257?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2013 14:10:37 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:75e2e4af-f410-4cb3-ab62-eba0a05ef327</guid><dc:creator>Former Member</dc:creator><description>&lt;p style="margin:0;"&gt;what file does mem_fd reference ?&amp;nbsp; /dev/kmem ?&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;With a length of 0x0FFFFFFF you&amp;#39;re trying to map a region of 256MB at address 0x8000000 which according to the am3359 TRM is ths start of RAM, so you&amp;#39;d expect to be overwriting something quite soon after that point.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;There are a couple of posibilities, kernel commandline mem= option can limit the amount of ram available, so in theory you can reserve some space that linux doesn&amp;#39;t know about at the top of memory.&amp;nbsp; Not sure if this really helps as you may be unable to mmap that region from userspace. Oh, and mem= does that on x86, not sure if Arm will do the same. Also this reservation would be at the top of ram, i.e. you&amp;#39;re setting the max memory to be 511Mb on your 512Mb board. So if your board ever gets 1GB, you&amp;#39;ve reserved 513MB !&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;The other is that in x86 there&amp;#39;s a kernel option to reserve a chunk of memory at the bottom of the address space due to the bios using SMI mode and assuming cetrain things about the contents of the start of ram due to hangovers from dos days. &lt;/p&gt;&lt;p style="margin:0;"&gt;If this exists on Arm kernels you have a way to reserve some space that the kernel won&amp;#39;t touch - kernel recompile will likely be needed though.&lt;/p&gt;&lt;p style="margin:0;"&gt;Hmm, seems the one I&amp;#39;m thinking of is called X86_RESERVE_LOW, so unfortunately not a generic feature although maybe it could be added. However if kernel surgery is the only way then maybe a proper device driver would be a better way longer term.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;Is there anything in devicetree that could help reserve an area ?&amp;nbsp; I&amp;#39;m assuming devicetree carries details of the board&amp;#39;s memory map which might be tweaked ?&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;In any case, you&amp;#39;re quickly getting to the point that your app couldn&amp;#39;t expect to run on an un-modified BBB anyway, so only useful for people who are prepared to recompile kernels, drivers and such like.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expanding shared memory on the BBB</title><link>https://community.element14.com/thread/34750?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2013 13:22:28 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:788831af-865e-494c-a5c5-d7c00a546c27</guid><dc:creator>shabaz</dc:creator><description>&lt;p style="margin:0;"&gt;The intention was to capture data at high speed from an ADC or a CCD, so I&amp;#39;d need to capture an entire frame at a time. &lt;/p&gt;&lt;p style="margin:0;"&gt;I can capture with the PRU and dump in any memory address, using (say):&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;MOV r1, 0x80001000&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;MOV r0, 0xaabbccdd&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;ST32 r0, r1 // store into address at r1&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;And for that r1 address, I&amp;#39;m free to use any location&lt;/p&gt;&lt;p style="margin:0;"&gt;(with the exception that if I want to address lower than&lt;/p&gt;&lt;p style="margin:0;"&gt;0x00080000 then I need to set a register (called PMAO) first.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;At the ARM end, I have something like this (this is a snippet from TI&amp;#39;s example app), and no malloc anywhere, so the memory must have been reserved at startup of the BBB:&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;#define DDR_BASEADDR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x80000000&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;#define OFFSET_DDR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00001000&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;ddrMem = mmap(0, 0x0FFFFFFF, PROT_WRITE | PROT_READ, MAP_SHARED, mem_fd, DDR_BASEADDR);&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;DDR_regaddr1 = ddrMem + OFFSET_DDR;&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;If I try to get the PRU to write more than about 8-12kbyte, then I get crashes, because I&amp;#39;m trampling on some memory.&lt;/p&gt;&lt;p style="margin:0;"&gt;So, either I need to find a way to reserve more memory at startup of the BBB, or I had thought some way to be able to perform a malloc and send the address to the PRU to use may help, but you&amp;#39;ve just reminded me it may not be contiguous :-(&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;I&amp;#39;m wondering if maybe today the 8kbyte is just hard-coded in some linker file possibly, since the address is fixed. So this could be messy to have any convenient approach to have people be able to modify it. I think 8kbyte is too low, because it is easily possible to exceed that when doing high-speed data aquisition for more than a few milliseconds. Anything much higher than 128kbyte may be more unusual I suppose. I&amp;#39;ll try doing a recursive grep for these addresses (might take a long time!), in case I can spot it, and I&amp;#39;ll report back.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expanding shared memory on the BBB</title><link>https://community.element14.com/thread/34733?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2013 12:41:29 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:89121f2e-d28c-4b4f-8228-6298728d26ca</guid><dc:creator>Former Member</dc:creator><description>&lt;p style="margin:0;"&gt;Can you explain a bit more about exactly what you&amp;#39;re trying to do ?&amp;nbsp; Maybe with a snippet of the problem code ?&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;mmap isn&amp;#39;t limited to 8KB as such, but what you&amp;#39;re trying to mmap could have limits, or what you&amp;#39;re trying to do might not be sensible in a virtual memory environment.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;in a bash shell, try typing ulimit -a which will show you process limits, to set these things from code you should start by looking at getrlimit &amp;amp; setrlimit, some of these can affect mmap&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;if you&amp;#39;re trying to mmap 128k of memory from userspace and have that be contiguous physical memory for the pru to use then it&amp;#39;s likely to be impossible from userspace as you&amp;#39;re creating a region that&amp;#39;s contiguous in virtual memory but which could be made up of pages scattered throuought physical memory. So the best you can do is a single page.&lt;/p&gt;&lt;p style="margin:0;"&gt;It&amp;#39;s been a few years since I had to do this and it was on x86, so the details may well be different, but it required writing a kernel driver which would do the actual memory allocation in physical memory, it then provided a device node in /dev which could be mmap&amp;#39;ed from userspace along with a pointer describing the physical address this corresponded to.&lt;/p&gt;&lt;p style="margin:0;"&gt;Inside the kernel there are (or were) some functions to do the conversions - virt_to_phys, phys_to_virt, virt_to_bus, bus_to_virt - which ones you need to use are dependant on the CPU, MMU etc, so my recollection of how it all fits together on x86 is probably not quite right for Arm.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;Other complications are that the virt addresses used by these are &amp;#39;kernel&amp;#39; virtual addresses which will be different to userspace virtual addresses and whether you need phys or bus will depend on how Arm does things.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;Interesting article here (although rather out of date, it should give you an idea of the complexities): &lt;a class="jive-link-external-small" href="http://www.tldp.org/LDP/khg/HyperNews/get/devices/addrxlate.html" rel="nofollow ugc noopener" target="_blank" title="http://www.tldp.org/LDP/khg/HyperNews/get/devices/addrxlate.html"&gt;http://www.tldp.org/LDP/khg/HyperNews/get/devices/addrxlate.html&lt;/a&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;blockquote class="jive-quote"&gt;&lt;p style="margin:0;"&gt;shabaz wrote:&lt;/p&gt;&lt;p style="margin:0;"&gt;Or, is there any way for a Linux application to malloc at runtime and somehow query the MMU for the physical address? Is this even possible? I suspect, maybe this is not possible.. If it was, it would solve the problem because then I could pass that address to the PRU application. &lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin:0;"&gt;I&amp;#39;d suggest reading the article and then doing some more digging. It seems likely that the things you can get direct access to from userspace are not going to be useful in the way you&amp;#39;d think.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>