<?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>This shouldn&amp;#39;t break, is my BLE unstable?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/128858/this-shouldn-t-break-is-my-ble-unstable</link><description>I happened to write some debug log code that broke my Bluetooth. I don&amp;#39;t think it should be doing that. When I burrow into the logging, I don&amp;#39;t see why this difference is important. I haven&amp;#39;t been able to burrow into the BLE, so I don&amp;#39;t know what is going</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 03 Aug 2026 21:15:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/128858/this-shouldn-t-break-is-my-ble-unstable" /><item><title>RE: This shouldn't break, is my BLE unstable?</title><link>https://devzone.nordicsemi.com/thread/569830?ContentTypeID=1</link><pubDate>Mon, 03 Aug 2026 21:15:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9aa522f6-747e-4fe7-9746-a72b960a3eb2</guid><dc:creator>Michael0123456</dc:creator><description>&lt;p&gt;I&amp;#39;m sorry, this was dumb.&lt;br /&gt;&lt;br /&gt;I wasn&amp;#39;t the one who changed this code &amp;quot;buttons_leds_init(&amp;amp;erase_bonds)&amp;quot;.&amp;nbsp; I thought this was just a matter of removing hardware that exists in the development board and doesn&amp;#39;t exist in the hardware I&amp;#39;m using.&amp;nbsp; But now I see it is leaving erase_bonds uninitialized.&lt;br /&gt;&lt;br /&gt;Turbo_J had this exactly right but I didn&amp;#39;t read that paragraph carefully.&amp;nbsp; Sorry about that.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Sorry for the waste of time.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; bool erase_bonds;&lt;br /&gt;//&amp;nbsp; &amp;nbsp; int i;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);&lt;br /&gt;&amp;nbsp; &amp;nbsp; nrf_power_dcdcen_set(true);&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; // Initialize.&lt;br /&gt;&amp;nbsp; &amp;nbsp; log_init();&lt;br /&gt;&amp;nbsp; &amp;nbsp; timers_init();&lt;br /&gt;//&amp;nbsp; &amp;nbsp; buttons_leds_init(&amp;amp;erase_bonds);&lt;br /&gt;&amp;nbsp; &amp;nbsp; power_management_init();&lt;br /&gt;&amp;nbsp; &amp;nbsp; ble_stack_init();&lt;br /&gt;&amp;nbsp; &amp;nbsp; scheduler_init();&lt;br /&gt;&amp;nbsp; &amp;nbsp; gap_params_init();&lt;br /&gt;&amp;nbsp; &amp;nbsp; gatt_init();&lt;br /&gt;&amp;nbsp; &amp;nbsp; advertising_init();&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: This shouldn't break, is my BLE unstable?</title><link>https://devzone.nordicsemi.com/thread/569780?ContentTypeID=1</link><pubDate>Mon, 03 Aug 2026 07:46:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f7be962-e34c-46d6-b8a5-6bb85333b424</guid><dc:creator>Michael0123456</dc:creator><description>&lt;p&gt;These are some good ideas, but at this point I&amp;#39;m thinking it is just the way the advertising works (or doesn&amp;#39;t).&lt;br /&gt;&lt;br /&gt;I was trying to measure delays around the logging and found that at the exact point in the code I&amp;#39;m doing that logging, clocks are starting up.That in and of itself is weird because I would think a lot of stuff that the code is starting up is going to be using clocking, and so there ought to be a point where everybody knows the clocks are working, and not try to use them before they are.&amp;nbsp; But anyway, while I was doing that I noticed I was getting some different messages from the advertising code, depending on changes in the amount of delay from the logging.&lt;br /&gt;&lt;br /&gt;That seems wrong to me.&amp;nbsp; And it also seems wrong that the code can easily go into an advertising mode where Windows ignores it.&amp;nbsp; But obviously I didn&amp;#39;t have any say in how the advertising was written, and I don&amp;#39;t know anything about how to advertise &amp;quot;properly&amp;quot; for Windows.&amp;nbsp; (I admit, I was hoping to learn that from code in the SDK, but people in hell want ice water...)&lt;br /&gt;&lt;br /&gt;I did notice that advertising_start() runs right after the logging I&amp;#39;m doing.&amp;nbsp; So my strong suspicion is that one or more threads that are started because of the logging are affecting the way the advertising starts up.&amp;nbsp; (And probably shouldn&amp;#39;t, but, you know, bugs and stuff.&amp;nbsp; Like, is the clock running?&amp;nbsp; Sure, I think so, we need to create some known delays here, etc.)&lt;br /&gt;&lt;br /&gt;I certainly don&amp;#39;t suspect stack overflow or any other kind of corruption.&amp;nbsp; There are no error messages, no indication of a crash.&amp;nbsp; All the code I&amp;#39;m involved with at this point does what I expect without complaint (mostly a heartbeat into the log in the case where I can&amp;#39;t connect it, but I think the advertising changes to slow after a while like it normally does).&amp;nbsp; The only symptom I know of at this point is it doesn&amp;#39;t show up in Windows as a device to connect to.&amp;nbsp; And as I said, I think there are some changes to what the log says about the advertising.&amp;nbsp; But I&amp;#39;m just barely starting to look at that.&amp;nbsp; I think I read much of the Bluetooth is actually in the &amp;quot;Soft Device&amp;quot; code and I have no idea how to get logging from that.&amp;nbsp; (I generally can&amp;#39;t even find the code that might be running.)&amp;nbsp; The first thing I have to figure out is what it does when it works.&amp;nbsp; Then figure out why it is doing something different.&lt;br /&gt;&lt;br /&gt;I&amp;#39;m sure there is another issue with the advertising and connection because when I reboot the device (after having it connected, when it works) it shows in Windows as toggling back and forth between connected and paired.&amp;nbsp; (My assumption is it would either connect without any intervention, or it would wait for me to connect it, not crash in this way where I have to disconnect it and then reboot it again.)&amp;nbsp; So I know there is work to do there.&lt;br /&gt;&lt;br /&gt;You mentioned erase_bonds.&amp;nbsp; I don&amp;#39;t see any indication of a problem.&amp;nbsp; But I can only say I started from the SDK.&amp;nbsp; I don&amp;#39;t know what is correct other than that.&amp;nbsp; Anyway, there are zero compile time warnings.&amp;nbsp; And zero run time errors reported that seem to have anything to do with the issue.&amp;nbsp; (Like I say, sometimes it puts up a message if I halt it from the JLink.)&amp;nbsp; I admit, I don&amp;#39;t know what would be logged by this code at this point, since I haven&amp;#39;t seen any of the messages of the type we might hope for.&lt;br /&gt;&lt;br /&gt;Anyway, thanks for your time and thoughts.&lt;br /&gt;&lt;br /&gt;PS.&amp;nbsp; As far as the string constants.&amp;nbsp; Note that the whole point of the code I wrote initially was that there was one string and I logged it from within a loop.&amp;nbsp; If that by itself was a problem it would be a problem when I run the loop one time.&amp;nbsp; And it isn&amp;#39;t a problem then.&amp;nbsp; It is only a problem when I run the loop two or more times.&amp;nbsp; (Or, I should say, I only see the problem.&amp;nbsp; I can&amp;#39;t say that the code that is breaking is working reliably with any logging code including what I checked out of GitLab, just that I see it work regularly.)&amp;nbsp; Changing the loop count limit definitely doesn&amp;#39;t take any more space in any memory, stack or otherwise.&amp;nbsp; The &amp;quot;lazy&amp;quot; code just cuts and pastes the log statement with the string in it.&amp;nbsp; I suspect the compiler wouldn&amp;#39;t notice the string is reusable, so it WOULD exist in memory multiple times.&amp;nbsp; In later testing I also got a change in behavior by doing the lazy cut and paste, which brought me to this post.&amp;nbsp; Not to mention this code probably uses a tiny fraction of the stack available to it.&amp;nbsp; At least I hope so, since it isn&amp;#39;t really doing anything yet, and does as close to nothing as it ever would before it is connected.&lt;br /&gt;&lt;br /&gt;That said, it probably is a good explanation for how the changes would be changing the delays of the logging executing.&amp;nbsp; If the string is in ROM or RAM, for example.&amp;nbsp; (Although I kind of feel like given the code that is there, I should be able to insert any delay I want there and it should still work, no?)&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: This shouldn't break, is my BLE unstable?</title><link>https://devzone.nordicsemi.com/thread/569760?ContentTypeID=1</link><pubDate>Sun, 02 Aug 2026 07:22:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60b18376-78d7-40e6-83d1-704d19eef8f9</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;Its probably just a stack overflow.&lt;/p&gt;
&lt;p&gt;I believe all those string constants will end up on the stack - they are not declared&amp;nbsp;&lt;code&gt;const&lt;/code&gt;.&amp;nbsp; And the old SDK has zero stack overflow handling - overflowing stack can silently corrupt (overwrite) other data.&lt;/p&gt;
&lt;p&gt;There is a reason why we don&amp;#39;t recommend this for new designs.&lt;/p&gt;
&lt;p&gt;Another cause could be RTT. By default is set up to throw away log messages when they don&amp;#39;t fit in the log buffers, but you might have changed that in the past and forgot about it.&lt;/p&gt;
&lt;p&gt;Does the compiler moan about &lt;code&gt;erase_bonds&lt;/code&gt;? I don&amp;#39;t see an initial value for this variable. Bond erasing behaviour could be random across compiler runs here.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: This shouldn't break, is my BLE unstable?</title><link>https://devzone.nordicsemi.com/thread/569759?ContentTypeID=1</link><pubDate>Sun, 02 Aug 2026 00:46:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd7fcfa9-a5bb-44cb-bec4-db00ae743495</guid><dc:creator>Michael0123456</dc:creator><description>&lt;p&gt;Also, I&amp;#39;m fully aware that the answer might be, this is old code and not really supported.&amp;nbsp; But at least if that is the answer, I would like to see it.&amp;nbsp; And it would be good to hear that this problem has surely been fixed in later BLE code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: This shouldn't break, is my BLE unstable?</title><link>https://devzone.nordicsemi.com/thread/569758?ContentTypeID=1</link><pubDate>Sun, 02 Aug 2026 00:42:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:edade966-9b73-4fe7-97cb-29fc74ab14db</guid><dc:creator>Michael0123456</dc:creator><description>&lt;p&gt;The AI answer makes sense.&amp;nbsp; Sending a pointer (potentially to RAM) into the logging system can affect its behavior.&amp;nbsp; Sure.&amp;nbsp; But I&amp;#39;d like my code to be fixed, not just accidentally run.&lt;br /&gt;&lt;br /&gt;If there is a critical timing relationship among the initialization calls in my main, why is there no information about it in the initialization code?&amp;nbsp; How come I can log the string 8 times with the literal in the macro but not even twice with an actual pointer.&amp;nbsp; I CAN log it once with the regular pointer, so that by itself is apparently not a problem.&amp;nbsp; How much delay can be tolerated?&amp;nbsp; What if I have some other high priority initialization going on that causes delay?&amp;nbsp; (And the logging always works, it is the BLE that breaks.&amp;nbsp; That makes me think the problem is in the BLE code.)&lt;br /&gt;&lt;br /&gt;EDIT:&amp;nbsp; I forgot about the case where I&amp;#39;m logging with the regular pointer, but I make calls each on their own line, and it works.&amp;nbsp; Even if I log the line 8 times!&amp;nbsp; What I can&amp;#39;t do is log from within a loop (unless the loop only runs once).&amp;nbsp; It is a true mystery...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>