> On 14 Jul 2023, at 20:31, Tommy Murphy <tommy_mur...@hotmail.com> wrote:
> 
> presumably something that Liviu might try on his target?

The target was the NUCLEO-F767ZI, connected via two probes, the on-board 
ST/LINK-v2 with the latest firmware, and a J-Link EDU Mini, connected via the 
6-pin SWD connecter, patched to provide the Vref on pin 1.

The test machine was an Intel MacMini, running macOS 12.6.7 (a bit old).

To create the test project I used the latest STM32CubeIDE (1.13.0), and the 
latest packages for STM32F7 (1.17.0). 

I created a default project for NUCLEO-F767ZI; I removed all peripherals, 
except GPIO (they were too many; I think this does not influence the test).

I left all other settings as the Cube defaults, including the interrupt 
handlers.

I added the pendsv_cnt counter in the PendSV_Handler(), but I think this is not 
very relevant to the test.

I added the following in the main() forever loop:

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */

        SCB->ICSR |= SCB_ICSR_PENDSVSET_Msk;

        // you may insert 0..8 __NOP() instructions as a delay here
        // no issue observed with a delay longer than 8 __NOP() instructions

        __NOP();
        __NOP();
        __NOP();
        __NOP();

        __NOP();
        __NOP();
        __NOP();
        __NOP();

        __NOP(); // 9

        __BKPT(0);


        loop_cnt++;

  }
  /* USER CODE END 3 */

Note there are 9 NOPs. the issue was no longer observed with 10 or more.

Since CubeIDE supports 3 debug configurations, I used them all.

1 ---

With 'ST-LINK (OpenOCD)' I got the following in the console:

```
Open On-Chip Debugger 0.12.0-00024-gc3ff39f8b (2023-06-26-16:54) 
[https://github.com/STMicroelectronics/OpenOCD]
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : STLINK V2J42M27 (API v2) VID:PID 0483:3752
Info : Target voltage: 3.237319
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : clock speed 4000 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x5ba02477
Info : [STM32F767ZITx.cpu] Cortex-M7 r1p0 processor detected
Info : [STM32F767ZITx.cpu] target has 8 breakpoints, 4 watchpoints
Info : starting gdb server for STM32F767ZITx.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : [STM32F767ZITx.cpu] external reset detected
Info : accepting 'gdb' connection on tcp/3333
[STM32F767ZITx.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000964 msp: 0x20080000
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : device id = 0x10016451
Info : flash size = 2048 KiB
Info : Single Bank 2048 kiB STM32F76x/77x found
Info : accepting 'gdb' connection on tcp/3333
[STM32F767ZITx.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000964 msp: 0x20080000
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
[STM32F767ZITx.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000964 msp: 0x20080000
```

The debugger stopped in main().

After a Resume, execution stopped in the PendSV_Handler(). 

The next Resume stopped on the BRK. 

Subsequent Resumes alternated, first in the PendSV_Handler and then on the BRK.

So each physical breakpoint was accompanied by a rogue one in the exception 
handler.

2 ---

With 'ST-LINK (ST-LINK GDB server)' I got the following in the console:

```
STMicroelectronics ST-LINK GDB server. Version 7.4.0
Copyright (c) 2023, STMicroelectronics. All rights reserved.

Starting server with the following options:
        Persistent Mode            : Disabled
        Logging Level              : 1
        Listen Port Number         : 61234
        Status Refresh Delay       : 15s
        Verbose Mode               : Disabled
        SWD Debug                  : Enabled
        InitWhile                  : Enabled

Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
      -------------------------------------------------------------------
                        STM32CubeProgrammer v2.14.0                  
      -------------------------------------------------------------------



Log output file:   /tmp/STM32CubeProgrammer_ZpWCIx.log
ST-LINK SN  : 0668FF555052836687032322
ST-LINK FW  : V2J42M27
Board       : NUCLEO-F767ZI
Voltage     : 3.23V
SWD freq    : 4000 KHz
Connect mode: Under Reset
Reset mode  : Hardware reset
Device ID   : 0x451
Revision ID : Rev Z
Device name : STM32F76x/STM32F77x
Flash size  : 2 MBytes
Device type : MCU
Device CPU  : Cortex-M7
BL Version  : 0x93



Memory Programming ...
Opening and parsing file: ST-LINK_GDB_server_t9x1Yh.srec
  File          : ST-LINK_GDB_server_t9x1Yh.srec
  Size          : 6.60 KB 
  Address       : 0x08000000 


Erasing memory corresponding to segment 0:
Erasing internal memory sector 0
Download in Progress:

File download complete
Time elapsed during download operation: 00:00:00.420

Verifying ...

Download verified successfully 
```


The debugger stopped in main().

After a Resume, execution stopped in the PendSV_Handler(). 

The next Resume stopped on the BRK. 

Subsequent Resumes stopped only on the BRK.

So only the first physical breakpoint was accompanied by a rogue one in the 
exception handler, all other were somehow masked.


3 ---

With 'SEGGER J-Link' console:

