2026-03-22 3:49 AM - edited 2026-03-22 3:50 AM
I'm stuck at trying to make motion_fx call MotionFX_LoadMagCalFromNVM and MotionFX_SaveMagCalInNVM - a problem which is mentioned already in link1 and link2 but to which actually there is no working solution (the rest of the motion_fx seems to work without any issue). I implemented the functions as below, but already when compiling, they get optimised out and end up being discarded - hence the motion_fx library never calls them, in contrary to what UM2220 suggests. My code does actively call MotionFX_MagCal_init(MFX_MAGCAL_SAMPLE_PERIOD_MS, 1); and MotionFX_MagCal_init(MFX_MAGCAL_SAMPLE_PERIOD_MS, 0); which as per UM2220 should trigger the call of the NVM functions. Here is my implementation:
volatile int deb_load_nvm_called = 0;
volatile int deb_save_nvm_called = 0;
char MotionFX_LoadMagCalFromNVM(unsigned short int dataSize, unsigned int *data)
{
Message_Logger("hi from save %i", deb_load_nvm_called);
deb_load_nvm_called++;
nvm_status_t s = NVM_Load(NVM_KEY_MAG_CAL, data, dataSize);
return (s == NVM_OK) ? 0 : 1; /* 0=success, 1=not performed per UM2220 */
}
char MotionFX_SaveMagCalInNVM(unsigned short int dataSize, unsigned int *data)
{
Message_Logger("hi from save %i", deb_save_nvm_called);
deb_save_nvm_called++;
nvm_status_t s = NVM_Save(NVM_KEY_MAG_CAL, data, dataSize);
return (s == NVM_OK) ? 0 : 1;
}Here is a snippet of my compiled .map file which confirms that they get optimised out.
.text.MotionFX_LoadMagCalFromNVM
0x00000000 0x50 ./Core/Src/motion_fx_fusion.o
.text.MotionFX_SaveMagCalInNVM
0x00000000 0x50 ./Core/Src/motion_fx_fusion.oEven after forcing the functions to not be discarded by the compiler
-Wl,--undefined=MotionFX_LoadMagCalFromNVM
-Wl,--undefined=MotionFX_SaveMagCalInNVMThe functions are now present in the .map file, but are never executed.
Is this eventually a misspelling of the functions? Can a ST employee please check this against the source code of the compiled library?
2026-04-01 6:23 AM
Hello @tizdipietro ,
I have sent you private message please check it.
2026-04-09 8:59 PM
I have encountered the same problem. Could you please tell me the solution?
2026-04-09 11:16 PM
Hello
@Miroslav BATEK confirmed that the issue is in the firmware. He suggested to send me a fix, but has not done so yet.
I solved it by storing the data from the application firmware directly on flash.