Quantcast

Code does not fit in ROM with mspgcc but fits with CCS compiler

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Code does not fit in ROM with mspgcc but fits with CCS compiler

arvindpdmn
Hi Folks,

My friend has Code Composer Studio (CCS) license. He compiled without debugging and no optimization. Code size (ROM) is only 35 KB. This is good for MSP430G2955 that has 56 KB of Flash.

I compiled the same code using mspgcc, I get the following (-g -Oo):

/usr/lib/gcc/msp430/4.6.3/../../../../msp430/bin/ld: lpwmn.elf section `.text' will not fit in region `rom'
/usr/lib/gcc/msp430/4.6.3/../../../../msp430/bin/ld: section .vectors loaded at [0000ffe0,0000ffff] overlaps section .text loaded at [00002100,0001078f]
/usr/lib/gcc/msp430/4.6.3/../../../../msp430/bin/ld: region `rom' overflowed by 2674 bytes
/usr/lib/gcc/msp430/4.6.3/libcrt0.a(_copy_data.o): In function `__do_copy_data':
/build/buildd/gcc-msp430-4.6.3~mspgcc-20120406/./gcc-4.6.3/gcc/config/msp430/crt0.S:195: relocation truncated to fit: R_MSP430_16_BYTE against symbol `__data_load_start' defined in *ABS* section in lpwmn.elf
/usr/lib/gcc/msp430/4.6.3/crt0ivtbl16.o: In function `__isr_14':
(.text+0x2): relocation truncated to fit: R_MSP430_16 against symbol `_unexpected_' defined in .text.crt0 section in /usr/lib/gcc/msp430/4.6.3/libcrt0.a(_unexpected_.o)
./4lpwmn/util/src/util.o: In function `UTIL_initTraceCntxt':
util.c:(.text+0x4f6): relocation truncated to fit: R_MSP430_16 against symbol `memset' defined in .text section in /usr/msp430/lib/libc.a(memset.o)
./4lpwmn/system/src/system.o: In function `SYS_init':
system.c:(.text+0x14): relocation truncated to fit: R_MSP430_16 against symbol `memset' defined in .text section in /usr/msp430/lib/libc.a(memset.o)
./4lpwmn/system/src/system.o: In function `SYS_loop':
system.c:(.text+0x614): relocation truncated to fit: R_MSP430_16 against symbol `PHY_PIB_init' defined in .text section in ./4lpwmn/802_15_4e/src/phy_pib.o
system.c:(.text+0x61c): relocation truncated to fit: R_MSP430_16 against symbol `ADP_init' defined in .text section in ./4lpwmn/adp/src/adp.o
system.c:(.text+0x716): relocation truncated to fit: R_MSP430_16 against symbol `ADP_evtHndlr' defined in .text section in ./4lpwmn/adp/src/adp.o
system.c:(.text+0x8ec): relocation truncated to fit: R_MSP430_16 against symbol `ADP_procPendingTrscns' defined in .text section in ./4lpwmn/adp/src/adp.o
system.c:(.text+0x974): relocation truncated to fit: R_MSP430_16 against symbol `ADP_evtHndlr' defined in .text section in ./4lpwmn/adp/src/adp.o
./4lpwmn/smac/src/s_mac_cc1101.o: In function `MAC_csmaAttemptTxOnCca':
s_mac_cc1101.c:(.text+0x704): relocation truncated to fit: R_MSP430_16 against symbol `CC1101_txToIdleTransitionTimeMilli' defined in .rodata section in ./4lpwmn/pltfrm/src/cc1101.o
./4lpwmn/smac/src/s_mac_cc1101.o: In function `MAC_getCsmaBackOff':
s_mac_cc1101.c:(.text+0x7f8): additional relocation overflows omitted from the output
collect2: ld returned 1 exit status
make: *** [lpwmn.elf] Error 1

If I remove -g option and optimize for size (-Os), then I can get it down to 32 KB. Problem is I can't do debugging in this case. Am I missing some trick or is CCS compiler doing something smart?

