<?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>Scheduler + UART. Function getting optimized out?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/30597/scheduler-uart-function-getting-optimized-out</link><description>Hey All, 
 I&amp;#39;m using the nrf_drv_uart UARTE driver (NRF52832) communicating with an external device. The UART init code is executed using a function (call all_main in this instance) that is called by the scheduler to update the state of the app, initialize</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 14 Mar 2018 12:31:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/30597/scheduler-uart-function-getting-optimized-out" /><item><title>RE: Scheduler + UART. Function getting optimized out?</title><link>https://devzone.nordicsemi.com/thread/124364?ContentTypeID=1</link><pubDate>Wed, 14 Mar 2018 12:31:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca67dbff-c0a4-4bd7-ac97-689a210b5792</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The log buffer is typically processed in the main loop if you have deferred logging enabled:&lt;/p&gt;
&lt;p&gt;// Enter main loop.&lt;br /&gt; for (;;)&lt;br /&gt; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (NRF_LOG_PROCESS() == false)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; power_manage();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;Is it possible that the changes you made caused the process function to be called more often, or reduced the amount of log messages? Wondering if this issue could be attributed to buffer overrun. You could try to increase the log buffer size in sdk_config to see if that helps.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Buffer configuration:&lt;/p&gt;
&lt;p&gt;NRF_LOG_MSGPOOL_ELEMENT_SIZE&lt;/p&gt;
&lt;p&gt;NRF_LOG_MSGPOOL_ELEMENT_COUNT&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler + UART. Function getting optimized out?</title><link>https://devzone.nordicsemi.com/thread/124227?ContentTypeID=1</link><pubDate>Tue, 13 Mar 2018 17:13:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4017c816-59eb-49dd-bc7d-e352c21419f1</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/vibe"&gt;Vidar Berg&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s not as consistent as it was before. I think it was because of a tight main loop. As I&amp;#39;ve built out the code and the main loop as increased significantly I haven&amp;#39;t seen the issue nearly as much. I did get some pointers from Rigado about re-flashing the J-Link on the development board itself but it didn&amp;#39;t make much of a difference.&lt;/p&gt;
&lt;p&gt;For other people who may have a similar issue: we&amp;#39;re using the scheduler and basically queuing a &amp;quot;main loop&amp;quot; after every run. We have a state machine inside that main loop that changes the state of the app. When that loop is very small (little to no operations) it could very well lead to unexpected behavior. I remember having to physically time hitting the&amp;nbsp;reset pin while trying to reset the chip when I &amp;quot;accidentally&amp;quot; programmed the chip with an unintentional blocking loop in the main function.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler + UART. Function getting optimized out?</title><link>https://devzone.nordicsemi.com/thread/122386?ContentTypeID=1</link><pubDate>Thu, 01 Mar 2018 07:23:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7fb1bac5-5a7b-47eb-90e2-6b874b619c95</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I haven&amp;#39;t been able to reproduce this on my side yet. I used a MacBook Air with Jlink v.6.30e installed and the pre-compiled bootloader hex file from SDK 14.2.0.&lt;/p&gt;
&lt;p&gt;Do you see this consistently with mentioned workflow, or is it still&amp;nbsp;intermittent?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler + UART. Function getting optimized out?</title><link>https://devzone.nordicsemi.com/thread/122364?ContentTypeID=1</link><pubDate>Wed, 28 Feb 2018 20:23:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:493abd76-b411-4b6c-9ced-7f66f8d44d2d</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;As I&amp;#39;m trying to reproduce the issue it may be around using the nrfjprog command while the RTT session is open. I haven&amp;#39;t had an issue up until recently using this workflow.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I set up the RTT connection using JLinkEXE and JLinkRTTClient, then while still open I&amp;#39;m developing I&amp;#39;m doing the occasional:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;nrfjprog -s $(PROG_SER) -f nrf52 -e&lt;/span&gt;&lt;br /&gt;&lt;span&gt;nrfjprog -s $(PROG_SER) -f nrf52 --program $(OUTPUT_DIRECTORY)/$(TARGET_NAME).combined.hex --sectorerase&lt;/span&gt;&lt;br /&gt;&lt;span&gt;nrfjprog -s $(PROG_SER) -f nrf52 --reset&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This is correlated with my `make flash` command. I really only run it after&amp;nbsp;I&amp;#39;ve done my checks and made changes to be tested.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler + UART. Function getting optimized out?</title><link>https://devzone.nordicsemi.com/thread/122202?ContentTypeID=1</link><pubDate>Tue, 27 Feb 2018 21:48:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:008c2a74-a621-4cd7-8e5d-7f2708f23142</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Seems like the only way for me to get it back in a working state is to unplug everything, put my computer to sleep, start JLinkEXE + RTTClient, full erase the chip, program my code back. Let me know if it&amp;#39;s useful to post some logs, etc.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler + UART. Function getting optimized out?</title><link>https://devzone.nordicsemi.com/thread/122197?ContentTypeID=1</link><pubDate>Tue, 27 Feb 2018 20:01:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05730bdc-f5b9-43b1-9f95-9ce33468fa6c</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Paying more attention closely to the logs, the device sometimes does lock up. When I re-flash and connect no RTT.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;J-Link&amp;gt;g
J-Link&amp;gt;r
Reset delay: 0 ms
Reset type NORMAL: Resets core &amp;amp; peripherals via SYSRESETREQ &amp;amp; VECTRESET bit.
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.
J-Link&amp;gt;g
J-Link&amp;gt;
****** Error: Communication timed out: Requested 12 bytes, received 0 bytes !
make: *** [debug] Interrupt: 2
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is the command I&amp;#39;m using to start my RTT session:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;JLinkExe -device NRF52832_XXAA -speed 4000 -if SWD -SelectEmuBySN $(PROG_SER) -autoconnect 1&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler + UART. Function getting optimized out?</title><link>https://devzone.nordicsemi.com/thread/122185?ContentTypeID=1</link><pubDate>Tue, 27 Feb 2018 18:19:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3587f65-f582-4b6f-a443-63590329c8ce</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;I&amp;#39;m using GCC only. I&amp;#39;m using the secure bootloader example along with a BLE&amp;nbsp;example and UART0 on a NRF53832.&lt;/p&gt;
&lt;p&gt;I did get the RTT to come over my console.. this time.I have noticed if I put my machine to sleep, I don&amp;#39;t get anything over RTT until I re-flash the device. Even if I close JLinkExe and JlinkRTTClient and re-open them.&lt;/p&gt;
&lt;p&gt;I noticed that my code (using the scheduler) continues to run in the background even if there is no RTT (LEDs turn on, UART traffic, responds to button presses). I did enable both DEBUG on both projects to see if I can catch the error by stepping through.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler + UART. Function getting optimized out?</title><link>https://devzone.nordicsemi.com/thread/122148?ContentTypeID=1</link><pubDate>Tue, 27 Feb 2018 14:14:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3213fbda-1d76-48e9-81eb-089ab69e142d</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Jared,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Are you developing with pure GCC, or with Segger embedded studio? Code changes may lead to code asserts, which by default, triggers a SW reset, see &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.2.0/lib_error.html?cp=4_0_0_3_13"&gt;SDK error module&lt;/a&gt;. These kind of errors may be easier to catch if you can step through the code (with GDB or in an IDE). However, this doesn&amp;#39;t explain why there is no RTT output. Could you try the ble_app_uart example and see if you get RTT output in the debug terminal (\examples\ble_peripheral\ble_app_uart\pca10056\s140\ses)?&lt;/p&gt;
&lt;p&gt;Note: all BLE examples have support for RTT logging, just change&amp;nbsp;NRF_LOG_BACKEND_RTT_ENABLED to &amp;#39;1&amp;#39; and&amp;nbsp;NRF_LOG_BACKEND_UART_ENABLED to &amp;#39;0&amp;#39; in sdk_config.h before re-building the example.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler + UART. Function getting optimized out?</title><link>https://devzone.nordicsemi.com/thread/122035?ContentTypeID=1</link><pubDate>Tue, 27 Feb 2018 04:54:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ea8c75d-0669-4139-a059-7c637ae54169</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;I did, for sanity, take a completely different dev-board (PCA10056) and try a very simple example. Code is the same from this:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/27769/rtt-on-sdk-14-2-and-segger"&gt;devzone.nordicsemi.com/.../rtt-on-sdk-14-2-and-segger&lt;br /&gt;&lt;br /&gt;&lt;/a&gt;Still no RTT output.&lt;/p&gt;
&lt;p&gt;Looks like it&amp;#39;s more of a Segger issue at this point. Version 6.30e Have you guys seen this at all&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/vibe"&gt;Vidar Berg&lt;/a&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler + UART. Function getting optimized out?</title><link>https://devzone.nordicsemi.com/thread/122031?ContentTypeID=1</link><pubDate>Tue, 27 Feb 2018 04:30:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72fc781e-e4fa-410a-9302-30a7d49d143a</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hey Vidar,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I think I managed to get past the issue. I definitely have still been seeing this off and on using the same setup. The more I&amp;#39;ve been using it the more I&amp;#39;m thinking it&amp;#39;s some type of intermittent hardware problem. Sometimes the board doesn&amp;#39;t boot at all, sometimes it boots but no RTT. It sometimes responds to reset commands (though that may be attributed to the tight main loop I&amp;#39;m running). Do note that when things stop working, it&amp;#39;s not because I&amp;#39;m fiddling with the bootloader but rather making small changes to the main application (setting gpios, etc)&lt;/p&gt;
&lt;p&gt;Have you guys seen any issues like this? I&amp;#39;m running on a newer MBP 15&amp;quot;. The only other thing I could think of is it&amp;#39;s the software on my machine that is causing the problems when flashing and running RTT. At this point I&amp;#39;m about to lose my sanity because the board works sometimes and doesn&amp;#39;t other times.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for the help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler + UART. Function getting optimized out?</title><link>https://devzone.nordicsemi.com/thread/121264?ContentTypeID=1</link><pubDate>Mon, 19 Feb 2018 13:43:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a68af99-5f6a-4d11-83fa-784d28295577</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;suspect&amp;nbsp;the problem is in the bootloader since you are not reaching main in the app. I would suggest&amp;nbsp; to try the debug version of the bootloader&amp;nbsp;which&amp;nbsp; has debug logging over RTT enabled by default, then check the log to see if there are any error messages. Alternatively, try the app without the bootloader present and see if you get the same result.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Note: if you are programming a new app image with a programmer you also need to manually update the bootloader settings page so that the CRC check in&amp;nbsp;nrf_dfu_app_is_valid() doesn&amp;#39;t fail.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>