微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Ceedling 使用了错误的启动文件

如何解决Ceedling 使用了错误的启动文件

我正在使用 Ceedling 对 STM32 代码进行单元测试。我的问题是 Ceedling 使用 crt0.S 作为启动文件,但我需要它使用 .S 代替(否则它会一直失败)。 可以在 project.yml 的某处指定吗?

这是我的编译器设置:

:tools:
  :test_compiler:
    :executable: arm-none-eabi-gcc
    :arguments:
      - "${1}"
      - '-c'
      - '-g'
      - '-mthumb' 
      - '-mcpu=cortex-m4' 
      - '-mfloat-abi=hard' 
      - '-mfpu=fpv5-sp-d16' 
      - '-mthumb' 
      - '-mabi=aapcs'
      - '-ffunction-sections'
      - '-ffreestanding' 
      - '-fdata-sections'
      - '-Wall'
      - '-Wno-address'
      #- '-std=c99'
      #- '-pedantic'
      - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE               #expands to -I search paths
      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_vendOR   #expands to -I search paths
      - -D$: COLLECTION_DEFInes_TEST_AND_vendOR  #expands to all -D defined symbols
      - -I"$": COLLECTION_PATHS_SOURCE_INCLUDE_vendOR
      - '-DTEST'
      - '-DUNITY_EXCLUDE_STDINT_H'
      - '-DUNITY_EXCLUDE_LIMITS_H'
      - '-DUNITY_EXCLUDE_SIZEOF'
      - '-DUNITY_INCLUDE_DOUBLE'
      - '-DUNITY_SUPPORT_TEST_CASES'
      - '-DUNITY_INT_WIDTH=32'
      - '-DUNITY_LONG_WIDTH=32'
  :test_linker:
    :executable: arm-none-eabi-gcc
    :arguments:
      - '-lm'
      - '-mcpu=cortex-m4'
      - '-mthumb'
      - '-specs=nosys.specs'
      - '-T STM32F412VGTx_FLASH.ld'
      - '-ffreestanding'

错误信息如下:

/usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: warning: cannot find entry symbol Reset_Handler; defaulting to 0000000008000000
/usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/lib/thumb/v7e-m/nofp/crt0.o: in function `_mainCRTStartup':
/build/newlib-CVVEyx/newlib-3.3.0/build/arm-none-eabi/thumb/v7e-m/nofp/libgloss/arm/semihv2m/../../../../../../../../libgloss/arm/crt0.S:545: undefined reference to `main'
collect2: error: ld returned 1 exit status
ERROR: Shell command Failed.

> Shell executed command:
'arm-none-eabi-gcc -lm -mcpu=cortex-m4 -mthumb -specs=nosys.specs -T STM32F412VGTx_FLASH.ld'
> And exited with status: [1].

还有我的 CMake 配置:

set(OBJECT_GEN_FLAGS "-ffunction-sections -fdata-sections")

set(CMAKE_C_FLAGS   "${OBJECT_GEN_FLAGS}" CACHE INTERNAL "C Compiler options")
set(CMAKE_CXX_FLAGS "${OBJECT_GEN_FLAGS}" CACHE INTERNAL "C++ Compiler options")
set(CMAKE_ASM_FLAGS "${OBJECT_GEN_FLAGS}" CACHE INTERNAL "ASM Compiler options")

# -Wl,--gc-sections     Perform the dead code elimination.
# --specs=nano.specs    Link with newlib-nano.
# --specs=nosys.specs   No syscalls,provide empty implementations for the POSIX system calls.
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections -ffunction-sections -fdata-sections -Wl,-Map=${CMAKE_PROJECT_NAME}.map" CACHE INTERNAL "Linker options")
# source files
set(SOURCES

    src/main.c
    src/ledblink.c
    src/sum2nums.c 
    Drivers/system_stm32f4xx.c

    inc/ledblink.h
    inc/sum2nums.h

    Drivers/stm32f4xx.h
    Drivers/system_stm32f4xx.h

    startup/startup_stm32f412vx.s
)

add_executable(${PROJECT_NAME}.elf ${SOURCES})

项目构建得很好...

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。