Regards,
Arvind

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Code does not fit in ROM with mspgcc but fits with CCS compiler

Eric Decker
have you tried, -g -Os

or -ggdb -Os

that is what I use to debug size optimized code.

works fine.

figuring out what the code is doing can be a bit tricky but it can be done.


On Wed, Feb 18, 2015 at 9:10 PM, Arvind Padmanabhan <
[hidden email]> wrote:

> Hi Folks,
>
> My friend has Code Composer Studio (CCS) license. He compiled without
> debugging and no optimization. Code size (ROM) is only 35 KB. This is good
> for MSP430G2955 that has 56 KB of Flash.
>
> I compiled the same code using mspgcc, I get the following (-g -Oo):
>
> /usr/lib/gcc/msp430/4.6.3/../../../../msp430/bin/ld: lpwmn.elf section
> `.text' will not fit in region `rom'
> /usr/lib/gcc/msp430/4.6.3/../../../../msp430/bin/ld: section .vectors
> loaded at [0000ffe0,0000ffff] overlaps section .text loaded at
> [00002100,0001078f]
> /usr/lib/gcc/msp430/4.6.3/../../../../msp430/bin/ld: region `rom'
> overflowed by 2674 bytes
> /usr/lib/gcc/msp430/4.6.3/libcrt0.a(_copy_data.o): In function
> `__do_copy_data':
> /build/buildd/gcc-msp430-4.6.3~mspgcc-20120406/./gcc-4.6.3/gcc/config/msp430/crt0.S:195:
> relocation truncated to fit: R_MSP430_16_BYTE against symbol
> `__data_load_start' defined in *ABS* section in lpwmn.elf
> /usr/lib/gcc/msp430/4.6.3/crt0ivtbl16.o: In function `__isr_14':
> (.text+0x2): relocation truncated to fit: R_MSP430_16 against symbol
> `_unexpected_' defined in .text.crt0 section in
> /usr/lib/gcc/msp430/4.6.3/libcrt0.a(_unexpected_.o)
> ./4lpwmn/util/src/util.o: In function `UTIL_initTraceCntxt':
> util.c:(.text+0x4f6): relocation truncated to fit: R_MSP430_16 against
> symbol `memset' defined in .text section in /usr/msp430/lib/libc.a(memset.o)
> ./4lpwmn/system/src/system.o: In function `SYS_init':
> system.c:(.text+0x14): relocation truncated to fit: R_MSP430_16 against
> symbol `memset' defined in .text section in /usr/msp430/lib/libc.a(memset.o)
> ./4lpwmn/system/src/system.o: In function `SYS_loop':
> system.c:(.text+0x614): relocation truncated to fit: R_MSP430_16 against
> symbol `PHY_PIB_init' defined in .text section in
> ./4lpwmn/802_15_4e/src/phy_pib.o
> system.c:(.text+0x61c): relocation truncated to fit: R_MSP430_16 against
> symbol `ADP_init' defined in .text section in ./4lpwmn/adp/src/adp.o
> system.c:(.text+0x716): relocation truncated to fit: R_MSP430_16 against
> symbol `ADP_evtHndlr' defined in .text section in ./4lpwmn/adp/src/adp.o
> system.c:(.text+0x8ec): relocation truncated to fit: R_MSP430_16 against
> symbol `ADP_procPendingTrscns' defined in .text section in
> ./4lpwmn/adp/src/adp.o
> system.c:(.text+0x974): relocation truncated to fit: R_MSP430_16 against
> symbol `ADP_evtHndlr' defined in .text section in ./4lpwmn/adp/src/adp.o
> ./4lpwmn/smac/src/s_mac_cc1101.o: In function `MAC_csmaAttemptTxOnCca':
> s_mac_cc1101.c:(.text+0x704): relocation truncated to fit: R_MSP430_16
> against symbol `CC1101_txToIdleTransitionTimeMilli' defined in .rodata
> section in ./4lpwmn/pltfrm/src/cc1101.o
> ./4lpwmn/smac/src/s_mac_cc1101.o: In function `MAC_getCsmaBackOff':
> s_mac_cc1101.c:(.text+0x7f8): additional relocation overflows omitted from
> the output
> collect2: ld returned 1 exit status
> make: *** [lpwmn.elf] Error 1
>
> If I remove -g option and optimize for size (-Os), then I can get it down
> to 32 KB. Problem is I can't do debugging in this case. Am I missing some
> trick or is CCS compiler doing something smart?
>
> Regards,
> Arvind
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
> _______________________________________________
> Mspgcc-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>
>

