This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

scary STM32F4 compiler issue?

I am investigating what looks to be a memory corruption issue. I am stepping through the assembler and I cannot explain what I see. It's as if the microcontroller is not correctly interpreting the assembler code that was generated by the compiler.

Brief context (more detail later):
- IDE-Version: µVision V5.18.0.0
- Toolchain: MDK-ARM Standard Version: 5.18
- C Compiler: Armcc.exe V5.06 update 1 (build 61)
- Assembler: Armasm.exe V5.06 update 1 (build 61)
- Target hardware: STM3240G-EVAL with STM32F457IGH6

Issue details:
I have trapped execution at a breakpoint in my code at which things seem to be fine ("*"=breakpoint, "-"=execution point).

    0x080073EC 4629      MOV           r1,r5
* - 0x080073EE F104000C  ADD           r0,r4,#0x0C
    0x080073F2 F7FEFD71  BL.W          FilterList::Add (0x08005ED8)


Registers and "Call Stack and Locals" are as I might expect.

I then hit F11 to step one instruction of the assembler and instead of the program counter moving to 0x080073F2, the Program Counter goes to 0x080073F0 and the disassembled code displayed is changed.

    0x080073EC 4629      MOV           r1,r5
*   0x080073EE F104000C  ADD           r0,r4,#0x0C
  - 0x080073F0 000C      MOVS          r4,r1
    0x080073F2 F7FEFD71  BL.W          FilterList::Add (0x08005ED8)


It's as though the MCU has executed a 2 byte instruction instead of the 4 byte instruction that was displayed.

The subsequent "unexpected" 2 byte instruction (MOVS r4,r1) then tramples all over a pointer which later gives rise to a Hard Fault error.

For all the world, it looks like the microcontroller is not doing what the compiler had intended it to do.

Other stuff that might or might not be relevant:
- The code uses ITM to display debug messages in the Serial "Debug (printf) viewer"
- Much of the code is written in C++ but also links to the ST "Cube" HAL.
- Microlib is enabled
- The microcontroller on the STM3240G-EVAL board is clearly marked "STM32F457IGH6". I can find no mention of this as a valid ST part. I have set the Device in uVision as STM32F407IGHx since that is what I had expected the STM3240G-EVAL board to contain.

Can anyone shed any light on what is going on?

Thanks,
Richard

Parents Reply Children