<?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>Turning on GCC optimizations prevents application from loading without debugger</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/43437/turning-on-gcc-optimizations-prevents-application-from-loading-without-debugger</link><description>Specs: SDK 14.1, nRF52832, S132 
 Env: Eclipse IDE, Linux 
 Hardware: Custom board 
 
 As the title explains, we&amp;#39;ve had no issues during development if the optimizations are set to -O0 -g. Once they are set to -O2, the program gets stuck somewhere during</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 14 Feb 2019 13:01:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/43437/turning-on-gcc-optimizations-prevents-application-from-loading-without-debugger" /><item><title>RE: Turning on GCC optimizations prevents application from loading without debugger</title><link>https://devzone.nordicsemi.com/thread/171139?ContentTypeID=1</link><pubDate>Thu, 14 Feb 2019 13:01:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69ca97f5-6254-4146-bf3a-7c7df49c5a1f</guid><dc:creator>senorwigglez</dc:creator><description>&lt;p&gt;Well I was able to figure this out by finally get breakpoints to work within the bootloader while debugging. The program seemed to freeze in the nrf_drv_clock_uninit function during the bootloader&amp;#39;s initialization in nrf_dfu_init. From here, I was able to find several users with the same problem and I guess SDK 14 doesn&amp;#39;t support the WDT and buttonless DFU. I guess SDK 15 does but we don&amp;#39;t want to transition to a new SDK after getting this one setup. &lt;/p&gt;
&lt;p&gt;The workaround suggested is to comment out the nrf_drv_clock_uninit function which seems to be working so far. What a pain.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Turning on GCC optimizations prevents application from loading without debugger</title><link>https://devzone.nordicsemi.com/thread/170981?ContentTypeID=1</link><pubDate>Wed, 13 Feb 2019 20:09:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85d30833-a1dd-43b2-9263-5262c24de0e7</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;that&amp;#39;s about it. &amp;nbsp;you can use the LED or some print to UART if debug is a most. Alternatively, you use this Eclipse based DFU project for SDK15.2. &amp;nbsp;You can put breakpoint anywhere. &amp;nbsp;&lt;a href="https://github.com/I-SYST/EHAL/tree/master/ARM/Nordic/nRF52/exemples/dfu"&gt;https://github.com/I-SYST/EHAL/tree/master/ARM/Nordic/nRF52/exemples/dfu&amp;nbsp;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Turning on GCC optimizations prevents application from loading without debugger</title><link>https://devzone.nordicsemi.com/thread/170808?ContentTypeID=1</link><pubDate>Wed, 13 Feb 2019 09:52:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48e19795-cb8c-4d96-9489-46195327b5d7</guid><dc:creator>senorwigglez</dc:creator><description>&lt;p&gt;I actually have debugging turned completely off in my main project and I only turned it on because I had no idea what was happening in the bootloader and I didn&amp;#39;t know how to debug it outside of the RTT Client. In my original project, I have pretty much anything with &amp;quot;LOG&amp;quot; in it disabled and I removed the log initializations from my main program. Is there anything else I would need to change?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Turning on GCC optimizations prevents application from loading without debugger</title><link>https://devzone.nordicsemi.com/thread/170796?ContentTypeID=1</link><pubDate>Wed, 13 Feb 2019 09:26:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b8d163e-d585-4351-a05b-e04a393609bd</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;Try to disable RTT when not debugging. &amp;nbsp;It is known to cause issues. &amp;nbsp;GCC optimization is not the cause.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Turning on GCC optimizations prevents application from loading without debugger</title><link>https://devzone.nordicsemi.com/thread/170780?ContentTypeID=1</link><pubDate>Wed, 13 Feb 2019 08:25:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d649d84c-2a4e-448a-bd4c-93698ac118a0</guid><dc:creator>senorwigglez</dc:creator><description>&lt;p&gt;Sure. What&amp;#39;s the easiest way for me to send you the code?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Turning on GCC optimizations prevents application from loading without debugger</title><link>https://devzone.nordicsemi.com/thread/170770?ContentTypeID=1</link><pubDate>Wed, 13 Feb 2019 08:07:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f570d684-f9b4-45b7-a2dd-716bfdd7852f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;is there any chance that you could help me reproduce this issue. I find it easy to narrow it down if I could reproduce it on my desk.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Turning on GCC optimizations prevents application from loading without debugger</title><link>https://devzone.nordicsemi.com/thread/170282?ContentTypeID=1</link><pubDate>Mon, 11 Feb 2019 09:10:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8cc0b398-83dd-4653-8fb2-69044e4ed7fb</guid><dc:creator>senorwigglez</dc:creator><description>&lt;p&gt;You are right I evidently was reading false information concerning the flash location. I&amp;#39;ve left my program at 0x23000 and I&amp;#39;m still experiencing the same issue. Is there a way to step through the debugger like a normal program while debugging?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Turning on GCC optimizations prevents application from loading without debugger</title><link>https://devzone.nordicsemi.com/thread/170278?ContentTypeID=1</link><pubDate>Mon, 11 Feb 2019 09:03:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d49b47b8-2462-45c6-bb57-071b86625e24</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="senorwigglez"]According to the documentation I could find, the S132 softdevice should occupy 0x01000 - 0x20000.[/quote]
&lt;p&gt;&amp;nbsp;Which documentation says the above? Can you please redirect me to that info. I do not think that is correct. You should look into the sizes of the softdevice in its release document.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Turning on GCC optimizations prevents application from loading without debugger</title><link>https://devzone.nordicsemi.com/thread/170125?ContentTypeID=1</link><pubDate>Fri, 08 Feb 2019 12:56:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:886019ff-1867-4bb0-b36c-962f24192abf</guid><dc:creator>senorwigglez</dc:creator><description>&lt;p&gt;I&amp;#39;m not sure either honestly. I received the following error without that flag:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;../../../../../components/libraries/bootloader/nrf_bootloader_app_start_asm.c: In function &amp;#39;nrf_bootloader_app_start_impl&amp;#39;:
../../../../../components/libraries/bootloader/nrf_bootloader_app_start_asm.c:129:1: error: r7 cannot be used in asm here
 }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But that&amp;#39;s neither here nor there at this point. I read that the memory locations for the bootloader needed to be modified slightly because the bootloader binary would be too big to fit in it&amp;#39;s originally allocated memory space so I just arbitrarily made it bigger based on another post I saw. Here are the current memory configurations (that don&amp;#39;t work):&lt;/p&gt;