--
Eric B. Decker
Senior (over 50 :-) Researcher

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Code does not fit in ROM with mspgcc but fits with CCS compiler

David Brown-4
In reply to this post by arvindpdmn
On 19/02/15 06:10, Arvind Padmanabhan wrote:
> Hi Folks,
>
> My friend has Code Composer Studio (CCS) license. He compiled without
> debugging and no optimization. Code size (ROM) is only 35 KB. This is
> good for MSP430G2955 that has 56 KB of Flash.

There is no standard for how much optimisation a compiler does -
settings are only relative to each other in a given compiler.  Sometimes
you can compare /types/ of optimisation pass between compilers, but even
then the details vary wildly.

When gcc is used with -O0 (or no optimisation flags), it produces blind
statement-at-a-time interpretation of the code that is very big, very
slow, and very hard to follow.  Apart from some tests of the compiler
itself, it is pretty much useless.

With -O1, you get little in the way of code reordering and no inlining
without the "inline" keyword, but variables go in registers and there is
some basic simplification.  If you want the easiest single-step
debugging, "-O1 -g" works much better than "-O0 -g" because you have
clearer and more logical assembly code.

With -Os (or -O2), you get a lot more re-arrangement of code, which can
give smaller and faster results but sometimes means that single-stepping
jumps around, and breakpoints don't always appear where you expect them
(a trick here is to make artificial volatile variables, and put
breakpoints on lines that use them).

-O3 and other options are a more specialised, and can sometimes make
code faster, sometimes slower.

With CCS, it's "no optimisation" setting would rate around 0.8 on gcc's
scale, while it's fullest optimisations are around 1.8 (varying by the
actual code in use, of course).


>
> I compiled the same code using mspgcc, I get the following (-g -Oo):

So use "-g -O1" or "-g -Os".

