【问题标题】:Ceedling and STM32CubeIDE: arm-none-eabi/bin/ld: warning: cannot find entry symbol Reset_Handler; defaulting to 0000000008000000Ceedling和STM32CubeIDE:arm-none-eabi/bin/ld:警告:找不到入口符号Reset_Handler;默认为 0000000008000000
【发布时间】:2022-11-11 05:30:25
【问题描述】:

我正在尝试使用 Ceedling/Unity/CMoke 为我的 STM32CubeIDE 项目创建第一个单元测试。

该项目已开始构建,但出现错误:

`正在链接 test_functions_STM32G474RB.out... /Applications/STMicroelectronics/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.macos64_1.0.0.202111181127/tools/bin/。 ./lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld:警告:找不到入口符号Reset_Handler;默认为 0000000008000000 运行 test_functions_STM32G474RB.out...

错误:测试可执行文件“test_functions_STM32G474RB.out”失败。

在 $stdout 中没有产生最终测试结果计数: sh: build/test/out/test_functions_STM32G474RB.out: 没有这样的文件或目录 并以状态退出:[0](失败测试计数)。 这通常是源代码或测试代码中内存访问错误的症状。

耙子中止了!`

这是 project.yml 文件:

'

---

# Notes:
# Sample project C code is not presently written to produce a release artifact.
# As such, release build options are disabled.
# This sample, therefore, only demonstrates running a collection of unit tests.

:project:
  :use_exceptions: FALSE
  :use_test_preprocessor: TRUE
  :use_auxiliary_dependencies: TRUE
  :build_root: build
#  :release_build: TRUE
  :test_file_prefix: test_
  :which_ceedling: gem
  :ceedling_version: 0.31.1
  :default_tasks:
    - test:all
        
#:test_build:
#  :use_assembly: TRUE

#:release_build:
#   :output: MyApp.out
#  :use_assembly: FALSE

:environment:

:extension:
  :executable: .out

:paths:
  :test:
    - +:test/**
    - -:test/support
  :source:
    - Core/Inc/**
    - Core/Src/**
    - Core/**
    - Drivers/CMSIS/Device/ST/STM32G4xx/Include/**
    - Drivers/CMSIS/Include/**
    - Drivers/STM32G4xx_HAL_Driver/Inc/**
    - Drivers/STM32G4xx_HAL_Driver/Inc/Legacy/**
  :support:
    - test/support
  :libraries: []

:defines:
  # in order to add common defines:
  #  1) remove the trailing [] from the :common: section
  #  2) add entries to the :common: section (e.g. :test: has TEST defined)
  :common: &common_defines []
  :test:
    - *common_defines
    - TEST
  :test_preprocess:
    - *common_defines
    - TEST

:cmock:
  :mock_prefix: mock_
  :when_no_prototypes: :warn
  :enforce_strict_ordering: TRUE
  :plugins:
    - :ignore
    - :callback
  :treat_as:
    uint8:    HEX8
    uint16:   HEX16
    uint32:   UINT32
    int8:     INT8
    bool:     UINT8
  :includes:
    - <stdbool.h>
    - <stdint.h>
  :treat_externs: :include

# Add -gcov to the plugins list to make sure of the gcov plugin
# You will need to have gcov and gcovr both installed to make it work.
# For more information on these options, see docs in plugins/gcov
:gcov:
  :reports:
    - HtmlDetailed
  :gcovr:
    :html_medium_threshold: 75
    :html_high_threshold: 90

#:tools:
# Ceedling defaults to using gcc for compiling, linking, etc.
# As [:tools] is blank, gcc will be used (so long as it's in your system path)
# See documentation to configure a given toolchain for use

:tools:
  :test_compiler:
    :executable: arm-none-eabi-gcc
    :arguments:
      - '${1}'
      - '-mcpu=cortex-m4'
      - '-std=gnu11'
      - '-g3'
      - '-DDEBUG'
      - '-DUSE_HAL_DRIVER'
      - '-DSTM32G474xx'
      - '-c'
      - '-I Core/Inc'
      - '-I Core/Startup'
      - '-I Drivers/STM32G4xx_HAL_Driver/Inc'
      - '-I Drivers/STM32G4xx_HAL_Driver/Inc/Legacy'
      - '-I Drivers/CMSIS/Device/ST/STM32G4xx/Include'
      - '-I Drivers/CMSIS/Include'
      - '-I #{Ceedling.load_path}/../vendor/unity/src'
      - '-I Core/Startup'
      - '-O0'
      - '-ffunction-sections'
      - '-fdata-sections'
      - '-Wall'
      - '-fstack-usage'
      - '--specs=nano.specs'
      - '-mfpu=fpv4-sp-d16'
      - '-mfloat-abi=hard'
      - '-mthumb'
  :test_linker:
    :executable: arm-none-eabi-gcc
    :arguments:
      - '-o "STM32G474RB - PLATFORM.elf"'
      - '-mcpu=cortex-m4'
      - '-T"/Users/raul/Documents/repository/platform-firmware-c/STM32G474RB - PLATFORM/STM32G474RBTX_FLASH.ld"'
      - '--specs=nosys.specs'
      - '-Wl,-Map="${BuildArtifactFileBaseName}.map"'
      - '-Wl,--gc-sections'
      - '-static'
      - '--specs=nano.specs'
      - '-mfpu=fpv4-sp-d16'
      - '-mfloat-abi=hard'
      - '-mthumb'
      - '-Wl,--start-group'
      - '-lc'
      - '-lm'
      - '-Wl,--end-group'

# LIBRARIES
# These libraries are automatically injected into the build process. Those specified as
# common will be used in all types of builds. Otherwise, libraries can be injected in just
# tests or releases. These options are MERGED with the options in supplemental yaml files.
:libraries:
  :placement: :end
  :flag: "-l${1}"
  :path_flag: "-L ${1}"
  :system: []    # for example, you might list 'm' to grab the math library
  :test: []
  :release: []

:plugins:
  :load_paths:
    - "#{Ceedling.load_path}"
  :enabled:
    - stdout_pretty_tests_report
    - module_generator
...

'

我试图在编译器/链接器标志上添加 .S 文件。但是,要么我做错了,要么它不起作用。

我真的很感激比我更有经验的人能指出我做错了什么。

提前致谢。

【问题讨论】:

  • 我怀疑您想从源代码中删除 Core/Src/** 和 Core/**。您尝试进行单元测试的代码在哪里?如果它位于单独的目录中,而不是与自动生成的东西混为一谈,那么测试它可能更容易。

标签: unit-testing stm32 stm32cubeide


【解决方案1】:

您没有组装您的启动文件 startup_stm32.S,其中可能定义了您的向量表和重置处理程序。

有时,我不知道为什么,在 Windows 上它没有被编译,因为扩展 S 有一个“不正确”的情况。尝试将其切换为小写或大写,它可能会有所帮助。

【讨论】:

    【解决方案2】:

    对于未来的访客,如果可以提供任何帮助……

    我最终使用 gcc 编译器而不是 arm 编译器。我从 :source: 包含中删除了 HAL 驱动程序和其余源文件。然后我用我想测试的代码创建了一个单独的 .h 和 .c 。然后我必须模拟一些包含的头文件,其中包含最少的函数和变量,以便能够构建测试代码。在某些情况下,对函数和变量进行了调整/模拟以使其工作。

    祝你好运…

    【讨论】:

      猜你喜欢
      • 2019-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-13
      相关资源
      最近更新 更多