J-link debug setup

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
AnMa_2111856
Level 1
Level 1
10 sign-ins 5 replies posted 5 sign-ins

Hi,

We have problems setting up debugging. 

We use WICED 6.4.0.61, and our debug target is STM32F427II on custom HW platform.  We use WLAN CYW43362 chip next to STM.

We can program target with both Olimex ARM-USB-TINY-H and Segger J-link Ultra+ via Segger driver. RTOS is ThreadX. 

Now we need to be able to debug the application. We are to single step until rtos is startet, then we stop at 

Program received signal SIGTRAP, Trace/breakpoint trap.
0x08046356 in mbedtls_pem_read_buffer (ctx=0x0, header=<optimized out>, footer=<optimized out>, data=<optimized out>, pwd=0xc1 "\004", pwdlen=1414025796, use_len=0x0) at WICED/security/BESL/mbedtls_open/library/pem.c:330
330 return( MBEDTLS_ERR_PEM_ALLOC_FAILED );

Note, when not debugging, the application continue running.

Yours sincerely,

Anton 

0 Likes
12 Replies
Aditi_B
Moderator
Moderator
Moderator
500 replies posted 5 questions asked 250 replies posted

Hi,

Can you share the openocd_log.txt file under the "build" folder in WICED when you try to run the application in debug mode? In better words, when you'll run the make target to run the application in debug mode, the openocd_log.txt will be populated. Please share that file with us. As per your response, it seems that the application runs fine when not in debugging mode, but you can't run the application in the debug mode, right?

Thanks

Aditi

0 Likes
lock attach
Attachments are accessible only for community members.

Hi Aditi,

Thanks for your fast reply. 

We are able to single step in the beginning of code, but we never get to our application start.

Here is a picture at were we are stuck right now. And openocd_log text is added here:

adapter speed: 1000 kHz
adapter_nsrst_delay: 100
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
jtag_ntrst_delay: 100
Warn : target name is deprecated use: 'cortex_m'
jtag_init
Warn : Failed to open device: LIBUSB_ERROR_NOT_SUPPORTED.
Error: No J-Link device found.

0 Likes
Aditi_B
Moderator
Moderator
Moderator
500 replies posted 5 questions asked 250 replies posted

Hi,

The openocd logs at the end says that - "No J-Link device found". Can you provide the snapshot of the device manager when you connect the J-Link adapter?

Thanks

Aditi

0 Likes
lock attach
Attachments are accessible only for community members.

AnMa_2111856_1-1615974239324.png

 

AnMa_2111856_0-1615973954120.png

I also add events in j-link-events.evtx file and ziped. use Event Viewer Snapin Launcher to see it.

0 Likes
Aditi_B
Moderator
Moderator
Moderator
500 replies posted 5 questions asked 250 replies posted

Hi,

Thanks for providing the snapshot. I would require the following details from you. Please provide the same. Before executing these steps, please download the latest version of the Jlink software and then do the same.

https://www.segger.com/downloads/jlink/JLink_Windows.exe

1. Jlink driver details from the device manager. You can go the the Jlink driver properties and then to the driver details. 

2. Do you have the Zadig software? If not, you can download it from here-

https://zadig.akeo.ie/

You can connect the jlink adapter and then open this software. Go to options->List All Devices-> select Jlink 

After doing this, please provide the snapshot of the details.

3. What make target have you provided for the debugging? Is it this ->

 snip.scan-CYW94343WWCD1_EVB-debug JTAG=jlink download (the platform will change in your case)

If yes, does this build happen successfully or do you see build errors here?

Thanks

Aditi

 

0 Likes

Hi Aditi,

I have (re)installed SEGGER JLink drivers from your link

In Zadig I readout this:

AnMa_2111856_0-1616414960048.png

 

After I install libusbK, I am able to write firmware to my target with this build target velux.KLG300-KLF200_HW3-debug JTAG=jlink download

my jlink.cfg has this content:

interface jlink

