<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.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>High RAM Application Questions</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/8588/high-ram-application-questions</link><description>According to the *.map file the .bss (RAM) usage for my Application is 0x16b8 or 5816 bytes. This is obviously a very high RAM Application, likely due to the abundance of app_timers I use. I am using SDK6.1 and SD7.1. I want to make sure I&amp;#39;m not going</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 12 Aug 2015 04:06:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/8588/high-ram-application-questions" /><item><title>RE: High RAM Application Questions</title><link>https://devzone.nordicsemi.com/thread/31432?ContentTypeID=1</link><pubDate>Wed, 12 Aug 2015 04:06:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4b4a81d-84ec-4265-9ffe-75ebd470ea12</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;I think I may have found the issue.  Perhaps some insight from Nordic could help.    My application uses the app_button module which internally uses the GPIOTE for timing.    I also use GPIOTE for PWM generation.   I just noticed that my application had APP_GPIOTE_MAX_USERS  2&lt;/p&gt;
&lt;p&gt;I believe that under a specific race condition a button push and buzzer tone attempting to generate at the same time may have caused the odd Lock-up issue.   If I think I may have found the issue.  Perhaps some insight from Nordic could help.    My application uses the app_button module which internally uses the GPIOTE for timing.    I also use GPIOTE for PWM generation.   I just noticed that my application had APP_GPIOTE_MAX_USERS  2&lt;/p&gt;
&lt;p&gt;I believe that under a specific race condition a button push and buzzer tone attempting to generate at the same time may have caused the odd Lock-up issue.  Does this sound legit?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High RAM Application Questions</title><link>https://devzone.nordicsemi.com/thread/31431?ContentTypeID=1</link><pubDate>Mon, 10 Aug 2015 05:42:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5311267-e225-472a-bc11-14bada41eae2</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;Hi RK,&lt;/p&gt;
&lt;p&gt;Currently I ignore the error NRF_ERROR_NO_MEM and move-on, effectively skipping the event_put.  I currently don&amp;#39;t drop events.  I&amp;#39;ll have to look more closely at this.  Perhaps there is something there.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m more concerned that an app_timer timeout handler cannot execute due to the FULL queue.  This is a condition I can&amp;#39;t trap.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High RAM Application Questions</title><link>https://devzone.nordicsemi.com/thread/31430?ContentTypeID=1</link><pubDate>Mon, 10 Aug 2015 03:14:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46554775-76e3-4eb1-b134-c38dfc932872</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;That&amp;#39;s odd - I can connect to running boards without a power cycle, it connects then I can halt. I&amp;#39;ll try one over battery power later and check it&amp;#39;s true in that case as well. There are other options for getting debug info later but they require manually erasing a flash page, dumping the registers and the contents of the stack page, you can try that, it&amp;#39;s 30-40 lines of assembler. Then you pull the data off and laboriously cull through it.&lt;/p&gt;
&lt;p&gt;So you think that it&amp;#39;s the scheduler queue filling up. What do you do if app_sched_event_put() returns NRF_ERROR_NO_MEM? Do you use APP_ERR_CHECK() on it and go to the error handler? can you drop events if you can&amp;#39;t queue them, can you at least make it light a different LED so you know this is the case?&lt;/p&gt;
&lt;p&gt;A quick look at the code for app_timer says it only calls the scheduler on timeout events.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High RAM Application Questions</title><link>https://devzone.nordicsemi.com/thread/31429?ContentTypeID=1</link><pubDate>Mon, 10 Aug 2015 02:56:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5042fc60-4e0c-41d1-a7aa-ff45128dcb69</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;Unforuntely we cannot get stack traces as there is a power-cycle uponing access the SWD pins.   I believe the issue may again be related to the Scheduler.  We use BLE event to trigger scheduler events.  These events start app_timers.   It is likely a condition where several BLE events (Stack uses the scheduler as well)  causing several scheduler events  which somehow fills up the Scheduler Queue and then odd things happen.   I don&amp;#39;t really know how to design around this.  I cannot increase the Scheduler Queue anymore without RAM overflows.&lt;/p&gt;
&lt;p&gt;When using app_timers with the scheduler,  do app_timer_start and app_timer_stop use the scheduler as well?   or just the timeout_handler?    Trying to track down how I could be filling up the queue.&lt;/p&gt;
&lt;p&gt;Thanks for the help guys.&lt;/p&gt;
&lt;p&gt;-DC&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High RAM Application Questions</title><link>https://devzone.nordicsemi.com/thread/31428?ContentTypeID=1</link><pubDate>Sat, 08 Aug 2015 03:07:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a9e46ac-ee38-4ae5-ad14-ce707b157996</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;One of those hard debugging situations, it only breaks when you&amp;#39;re not looking. What errors cause the LED to turn on and the next push to reset? APP_ERROR_CHECK(), hardfault, all of the above? That might help fractionally to narrow it down, but you probably have lots of app error checks so it may not.&lt;/p&gt;
&lt;p&gt;You can run release firmware on a board and still get a debugger on it when it fails. That at least gives you a stack trace and there&amp;#39;s enough information in the original binary file to figure out where you were, especially if you&amp;#39;ve built release code (ie optimized) with debug info.&lt;/p&gt;
&lt;p&gt;You need some kind of post-mortem when the thing fails, somehow, it&amp;#39;s the only way.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High RAM Application Questions</title><link>https://devzone.nordicsemi.com/thread/31427?ContentTypeID=1</link><pubDate>Sat, 08 Aug 2015 02:18:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cab3f322-f2c1-4b9d-886e-966de6afb5e5</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;You absolutely correct, I was speaking in terms of external perception.   When this happens a GPIO does raise (red LED turns on).  Upon on the next button push the device restarts.&lt;/p&gt;
&lt;p&gt;We can&amp;#39;t get this to occur on the bench, have only seen it in field tests with release firmware.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High RAM Application Questions</title><link>https://devzone.nordicsemi.com/thread/31426?ContentTypeID=1</link><pubDate>Sat, 08 Aug 2015 02:09:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a10afd1-a1f2-4dc0-93b1-5f7921d70b37</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;CPUs don&amp;#39;t freeze, they get in loops, they go to fault handlers when they detect error conditions, and they are very good at finding seemingly impossible race conditions, but they don&amp;#39;t just stop working. Your CPU is running and it&amp;#39;s doing something even though your board is unresponsive. What does your hardfault handler do, just loop, how about your app error handler, does it turn on some LEDs or raise a GPIO line you can check externally? When the device becomes unresponsive can you get a debugger attached to it and find out where it is?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High RAM Application Questions</title><link>https://devzone.nordicsemi.com/thread/31425?ContentTypeID=1</link><pubDate>Sat, 08 Aug 2015 01:28:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00cec9bd-b867-4ab9-a44f-b8ca189af1ed</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;We have seen (seemly at random)  when I go to press the button, the chip seems to grind to a halt.  This can happen at any point.  Within 2hrs of programming or +3weeks.  I had suspected that something to do with the app_button module was causing this.  Since the Button Module uses the scheduler, along with App_timers and SoftDevice.  Could these 3 items all using the Scheduler at the same time potentially cause a CPU freeze?&lt;/p&gt;
&lt;p&gt;I have recently bumped up the SCHED_QUEUE_SIZE to 30 (from 18).     Is there a rule of thumb for setting this?   We have 20 app_timers, 2 other misc app_sched_event_put handlers, app_button and the SoftDevice.   Thanks for the help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High RAM Application Questions</title><link>https://devzone.nordicsemi.com/thread/31422?ContentTypeID=1</link><pubDate>Fri, 07 Aug 2015 07:12:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e535eba-1c8d-4fb8-8159-c9709bb83d3b</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;I have seen this blog, thought using Eclipse it is not quite as useful.   I do not have any malloc() is my code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High RAM Application Questions</title><link>https://devzone.nordicsemi.com/thread/31420?ContentTypeID=1</link><pubDate>Fri, 07 Aug 2015 06:28:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c5efd73-6d2d-4a20-b260-7b04505f91b9</guid><dc:creator>&amp;#216;yvind Karlsen</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Have you seen the RAM reduction measures described in &lt;a href="https://devzone.nordicsemi.com/blogs/723/rom-and-ram-management/"&gt;this blog&lt;/a&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High RAM Application Questions</title><link>https://devzone.nordicsemi.com/thread/31424?ContentTypeID=1</link><pubDate>Fri, 07 Aug 2015 02:59:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb76fe98-0dfc-40fe-bdf7-db0fa8cc3417</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;if you look in the .ld file there should be a check that ram doesn&amp;#39;t overflow into stack. As long as you pass that, and your stack stays within limits during runtime, you&amp;#39;re good to go. That&amp;#39;s one of the benefits of having static RAM allocation instead of using heap/malloc() etc, if it links, it runs.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High RAM Application Questions</title><link>https://devzone.nordicsemi.com/thread/31423?ContentTypeID=1</link><pubDate>Fri, 07 Aug 2015 02:53:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c6f34d8-3e96-43b2-82aa-64ecb42021ae</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;My question was specifically about run-time RAM usage.  The project compiles, links and programs fine.  But since I&amp;#39;ve designedd such a RAM heavy application I was to make sure I have enough headroom for whatever is happening during run-time.   I&amp;#39;ve set my APP_TIMER_MAX to 4 above what I actually use,  and set the queue to 2 more than the total number of app_timers,  just to be sure.&lt;/p&gt;
&lt;p&gt;More than anything I just want to make sure there isn&amp;#39;t some consideration i should be making when using so many app_timers (besides the obvious ones like settings the max, and using the scheduler).   Thanks for the reply RK&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High RAM Application Questions</title><link>https://devzone.nordicsemi.com/thread/31421?ContentTypeID=1</link><pubDate>Fri, 07 Aug 2015 01:30:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85fe7a77-cdf0-4b6e-96c7-3eec36bb06a3</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Don&amp;#39;t totally understand the question. If the app links without error and fits in the available space, it works, the link script has a check for this. The startup file is entirely generic and just copies things from one place to another, it doesn&amp;#39;t matter if it copies 1 byte, 10 bytes or 16Kb.&lt;/p&gt;
&lt;p&gt;What issues were you concerned about, perhaps I&amp;#39;m just missing the point?&lt;/p&gt;
&lt;p&gt;That is a lot of RAM usage, the map file should tell you what it&amp;#39;s all used for, although they&amp;#39;re annoyingly tricky to read, you might want to confirm to yourself that it is app timer usage (they use that much??) and not something else.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>