Hard Fault in Standard Library Math Functions for Cortex M0+

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Hard Fault in Standard Library Math Functions for Cortex M0+


      I've been having issues with what I think are the precompiled standard libraries for the ARM architecture I'm using. I'm compiling for an STM32G031J6.

      I first noticed the issues appearing as a hard fault when trying to do floating-point operations. The chip doesn't have an FPU, and according to the debugger it was using pre-compiled functions for that math as expected. I switched to fixed-point math when I couldn't solve the issue, but it cropped up again when trying to do 64-bit division for the fixed-point math. Currently the code is getting stuck in an infinite loop inside this function: __int64_udivmod.

      What I've tried so far:
      Lots of Googling for issues related to math functions
      Trial-and-error toggling of settings in SES that seem related to compilation targets, standard library, etc
      Switching SES compiler to clang instead of GCC. Code got stuck in the equivalent clang math function.
      Switching SES compiler to SEGGER instead of GCC. Code got stuck in the __udivdi3 function.
      Switching ARM architectures wherever it's found in SES settings to v6 or v7, instead of v6M. Code hard-faulted or got stuck in the same function.

      I attached pictures of the SES settings window.

      Any pointers towards a solution for this would be appreciated.
      • Settings1.PNG

        36.04 kB, 551×676, viewed 18 times
      • Settings2.PNG

        26.57 kB, 659×481, viewed 15 times
    • Hello,

      Thank you for your inquiry.
      Such an issue is not known to us.
      Which Embedded Studio version are you using?
      Do you see the same behaviour with the latest Embedded Studio version?
      Could you provide an example project for the STM32G031 for reproduction?
      Are you using custom hardware or an eval board?

      Best regards,
      Please read the forum rules before posting: Forum Rules

      Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.