set BSTAPID 0x06419041

reset_config trst_and_srst srst_push_pull srst_nogate connect_assert_srst

 

Now I the switch back to Segger JLink driver again and start debugger.

AnMa_2111856_1-1616415680323.pngAnMa_2111856_2-1616415827626.png

If I hit <run> I get this log:

 

SEGGER J-Link GDB Server V6.98c Command Line Version

JLinkARM.dll V6.98c (DLL compiled Mar 16 2021 12:19:26)

Command line: -if jtag -device STM32F427II -endian little -speed 1000 -port 2331 -swoport 2332 -telnetport 2333 -vd -ir -localhostonly 1 -singlerun -strict -timeout 0 -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: localhost only
Generate logfile: off
Verify download: on
Init regs on start: on
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: STM32F427II
Target interface: JTAG
Target interface speed: 1000kHz
Target endian: little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link Ultra V5 compiled Mar 8 2021 12:57:36
Hardware: V5.00
S/N: 505000833
Feature(s): RDI, FlashBP, FlashDL, JFlash, GDB
Checking target voltage...
Target voltage: 3.28 V
Listening on TCP/IP port 2331
Connecting to target...

J-Link found 2 JTAG devices, Total IRLen = 9
JTAG ID: 0x4BA00477 (Cortex-M4)
Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
Read 4 bytes @ address 0x00000000 (Data = 0x20005804)
Read 2 bytes @ address 0x00000000 (Data = 0x5804)
Received monitor command: speed 1000
Target interface speed set to 1000 kHz
Received monitor command: clrbp
Received monitor command: reset
Resetting target
Received monitor command: halt
Halting target CPU...
...Target halted (PC = 0x1FFF5162)
Received monitor command: regs
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 20002D40, MSP= 20002D40, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 1FFF5162
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00

Security extension regs:
MSP_S = 00000000, MSPLIM_S = 00000000
PSP_S = 00000000, PSPLIM_S = 00000000
MSP_NS = 20002D40, MSPLIM_NS = 00000000
PSP_NS = 00000000, PSPLIM_NS = 00000000
CONTROL_S 00, FAULTMASK_S 00, BASEPRI_S 00, PRIMASK_S 00
CONTROL_NS 00, FAULTMASK_NS 00, BASEPRI_NS 00, PRIMASK_NS 00

