Enabling FPU causes device to reboot

I have this function that normalizes acceleration from IMU:

_Float16 normalize_accel_magnitude(_Float16 x, _Float16 y, _Float16 z, _Float16 max_g) {
  // Compute the magnitude squared of the acceleration vector
  _Float16 magnitude_squared = x * x + y * y + z * z;

  // Protect against very small values
  if (magnitude_squared < __FLT16_MIN__) {
    magnitude_squared = __FLT16_MIN__;
  }

  // Compute the magnitude of the acceleration vector
  _Float16 magnitude = sqrtf(magnitude_squared);

  // Normalize the magnitude using max_g
  if (max_g == 0.0f || fabs(max_g) < __FLT16_MIN__) {
    return 0.0f;
  }

  _Float16 normalized_value = (magnitude / max_g) - 1.0f;

  // Validate the normalized value
  if (!is_valid_float(normalized_value)) {
    return 0.0f;
  }

  return normalized_value;
}

If I enable FPU

CONFIG_FPU=y
CONFIG_FPU_SHARING=y
device works for a while (10s of seconds) then reboots, if its commented out it works fine ? the issue seams to be with 
sqrtf. 
Any ideas why enabling FPU would cause it?  Thanks!
Parents
  • Any ideas why enabling FPU would cause it?  Thanks!

    It would be best to first understand the nature of the reboot. If it is a softreset, then you should be able to put a breakpoint in sys_reboot function, start the application in debugger and try to understand the context of this reboot. If it is hardfault then you should enable the more logs to catch some serial logs to get the nature of the hardfault. 

Reply
  • Any ideas why enabling FPU would cause it?  Thanks!

    It would be best to first understand the nature of the reboot. If it is a softreset, then you should be able to put a breakpoint in sys_reboot function, start the application in debugger and try to understand the context of this reboot. If it is hardfault then you should enable the more logs to catch some serial logs to get the nature of the hardfault. 

Children
Related