/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Float / double math on CircleOS

Username:     
Password:     
             

Forum

# 1   2007-10-19 23:17:04 Float / double math on CircleOS

Tomorokoshi
New member
Registered: 2007-10-12
Posts: 3

Float / double math on CircleOS

I am working on something that will need floating point math. I can declare doubles, but I don't seem to get good math results, and there are no functions or output routines that use them.

Is this something in the works for a future update? Is anyone else working on adding floating point math to it?

Offline

 

# 2   2007-10-20 04:38:24 Float / double math on CircleOS

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: Float / double math on CircleOS

There is not any use of the loating point numbers in the CircleOS. But you are free to use float/double in your application. The math libraries provided with GCC will be added by the linker to your application (that will be probably big...).

Offline

 

# 3   2007-10-20 05:34:08 Float / double math on CircleOS

Tomorokoshi
New member
Registered: 2007-10-12
Posts: 3

Re: Float / double math on CircleOS

I tracked down part of my initial problem, and now it seems I can use the float math. However, I am using too much, because I get the following error:

----------------Make Started: 'PocketC5' in configuration 'Circle_Release'--------------------------
 
Building D:\Raisonance\Ride\Examples\PocketC5.rapp
Running : LD
\arm-none-eabi-gcc.exe -mcpu=cortex-m3 -mthumb  -Wl,-T -Xlinker "D:\Raisonance\Ride\Examples\objrelease\PocketC5.elf.ld" -u _start -Wl,-static -Wl,--gc-sections -nostartfiles -Wl,-Map -Xlinker "D:\Raisonance\Ride\Examples\objrelease\PocketC5.map"   
d:/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.2.0/../../../../arm-none-eabi/bin/ld.exe: region FLASH is full (D:\Raisonance\Ride\Examples\objrelease\PocketC5.elf section .text) 
rdimon-ram.ld:1: undefined symbol `!!!!!!!!! FLASH IS FULL !!!!!!!!!' referenced in expression 
collect2: ld returned 1 exit status 
 
Build failed

In other words, I am filling up the flash with a combination of float math and sprintf() to write a float variable to a text string. I set it to tiny printf, release mode, and optimize for size, but I cannot free enough memory. Because the compile fails, there is no memory map. What is the best way to determine how much memory I need to free to make it work?

Offline

 

# 4   2007-10-20 09:20:09 Float / double math on CircleOS

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: Float / double math on CircleOS

You reached the 32 KB limitation.
However the software tools are not really limited (only debugging with the embedded RLink). Therefore, you can pass over this message by modifying the LD script file.

Offline

 

# 5   2007-11-02 11:43:20 Float / double math on CircleOS

ThomasScherrer
Member
From: Denmark
Registered: 2007-10-29
Posts: 64
Website

Re: Float / double math on CircleOS

I included #include <math.h>
but cant x=sin(y);
get just Build Failed !
what is wrong ?


Thomas Scherrer Denmark webx.dk

Offline

 

# 6   2007-11-02 13:37:29 Float / double math on CircleOS

Tomorokoshi
New member
Registered: 2007-10-12
Posts: 3

Re: Float / double math on CircleOS

It seems that the functions for floating point math are not there. I will need to write my own 10^x, sqrt(x), and simple sprintf() routines.

The actual floating point math addition, subtraction, multiplication, and division seem to work. You should be able to find a lot about how to write those routines. The design of CircleOS seems to be that a minimum amount is provided to allow maximum space for other things.

Offline

 

# 7   2007-11-02 13:56:25 Float / double math on CircleOS

ThomasScherrer
Member
From: Denmark
Registered: 2007-10-29
Posts: 64
Website

Re: Float / double math on CircleOS

YIKES, I am not writing my own, it must be possible simply to include math.h the right place
and then get access to math ??
it can't be right this is not possible


Thomas Scherrer Denmark webx.dk

Offline

 

# 8   2007-11-02 14:15:32 Float / double math on CircleOS

ThomasScherrer
Member
From: Denmark
Registered: 2007-10-29
Posts: 64
Website

Re: Float / double math on CircleOS

>Therefore, you can pass over this message by modifying the LD script file.

HOW ??
can you please explain how this is done ?


Thomas Scherrer Denmark webx.dk

Offline

 

# 9   2007-11-02 14:19:34 Float / double math on CircleOS

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: Float / double math on CircleOS

I just opened a project, included math.h and checked that the following code works properly. It does.

float myf = 0;
void test ( void )
   {
   myf = 2*asin(1);
   }

Check the path of the "include" directories.

Offline

 

# 10   2009-02-07 21:15:09 Float / double math on CircleOS

auto.response
New member
Registered: 2007-12-06
Posts: 2

Re: Float / double math on CircleOS

It's looke like I have a similar problem.

#include <math.h>

...

void test_func()
{
  float calc_result_1 = 0.0;
  float calc_result_2 = 0.0;
  float test_value    = 0.6;

  calc_result_1 = atanf(0.6); // works ok
  //calc_result_2 = atanf(test_value); // uncommented and the following error message appears
}




----------------Build Started: 'Mems' in configuration 'Circle_Debug'--------------------------

Building C:\Programme\Raisonance\Ride\Examples\ARM\Primer\STM32\Mems\src\Mems.c
Running: GCC
\"C:\Programme\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -MD -D_STM32F103RBT6_ -D_STM3x_ -D_STM32x_ -mthumb   -mcpu=cortex-m3 "C:\Programme\Raisonance\Ride\Examples\ARM\Primer\STM32\Mems\src\Mems.c" -o "C:\Programme\Raisonance\Ride\Examples\ARM\Primer\STM32\Mems\src\objdebug\Mems.o" -I "." -I "C:\Programme\Raisonance\Ride\Lib\ARM\include" -c     -fsigned-char  -g          -ffunction-sections         -mlittle-endian
\"C:\Programme\Raisonance\Ride\Bin\rexrdr.exe" "C:\Programme\Raisonance\Ride\Examples\ARM\Primer\STM32\Mems\src\objdebug\Mems.lst" 0 "C:\Programme\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-objdump.exe" --disassemble -all --source "C:\Programme\Raisonance\Ride\Examples\ARM\Primer\STM32\Mems\src\objdebug\Mems.o"
\"C:\Programme\Raisonance\Ride\Bin\rexrdr.exe" "C:\Programme\Raisonance\Ride\Examples\ARM\Primer\STM32\Mems\src\objdebug\Mems.o.sizetmp" 0 "C:\Programme\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-size.exe" "C:\Programme\Raisonance\Ride\Examples\ARM\Primer\STM32\Mems\src\objdebug\Mems.o"
 
Building C:\Programme\Raisonance\Ride\Examples\ARM\Primer\STM32\Mems\src\Mems.rapp
Running: LD
\"C:\Programme\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -mcpu=cortex-m3 -mthumb  -Wl,-T -Xlinker "C:\Programme\Raisonance\Ride\Examples\ARM\Primer\STM32\Mems\src\objdebug\Mems.elf.ld" -u _start  -nostartfiles -Wl,-Map -Xlinker "C:\Programme\Raisonance\Ride\Examples\ARM\Primer\STM32\Mems\src\objdebug\Mems.map"   
c:/programme/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/bin/ld.exe: C:\Programme\Raisonance\Ride\Examples\ARM\Primer\STM32\Mems\src\objdebug\Mems.elf section .text will not fit in region FLASH 
c:/programme/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/bin/ld.exe: region FLASH overflowed by 1328 bytes
collect2: ld returned 1 exit status 
 
Build failed


I use the following versions:

Ride7 IDE v7.16.0000
RKit-ARM for Ride7 v1.16.0930


How can I solve this ?
Thanks for help.


#########################################
==> Following works for me:
GCC Compiler
Optimization level: Size optimization

Last edited by auto.response (2009-02-07 21:37:05)

Offline

 

# 11   2009-02-07 21:50:58 Float / double math on CircleOS

sjoerd
Member
From: Stad aan het Haringvliet
Registered: 2008-09-04
Posts: 65

Re: Float / double math on CircleOS

You need to extend the flash region in the .ld file of your project.

For example:
FLASH (rx) : ORIGIN = 0x8006000, LENGTH = 16K

also change _eflash accordingly.

Offline

 

# 12   2009-02-08 01:01:03 Float / double math on CircleOS

auto.response
New member
Registered: 2007-12-06
Posts: 2

Re: Float / double math on CircleOS

Thanks sjoerd.

I added the Circle_App.ld file to my project list and
changed the size.

[CODE]
...
MEMORY
{
  RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 16K
  FLASHB1 (r) : ORIGIN = 0x8000000, LENGTH = 0x0006000
  /*before*/// FLASH (rx) : ORIGIN = 0x8006000, LENGTH = 8K
  /*after*/ FLASH (rx) : ORIGIN = 0x8006000, LENGTH = 16K
  EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0
  EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0
  EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0
  EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0
}

/* higher address of the flash allowed for the program */
_eflash = 0x8006000 + 16K -1;
...
[\CODE]


But I don't know what to change at "_eflash = 0x8006000 + 16K -1;"
so I changed nothing (it works fine).

For explanations I found this:
http://www.stm32circle.com/forum/viewtopic.php?id=129

Offline

 

Board footer