mcu-debug / peripheral-viewer

Standalone Peripheral(SVD) Viewer extension extracted from cortex-debug, now works with any debugger
MIT License
10 stars 5 forks source link

SVD file in config, error during microcontroller initialization FDCAN->ARA being set #13

Open andyinno opened 1 year ago

andyinno commented 1 year ago

Type: Bug Report

Describe the bug

Just for future reader... I posted my original question here: https://github.com/Marus/cortex-debug/issues/931#issue-1900492186

I am configuring FDCAN on a STM32 H5 microcontroller.

I have the situation in which adding the following line:

"svdFile": "${workspaceRoot}/.vscode/STM32H573.svd",

and enabling the interrupts I have continuously the following error set:

immagine

I therefore disabled the interrupt again and while having the XPERIPHERALS windows active I checked in which line the error flag is set.

the flag is set as soon as the __HAL_RCC_FDCAN_CLK_ENABLE macro is called in the initialization code. The interrupt is then always asserted and the program does not proceed.

Seen that I am using openocd for connecting to the nucleo board, (openocd config generated by stm32cube) I loaded the elf file in stm32cube and debugged it from there. I can confirm that also enabling the corresponding XPERIPHERALS window of the stm32cube, the program executes normally. The error is not set.

this means:

To Reproduce Steps to reproduce the behavior:

  1. Configure FDCAN
  2. In launch.json enable the SVD file loading
  3. proceed to FDCAN initialization
  4. step on __HAL_RCC_FDCAN_CLK_ENABLE macro
  5. FDCAN ARA in FDCAN_IR is set
  6. disabling the svd in launch.json fdcan initialize correctly and it works correctly

Expected behavior

to be able to debug my code while having a SVD file loaded

Code sample and logs


      "executable": "${workspaceRoot}/build/Target/Cross/STM32H573VI/NonSecure/non_secure.elf",
      "servertype": "openocd",
      "serverpath": "/home/andrea/st/stm32cubeide_1.9.0/plugins/com.st.stm32cube.ide.mcu.externaltools.openocd.linux64_2.2.300.202301161003/tools/bin/openocd",
      "searchDir": [
        "/home/andrea/st/stm32cubeide_1.9.0/plugins/com.st.stm32cube.ide.mcu.debug.openocd_2.1.0.202306221132/resources/openocd/st_scripts"
      ],
      "configFiles": [
        "${workspaceRoot}/Src/Target/Cross/STM32H573VI/NonSecure/STM32H573VI.cfg"
      ],
      "name": "hdm",
      "cwd": "${workspaceRoot}",
      "gdbPath": "arm-none-eabi-gdb",
      "runToEntryPoint": "main",
      "postRestartCommands": ["break main", "continue"],
      "request": "launch",
      "type": "cortex-debug",
      "showDevDebugOutput": "raw",
      "loadFiles": [
        "${workspaceRoot}/build/Target/Cross/STM32H573VI/Secure/secure.elf",
        "${workspaceRoot}/build/Target/Cross/STM32H573VI/NonSecure/non_secure.elf"
      ],
      "symbolFiles": [
        {
          "file": "${workspaceRoot}/build/Target/Cross/STM32H573VI/NonSecure/non_secure.elf"
        },
        { "file": "${workspaceRoot}/build/Target/Cross/STM32H573VI/Secure/secure.elf" }
      ],
      // "svdFile": "${workspaceRoot}/.vscode/STM32H573.svd",
       "liveWatch": {
         "enabled": true,
         "samplesPerSecond": 4
       },

      //"rttConfig": {
      //  "enabled": true,
      //  "address": "auto",
      //  "clearSearch": true,
      //  "decoders": [
      //    {
      //      "label": "RTT CH: 0",
      //      "port": 0,
      //      "type": "console"
      //    }
      //  ]
      //},
       "swoConfig": {
         "enabled": true,
         "cpuFrequency": 250000000,
         "swoFrequency": 2500000,
         "source": "probe",
         "decoders": [
           {
             "type": "console",
             "label": "ITM0",
             "port": 0,
             "encoding": "ascii"
           }
         ]
       }
    }```

**Screenshots**
<!-- If applicable, add screenshots to help explain your problem. -->

**Additional context**
<!-- Provide any other context about the problem. -->

I configured the microcontroller with TrustZone, can initialization takes place in secure fw. 
andyinno commented 1 year ago

As an additional information, I tried to step debug with SVD file loading by using jlink instead.

By using jlink the FDCAN initialization proceed without the error mentioned before by using openocd.

With this information I am unsure if this issue is related to peripheral viewer or to openocd. Feel free to close it if not related to peripheral viewer. Otherwise if you think I need to investigate a bit more, please provide some additional test to perform.

thank you