&lt;p&gt;Bootloader:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;  FLASH (rx) : ORIGIN = 0x78000, LENGTH = 0x6000
  RAM (rwx) :  ORIGIN = 0x20002830, LENGTH = 0xd7d0
  
  bootloader_settings_page (r) : ORIGIN = 0x0007F000, LENGTH = 0x1000
  uicr_bootloader_start_address (r) : ORIGIN = 0x10001014, LENGTH = 0x4
  mbr_params_page (r) : ORIGIN = 0x0007E000, LENGTH = 0x1000
  uicr_mbr_params_page (r) : ORIGIN = 0x10001018, LENGTH = 0x4&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Application:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;  FLASH (rx) : ORIGIN = 0x23000, LENGTH = 0x55000
  RAM (rwx) : ORIGIN = 0x20004300, LENGTH = 0xBD00&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The softdevice is S132. According to the documentation I could find, the S132 softdevice should occupy 0x01000 - 0x20000. This seems to contradict what the linker script sets for the secure ble bootloader example sets (0x23000 as shown above). I tried setting this back to 0x20000 but I get a merge conflict with mergehex so clearly they are overlapping.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Turning on GCC optimizations prevents application from loading without debugger</title><link>https://devzone.nordicsemi.com/thread/170092?ContentTypeID=1</link><pubDate>Fri, 08 Feb 2019 10:56:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e30a3600-dcf4-48d7-8330-d8455b53a85b</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Andrew,&lt;/p&gt;
[quote user=""] needed to add &lt;strong&gt;-fomit-frame-pointer&lt;/strong&gt; otherwise the linker[/quote]
&lt;p&gt;I did not realize that a compiler will force you to set the omit-frame-pointer option. In my head, it was the other way around, that you can set it, but the compiler will still decide to use and not use frame pointer allocations for functions necessary. I am not able to understand why a linker will force you to set this.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;FLASH (rx) : ORIGIN = 0x53000, LENGTH = 0x26000&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So the problem is not with the set of instructions produced but the data fetched. So there is high chance that your earlier flash settings were in conflict with some other module using the flash address between 0x78000 and (0x78000+LENGTH).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If it was a code overlap due to two linker script conflicts&amp;nbsp; (having memory segments too close to each other) then you should have seen problem when not using optimization, which would result in code size being a bit larger and possibly overflowing into next memory segment.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would recommend to check all your memory segments in various linker scripts and also see if any part of your code has hardcoded memory address to the flash size in 0X78000 to 0x78000+LENGTH.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Turning on GCC optimizations prevents application from loading without debugger</title><link>https://devzone.nordicsemi.com/thread/169917?ContentTypeID=1</link><pubDate>Thu, 07 Feb 2019 12:35:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99096095-9b23-47a7-86c9-f7bdf6769cc2</guid><dc:creator>senorwigglez</dc:creator><description>&lt;p&gt;I am combining the bootloader, the bootloader settings, the soft device, and the application into a single hex file and then programming that file.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;nrfutil settings generate --family NRF52 --application $(OUT_FILE) --application-version 1 --bootloader-version 1 --bl-settings-version 1 ../bin/bootloader_settings.hex&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I am generating the settings using the above command in a Makefile. The exact same commands are run for this whole process independent of the optimization level.&lt;/p&gt;
&lt;p&gt;1. Program is compiled using make&lt;/p&gt;
&lt;p&gt;2. Bootloader settings are generated&lt;/p&gt;
&lt;p&gt;3. The four files named above are combined into one hex file using mergehex&lt;/p&gt;
&lt;p&gt;4. Device flash is erased using nrfjprog --eraseall&lt;/p&gt;
&lt;p&gt;5. Hex file is programmed and device is reset&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Turning on GCC optimizations prevents application from loading without debugger</title><link>https://devzone.nordicsemi.com/thread/169882?ContentTypeID=1</link><pubDate>Thu, 07 Feb 2019 10:21:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9e769ee-961c-41fe-8acf-f6da5cf85d4c</guid><dc:creator>Turbo J</dc:creator><description>[quote userid="67878" url="~/f/nordic-q-a/43437/turning-on-gcc-optimizations-prevents-application-from-loading-without-debugger"]Once I hit pause, I&amp;#39;m in a non-defined section of the program[/quote]
&lt;p&gt;Nope, you are still in the bootloader. Note the rather high address, which is bigger than 0x78000.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Which explains yor problem: The NRF bootloaders calculate the checksum of the flashed program, and refuse to start it should that be different to the saved settings.&lt;/p&gt;
&lt;p&gt;Workarounds:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Flash the app with the bootloader or&lt;/li&gt;
&lt;li&gt;Flash the correctly calculated checksum into the bootloader settings page&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>