<?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>debug nrf52840 zephyr app with threads using JLINK + gdb</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/115007/debug-nrf52840-zephyr-app-with-threads-using-jlink-gdb</link><description>hi. 
 I have a zephyr app that includes threads, 3 to be exact. 
 I&amp;#39;m compiling thread info using -D param passed on to the west command (well vs code does it for me, i&amp;#39;m just verifying it&amp;#39;s there). 
 When i want to de bug the app i connect j-link to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 30 Sep 2024 07:34:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/115007/debug-nrf52840-zephyr-app-with-threads-using-jlink-gdb" /><item><title>RE: debug nrf52840 zephyr app with threads using JLINK + gdb</title><link>https://devzone.nordicsemi.com/thread/504286?ContentTypeID=1</link><pubDate>Mon, 30 Sep 2024 07:34:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60fd8cc1-eb9b-4508-b3f1-5c9656d86200</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Eya_Gal"]this is my setup, as yu can see when i&amp;#39;m on &amp;quot;app&amp;quot; i can see just build\flash operations, but if i go to a specific domain i can do more.[/quote]
&lt;p&gt;Yes, this is the expected scenario and it is a side effect of sysbuild.&lt;/p&gt;
&lt;p&gt;Each image will have a dedicated build/$(image_name) catalog, where the root of the build-catalog will hold the merged image. To debug a specific target, you have to ensure that it is selected.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: debug nrf52840 zephyr app with threads using JLINK + gdb</title><link>https://devzone.nordicsemi.com/thread/504221?ContentTypeID=1</link><pubDate>Fri, 27 Sep 2024 17:05:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa5dbeb7-6748-42ca-bfcc-50175adff310</guid><dc:creator>Eyal_Gal</dc:creator><description>&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1727456686022v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;this is my setup, as yu can see when i&amp;#39;m on &amp;quot;app&amp;quot; i can see just build\flash operations, but if i go to a specific domain i can do more.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: debug nrf52840 zephyr app with threads using JLINK + gdb</title><link>https://devzone.nordicsemi.com/thread/504115?ContentTypeID=1</link><pubDate>Fri, 27 Sep 2024 08:23:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c317652-be24-4619-a8f9-1b9fc9f78a9b</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Glad to hear that the setup itself works as it should.&lt;/p&gt;
&lt;p&gt;Let me know if you still run into issues with your current firmware, and please provide a &amp;quot;bt&amp;quot; and &amp;quot;mon regs&amp;quot; output if that still does not give you your thread info.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="Eya_Gal"]SI and NI instructions work nicely, so i&amp;#39;m not sure what&amp;#39;s causing an issue with our app.&lt;br /&gt;I&amp;#39;ll keep this request open after i&amp;#39;ll try again (we are in the middle of merges of features...)&lt;br /&gt;I also have noticed (dunno if it&amp;#39;s new or not) that now if in the nrf-connect extension page under applications -&amp;gt; app -&amp;gt; build i do not have debug, but if i go further to&amp;nbsp;&lt;span&gt;applications -&amp;gt; app -&amp;gt; build -&amp;gt;app (it&amp;#39;s sys-build based west ws) then i do have both debug and debug with ozone, didn&amp;#39;t test it yet but i have a hunch it will work, so if i&amp;#39;ll update the runners yaml to include the zephyr rtos plugin it will work, ozone loads it automatically if it identifies rtos, so no need to update.&lt;/span&gt;[/quote]
&lt;p&gt;It is similar to this, right?&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/pastedimage1727425287278v3.png" alt=" " /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is because sysbuild will append the image name inside the build-folder, as opposed to the partition manager.&lt;/p&gt;
&lt;p&gt;So now it will be build/$(IMAGE_NAME)/zephyr/ where the build files are located, as without sysbuild it is build/zephyr/&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: debug nrf52840 zephyr app with threads using JLINK + gdb</title><link>https://devzone.nordicsemi.com/thread/503955?ContentTypeID=1</link><pubDate>Thu, 26 Sep 2024 11:25:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c678ba3-fcee-4ec6-974f-cd934166dff0</guid><dc:creator>Eyal_Gal</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Seems like you are right,&lt;/p&gt;
&lt;p&gt;i have copied my workspace to another location, removed everything but main.c in my /app directory, updated cmake and main.c to run an endless while loop with sleep and led 1 toggle, another thread is started and toggles another led and sleeps a different amount of time.&lt;/p&gt;
&lt;p&gt;started the gdb server like before and the arm-gdb as well.&lt;br /&gt;This time using info threads yielded&amp;nbsp;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;(gdb) info threads
  Id   Target Id                                    Frame 
