Skip to content

atan2f causes reset/reboot #490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
KillingJacky opened this issue Jun 30, 2015 · 3 comments
Closed

atan2f causes reset/reboot #490

KillingJacky opened this issue Jun 30, 2015 · 3 comments

Comments

@KillingJacky
Copy link
Contributor

The following code:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("\r\n");
}

void loop() {
  // put your main code here, to run repeatedly:
  float f = -459.00;
  float t = -38.00;
  int i = digitalRead(13);
  t += i * 10.0;  //if comment out this line, it works!
  Serial.println(atan2f(t, f));

  delay(1000);
}

The weird thing is, if comment out t+=i*10.0 , it works. Actually, the code above is simplified from my project. In my project, I propagated the operation variable of atan2f from the reading of I2C device.
So the sign is, if the variable for atan2f is polluted by hardware output, atan2f will cause reset.

Another info, if call ets_memcpy/os_memcpy before atan2f, will also make atan2f call cause reboot.

Why? Another bug of cross-toolchain?

@KillingJacky
Copy link
Contributor Author

I tried put libm into .text section rather than .irom0.text, no good.
Also I tried using -O1 rather than -Os, no good either.

@igrr
Copy link
Member

igrr commented Jun 30, 2015

see #233, #354
The fix has two parts:

  • 81c9edb
  • on Windows, libm.a was not built with math functions enabled. I have uploaded an updated toolchain but haven't changed the .json files yet. Use libm.a from linux or mac toolchain if you happen to be on windows.

@KillingJacky
Copy link
Contributor Author

Fixed.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants