<?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>Advertising failed to start (err -120)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/114723/advertising-failed-to-start-err--120</link><description>I am running into an issue (title), where I am attempting to switch the advertising interval to a slower interval after a set period of advertising in order to save power. Advertising is being successfully started the first time, I then start a timer</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 04 Oct 2024 21:58:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/114723/advertising-failed-to-start-err--120" /><item><title>RE: Advertising failed to start (err -120)</title><link>https://devzone.nordicsemi.com/thread/505052?ContentTypeID=1</link><pubDate>Fri, 04 Oct 2024 21:58:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:047063ad-d603-49a5-a9d7-9893c1001aba</guid><dc:creator>dlewis</dc:creator><description>&lt;p&gt;That makes sense, thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising failed to start (err -120)</title><link>https://devzone.nordicsemi.com/thread/504835?ContentTypeID=1</link><pubDate>Thu, 03 Oct 2024 13:08:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2a3bbef-a127-4641-9a2b-ccd1e898a71f</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;It has to do with interrupt priorities. The error message is a bit misleading, and difficult to understand, but the issue is that stopping and starting the advertisements are dependent on interrupts from the SoftDevice controller. When it is trying to do this, while already being in a timeout interrupt, you will enter a deadlock. The SoftDevice controller can&amp;#39;t tell the application that it has stopped, and the application is waiting for it to stop.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So what we are doing with the work handler is basically to queue up the advertising actions (stop -&amp;gt; start), so that it can execute outside the interrupt when you are done in the current interrupt (the timeout handler).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Hope that made some sense.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising failed to start (err -120)</title><link>https://devzone.nordicsemi.com/thread/504735?ContentTypeID=1</link><pubDate>Wed, 02 Oct 2024 16:22:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ff1e346-b569-46e3-98f3-de06818b4e7d</guid><dc:creator>dlewis</dc:creator><description>&lt;p&gt;Hi Edvin, thanks for the suggestion, it appears to fix the issue in both the example code and my custom application! Do you know why this would work, but why when I tried moving the advertise stop and start functions to a thread, that did not work?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising failed to start (err -120)</title><link>https://devzone.nordicsemi.com/thread/504555?ContentTypeID=1</link><pubDate>Tue, 01 Oct 2024 13:59:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f322f6b-64d1-402f-ba74-fdb1ed513400</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;So I managed to reproduce the issue you were seeing on the ble_adv_bug_test.zip:&lt;/p&gt;
&lt;p&gt;Please try the attached app_ble.c:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/app_5F00_ble.c"&gt;devzone.nordicsemi.com/.../app_5F00_ble.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The only difference is that I offloaded the actual starting stopping of the advertisement to a k_work instance, so that it doesn&amp;#39;t try to do it in the interrupt itself, but leaves the interrupt, and the work handler will take care of it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;With the other application I struggled to make the compiler include my custom board folder. It showed as an option under custom boards in VS code, but the board was still not found when building, and not included in my list of available boards. I guess I have not played around with custom boards that much.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The advertising stopping and re-starting looks similar in your original question, so I guess the issue could be the same.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The usage of k_work and k_timer is described here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/kernel/services/timing/timers.html#using_a_timer_expiry_function"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/kernel/services/timing/timers.html#using_a_timer_expiry_function&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Give it a go, and let me know if it doesn&amp;#39;t work.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising failed to start (err -120)</title><link>https://devzone.nordicsemi.com/thread/504443?ContentTypeID=1</link><pubDate>Mon, 30 Sep 2024 21:27:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d0ae361-03c5-44b0-a2bb-74bc4d9b6fae</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am terribly sorry for the late reply. I had to work on some non-DevZone related things the last week and a half. I tried to run through my tickets today, but I wasn&amp;#39;t able to cover them all. I promise I will give your application another look tomorrow.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am sorry for the inconvenience.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising failed to start (err -120)</title><link>https://devzone.nordicsemi.com/thread/503631?ContentTypeID=1</link><pubDate>Tue, 24 Sep 2024 18:14:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20c80aaa-4ae8-40fa-a9f4-d9818c957343</guid><dc:creator>dlewis</dc:creator><description>&lt;p&gt;Hi, do you have any updates on your end? I have been trying to debug on my end over the last week and still have not made any progress.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising failed to start (err -120)</title><link>https://devzone.nordicsemi.com/thread/502992?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2024 18:09:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:102a74ae-0f77-4b43-a8c2-a8cb2495a2df</guid><dc:creator>dlewis</dc:creator><description>&lt;p&gt;Attached below is a zip of the ble lbs example with my ported problematic code. A fault still occurs at a similar spot as with my custom project, but the error is different in this case.&lt;br /&gt;The print output looks as follows:&lt;/p&gt;
&lt;p&gt;Advertising Started&lt;br /&gt;slow_adv_timer EXPIRED &lt;br /&gt;ASSERTION FAIL @ WEST_TOPDIR/zephyr/kernel/sem.c:136&lt;br /&gt;E: r0/a1: 0x00000004 r1/a2: 0x00000088 r2/a3: 0x00000001&lt;br /&gt;E: r3/a4: 0x0001be65 r12/ip: 0x00000000 r14/lr: 0x000202f7&lt;br /&gt;E: xpsr: 0x61000021&lt;br /&gt;E: Faulting instruction address (r15/pc): 0x00023a7c&lt;br /&gt;E: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0&lt;br /&gt;E: Fault during interrupt handling&lt;/p&gt;
&lt;p&gt;E: Current thread: 0x20002558 (unknown)&lt;br /&gt;&lt;br /&gt;This time, instruction address 0x000023a7c correlates to assert_post_action() as opposed to&amp;nbsp;&lt;span&gt;sys_dlist_remove() from my custom project.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ble_5F00_adv_5F00_bug_5F00_test.zip"&gt;devzone.nordicsemi.com/.../ble_5F00_adv_5F00_bug_5F00_test.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising failed to start (err -120)</title><link>https://devzone.nordicsemi.com/thread/502976?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2024 15:19:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28724da4-641e-4236-8830-c6772d5bea8b</guid><dc:creator>dlewis</dc:creator><description>&lt;p&gt;What part of the custom board setup isn&amp;#39;t working for you? The project was developed with an nRF52dk using the custom board files as the only difference between the custom hardware and the DK are the button and LED pins which should not be relevant for this bug.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;I can work on putting the problem portion of the code into one of the examples and make sure the issue is replicable before sending it over.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising failed to start (err -120)</title><link>https://devzone.nordicsemi.com/thread/502908?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2024 10:33:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e73ff7e5-a10e-4c8c-b564-76ac89439e43</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am strugglnig a bit with the custom board setup. Is it possible to send an application that I can build for the board nrf52dk_nrf52832? If it complains a lot about peripherals and gpios, it should be possible to either add it to the nrf52dk_nrf52832.overlay, or you can just exclude those parts from the application. It shouldn&amp;#39;t matter much for the BLE part of the application.&lt;/p&gt;
&lt;p&gt;Alternatively, just take the BLE part of your application and add it to any of the BLE samples in NCS.&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising failed to start (err -120)</title><link>https://devzone.nordicsemi.com/thread/502814?ContentTypeID=1</link><pubDate>Tue, 17 Sep 2024 17:02:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2dd24942-5a87-4c60-a4f2-7e3c1e705852</guid><dc:creator>dlewis</dc:creator><description>&lt;p&gt;Below is the project and board files. The board file has been modified to work with nrf52dk.&amp;nbsp;&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/RES_2D00_BPB_2D00_TEST.zip"&gt;devzone.nordicsemi.com/.../RES_2D00_BPB_2D00_TEST.zip&lt;/a&gt;&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/6505.centurion_5F00_anywhere_5F00_button.zip"&gt;devzone.nordicsemi.com/.../6505.centurion_5F00_anywhere_5F00_button.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising failed to start (err -120)</title><link>https://devzone.nordicsemi.com/thread/502813?ContentTypeID=1</link><pubDate>Tue, 17 Sep 2024 16:54:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e75d2640-ac50-4491-805f-a95ad6f71be0</guid><dc:creator>dlewis</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;br /&gt;&lt;br /&gt;EALREADY returns every time bt_le_adv_start() is called beyond the initial instance. The initial&amp;nbsp;&lt;span&gt;bt_le_adv_start() call occurs before the infinite loop in main. The bt_le_adv_stop() and subsequent bt_le_adv_start() calls occur in a timer timeout handler.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I also turned on more detailed logs and it is printing the following immediately after returning err -120&lt;br /&gt;Advertising failed to start (err -120)&lt;br /&gt;[00:00:14.666,625] &amp;lt;err&amp;gt; os: ***** USAGE FAULT *****&lt;br /&gt;[00:00:14.666,625] &amp;lt;err&amp;gt; os: Unaligned memory access&lt;br /&gt;[00:00:14.666,656] &amp;lt;err&amp;gt; os: r0/a1: 0x00414643 r1/a2: 0x0000002c r2/a3: 0x2000bd18&lt;br /&gt;[00:00:14.666,656] &amp;lt;err&amp;gt; os: r3/a4: 0x00000040 r12/ip: 0x00000000 r14/lr: 0x0002dc73&lt;br /&gt;[00:00:14.666,687] &amp;lt;err&amp;gt; os: xpsr: 0x21000000&lt;br /&gt;[00:00:14.666,687] &amp;lt;err&amp;gt; os: Faulting instruction address (r15/pc): 0x0002dc5c&lt;br /&gt;[00:00:14.666,717] &amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 31: Unknown error on CPU 0&lt;br /&gt;[00:00:14.666,748] &amp;lt;err&amp;gt; os: Current thread: 0x20003040 (unknown)&lt;br /&gt;&lt;br /&gt;The function at 0x0002dc5c as shown in the debugger memory tool is sys_dlist_remove()&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I will work on uploading the application here shortly.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising failed to start (err -120)</title><link>https://devzone.nordicsemi.com/thread/502759?ContentTypeID=1</link><pubDate>Tue, 17 Sep 2024 12:15:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f6dbf2e5-cc30-4198-ad2e-a0365c6f5465</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Is the behavior consistent, meaning does the EALREADY return every time you test this (the second time you try to start advertising)? Or only from time to time?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I suspect it has to do with scheduling. From where do you call advertising stop and advertising start? Is it possible to upload the application so that I can build it and run it on an nRF52832 DK?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>