Skip to main content
AMais.1
Associate
Jan 6, 2022 2:08 PM UTC
Solved

MotionEC_Initialize generates an error when it is called

Hello,

It seems that the library MotionMC_CM7F_wc32_ot_hard.a is missing the called function, here the error :

c:\st\stm32cubeide_1.6.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\bin\ld.exe: ../Middlewares/ST/STM32_MotionMC_Library/Lib\MotionMC_CM7F_wc32_ot_hard.a(motion_mc.o): in function `MotionMC_Initialize':

motion_mc.c:(.text.MotionMC_Initialize+0xde): undefined reference to `MotionMC_SaveCalInNVM'

c:\st\stm32cubeide_1.6.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\bin\ld.exe: motion_mc.c:(.text.MotionMC_Initialize+0x1fc): undefined reference to `MotionMC_LoadCalFromNVM'

I'm just doing like the example, I erased and reinstalled MEMS and this library at the previous version but nothing changes, can you help me ?

Here the call :

#define VERSION_STR_LENGTH 35

#define SAMPLE_TIME 20

/* Magnetometer calibration API initialization function */

MotionMC_Initialize(SAMPLE_TIME, 1);

    This topic has been closed for replies.
    Miroslav BATEKBest answer
    ST Employee
    Jan 6, 2022 2:28 PM UTC

    Please add following function in your code.

    // NOTE: Must be implemented for each platform separately, because its implementation

    //    is platform dependent. No need to call this function, library call this

    //    function automatically.

    /**

     * @brief Load the calibration parameters from storage

     * @param dataSize size of data

     * @param data pointer to data

     * @retval Will return 0 the if it is success and 1 if it is failure

     */

    char MotionMC_LoadCalFromNVM(unsigned short int datasize, unsigned int *data)

    {

     return 1; /* FAILURE: Read from NVM not implemented. */

    }

    // NOTE: Must be implemented for each platform separately, because its implementation

    //    is platform dependent. No need to call this function, library call this

    //    function automatically.

    /**

     * @brief Save the calibration parameters in storage

     * @param dataSize size of data

     * @param data pointer to data

     * @retval Will return 0 the if it is success and 1 if it is failure

     */

    char MotionMC_SaveCalInNVM(unsigned short int datasize, unsigned int *data)

    {

     return 1; /* FAILURE: Write to NVM not implemented. */

    }

    5 replies

    Miroslav BATEKBest answer
    ST Employee
    Jan 6, 2022 2:28 PM UTC

    Please add following function in your code.

    // NOTE: Must be implemented for each platform separately, because its implementation

    //    is platform dependent. No need to call this function, library call this

    //    function automatically.

    /**

     * @brief Load the calibration parameters from storage

     * @param dataSize size of data

     * @param data pointer to data

     * @retval Will return 0 the if it is success and 1 if it is failure

     */

    char MotionMC_LoadCalFromNVM(unsigned short int datasize, unsigned int *data)

    {

     return 1; /* FAILURE: Read from NVM not implemented. */

    }

    // NOTE: Must be implemented for each platform separately, because its implementation

    //    is platform dependent. No need to call this function, library call this

    //    function automatically.

    /**

     * @brief Save the calibration parameters in storage

     * @param dataSize size of data

     * @param data pointer to data

     * @retval Will return 0 the if it is success and 1 if it is failure

     */

    char MotionMC_SaveCalInNVM(unsigned short int datasize, unsigned int *data)

    {

     return 1; /* FAILURE: Write to NVM not implemented. */

    }

    weibo
    Visitor II
    Oct 7, 2025 5:18 PM UTC

    Hello

    I have the same question as Melodi, that is where should I implement such two functions?

    I have tried some method, but they do not work. First, I implement these two functions in a sandbox in main.c, it does not word. Then I create a source file motion_ac.c in the same fold as motion_ac.h, and implement these two functions in motion_ac.c and declare function prototype in motion_ac.h, but it does not work either.

    So, where should I  implement such two functions?

    Thanks

    weibo
    Visitor II
    Oct 7, 2025 5:42 PM UTC

    I have solved this problem.

    These two functions should be implemented in a sandbox in main.c,and their function prototypes should be declared  in main.h.

    I previouly treated them as weak functions without declared prototypes, which lead to compile errors.

    AMais.1
    AMais.1Author
    Associate
    Jan 6, 2022 3:49 PM UTC

    Thank you, it works.

    Visitor II
    Jan 23, 2025 10:47 AM UTC

    Hello, 

    Where did you implement these functions in your code to make it work?

    Thanks,