ThrowTheSwitch / Ceedling

Ruby-based unit testing and build system for C projects
http://throwtheswitch.org
Other
597 stars 246 forks source link

Ceedling Build Error: No Such Instruction cpsid i in cmsis_gcc.h #917

Closed DanSop closed 3 months ago

DanSop commented 3 months ago

I'm encountering a build error in my Ceedling project related to ARM Cortex-M assembly instructions. The error message is as follows:

Drivers/CMSIS/Include/cmsis_gcc.h:209: Error: no such instruction: cpsid i

This error is followed by many more of the same type. I have the following settings for my tools section of my project.yml file:

:tools: :test_file_preprocessor: :executable: arm-none-eabi-gcc :name: default_test_file_preprocessor :stderr_redirect: :none :background_exec: :none :optional: false :arguments:

  • "-E"
  • -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
  • -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE
  • "-D$": COLLECTION_DEFINES_TEST_AND_VENDOR
  • "-D$": DEFINES_TEST_PREPROCESS
  • "-DGNU_COMPILER"
  • "-include FreeRTOS.h"
  • '"${1}"'
  • -o "${2}" :test_file_preprocessor_directives: :executable: arm-none-eabi-gcc :name: default_test_file_preprocessor_directives :stderr_redirect: :none :background_exec: :none :optional: false :arguments:
  • "-E"
  • -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
  • -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE
  • "-D$": COLLECTION_DEFINES_TEST_AND_VENDOR
  • "-D$": DEFINES_TEST_PREPROCESS
  • "-DGNU_COMPILER"
  • "-include FreeRTOS.h"
  • "-fdirectives-only"
  • '"${1}"'
  • -o "${2}" :test_includes_preprocessor: :executable: arm-none-eabi-gcc :name: default_test_includes_preprocessor :stderr_redirect: :none :background_exec: :none :optional: false :arguments:
  • "-E"
  • "-MM"
  • "-MG"
  • -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
  • -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE
  • "-D$": COLLECTION_DEFINES_TEST_AND_VENDOR
  • "-D$": DEFINES_TEST_PREPROCESS
  • "-DGNU_COMPILER"
  • "-include FreeRTOS.h"
  • '"${1}"' :test_dependencies_generator: :executable: arm-none-eabi-gcc :name: default_test_dependencies_generator :stderr_redirect: :none :background_exec: :none :optional: false :arguments:
  • "-E"
  • -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
  • -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE
  • "-D$": COLLECTION_DEFINES_TEST_AND_VENDOR
  • "-D$": DEFINES_TEST_PREPROCESS
  • "-DGNU_COMPILER"
  • "-include FreeRTOS.h"
  • -MT "${3}"
  • "-MM"
  • "-MD"
  • "-MG"
  • -MF "${2}"
  • -c "${1}"

I am wondering how you deal with the ARM-specific instructions files for unit testing code that has dependencies on them (for example disable_irq).

Any help would be appreciated.

Letme commented 3 months ago

That tools section is missing test_compiler and test_linker fields, so I would actually assume your native GCC is trying to compile these files for x86x64.

Also, I assume you want to run this on target or in simulator correct?

DanSop commented 3 months ago

I am planning on running the test build on a simulator (likely qemu). I am only interested in the test build and not the release build at the moment.

Ah I forgot about those sections... I added the following:

:tools:
  :test_compiler:
    :executable: arm-none-eabi-gcc
    :arguments:
      - ${1}
      - -DTARGET
      - -mcpu=cortex-m7
      - -mthumb
      - -mfloat-abi=hard
      - -g
      - -I../            
      - -I"$": COLLECTION_PATHS_RELEASE_TOOLCHAIN_INCLUDE 
      - -Wall
      - -Os
      - -c
      - -o ${2}
  :test_linker:
    :executable: arm-none-eabi-gcc
    :arguments:
      - ${1}
      - -DTARGET
      - -I../            
      - -I"$": COLLECTION_PATHS_RELEASE_TOOLCHAIN_INCLUDE 
      - -mcpu=cortex-m7
      - -mthumb
      - -mfloat-abi=hard
      - -Wl,-Map="stmBase.map"
      - -g
      - -T"../STM32H743IIKX_FLASH.ld"  
      - --specs=nosys.specs
      - -o ${2}.elf
  :test_assembler:
    :executable: arm-none-eabi-gcc
    :arguments:
      - ${1}
      - -DTARGET
      - -I"$": COLLECTION_PATHS_RELEASE_TOOLCHAIN_INCLUDE 
      - -mcpu=cortex-m7
      - -mthumb
      - -mfloat-abi=hard
      - -g
      - -Wall
      - -Os
      - -c
      - -o ${2}

Unfortunately when I run test:all I get the following error:

Generating include list for arm_math.h...
Creating mock for arm_math...
Generating runner for test_DSP.c...
Compiling test_DSP_runner.c...
build/test/runners/test_DSP_runner.c:4:10: fatal error: unity.h: No such file or directory
    4 | #include "unity.h"
      |          ^~~~~~~~~

Seems that this unity dependency is no longer being met. This unity include seems to work just fine with GCC. I installed ceedling from gem install ceedling therefore I assume that these files are already in my system path?

Is my only option here to manually include the unity source files in this ceedling build?

Letme commented 3 months ago

You are missing some includes in the test_compiler section, which by default structure are included, but because you overwrite that you need to ensure they are also part of it. But from the top of my head I do not remember which (sorry). You also have COLLECTION_PATHS_RELEASE_TOOLCHAIN_INCLUDE, while I after quick search of my projects have:

      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR
      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
DanSop commented 3 months ago

Ah thank you that worked! Very much appreciated I believe I can get the rest of it working now.