cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with memcpy function in new IDE version

DBrau.2
Associate III

When I use memcpy like this: 

memcpy(&config, SavedConf, sizeof(config));

whre config is an object and SavedConf is an array it turns out that nothing is copied.

The problem is in version 1.9 of CubeIDE, when I compile it in 1.7 the array is copied normally.

6 REPLIES 6
TDK
Guru

What chip? Is data cache enabled?

> it turns out that nothing is copied

How did you determine this exactly?

memcpy is a pretty standard function. You can step through (in assembly) to verify that it does in fact copy bytes over.

If you feel a post has answered your question, please click "Accept as Solution".
KnarfB
Principal III

A minimum working example demonstrating the error is needed.

KnarfB

DBrau.2
Associate III

I check it running program (empty config not allow to log in) and debugging where I see that object config is empty after memcpy.

The chip is stm32g474. I didn't change anything in protection of memory and the same code works on CubeIDE 1.7 version

DBrau.2
Associate III

I have installed toolchain 9-2020-q2-update and the problem is solved, but I'd like to know what caused that and what can I change to run it using new toolchain 10.3-2021.10

Bob S
Principal

Do what @TDK​ and @KnarfB​ have suggested above :)

The ver 10 compiler has different configuration defaults from the 9.x version. Do you get any warnings when compiling? Turn on -Wall and -Wextra (which may flag some lines in Cube-provided code). Turn off optimization and see if that makes a difference. memcpy() may be inlined in come circumstances (usually for "small" structures/objects).

You'd probably want to start with a disassembly to understand if it's calling library code, inlining, or optimizing away things.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..