Reading all registers
Received monitor command: speed 10000
Target interface speed set to 10000 kHz
Received monitor command: flash breakpoints 0
Flash breakpoints disabled
Read 4 bytes @ address 0x1FFF5162 (Data = 0x46C046C0)
Read 2 bytes @ address 0x1FFF5162 (Data = 0x46C0)
Read 4 bytes @ address 0x1FFF5162 (Data = 0x46C046C0)
Read 2 bytes @ address 0x1FFF5162 (Data = 0x46C0)
Downloading 396 bytes @ address 0x08040000 - Verified OK
Downloading 15984 bytes @ address 0x080401C0 - Verified OK
Downloading 16064 bytes @ address 0x08044030 - Verified OK
Downloading 16112 bytes @ address 0x08047EF0 - Verified OK
Downloading 15984 bytes @ address 0x0804BDE0 - Verified OK
Downloading 16048 bytes @ address 0x0804FC50 - Verified OK
Downloading 16016 bytes @ address 0x08053B00 - Verified OK
Downloading 16016 bytes @ address 0x08057990 - Verified OK
Downloading 16048 bytes @ address 0x0805B820 - Verified OK
Downloading 16016 bytes @ address 0x0805F6D0 - Verified OK
Downloading 16080 bytes @ address 0x08063560 - Verified OK
Downloading 16016 bytes @ address 0x08067430 - Verified OK
Downloading 16112 bytes @ address 0x0806B2C0 - Verified OK
Downloading 16048 bytes @ address 0x0806F1B0 - Verified OK
Downloading 16032 bytes @ address 0x08073060 - Verified OK
Downloading 16176 bytes @ address 0x08076F00 - Verified OK
Downloading 16032 bytes @ address 0x0807AE30 - Verified OK
Downloading 16096 bytes @ address 0x0807ECD0 - Verified OK
Downloading 16112 bytes @ address 0x08082BB0 - Verified OK
Downloading 16032 bytes @ address 0x08086AA0 - Verified OK
Downloading 16048 bytes @ address 0x0808A940 - Verified OK
Downloading 16000 bytes @ address 0x0808E7F0 - Verified OK
Downloading 16144 bytes @ address 0x08092670 - Verified OK
Downloading 16048 bytes @ address 0x08096580 - Verified OK
Downloading 16128 bytes @ address 0x0809A430 - Verified OK
Downloading 16096 bytes @ address 0x0809E330 - Verified OK
Downloading 16048 bytes @ address 0x080A2210 - Verified OK
Downloading 16192 bytes @ address 0x080A60C0 - Verified OK
Downloading 16048 bytes @ address 0x080AA000 - Verified OK
Downloading 15920 bytes @ address 0x080ADEB0 - Verified OK
Downloading 16176 bytes @ address 0x080B1CE0 - Verified OK
Downloading 16352 bytes @ address 0x080B5C10 - Verified OK
Downloading 16336 bytes @ address 0x080B9BF0 - Verified OK
Downloading 16208 bytes @ address 0x080BDBC0 - Verified OK
Downloading 16224 bytes @ address 0x080C1B10 - Verified OK
Downloading 16160 bytes @ address 0x080C5A70 - Verified OK
Downloading 16064 bytes @ address 0x080C9990 - Verified OK
Downloading 16080 bytes @ address 0x080CD850 - Verified OK
Downloading 16000 bytes @ address 0x080D1720 - Verified OK
Downloading 16080 bytes @ address 0x080D55A0 - Verified OK
Downloading 16064 bytes @ address 0x080D9470 - Verified OK
Downloading 16096 bytes @ address 0x080DD330 - Verified OK
Downloading 16304 bytes @ address 0x080E1210 - Verified OK
Downloading 16096 bytes @ address 0x080E51C0 - Verified OK
Downloading 15888 bytes @ address 0x080E90A0 - Verified OK
Downloading 16272 bytes @ address 0x080ECEB0 - Verified OK
Downloading 16240 bytes @ address 0x080F0E40 - Verified OK
Downloading 16224 bytes @ address 0x080F4DB0 - Verified OK
Downloading 2704 bytes @ address 0x080F8D10 - Verified OK
Downloading 44 bytes @ address 0x080F97A0 - Verified OK
Downloading 88 bytes @ address 0x080F97CC - Verified OK
Downloading 8 bytes @ address 0x080F9824 - Verified OK
Downloading 5108 bytes @ address 0x080F982C - Verified OK
Comparing flash [....................] Done.
Erasing flash [....................] Done.
Programming flash [....................] Done.
Writing register (PC = 0x 804069c)
Read 4 bytes @ address 0x0804069C (Data = 0x468D493A)
Reading 64 bytes @ address 0x00801080
WARNING: Failed to read memory @ address 0x00801080
WARNING: Failed to read memory @ address 0x0080108E
Reading 64 bytes @ address 0x08041240
Reading 64 bytes @ address 0x00801080
WARNING: Failed to read memory @ address 0x00801080
WARNING: Failed to read memory @ address 0x0080108E
WARNING: Failed to read memory @ address 0x0080108A
Read 2 bytes @ address 0x0804124E (Data = 0xF003)
Reading 64 bytes @ address 0x00801080
WARNING: Failed to read memory @ address 0x00801080
WARNING: Failed to read memory @ address 0x0080108E
WARNING: Failed to read memory @ address 0x0080108E
Read 2 bytes @ address 0x0804124E (Data = 0xF003)
Reading 64 bytes @ address 0x08040680
Read 4 bytes @ address 0x08040788 (Data = 0x2000E99C)
Reading 64 bytes @ address 0x008004C0
WARNING: Failed to read memory @ address 0x008004C0
WARNING: Failed to read memory @ address 0x008004DC
Read 2 bytes @ address 0x0804069C (Data = 0x493A)
WARNING: Failed to read memory @ address 0x008004DC
Reading 64 bytes @ address 0x00846440
WARNING: Failed to read memory @ address 0x00846440
WARNING: Failed to read memory @ address 0x0084647E
Reading 64 bytes @ address 0x08086600
WARNING: Failed to read memory @ address 0x008465F2
Read 2 bytes @ address 0x080867B2 (Data = 0x9B05)
Reading 64 bytes @ address 0x008004C0
WARNING: Failed to read memory @ address 0x008004C0
WARNING: Failed to read memory @ address 0x008004DC
Read 4 bytes @ address 0x08040788 (Data = 0x2000E99C)
WARNING: Failed to read memory @ address 0x0080057E
Read 2 bytes @ address 0x0804073E (Data = 0xF000)
Reading 64 bytes @ address 0x00809700
WARNING: Failed to read memory @ address 0x00809700
WARNING: Failed to read memory @ address 0x0080972E
Reading 64 bytes @ address 0x080498C0
WARNING: Failed to read memory @ address 0x00809778
Read 2 bytes @ address 0x08049938 (Data = 0x484D)
Reading 64 bytes @ address 0x00801080
WARNING: Failed to read memory @ address 0x00801080
WARNING: Failed to read memory @ address 0x0080108E
Reading 64 bytes @ address 0x00801080
WARNING: Failed to read memory @ address 0x00801080
WARNING: Failed to read memory @ address 0x0080108E
WARNING: Failed to read memory @ address 0x0080108A
Read 2 bytes @ address 0x0804124E (Data = 0xF003)
Received monitor command: regs
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 20002D40, MSP= 20002D40, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 0804069C
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00

