<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: Maple r5 flash memory overflow with only 50KB load</title>
		<link>http://forums.leaflabs.com/topic.php?id=995</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:21:31 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=995" rel="self" type="application/rss+xml" />

		<item>
			<title>polpla on "Maple r5 flash memory overflow with only 50KB load"</title>
			<link>http://forums.leaflabs.com/topic.php?id=995#post-6072</link>
			<pubDate>Wed, 24 Aug 2011 12:49:27 +0000</pubDate>
			<dc:creator>polpla</dc:creator>
			<guid isPermaLink="false">6072@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Yes, I have been reading more on the topic of writing on Flash memory and it is discouraged because it will eventually destroy it. Apparently flash memory has a life of around 100K writes and it becomes unusable after that. That is, if I was buffering images there for 30 minutes I will need to replace the micro. We don't want that to happen ;) so, I understand why it is discouraged (and I subscribe).&#60;/p&#62;
&#60;p&#62;Regarding your question, I am not using an LCD but an OLED display. The model that I am using is the NEWTECH NL128128C that I bought from Sparkfun. This display does not have extra GRAM, it only has 128x128x18bits which is the memory necessary for the current frame.&#60;/p&#62;
&#60;p&#62;However, I did further research and there are three approaches to work around this memory problem with displays:&#60;/p&#62;
&#60;p&#62;1) The Maple RET6 offers 64K of ram. That should be enough to store at least one buffer in my case (if you work really hard on optimization you might be able to even squeeze two).&#60;/p&#62;
&#60;p&#62;2) Work with a color pallet with a subset of the colors. The specific screen that I am using can do color up to 18bit color (6bits per color, total of 262K colors). If you reduce the amount of bits to encode color the required size for the buffer will consequently be smaller so you might be able to fit the buffer in the 20K ram of the regular Maple. For example, if you encode color in 8bits (3red,3green,2blue) you will only need 128x128 (16KB). You can also create a look up table if you want to configure a pallet of colors (make sure to hard code it so that it gets stored into flash).&#60;/p&#62;
&#60;p&#62;3) Finally there is the bufferless approach. This technique requires a higher programming expertise and consist on keeping track of all the different elements or &#34;sprites&#34; on your image and calculate each frame on the fly. You want to give each sprite coordinates, size and shape as well as depth (to solve collisions).&#60;/p&#62;
&#60;p&#62;Since I am not willing to sacrifice color I am going to try both 1 and 3 (maybe even a combination of both) and see how it goes. I'll post here as soon as I make some progress
&#60;/p&#62;</description>
		</item>
		<item>
			<title>robodude666 on "Maple r5 flash memory overflow with only 50KB load"</title>
			<link>http://forums.leaflabs.com/topic.php?id=995#post-6064</link>
			<pubDate>Tue, 23 Aug 2011 20:39:28 +0000</pubDate>
			<dc:creator>robodude666</dc:creator>
			<guid isPermaLink="false">6064@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;The best I can do is direct you to two pages:&#60;/p&#62;
&#60;p&#62;ST's &#60;a href=&#34;http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/PROGRAMMING_MANUAL/CD00283419.pdf&#34;&#62;PM0075 Programming Manual - STM32F10xxx Flash memory controllers&#60;/a&#62; and a thread on the forums: &#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=146&#34;&#62;Storing data in Maple's flash memory&#60;/a&#62;; specifically, the third post by poslathian. Like poslathian said, it's discouraged so use at your own risk.&#60;/p&#62;
&#60;p&#62;Which LCD are you using? Most LCDs have their own GRAM, with the ability to write directly to the GRAM. If your program is written correctly, you won't have to buffer a single thing.&#60;/p&#62;
&#60;p&#62;I've been playing around with a number of LCDs, and while I originally started with a goal of buffering the LCD locally on the MCU I realized it would become to problematic of a solution and I found other ways of doing it.&#60;/p&#62;
&#60;p&#62;-robodude666
&#60;/p&#62;</description>
		</item>
		<item>
			<title>polpla on "Maple r5 flash memory overflow with only 50KB load"</title>
			<link>http://forums.leaflabs.com/topic.php?id=995#post-6062</link>
			<pubDate>Tue, 23 Aug 2011 14:57:32 +0000</pubDate>
			<dc:creator>polpla</dc:creator>
			<guid isPermaLink="false">6062@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;In the meantime, although it is highly discouraged, could you explain how to write variables to flash memory?&#60;/p&#62;
&#60;p&#62;Thanks again!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>polpla on "Maple r5 flash memory overflow with only 50KB load"</title>
			<link>http://forums.leaflabs.com/topic.php?id=995#post-6061</link>
			<pubDate>Tue, 23 Aug 2011 14:26:53 +0000</pubDate>
			<dc:creator>polpla</dc:creator>
			<guid isPermaLink="false">6061@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thanks robodude666!&#60;/p&#62;
