<?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>nRF5340 Audio App Stack overflow</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/101976/nrf5340-audio-app-stack-overflow</link><description>Hello. I am Soeta. 
 I am using nRF5340 Audio App on nRF5340 Audio DK. When I run the following thread, I get a Stack overflow. ----- thread ----------------------------------------------------------- K_THREAD_STACK_DEFINE(DSP_thread_stack, 100); DSP_thread_id</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 26 Jul 2023 09:10:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/101976/nrf5340-audio-app-stack-overflow" /><item><title>RE: nRF5340 Audio App Stack overflow</title><link>https://devzone.nordicsemi.com/thread/438189?ContentTypeID=1</link><pubDate>Wed, 26 Jul 2023 09:10:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fcdd2317-ea2f-4788-af56-92e577d42075</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Thank you for providing the solution which worked for you. I am glad to hear that the error is no more there.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 Audio App Stack overflow</title><link>https://devzone.nordicsemi.com/thread/438150?ContentTypeID=1</link><pubDate>Wed, 26 Jul 2023 02:35:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f9f5a2df-26fb-453f-96c3-2251fc4b5abb</guid><dc:creator>soeta</dc:creator><description>&lt;p&gt;Hello.&lt;br /&gt;I am contacting you because the situation has improved.&lt;br /&gt;I have tried various things.&lt;br /&gt;The situation has been improved by adding k_sleep() to the process in the thread.&lt;br /&gt;There is no stack overflow and the added thread is running.&lt;/p&gt;
