cancel
Showing results for 
Search instead for 
Did you mean: 

MotionFX_LoadMagCalFromNVM and MotionFX_SaveMagCalInNVM never called

tizdipietro
Associate III

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.o

 Even after forcing the functions to not be discarded by the compiler

-Wl,--undefined=MotionFX_LoadMagCalFromNVM
-Wl,--undefined=MotionFX_SaveMagCalInNVM

 The 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?

3 REPLIES 3
Miroslav BATEK
ST Employee

Hello @tizdipietro ,

I have sent you private message please check it.

I have encountered the same problem. Could you please tell me the solution?

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.