Unless you have something you need to step through carefully (in which
case use "-g -O1", it is best to use exactly the same settings ("-g
-Os") all the time - that way you are debugging what you are going to
release, and releasing what you have debugged.

>
<snip>
> If I remove -g option and optimize for size (-Os), then I can get it
> down to 32 KB. Problem is I can't do debugging in this case. Am I
> missing some trick or is CCS compiler doing something smart?
>
> Regards, Arvind
>
>



------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Code does not fit in ROM with mspgcc but fits with CCS compiler

Olivier Girard
Hi Arvind,

I completely agree with the comment from David, I would also recommend do
use use "-g -Os" by default and "-g -O1" if you struggle while debugging.

Regarding the binary size, I have recently played around with the TI/RedHat
GCC release and the results are IMO really really bad (standard library??):

 ==============================================================================||

    ||||                        CODE SEGMENT SIZE    (in kB)
             ||||

||||============================================================================||||
  BENCHMARK NAME    |    COMPILER VERSION    |   -Os   |   -O2   |
-O3   ||||=====================+========================+=========+=========+=========||||
Dhrystone v2.1      |   mspgcc     v4.7.2    |   5.81  |   5.79  |
5.81  |||| (common version)    |   msp430-elf v4.9.1    |  36.60  |
37.10  |  37.11
||||---------------------+------------------------+---------+---------+---------||||
Dhrystone v2.1      |   mspgcc     v4.7.2    |   5.70  |   5.67  |
5.69  |||| (MCU adapted)       |   msp430-elf v4.9.1    |  36.61  |
37.08  |  37.10
||||---------------------+------------------------+---------+---------+---------||||
CoreMark v1.0       |   mspgcc     v4.7.2    |  10.48  |  11.26  |
16.22  |||| (official version)  |   msp430-elf v4.9.1    |  41.43  |
42.43  |  49.24  ||
==============================================================================


More about that in this thread:
https://groups.google.com/forum/?fromgroups#!topic/discuss_openmsp430/W-22HePtJsQ

Cheers,
Olivier

On Thu, Feb 19, 2015 at 9:13 AM, David Brown <[hidden email]> wrote:

> On 19/02/15 06:10, Arvind Padmanabhan wrote:
> > Hi Folks,
> >
> > My friend has Code Composer Studio (CCS) license. He compiled without
> > debugging and no optimization. Code size (ROM) is only 35 KB. This is
> > good for MSP430G2955 that has 56 KB of Flash.
>
> There is no standard for how much optimisation a compiler does -
> settings are only relative to each other in a given compiler.  Sometimes
> you can compare /types/ of optimisation pass between compilers, but even
> then the details vary wildly.
>
> When gcc is used with -O0 (or no optimisation flags), it produces blind
> statement-at-a-time interpretation of the code that is very big, very
> slow, and very hard to follow.  Apart from some tests of the compiler
> itself, it is pretty much useless.
>
> With -O1, you get little in the way of code reordering and no inlining
> without the "inline" keyword, but variables go in registers and there is
> some basic simplification.  If you want the easiest single-step
> debugging, "-O1 -g" works much better than "-O0 -g" because you have
> clearer and more logical assembly code.
>
> With -Os (or -O2), you get a lot more re-arrangement of code, which can
> give smaller and faster results but sometimes means that single-stepping
> jumps around, and breakpoints don't always appear where you expect them
> (a trick here is to make artificial volatile variables, and put
> breakpoints on lines that use them).
>
> -O3 and other options are a more specialised, and can sometimes make
> code faster, sometimes slower.
>
> With CCS, it's "no optimisation" setting would rate around 0.8 on gcc's
> scale, while it's fullest optimisations are around 1.8 (varying by the
> actual code in use, of course).
>
>
> >
> > I compiled the same code using mspgcc, I get the following (-g -Oo):
>
> So use "-g -O1" or "-g -Os".
>
> Unless you have something you need to step through carefully (in which
> case use "-g -O1", it is best to use exactly the same settings ("-g
> -Os") all the time - that way you are debugging what you are going to
> release, and releasing what you have debugged.
>
> >
> <snip>
> > If I remove -g option and optimize for size (-Os), then I can get it
> > down to 32 KB. Problem is I can't do debugging in this case. Am I
> > missing some trick or is CCS compiler doing something smart?
> >
> > Regards, Arvind
> >
> >
>
>
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
> _______________________________________________
> Mspgcc-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Code does not fit in ROM with mspgcc but fits with CCS compiler

arvindpdmn
In reply to this post by David Brown-4
Thanks to both Eric and David for their inputs. Indeed, although "-Os -g" worked for me, it was difficult to set breakpoints at the right places. At times I had to resort single-stepping in assembly to get what I wanted.

It is nice David pointed out that CCS default optimization is like 0.8 on mspgcc scale. I attempted "-O1 -g" and the code fits nicely in Flash. I also figured out that -g option affects only the ELF file size and has no effect on the program size downloaded to Flash. Option "-O3" explodes the code size. I assume it is sophisticated performance optimization probably involved lookup tables. Finally, I tried "-O1 -g3" (maximum debugging) and this is probably what I will use for debugging. See below for full comparison.

Options        Program Size       ELF File Size
===============================================
-O1            37048                63836
-O1 -g1        37048                91592
-O1 -g         37048               249184
-O1 -g3        37048              1700844
-----------------------------------------------
-O2            35280                62095
-O2 -g         35280               255343
-----------------------------------------------
-O3            55156                82204
-O3 -g         55156               321648
-----------------------------------------------
-Os            32152                59387
-Os -g         32152               244543


Regards,
Arvind


      From: David Brown <[hidden email]>
 To: [hidden email]
 Sent: Thursday, 19 February 2015, 13:43
 Subject: Re: [Mspgcc-users] Code does not fit in ROM with mspgcc but fits with CCS compiler
   
On 19/02/15 06:10, Arvind Padmanabhan wrote:
> Hi Folks,
>
> My friend has Code Composer Studio (CCS) license. He compiled without
> debugging and no optimization. Code size (ROM) is only 35 KB. This is
> good for MSP430G2955 that has 56 KB of Flash.

There is no standard for how much optimisation a compiler does -
settings are only relative to each other in a given compiler.  Sometimes
you can compare /types/ of optimisation pass between compilers, but even
then the details vary wildly.

When gcc is used with -O0 (or no optimisation flags), it produces blind
statement-at-a-time interpretation of the code that is very big, very
slow, and very hard to follow.  Apart from some tests of the compiler
itself, it is pretty much useless.

With -O1, you get little in the way of code reordering and no inlining
without the "inline" keyword, but variables go in registers and there is
some basic simplification.  If you want the easiest single-step
debugging, "-O1 -g" works much better than "-O0 -g" because you have
clearer and more logical assembly code.

With -Os (or -O2), you get a lot more re-arrangement of code, which can
give smaller and faster results but sometimes means that single-stepping
jumps around, and breakpoints don't always appear where you expect them
(a trick here is to make artificial volatile variables, and put
breakpoints on lines that use them).

-O3 and other options are a more specialised, and can sometimes make
code faster, sometimes slower.

With CCS, it's "no optimisation" setting would rate around 0.8 on gcc's
scale, while it's fullest optimisations are around 1.8 (varying by the
actual code in use, of course).


>
> I compiled the same code using mspgcc, I get the following (-g -Oo):

So use "-g -O1" or "-g -Os".

Unless you have something you need to step through carefully (in which
case use "-g -O1", it is best to use exactly the same settings ("-g
-Os") all the time - that way you are debugging what you are going to
release, and releasing what you have debugged.

>
<snip>


> If I remove -g option and optimize for size (-Os), then I can get it
> down to 32 KB. Problem is I can't do debugging in this case. Am I
> missing some trick or is CCS compiler doing something smart?
>
> Regards, Arvind
>
>



------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users



------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Code does not fit in ROM with mspgcc but fits with CCS compiler

David Brown-4
On 19/02/15 11:21, Arvind Padmanabhan wrote:

> Thanks to both Eric and David for their inputs. Indeed, although "-Os
> -g" worked for me, it was difficult to set breakpoints at the right
> places. At times I had to resort single-stepping in assembly to get
> what I wanted.
>
> It is nice David pointed out that CCS default optimization is like
> 0.8 on mspgcc scale. I attempted "-O1 -g" and the code fits nicely in
> Flash. I also figured out that -g option affects only the ELF file
> size and has no effect on the program size downloaded to Flash.
> Option "-O3" explodes the code size. I assume it is sophisticated
> performance optimization probably involved lookup tables. Finally, I
> tried "-O1 -g3" (maximum debugging) and this is probably what I will
> use for debugging. See below for full comparison.
>

-O3 does things like extra inlining (inlining can save space or cost
space, depending on the size of the functions and the degree of
additional optimisations it allows - but -O3 inlines even when there is
significant cost in space), loop unrolling (which will be faster on an
msp430, but takes more space), and other such expensive optimisations.
It is seldom a useful choice.

Some compilers generate different code when debugging is enabled,
because they (and their matching debuggers) cannot track program state
for some types of optimisation.  gcc + gdb can do a pretty good job of
tracking the state even in heavily optimised code - so "-g" makes almost
no difference to the code generation.

mvh.,

David



------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Loading...