&lt;p&gt;The thread source code is shown below.&lt;/p&gt;
&lt;p&gt;--------------------------------------------------------------&lt;br /&gt;static void DSP_thread(void *arg1, void *arg2, void *arg3)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; static uint64_t exec_count = 0;&lt;br /&gt;&amp;nbsp; &amp;nbsp;while (1) &lt;br /&gt;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (exec_count == 0){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LOG_INF(&amp;quot;DSP_thread Exec&amp;quot;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(*1)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;++exec_count;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (exec_count &amp;gt; 10000) exec_count = 0;&lt;br /&gt;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;--------------------------------------------------------------&lt;/p&gt;
&lt;p&gt;In (*1) above&lt;br /&gt;&amp;nbsp; &amp;nbsp; k_sleep(K_MSEC(5));&lt;br /&gt;above (*1) has improved the situation.&lt;/p&gt;
&lt;p&gt;The cause of the stack overflow is unknown, but since it has improved, we will proceed in this state.&lt;br /&gt;Thank you in advance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 Audio App Stack overflow</title><link>https://devzone.nordicsemi.com/thread/437991?ContentTypeID=1</link><pubDate>Tue, 25 Jul 2023 07:23:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99cfa2a4-95ef-4d8f-9018-6a78986e9b29</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="soeta"]I have never set K_THREAD_STACK_DEFINE.&lt;br /&gt;I have also searched the project and could not find anything that uses this word.[/quote]
&lt;p&gt;In your initial question, there was this line -&amp;nbsp;K_THREAD_STACK_DEFINE(DSP_thread_stack, 100).&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 Audio App Stack overflow</title><link>https://devzone.nordicsemi.com/thread/437770?ContentTypeID=1</link><pubDate>Mon, 24 Jul 2023 00:46:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:575658c1-f81f-420c-8432-6344ca68e357</guid><dc:creator>soeta</dc:creator><description>&lt;p&gt;Hello.&lt;/p&gt;
&lt;p&gt;I have never set K_THREAD_STACK_DEFINE.&lt;br /&gt;I have also searched the project and could not find anything that uses this word.&lt;br /&gt;I have set CONFIG_**** and other settings in prj.conf, but where should I set K_THREAD_STACK_DEFINE?&lt;/p&gt;
&lt;p&gt;Thank you in advance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 Audio App Stack overflow</title><link>https://devzone.nordicsemi.com/thread/437690?ContentTypeID=1</link><pubDate>Fri, 21 Jul 2023 13:39:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97342395-7d30-4339-be4d-14a7552c54d7</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;&lt;span&gt;K_THREAD_STACK_DEFINE line should be outside of the function. Have you done it that way?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 Audio App Stack overflow</title><link>https://devzone.nordicsemi.com/thread/437560?ContentTypeID=1</link><pubDate>Fri, 21 Jul 2023 02:21:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f812b77-5c04-4caf-b9e1-fdc554e15b9f</guid><dc:creator>soeta</dc:creator><description>&lt;p&gt;Hello.&lt;/p&gt;
&lt;p&gt;I ran with CONFIG_THREAD_NAME=y&lt;br /&gt;but there is no change in the LOG and the name of the thread is not displayed.&lt;br /&gt;However, as I mentioned in my initial question, this is caused by adding a new thread, so it is clear that adding a thread is the cause.&lt;br /&gt;We believe that there is not enough OS stack to launch this thread.&lt;br /&gt;Please let me know the settings to increase the OS stack.&lt;/p&gt;
&lt;p&gt;Thank you in advance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 Audio App Stack overflow</title><link>https://devzone.nordicsemi.com/thread/437276?ContentTypeID=1</link><pubDate>Wed, 19 Jul 2023 13:34:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2dea9c88-f193-44d7-ad51-7cbe7c3fa3be</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;As shown in your initial log, the thread that produces stack overflow is unknown. You could include following configuration option to enable printing of the thread name:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_THREAD_NAME=y&lt;/pre&gt;&lt;br /&gt;When you know the name of the thread which produces the overflow, then you could proceed to increasing its stack size.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 Audio App Stack overflow</title><link>https://devzone.nordicsemi.com/thread/437120?ContentTypeID=1</link><pubDate>Wed, 19 Jul 2023 05:49:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d26a0403-5d18-49e9-a2e6-583afd63e1e8</guid><dc:creator>soeta</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am aware that there is a stack size setting shown below.&lt;br /&gt;However, I do not know how to specify the stack size to be increased when adding a thread.&lt;br /&gt;I assumed that CONFIG_MAIN_STACK_SIZE would be applicable and increased it, but it was not.&lt;/p&gt;
&lt;p&gt;-----------------------------------------------------------------&lt;br /&gt;#define CONFIG_MAIN_STACK_SIZE 7232&lt;br /&gt;#define CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE 4096&lt;br /&gt;#define CONFIG_ENCODER_STACK_SIZE 7500&lt;br /&gt;#define CONFIG_AUDIO_DATAPATH_STACK_SIZE 4096&lt;br /&gt;#define CONFIG_CS47L63_STACK_SIZE 700&lt;br /&gt;#define CONFIG_POWER_MEAS_STACK_SIZE 1152&lt;br /&gt;#define CONFIG_PRIVILEGED_STACK_SIZE 1024&lt;br /&gt;#define CONFIG_BT_HCI_TX_STACK_SIZE 1024&lt;br /&gt;#define CONFIG_BT_RX_STACK_SIZE 2048&lt;br /&gt;#define CONFIG_MPSL_WORK_STACK_SIZE 1024&lt;br /&gt;#define CONFIG_IDLE_STACK_SIZE 320&lt;br /&gt;#define CONFIG_ISR_STACK_SIZE 2048&lt;br /&gt;#define CONFIG_IPC_SERVICE_BACKEND_RPMSG_WQ_STACK_SIZE 1024&lt;br /&gt;#define CONFIG_LOG_PROCESS_THREAD_STACK_SIZE 2048&lt;br /&gt;#define CONFIG_SHELL_STACK_SIZE 1024&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-----------------------------------------------------------------&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Thank you in advance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 Audio App Stack overflow</title><link>https://devzone.nordicsemi.com/thread/437059?ContentTypeID=1</link><pubDate>Tue, 18 Jul 2023 14:22:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:213e4789-db84-498e-984f-0279cd7230b5</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;There are many configuration options which allow you to set desired stack sizes. You could have a look at&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/nrf5340_audio/README.html#application-configuration-options"&gt;application configuration options&lt;/a&gt;&amp;nbsp;for&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/nrf5340_audio/README.html#nrf5340-audio"&gt;nrf5340 audio&lt;/a&gt;&amp;nbsp;application.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>