/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / view file sizes / stdlib huge filesize puts Rlink over limit

Username:     
Password:     
             

Forum
  • Index
  •  » STM32 primer
  •  » view file sizes / stdlib huge filesize puts Rlink over limit

# 1   2009-05-17 23:58:43 view file sizes / stdlib huge filesize puts Rlink over limit

The_Todd
Member
Registered: 2008-12-07
Posts: 15

view file sizes / stdlib huge filesize puts Rlink over limit

First of all, what is the best way to see how many bytes each *.c file in my project uses when compiled? (Is this what the "text=xxx data=0 bss=0" means in the project explorer, if not, what do those mean?). My current method of determining this is looking in the output folder and see how many Kb the *.hex file is, but there must be a better way.

Second, When I include <stdlib.h> and call:

Code:

float f;
f = atoff("123.456");

Just this change causes the size of my hex file to more than double, from 39.6kb to 81.8kb, and causes me to get "code size exceeded" error!

The same thing happens when doing this to the "toggle" example project.
(using double and atof, or int and atoi have same issue)

Any input appreciated! This is a student project trying to use atoff when reading serial from a GPS.

Thanks,
Todd

Offline

 

# 2   2009-05-18 06:39:46 view file sizes / stdlib huge filesize puts Rlink over limit

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

Re: view file sizes / stdlib huge filesize puts Rlink over limit

The overall size can be much bigger than 81KB. You have to edit the LD file of your project to increase the size of FLASH managed by the linker.

Offline

 

# 3   2009-05-18 07:49:17 view file sizes / stdlib huge filesize puts Rlink over limit

The_Todd
Member
Registered: 2008-12-07
Posts: 15

Re: view file sizes / stdlib huge filesize puts Rlink over limit

Sorry, I meant that I get the "code size exceeded" error when trying to debug with RLink (32k limit). This is because a single call to stdlib uses basically all of the 32k limit. Is there a way to reduce the size of stdlib? atoff() can't actually consume 40k of flash can it?!

Also, for the first part of my initial question, how can I see the size of the compiled *.c files?

Thanks,
Todd

Offline

 

# 4   2009-05-18 08:52:58 view file sizes / stdlib huge filesize puts Rlink over limit

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

Re: view file sizes / stdlib huge filesize puts Rlink over limit

