Skip to main content
Visitor II
January 6, 2022
Solved

MotionEC_Initialize generates an error when it is called

  • January 6, 2022
  • 2 replies
  • 2399 views

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.
    Best answer by Miroslav BATEK

    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. */

    }

    2 replies

    ST Employee
    January 6, 2022

    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. */

    }

    Visitor II
    October 7, 2025

    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

    Visitor II
    October 7, 2025

    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.1Author
    Visitor II
    January 6, 2022

    Thank you, it works.

    Visitor II
    January 23, 2025

    Hello, 

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

    Thanks,