* 2    Thread 536877336 (main RUNNING PRIO 0)       main () at /home/eyal/develop/scms/staging_area/west_ws_1/nrf-connect-tondo/app/src/main.c:51
  3    Thread 536877120 (idle UNKNOWN PRIO 15)      0x00031222 in arch_cpu_idle () at /home/eyal/develop/scms/staging_area/west_ws_1/zephyr/arch/arm/core/cortex_m/cpu_idle.c:98
  4    Thread 536872464 (logging PENDING PRIO 14)   arch_swap (key=key@entry=0) at /home/eyal/develop/scms/staging_area/west_ws_1/zephyr/arch/arm/core/cortex_m/swap.c:49
  5    Thread 536877616 (sysworkq PENDING PRIO 255) arch_swap (key=key@entry=0) at /home/eyal/develop/scms/staging_area/west_ws_1/zephyr/arch/arm/core/cortex_m/swap.c:49
  6    Thread 536876840 (mcumgr smp QUEUED PRIO 3)  z_thread_entry (entry=0x2c209 &amp;lt;work_queue_main&amp;gt;, p1=0x20001728 &amp;lt;smp_work_queue&amp;gt;, p2=0x0, p3=0x0)
    at /home/eyal/develop/scms/staging_area/west_ws_1/zephyr/lib/os/thread_entry.c:37
  7    Thread 536872248 (thread1_id QUEUED PRIO 7)  z_thread_entry (entry=0x23bdd &amp;lt;thread1&amp;gt;, p1=0x0, p2=0x0, p3=0x0) at /home/eyal/develop/scms/staging_area/west_ws_1/zephyr/lib/os/thread_entry.c:37
(gdb) si
0x00023c36	51		ret = gpio_pin_configure_dt(&amp;amp;led, GPIO_OUTPUT_ACTIVE);
(gdb) si
0x00023c38	51		ret = gpio_pin_configure_dt(&amp;amp;led, GPIO_OUTPUT_ACTIVE);
(gdb) si
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So the general setup seems to work, why i have an SMP thread, i have no idea, related to mcuboot i assume.&lt;/p&gt;
&lt;p&gt;SI and NI instructions work nicely, so i&amp;#39;m not sure what&amp;#39;s causing an issue with our app.&lt;br /&gt;I&amp;#39;ll keep this request open after i&amp;#39;ll try again (we are in the middle of merges of features...)&lt;br /&gt;I also have noticed (dunno if it&amp;#39;s new or not) that now if in the nrf-connect extension page under applications -&amp;gt; app -&amp;gt; build i do not have debug, but if i go further to&amp;nbsp;&lt;span&gt;applications -&amp;gt; app -&amp;gt; build -&amp;gt;app (it&amp;#39;s sys-build based west ws) then i do have both debug and debug with ozone, didn&amp;#39;t test it yet but i have a hunch it will work, so if i&amp;#39;ll update the runners yaml to include the zephyr rtos plugin it will work, ozone loads it automatically if it identifies rtos, so no need to update.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: debug nrf52840 zephyr app with threads using JLINK + gdb</title><link>https://devzone.nordicsemi.com/thread/503882?ContentTypeID=1</link><pubDate>Thu, 26 Sep 2024 07:30:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2050c979-7078-45b0-8e86-63f44938032a</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tested quickly in a standard application, with &amp;quot;west build ...args -- -DCONFIG_DEBUG__THREAD_INFO=y&amp;quot;, and setup the GDBServer&amp;nbsp;similar to&amp;nbsp;you (just different SoC + macos):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;JLinkGDBServer -if swd -device NRF9160_XXAA -speed 1000  -rtos /Applications/SEGGER/JLink/GDBServer/RTOSPlugin_Zephyr.dylib -singlerun -nogui 
SEGGER J-Link GDB Server V7.98i Command Line Version

JLinkARM.dll V7.98i (DLL compiled Sep 18 2024 15:49:01)

Command line: -if swd -device NRF9160_XXAA -speed 1000 -rtos /Applications/SEGGER/JLink/GDBServer/RTOSPlugin_Zephyr.dylib -singlerun -nogui
-----GDB Server start settings-----
GDBInit file:                  none
GDB Server Listening port:     2331
SWO raw output listening port: 2332
Terminal I/O port:             2333
Accept remote connection:      yes
Generate logfile:              off
Verify download:               off
Init regs on start:            off
Silent mode:                   off
Single run mode:               on
Target connection timeout:     0 ms
------J-Link related settings------
J-Link Host interface:         USB
J-Link script:                 none
J-Link settings file:          none
------Target related settings------
Target device:                 NRF9160_XXAA
Target device parameters:      none
Target interface:              SWD
Target interface speed:        1000kHz
Target endian:                 little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link OB-nRF5340-NordicSemi compiled Sep 11 2024 13:35:00
Hardware: V1.00
S/N: 1051242634
Feature(s): RDI, FlashBP, FlashDL, JFlash, GDB
Checking target voltage...
Target voltage: 3.30 V
Listening on TCP/IP port 2331
Connecting to target...
Halting core...
Core security extensions: Implemented
Connected to target
...rest&lt;/pre&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And setup arm-zephyr-eabi-gdb:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;(gdb) target remote :2331
Remote debugging using :2331
__enable_irq () at /opt/ncs/modules/hal/cmsis/CMSIS/Core/Include/cmsis_gcc.h:951
951	  __ASM volatile (&amp;quot;cpsie i&amp;quot; : : : &amp;quot;memory&amp;quot;);
(gdb) si
[New Thread 536871920]
[New Thread 536871712]
[New Thread 536871536]
[New Thread 536871360]
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;info threads:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;(gdb) info threads
  Id   Target Id                                     Frame 