Size information: In the Project Windows, you can display this information (push on 'Show' then select Build Information. You can also look at the MAP file (View MAP File), but only after linked.

For debugging, this the difference between the standard license (limited up to 32KB) and the Pro license (no limitation). 
As a workaround, you can force the relocation of some functions (done in CircleOS) in the non-debuggable part (e.g. above 08008000). 
I am not sure if it works, but try the linker option 'Use small printf library'. We reduced the overall code size for Printf (and the called functions). But I am not sure because I don't see why atoff would be called (except if scanf had been optimized too...).

Offline

 

# 5   2009-05-18 22:04:51 view file sizes / stdlib huge filesize puts Rlink over limit

kubsztal
Member
Registered: 2009-01-27
Posts: 15

Re: view file sizes / stdlib huge filesize puts Rlink over limit

The_Todd :

Is there a way to reduce the size of stdlib? atoff() can't actually consume 40k of flash can it?!

Hi Todd,
I believe you don't need to use any library function for ascii to float conversion. Please check my small example I've just created:

float jma_atof(char * str);
float jma_atof(char * str)
{
    float float_1 = 0, float_2 = 0;
    char ind;
    unsigned long multi, divid;

    multi = 10;
    while (*str != '.' && *str != NULL)
    {
        float_1 *= multi;
        float_1 += (*str - 48);
        str++;
    }
    ind = 0;
    multi = 10;
    divid = 1;
    if (*str == '.')
    {
        str++;
        while (*str != NULL)
        {
            float_2 *= multi;
            float_2 += (*str - 48);
            divid *= 10;
            str++;
        }
        float_2 /= divid;
    }
    else
    {
        return float_1;
    }
    return (float_1 + float_2);
}

and for:

float a, b, c;
a = jma_atof("12345.6789");
b = jma_atof("12345");
c = jma_atof(".6789");

you should get the results as follows:

a = 12345.679
b = 12345.000
c = 0.67890000

For sure this function doesn't take 40kB wink

Offline

 

# 6   2009-05-19 06:30:47 view file sizes / stdlib huge filesize puts Rlink over limit

The_Todd
Member
Registered: 2008-12-07
Posts: 15

Re: view file sizes / stdlib huge filesize puts Rlink over limit

Thanks for your responses. kubsztal, I will try your code tommorow, I have tried to relocate stdlib to new flash section, and its getting very late. Do you have an atoi function as well?

Francis :

I am not sure if it works, but try the linker option 'Use small printf library'. We reduced the overall code size for Printf (and the called functions). But I am not sure because I don't see why atoff would be called (except if scanf had been optimized too...).

This does not affect the size of my program.

Francis :

For debugging, this the difference between the standard license (limited up to 32KB) and the Pro license (no limitation). 
As a workaround, you can force the relocation of some functions (done in CircleOS) in the non-debuggable part (e.g. above 08008000).

I tried this, and I did as you said by putting all standard library functions in a separate memory section above 0x8008000. I thought I would still be able to debug on the first 32k (put breakpoints and view values in first 32k only). The code with my modified linker compiles fine, however, I still get the code size limit exceeded error from Rlink when trying to debug. Here is how I modified the default linker file:

in ..._Defs.ld

Code:

/* Memory Spaces Definitions */

MEMORY
{
  RAM (xrw)         : ORIGIN = 0x20000000, LENGTH = 20K
  FLASH (rx)        : ORIGIN = 0x8000000, LENGTH = 32K
  FLASHBIG (rx)   : ORIGIN = 0x800B000, LENGTH = 64K

...................

in sections_FLASH.ld:

Code:

/* Sections Definitions */

SECTIONS
{
    /* ADDED BY ME This should catch stdlib code */
    .sect2 : 
    {
    . = ALIGN(4);
        lib_a* (.text .text.* .rodata .rodata.* .glue_7 .glue_7t) 
    } >FLASHBIG 
   /* REGULAR CODE BELOW */    

    /* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */
    .isr_vector :
    {
    . = ALIGN(4);
        KEEP(*(.isr_vector))            /* Startup code */
    . = ALIGN(4);
    } >FLASH

.............................

I've verified that the standard lib functions get put in the FLASHBIG section looking at the map file.

I would like to be able to at least debug (put breakpoints and watch variables)in the first 32k, while still being able to call the standard library functions located outside of the first 32k.

Todd

Offline

 

# 7   2009-05-19 07:35:25 view file sizes / stdlib huge filesize puts Rlink over limit

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

Re: view file sizes / stdlib huge filesize puts Rlink over limit

It's possible to debug, but with some limitations: youmust avoid any 'stop' in the non-debuggable area. It means that you have to go from a breakpoint to another without stopping (nor single-stepping) in the non-debuggable area. When you want to stop, set a breakpoint in the debuggable area at a location you know you will pass..

Offline

 

# 8   2009-05-19 08:07:50 view file sizes / stdlib huge filesize puts Rlink over limit

The_Todd
Member
Registered: 2008-12-07
Posts: 15

Re: view file sizes / stdlib huge filesize puts Rlink over limit

What you just described is what I would like to do.

Attached is my modified Primer Toggle Example project with my modified linker script. The stdlib functions are in the FLASH above 32Kb, the main.c functions all in the first 32Kb. It builds, programs, and runs fine, but will not debug.

Regards,
Todd

Offline

 

# 9   2009-05-19 16:11:08 view file sizes / stdlib huge filesize puts Rlink over limit

The_Todd
Member
Registered: 2008-12-07
Posts: 15

Re: view file sizes / stdlib huge filesize puts Rlink over limit

Sorry, I though I could attach a zip project but its just for images. Here is my example project:

http://www.mediafire.com/?sharekey=b75c … f6e8ebb871

-Todd

Offline

 

# 10   2009-05-19 17:33:34 view file sizes / stdlib huge filesize puts Rlink over limit

kubsztal
Member
Registered: 2009-01-27
Posts: 15

Re: view file sizes / stdlib huge filesize puts Rlink over limit

The_Todd :

Do you have an atoi function as well?

I don't have such one because I created atof just during reading this forum. For atoi you need only first loop from my example, remove checking for dot and assign result of calculations to (un)signed long instead of float. Before this loop you may add checking for minus sign in order to convert negative values correctly. Then after conversion of whole string multiply result by -1. You may also add checking for boundaries of (un)signed long and for accidental ascii characters other than digits inside the string.

Offline

 

# 11   2009-05-21 04:49:48 view file sizes / stdlib huge filesize puts Rlink over limit

The_Todd
Member
Registered: 2008-12-07
Posts: 15

Re: view file sizes / stdlib huge filesize puts Rlink over limit

Thanks kubsztal, I think I will probably end up using your function and doing atoi as well.

Francis, I know you are quite busy. I would still like to know how I could debug the first 32k while having additional data in flash above 32k with the Rlink. The file in my last post above contains the toggle example, adding in a call to atoff and my customized linker script that puts stdlib functions above 32k flash, Rlink still will not let me debug.

Thanks for your help!

Todd

Offline

 

# 12   2009-05-21 07:10:48 view file sizes / stdlib huge filesize puts Rlink over limit

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

Re: view file sizes / stdlib huge filesize puts Rlink over limit

No. you can debug the lowest part of your module as long as you don't "break" your execution in the upper part. Perhaps some old versin of RIDE7 didn't allow this mode (get the latest one from the Raisonance web site, but a new version will be released early next week...).

Offline

 

# 13   2009-05-22 01:57:35 view file sizes / stdlib huge filesize puts Rlink over limit

The_Todd
Member
Registered: 2008-12-07
Posts: 15

Re: view file sizes / stdlib huge filesize puts Rlink over limit

Francis, I'm using RIDE7 version 7.18.0903 and Rkit-ARM 1.18.0903, and I cannot perform the functionality you are describing. However, I will wait one week for the new version, try it again, and post the outcome.

Thanks,
Todd

Offline

 

# 14   2009-05-22 06:09:21 view file sizes / stdlib huge filesize puts Rlink over limit

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

Re: view file sizes / stdlib huge filesize puts Rlink over limit

It looks strange: you have the latest ARM kit, and it should work..
Could you describe what happen when you launch a debug session ?
Thanks

Offline

 

# 15   2009-05-22 08:30:18 view file sizes / stdlib huge filesize puts Rlink over limit

The_Todd
Member
Registered: 2008-12-07
Posts: 15

Re: view file sizes / stdlib huge filesize puts Rlink over limit

Francis, I have posted a youtube video of my screen showing what I experience:
http://www.youtube.com/watch?v=_VVl2lCKlLs
Sorry if the framerates a bit quick (Use the pause to read titles).

Thanks,
-Todd

Last edited by The_Todd (2009-05-22 08:32:35)

Offline

 

# 16   2009-05-22 09:05:27 view file sizes / stdlib huge filesize puts Rlink over limit

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

Re: view file sizes / stdlib huge filesize puts Rlink over limit

In the 'advanced ARM options', select 'STM32_PrimerX_CircleOS' and it will work (with X='1' or X='2').

Offline

 

# 17   2009-05-22 17:47:06 view file sizes / stdlib huge filesize puts Rlink over limit

The_Todd
Member
Registered: 2008-12-07
Posts: 15

Re: view file sizes / stdlib huge filesize puts Rlink over limit

Thank you so much Francis, that has resolved the problem. I really appreciate your time and effort with helping me.

Thanks,
Todd

Offline

 

  • Index
  •  » STM32 primer
  •  » view file sizes / stdlib huge filesize puts Rlink over limit

Board footer