&#60;p&#62;That clarifies things a lot. I guess I'll have to create my own board to interface with the screen and make sure I pick up a micro that has enough SRAM to store my buffer.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>robodude666 on "Maple r5 flash memory overflow with only 50KB load"</title>
			<link>http://forums.leaflabs.com/topic.php?id=995#post-6056</link>
			<pubDate>Tue, 23 Aug 2011 13:03:54 +0000</pubDate>
			<dc:creator>robodude666</dc:creator>
			<guid isPermaLink="false">6056@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;The Maple has 120kB of FLASH memory, and 20kB of RAM.&#60;/p&#62;
&#60;p&#62;The application you are writing is stored in FLASH. Your data, such as variables, arrays, etc. is stored in RAM. The array you've created is statically allocated and stored in RAM memory. Because it is 49kB, and larger than the 20kB RAM you have available it cannot be allocated and therefore you receive an overflow in the ram region.&#60;/p&#62;
&#60;p&#62;The two options you see in the MapleIDE, Flash and Ram modes, control where the program gets uploaded to. If you select Flash, it will be written to the 120kB FLASH memory and will be present on bootup (it won't be lost when powered down). If you select Ram, it will be written to the 20kB RAM memory and will be lost upon disconnecting power however it will run faster.&#60;/p&#62;
&#60;p&#62;If you need to store a large array of read-only data, you can mark an array as __FLASH__ and it will be written to FLASH memory. This is similar to the Arduino's PROGMEM. For example:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;static const uint8 mybuffer[10] __FLASH__ = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Will create an 8-byte array in FLASH memory that is READ ONLY. There is a way to write to FLASH memory during run time, but it's strongly advised against.&#60;/p&#62;
&#60;p&#62;If you are trying to buffer an image for an LCD, you will have to use external SRAM and manually interface with it. This can be done via a Parallel interface for best performance, or an SPI RAM/FLASH module.&#60;/p&#62;
&#60;p&#62;Alternatively, the yet-to-be-released Maple Native features a higher-end STM32 MCU that has an onboard FSMC with a MB or so of external SRAM.&#60;/p&#62;
&#60;p&#62;-robodude666
&#60;/p&#62;</description>
		</item>
		<item>
			<title>polpla on "Maple r5 flash memory overflow with only 50KB load"</title>
			<link>http://forums.leaflabs.com/topic.php?id=995#post-6053</link>
			<pubDate>Tue, 23 Aug 2011 11:17:52 +0000</pubDate>
			<dc:creator>polpla</dc:creator>
			<guid isPermaLink="false">6053@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi!&#60;/p&#62;
&#60;p&#62;I am using IDE version 0.11 on OSX with a Maple r5 and I am having memory problems compiling a code for addressing a lcd display. I was trying to buffer the images before displaying using a byte array. The screen is 128x128 and it stores color in 3 bytes per pixel. When I try to compile my code (with device r3+ flash selected) I get the following error:&#60;/p&#62;
&#60;p&#62;-------------------------&#60;br /&#62;
elf section &#60;code&#62;.bss&#38;#39; will not fit in region&#60;/code&#62;ram'&#60;br /&#62;
/Applications/MapleIDE.app/Contents/Resources/Java/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/bin/ld: region `ram' overflowed by 33784 bytes&#60;br /&#62;
-------------------------&#60;/p&#62;
&#60;p&#62;To make sure that it was independent of my code I created an simple sketch where I only declare the array and use it once. The code looks like this:&#60;/p&#62;
&#60;p&#62;-------------------------&#60;br /&#62;
byte buffer[128][128][3];&#60;/p&#62;
&#60;p&#62;void setup(){&#60;br /&#62;
  buffer[0][0][0] = 0x32;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;void loop(){}&#60;br /&#62;
-------------------------&#60;/p&#62;
&#60;p&#62;I got the same error:&#60;/p&#62;
&#60;p&#62;-------------------------&#60;br /&#62;
elf section &#60;code&#62;.bss&#38;#39; will not fit in region&#60;/code&#62;ram'&#60;br /&#62;
/Applications/MapleIDE.app/Contents/Resources/Java/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/bin/ld: region `ram' overflowed by 33768 bytes&#60;/p&#62;
&#60;p&#62;collect2: ld returned 1 exit status&#60;br /&#62;
-------------------------&#60;/p&#62;
&#60;p&#62;If my math is right:&#60;br /&#62;
128x128x3 = 48.952bytes ~ 49Kbytes&#60;/p&#62;
&#60;p&#62;The documentation says that the Maple r5 should support out of 120KB (for what I have read in other posts 108KB because of the bootloader). However, it seems that it is not able to fit 49KB.&#60;/p&#62;
&#60;p&#62;One of the things that does not look right to me is that the error talks about 'ram' when I have the &#34;Maple Rev 3+ Flash&#34; option selected in my tools menu. If there is overflow it should be of flash memory. Of course, 49KB don't fit on the ram (which is 20KB minus bootloader overhead) but they should fit in 108KB.  &#60;/p&#62;
&#60;p&#62;Am I doing something wrong? Can someone help with this?&#60;/p&#62;
&#60;p&#62;Thanks in advance!!
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