Security extension regs:
MSP_S = 00000000, MSPLIM_S = 00000000
PSP_S = 00000000, PSPLIM_S = 00000000
MSP_NS = 20002D40, MSPLIM_NS = 00000000
PSP_NS = 00000000, PSPLIM_NS = 00000000
CONTROL_S 00, FAULTMASK_S 00, BASEPRI_S 00, PRIMASK_S 00
CONTROL_NS 00, FAULTMASK_NS 00, BASEPRI_NS 00, PRIMASK_NS 00

Reading all registers
Setting breakpoint @ address 0x0080108A, Size = 2, BPHandle = 0x0001
Setting breakpoint @ address 0x00809778, Size = 2, BPHandle = 0x0002
Setting breakpoint @ address 0x0804124E, Size = 2, BPHandle = 0x0003
Setting breakpoint @ address 0x08049938, Size = 2, BPHandle = 0x0004
Starting target CPU...
...Breakpoint reached @ address 0x0804124E
Reading all registers
Removing breakpoint @ address 0x0080108A, Size = 2
Removing breakpoint @ address 0x00809778, Size = 2
Removing breakpoint @ address 0x0804124E, Size = 2
Removing breakpoint @ address 0x08049938, Size = 2
Read 4 bytes @ address 0x0804124E (Data = 0xFE79F003)
Starting target CPU...
Reading all registers
Read 4 bytes @ address 0x080410F4 (Data = 0xBF00BE00)
Read 4 bytes @ address 0x080482E4 (Data = 0xF7FE68F8)
Reading 64 bytes @ address 0x080482C0
Reading 64 bytes @ address 0x200120C0
Read 4 bytes @ address 0x08045186 (Data = 0xF0012001)
Reading 64 bytes @ address 0x08045100
Read 4 bytes @ address 0x0804530C (Data = 0x20001D38)
Reading 64 bytes @ address 0x20012100
Read 4 bytes @ address 0x08046F62 (Data = 0xF7FF2001)
Reading 64 bytes @ address 0x08046EC0
Reading 64 bytes @ address 0x20012140
Read 4 bytes @ address 0x08046EAE (Data = 0xF7FE69F8)
Reading 64 bytes @ address 0x08046D00
Reading 64 bytes @ address 0x20012180
Read 4 bytes @ address 0x08045946 (Data = 0x68FB60F8)
Reading 64 bytes @ address 0x080458C0
Read 4 bytes @ address 0x0804149E (Data = 0x2B004603)
Read 4 bytes @ address 0x0805FF0C (Data = 0x2B004603)
Read 4 bytes @ address 0x08063AFC (Data = 0x3027F897)
Reading 64 bytes @ address 0x200121C0
Read 4 bytes @ address 0x08063762 (Data = 0xF0234603)
Read 4 bytes @ address 0x0805FEE8 (Data = 0x817B4603)
Reading 64 bytes @ address 0x20012200
Read 4 bytes @ address 0x0806A0F0 (Data = 0x0000E7EE)
Read 4 bytes @ address 0x08048188 (Data = 0x681B4B18)
Reading 64 bytes @ address 0x08048140
Read 4 bytes @ address 0x080481EA (Data = 0x1DD42000)
Reading 64 bytes @ address 0x20012240
Read 4 bytes @ address 0xFFFFFFFE (Data = 0x2D400000)
Read 2 bytes @ address 0xFFFFFFFE (Data = 0x0000)
Read 4 bytes @ address 0xFFFFFFFE (Data = 0x2D400000)
Read 2 bytes @ address 0xFFFFFFFE (Data = 0x0000)

 

