Weird assembly error in arm cortex m7f

Hey guys, I'm writing code for an project and I'm using the verdim imx8mp SOM that have an Arm Cortex®-M7F that I'm going to use as a way to integrate the gpio part of the project.

I'm using the cortex-m in version 0.7.7 and when I compile the code got this that is super weird:

error: unknown directive
  |
note: instantiated into assembly here
 --> <inline asm>:5:25
  |
5 |                         .thumb_func
  |                         ^

error: invalid operand for instruction
  |
note: instantiated into assembly here
 --> <inline asm>:8:5
  |
8 | mov r0, lr
  |     ^

error: invalid operand for instruction
  |
note: instantiated into assembly here
 --> <inline asm>:9:34
  |
9 | ...                   movs r1, #4
  |                            ^

error: invalid operand for instruction
   |
note: instantiated into assembly here
  --> <inline asm>:10:33
   |
10 | ...                   tst r0, r1
   |                           ^

error: invalid operand for instruction
   |
note: instantiated into assembly here
  --> <inline asm>:12:33
   |
12 | ...                   mrs r0, MSP
   |                           ^

error: invalid operand for instruction
   |
note: instantiated into assembly here
  --> <inline asm>:15:33
   |
15 | ...                   mrs r0, PSP
   |                           ^

I'm not using any type of assembly code in my project is just rust for the arm processor and for the a53 CPU.

Does anybody can help me debug this? If you need a code snippet from my project feel free to ask

Thanks for the help in advance

This looks like some assembly coming from the cortex-m or cortex-m-rt internals — Rust is just showing you the exact inline asm the crate expands to.

The real issue is usually that the Cortex-M code is being compiled with the wrong target triple, so the A53 assembler tries to read Thumb instructions and chokes on things like .thumb_func, movs, mrs, etc.

Basically, nothing is wrong with your Rust, but something you, maybe indirectly. depend on does include raw assembly, and Rust is just reporting it. Double-check your Cargo config and make sure that your Cortex-M crate is actually built for thumbv7em-none-eabihf (or whichever Cortex-M7 target you're using) instead of an aarch64 target.

I have fixed the issue. It's like you told, I had in /.cargo/cargo.toml the project building for M7 using gcc and it was conflicting for the sub project for the M7 that have it's on cargo.toml.

Thanks for the help!

Glad it’s resolved!
If my earlier reply pointed you in the right direction, you could mark it as the solution so others can find it more easily.