C-code generation with Simulink for AVR32

12 posts / 0 new
Last post
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello! Does anybody use Simulink Real-Time Workshop Embedded Coder to generate c-code for AVR32 linux application? My program was successfully compiled but give NaN output instead of double value after some correct iterations on NGW100 board, while it successfully run on host maschine under Ubuntu 8.04 (compiled with gcc in eclipse) and under WinXP. I use avr32-linux-gcc compiler generated with Buildroot 2.2.0-rc6. Maybe there are key factors in c-code generator setup specially for AVR32 target? Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Update to buildroot 2.2.0 stable, there was a fix which for almost exactly what you say. I thought that fix was in -rc6 but I can't be sure..

-S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I thought that latest Buildroot is 2.2.0-rc6. I confused with Buildroot versions.. Tell me please what is 2.2.0 stable and what rc6 means? I heard about NaN fix in latest Buildroot but I can't find any information about this problem on web. Atmel's support answered me with suggestion to debug program with gdb server but there are no words about avr32-linux-compiler version.
And what You mean saying about Buildroot update? Is it only avr32 compiler version update actual for me? Or I need new linux rootfs and kernel update? Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

RC6 - Release Candidate 6 (this is from 20080918) while the stable version is from 20080925.

http://www.atmel.no/buildroot/buildroot-src.html

Life's to short for waiting on slow CPU's

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

eaanon01, thanks for explanation!

squidgit wrote:
Update to buildroot 2.2.0 stable, there was a fix which for almost exactly what you say. I thought that fix was in -rc6 but I can't be sure..

-S.


squidgit, I compiled my project with avr32-linux-gcc generated with Buildroot 2.2.0 stable and 2.2.0-rc6 both but there is still NaN error.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can you reduce the failing code to a small test case? Hard to debug this without any code.

Hans-Christian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I found the source of NaN problem. The code is:

    eml_N_sum = sqrt(eml_N_hor_sp * eml_N_hor_sp + eml_N_ver_sp * eml_N_ver_sp);
    rtb_Gam_sp = asin(eml_N_hor_sp * sqrt(eml_N_sum * eml_N_sum - eml_N_ver_sp *
      eml_N_ver_sp) / eml_N_sum);

When eml_N_hor_sp == 0 && eml_N_ver_sp != 0, then Sqrt counts eml_N_sum incorrectly, so after first sqrt
(eml_N_sum < eml_N_ver_sp)
(in WinXP host machine they are equal and there is no error!). Next command try to take sqrt from negative number and gives NaN.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tried implementing this example in avr32studio(XP) but I got a strange error(strange for me at least).

#include 
...
{
double start=4;
sqrt(4);
sqrt(start);
...

Then I get the following error:

undefined reference to `sqrt' Test01 main.c

But only on the sqrt with a variable as input?

Life's to short for waiting on slow CPU's

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you link with "-lm"?

Hans-Christian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can You tell me is the function sqrt for AVR32 of double type? I can't understand where is the problem why sqrt of host machine works good but not on AVR32? Is it only architecture difference or math.h incompatibility?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

From libm/w_sqrt.c:

Quote:
double sqrt(double x)

Implemented in the libm/e_sqrt.c file, and it is a general implementation done in C, not architecture specific.

Hans-Christian

Pages