azhel12 / Zhele

Framework for Stm32 MCU on C++ templates. Project based on "mcucpp" by Konstantin Chizhov.
BSD 2-Clause "Simplified" License
42 stars 10 forks source link

Debug #36

Open dlprfid opened 1 month ago

dlprfid commented 1 month ago

Hi. Can you help me for debug? I am connected in-circuit by st-link v3. My configuration: { "name": "Cortex Debug", "cwd": "${workspaceFolder}", "executable": "${command:cmake.launchTargetPath}", "request": "launch", "type": "cortex-debug", "interface": "swd", "runToEntryPoint": "main", "showDevDebugOutput" : "raw", "device": "STM32G431KBUx", "servertype": "openocd", "configFiles": [ "interface/stlink.cfg", "target/stm32g4x.cfg" ], "svdFile": "${workspaceFolder}/misc/STM32G431.svd" }

CPU write good, but not debug. When I start connection yes, but not stop on main(). Debug console i see error: ........... 19-var-create --thread 1 --frame 0 hover_7a75c957b76689d3b6a0a85c8c658938ef2dc0b775bca777cfb982c515a1b9e3 @ "_tx_thread_created_ptr" -> 19^error,msg="-var-create: unable to create variable object" .........

Have you any idea for it?

Thank you.

azhel12 commented 1 month ago

Hello, debug is not a part of my project, but some ideas:

  1. This error ("-var-create: unable to create variable object") as I think, not an associated with whole debug problem. Variable may be optimized.
  2. What optimizer flags is used? Try O0 or Og for debug.
  3. Try to add breakpoint on some main function manually.
  4. With high-level optimize compiler can remove main() call, I see this one time.
dlprfid commented 1 month ago

Hi! Thank you for your answer.

........ SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -gstabs+" CACHE INTERNAL "c debug compiler flags") SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -gstabs+" CACHE INTERNAL "cxx debug compiler flags") SET(CMAKE_ASM_FLAGS_DEBUG "-g -gstabs+" CACHE INTERNAL "asm debug compiler flags") ....... It's my settings. Can you write example for your settings?

dlprfid commented 1 month ago

I think my problem in FreeRTOS added... If you have any example with FreeRTOS & Zhele - help me, please...

azhel12 commented 1 month ago

This is CMakeLists example, debug also works (for my F4)

# Add zhele
include(FetchContent)
FetchContent_Declare(Zhele
    zhele
    GIT_REPOSITORY https://github.com/azhel12/Zhele.git
    GIT_TAG        master
)
FetchContent_MakeAvailable(zhele)

# Add FreeRTOS
include(FetchContent)
FetchContent_Declare(
    freertos_kernel
    GIT_REPOSITORY https://github.com/FreeRTOS/FreeRTOS-Kernel.git
    GIT_TAG        V11.1.0
)
FetchContent_Populate(freertos_kernel)
set(FREERTOS_PATH "${freertos_kernel_SOURCE_DIR}")
find_package(FreeRTOS COMPONENTS ARM_CM4F REQUIRED)
target_include_directories(FreeRTOS INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty_configs/FreeRTOS)

...

add_executable(${CMAKE_PROJECT_NAME} ${PROJECT_SOURCES})
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE
    CMSIS::STM32::F407VG zhele::zhele
    FreeRTOS FreeRTOS::ARM_CM4F FreeRTOS::Timers FreeRTOS::Heap::4 FreeRTOS::EventGroups
    lwip_core lwip_apps lwip_mbedtls
    STM32::NoSys STM32::Nano)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE HSE_VALUE=16000000 HSI_VALUE=16000000 F_CPU=168000000)
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -flto)
dlprfid commented 1 month ago

figure_1 Hi! Thank you for replay! My settings the same. So, maybe error in launch.json? Can you show me it?

azhel12 commented 1 month ago

My launch.json more simple:) Example for G0 (I'm using CMSIS-DAP, replace interface setting with st-link, target and SVD with your):

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Cortex Debug",
            "cwd": "${workspaceFolder}",
            "executable": "./build/${workspaceFolderBasename}.elf",
            "request": "launch",
            "type": "cortex-debug",
            "runToEntryPoint": "main",
            "servertype": "openocd",
            "configFiles": [
                "interface/cmsis-dap.cfg",
                "target/stm32g0x.cfg"
            ],
            "svdFile": "${workspaceFolder}/misc/STM32G030.svd"
        }
    ]
}