* 2    Thread 536871920 (idle UNKNOWN PRIO 15)       arch_cpu_idle () at /opt/ncs/zephyr/arch/arm/core/cortex_m/cpu_idle.c:97
  3    Thread 536871712 (blink0_id SUSPENDED PRIO 7) arch_swap (key=key@entry=0) at /opt/ncs/zephyr/arch/arm/core/cortex_m/swap.c:49
  4    Thread 536871536 (blink1_id SUSPENDED PRIO 7) arch_swap (key=key@entry=0) at /opt/ncs/zephyr/arch/arm/core/cortex_m/swap.c:49
  5    Thread 536871360 (uart_out_id PENDING PRIO 7) arch_swap (key=0) at /opt/ncs/zephyr/arch/arm/core/cortex_m/swap.c:49&lt;/pre&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Did you try any other sample and get the threads info?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: debug nrf52840 zephyr app with threads using JLINK + gdb</title><link>https://devzone.nordicsemi.com/thread/503826?ContentTypeID=1</link><pubDate>Wed, 25 Sep 2024 17:34:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c257952-1053-40b6-8404-1426eac26ae8</guid><dc:creator>Eyal_Gal</dc:creator><description>&lt;p&gt;no i don&amp;#39;t have BLE yet in my code, but i do have several timers, i2c devices, UART0 and UART1 used in async mode, so definitely there are interrupts running around.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Also my app is not &amp;quot;alone&amp;quot; we used b0 bootloader with mcubootloader (immutable bootloader and mcu bootloader that can be upgraded and can upgrade the app as well.) so i have to use the same struct along with a new app, more basic.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: debug nrf52840 zephyr app with threads using JLINK + gdb</title><link>https://devzone.nordicsemi.com/thread/503818?ContentTypeID=1</link><pubDate>Wed, 25 Sep 2024 16:31:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18acb352-cf4e-45c7-b9cf-b2372b0c2944</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Are you debugging a bluetooth sample? If so, try to break first on main, then add your actual break point and continue.&lt;/p&gt;
&lt;p&gt;There are assertions/ISRs that will run inside the stack, and those will cause problems if you step too far with the debug client.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Eya_Gal"]You think maybe something in our thread causes an issue to debug it ?[/quote]
&lt;p&gt;It could be, but running a simpler sample is basically just to verify the process itself, ie. that the rtos plugin is loaded correctly and that it can detect the threads properly. If that works, we know it is not a&amp;nbsp;host setup&amp;nbsp;issue.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: debug nrf52840 zephyr app with threads using JLINK + gdb</title><link>https://devzone.nordicsemi.com/thread/503781?ContentTypeID=1</link><pubDate>Wed, 25 Sep 2024 13:44:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2996fb6a-21d4-4f73-a35b-c2db9fb6ee74</guid><dc:creator>Eyal_Gal</dc:creator><description>&lt;p&gt;thanks Hakon.&lt;/p&gt;
&lt;p&gt;Naturally i can try to use a simpler app, i didn&amp;#39;t try si though just &amp;#39;s&amp;#39; and &amp;#39;n&amp;#39; so it might work.&lt;/p&gt;
&lt;p&gt;You think maybe something in our thread causes an issue to debug it ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: debug nrf52840 zephyr app with threads using JLINK + gdb</title><link>https://devzone.nordicsemi.com/thread/503775?ContentTypeID=1</link><pubDate>Wed, 25 Sep 2024 13:29:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7060b91f-6553-45f4-86a8-fcb1a8375141</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s a way to use gdb + threadaware plugin:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/86265/gdb-commands-to-list-zephyr-app-threads/360199"&gt;RE: gdb commands to list Zephyr app threads?&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Based on your commands, it seems that you are following this.&lt;/p&gt;
&lt;p&gt;What I have seen is that you have to do a single instruction &amp;quot;si&amp;quot; for the gdb server / client to get the thread info.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you try to reproduce this in a simpler sample, like the zephyr/samples/basic/threads?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>