```
SEGGER J-Link GDB Server V7.88h Command Line Version

JLinkARM.dll V7.88h (DLL compiled Jun 16 2023 09:16:13)

Command line: -port 2331 -s -device STM32F767ZI -endian little -speed 4000 -if 
swd -vd
-----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:               on
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:                 STM32F767ZI
Target device parameters:      none
Target interface:              SWD
Target interface speed:        4000kHz
Target endian:                 little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link EDU Mini V1 compiled Jun  6 2023 10:50:57
Hardware: V1.00
S/N: 801031924
Feature(s): FlashBP, GDB
Checking target voltage...
Target voltage: 3.30 V
Listening on TCP/IP port 2331
Connecting to target...
Halting core...
Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
GDB client (conn. 12) requested target.xml from GDB Server
Reading common registers: Read register 'r0' (4 bytes) from hardware: 0x00180240
Read register 'r1' (4 bytes) from hardware: 0x00B0B000
Read register 'r2' (4 bytes) from hardware: 0x00ED00E0
Read register 'r3' (4 bytes) from hardware: 0x00000010
Read register 'r4' (4 bytes) from hardware: 0x34000020
Read register 'r5' (4 bytes) from hardware: 0x00000000
Read register 'r6' (4 bytes) from hardware: 0x00000000
Read register 'r7' (4 bytes) from hardware: 0xD4FF0720
Read register 'r8' (4 bytes) from hardware: 0x00000000
Read register 'r9' (4 bytes) from hardware: 0x00000000
Read register 'r10' (4 bytes) from hardware: 0x00000000
Read register 'r11' (4 bytes) from hardware: 0x00000000
Read register 'r12' (4 bytes) from hardware: 0x00000080
Read register 'sp' (4 bytes) from hardware: 0xD4FF0720
Read register 'lr' (4 bytes) from hardware: 0xF9FFFFFF
Read register 'pc' (4 bytes) from hardware: 0xE6080008
Read register 'xpsr' (4 bytes) from hardware: 0x03000001
Read 4 bytes @ address 0x080008E6 (Data = 0xB480E7FE)
Received monitor command: ReadAPEx 0x0 0xF8
O.K.:0xE00FD003
Received monitor command: ReadMemAP 0x0 0xE00FDFD0 0x8 0x0
O.K.:0x00000000,0x00000000,0x00000000,0x00000000,0x00000051,0x00000004,0x0000001A,0x00000000
Connected to 127.0.0.1
GDB client (conn. 13) requested target.xml from GDB Server
Reading common registers: Read register 'r0' (4 bytes) from hardware: 0x00180240
Read register 'r1' (4 bytes) from hardware: 0x00B0B000
Read register 'r2' (4 bytes) from hardware: 0x00ED00E0
Read register 'r3' (4 bytes) from hardware: 0x00000010
Read register 'r4' (4 bytes) from hardware: 0x34000020
Read register 'r5' (4 bytes) from hardware: 0x00000000
Read register 'r6' (4 bytes) from hardware: 0x00000000
Read register 'r7' (4 bytes) from hardware: 0xD4FF0720
Read register 'r8' (4 bytes) from hardware: 0x00000000
Read register 'r9' (4 bytes) from hardware: 0x00000000
Read register 'r10' (4 bytes) from hardware: 0x00000000
Read register 'r11' (4 bytes) from hardware: 0x00000000
Read register 'r12' (4 bytes) from hardware: 0x00000080
Read register 'sp' (4 bytes) from hardware: 0xD4FF0720
Read register 'lr' (4 bytes) from hardware: 0xF9FFFFFF
Read register 'pc' (4 bytes) from hardware: 0xE6080008
Read register 'xpsr' (4 bytes) from hardware: 0x03000001
Read 4 bytes @ address 0x080008E6 (Data = 0xB480E7FE)
Received monitor command: reset
Resetting target
Downloading 504 bytes @ address 0x08000000 - Verified OK
Downloading 6208 bytes @ address 0x080001F8 - Verified OK
Downloading 16 bytes @ address 0x08001A38 - Verified OK
Downloading 8 bytes @ address 0x08001A48 - Verified OK
Downloading 4 bytes @ address 0x08001A50 - Verified OK
Downloading 4 bytes @ address 0x08001A54 - Verified OK
Downloading 12 bytes @ address 0x08001A58 - Verified OK
Writing register 'pc' = 0x08000964
Read 4 bytes @ address 0x08000964 (Data = 0xD034F8DF)
Read 2 bytes @ address 0x08000964 (Data = 0xF8DF)
Read 2 bytes @ address 0x08000966 (Data = 0xD034)
Read 4 bytes @ address 0xE000ED14 (Data = 0x00040200)
Reading register 'msp' = 0x20080000
Reading register 'psp' = 0x00000000
Downloading 4 bytes @ address 0xE000ED14 - Verified OK
Reading common registers: Read register 'r0' (4 bytes) from hardware: 0x00000000
Read register 'r1' (4 bytes) from hardware: 0x00000000
Read register 'r2' (4 bytes) from hardware: 0x00000000
Read register 'r3' (4 bytes) from hardware: 0x00000000
Read register 'r4' (4 bytes) from hardware: 0x00000000
Read register 'r5' (4 bytes) from hardware: 0x00000000
Read register 'r6' (4 bytes) from hardware: 0x00000000
Read register 'r7' (4 bytes) from hardware: 0x00000000
Read register 'r8' (4 bytes) from hardware: 0x00000000
Read register 'r9' (4 bytes) from hardware: 0x00000000
Read register 'r10' (4 bytes) from hardware: 0x00000000
Read register 'r11' (4 bytes) from hardware: 0x00000000
Read register 'r12' (4 bytes) from hardware: 0x00000000
Read register 'sp' (4 bytes) from hardware: 0x00000820
Read register 'lr' (4 bytes) from hardware: 0xFFFFFFFF
Read register 'pc' (4 bytes) from hardware: 0x64090008
Read register 'xpsr' (4 bytes) from hardware: 0x00000001
Read 4 bytes @ address 0x08000964 (Data = 0xD034F8DF)
Read 2 bytes @ address 0x08000964 (Data = 0xF8DF)
Read 2 bytes @ address 0x08000966 (Data = 0xD034)
Reading register 'msp' = 0x20080000
Reading register 'psp' = 0x00000000
Read 4 bytes @ address 0xE000EDFC (Data = 0x01000000)
Downloading 4 bytes @ address 0xE000EDFC - Verified OK
Reading common registers: Read register 'r0' (4 bytes) from hardware: 0x00000000
Read register 'r1' (4 bytes) from hardware: 0x00000000
Read register 'r2' (4 bytes) from hardware: 0x00000000
Read register 'r3' (4 bytes) from hardware: 0x00000000
Read register 'r4' (4 bytes) from hardware: 0x00000000
Read register 'r5' (4 bytes) from hardware: 0x00000000
Read register 'r6' (4 bytes) from hardware: 0x00000000
Read register 'r7' (4 bytes) from hardware: 0x00000000
Read register 'r8' (4 bytes) from hardware: 0x00000000
Read register 'r9' (4 bytes) from hardware: 0x00000000
Read register 'r10' (4 bytes) from hardware: 0x00000000
Read register 'r11' (4 bytes) from hardware: 0x00000000
Read register 'r12' (4 bytes) from hardware: 0x00000000
Read register 'sp' (4 bytes) from hardware: 0x00000820
Read register 'lr' (4 bytes) from hardware: 0xFFFFFFFF
Read register 'pc' (4 bytes) from hardware: 0x64090008
Read register 'xpsr' (4 bytes) from hardware: 0x00000001
Read 4 bytes @ address 0x08000964 (Data = 0xD034F8DF)
Read 2 bytes @ address 0x08000964 (Data = 0xF8DF)
Read 2 bytes @ address 0x08000966 (Data = 0xD034)
Reading register 'msp' = 0x20080000
Reading register 'psp' = 0x00000000
Reading 64 bytes @ address 0x08000500
Read 2 bytes @ address 0x08000538 (Data = 0xF000)
Setting breakpoint @ address 0x08000538, Kind = 2, Type = THUMB, BPHandle = 
0x0001
Starting target CPU...
...Breakpoint reached @ address 0x08000538
Reading common registers: Read register 'r0' (4 bytes) from hardware: 0x00000020
Read register 'r1' (4 bytes) from hardware: 0x0C000020
Read register 'r2' (4 bytes) from hardware: 0x00ED00E0
Read register 'r3' (4 bytes) from hardware: 0x1D020008
Read register 'r4' (4 bytes) from hardware: 0x34000020
Read register 'r5' (4 bytes) from hardware: 0x00000000
Read register 'r6' (4 bytes) from hardware: 0x00000000
Read register 'r7' (4 bytes) from hardware: 0xF8FF0720
Read register 'r8' (4 bytes) from hardware: 0x00000000
Read register 'r9' (4 bytes) from hardware: 0x00000000
Read register 'r10' (4 bytes) from hardware: 0x00000000
Read register 'r11' (4 bytes) from hardware: 0x00000000
Read register 'r12' (4 bytes) from hardware: 0x00000000
Read register 'sp' (4 bytes) from hardware: 0xF8FF0720
Read register 'lr' (4 bytes) from hardware: 0x9B090008
Read register 'pc' (4 bytes) from hardware: 0x38050008
Read register 'xpsr' (4 bytes) from hardware: 0x00000061
Removing breakpoint @ address 0x08000538, Size = 2
Read 4 bytes @ address 0x08000538 (Data = 0xFA3DF000)

```

The debugger stopped in main().

After a Resume, execution stopped on the BRK. 

Subsequent Resumes stopped only on the BRK.

So no physical breakpoint was accompanied by a rogue one in the exception 
handler, all were somehow masked.

---

To summarise:

- with J-Link, there were no rogue breaks; this confirms my initial report, 
that my tests passed with J-Link
- with ST-Link & ST-LINK GDB server, only the first break was accompanied by a 
rogue one
- with ST-LINK & OpenOCD, each break was accompanied by a rogue one.


Regards,

Liviu








Reply via email to