and code break at this:

AnMa_2111856_3-1616415958700.png

 

-----------

I will now try to get snip.scan run on my hardware... more info will follow on that, hopefully 🙂

0 Likes

Hi again, 

I have now tried with snip.scan, but unfortunately I get in to same situation. In scan.c I have a breakpoint, but I never get to that point. 

When I pause debug, I see that we are in /WICED/platform/MCU/STM32F4xx/peripherals/platform_mcu_powersave.c file in function stop_mode_power_down_hook()

 

AnMa_2111856_0-1616419036504.png

 

 

0 Likes
Aditi_B
Moderator
Moderator
Moderator
500 replies posted 5 questions asked 250 replies posted

Hi,

Can you also go through this link and see if this works in your case?

https://community.cypress.com/t5/Resource-Library/Downloading-and-debugging-CYW43907-using-Jlink-Seg...

Thanks

Aditi

0 Likes

Thanks for the link, I have used it in my  post above.

0 Likes

Is it not possible to use debugger with WICED stack? 

0 Likes
Aditi_B
Moderator
Moderator
Moderator
500 replies posted 5 questions asked 250 replies posted

Yes, it's possible to use debugger with WICED stack

0 Likes
lock attach
Attachments are accessible only for community members.
Aditi_B
Moderator
Moderator
Moderator
500 replies posted 5 questions asked 250 replies posted

Hi,

Can you try out these steps and see if this works in your use case?

1. Connect the Jlink adapter and see the driver details. The "Jlink" should appear under "Universal Serial Bus Devices" as given below-

AditiB_81_0-1618379081422.png

The driver details should be like as given below:

AditiB_81_1-1618379178011.png

If this is not the same in your setup, use zadig to convert the Jlink driver to WinUSB. You've attached a similar snapshot in your previous response. In that you have to click on "Replace Driver".

2. Setup Debug Configurations under "GDB Hardware Debugging" in 43xxx_Wi-Fi_Debug_Windows. I've attached a file that provides the required steps.

3. After this, provide the make target in WICED STUDIO as this - 

snip.scan-BCM94343WWCD2-debug JTAG=jlink download (in your case, provide the relevant platform)

4. Run this make target and then debug as 43xxx_Wi-Fi_Debug_Windows. I am able to place the breakpoint in this way and run the application as well.

AditiB_81_2-1618379755435.png

Let us know if this works for you.

Thanks

Aditi

0 Likes