public inbox for ecos-devel@sourceware.org
 help / color / mirror / Atom feed
* Re: [ECOS] raw output to serial port and dataflash + legacy API  questions
       [not found] <2a382c6e0905070357u76683dacqfe8bd885c9260671@mail.gmail.com>
@ 2009-05-11 17:44 ` Evgeniy Dushistov
  2009-05-11 17:57   ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Evgeniy Dushistov @ 2009-05-11 17:44 UTC (permalink / raw)
  To: Dave Milter; +Cc: ecos-discuss, ecos-devel

On Thu, May 07, 2009 at 02:57:56PM +0400, Dave Milter wrote:
> 2)I have board with dataflash, it supported with package in directory
> packages/devs/flash/atmel/dataflash, but on my board
> as against eb55 there is only dataflash, there is no NOR flash.
> 
> I build redboot, but
> arm-eabi-nm redboot.elf | grep dataflash is empty.
> while
> arm-eabi-nm libtarget.a | grep dataflash give all symbols
> that I expect to see.
> 
> During my investigation I remove norflash from eb55 description
> and receive the same result for eb55 redboot.
> 


I had the similar problem when adding support for dataflash 
for at91sam9263 cpu.

As far as I understand, the problem is following.

For example, you write this code in some ".c" file:

__externC cyg_spi_at91_device_t spi_dataflash_dev0;

CYG_DATAFLASH_FLASH_DRIVER( cyg_eb55_dataflash,
                            &spi_dataflash_dev0,
                            0x08000000,
                            0,
                            16 );

this file contains only definitions of variables,
no code. For some reasons linker will remove
such kind of object file in the resulting binary, and also all the stuff like dataflash module, because
without this file there are no links to dataflash module functions.

I suppose, this is bug either in build system of ecos, or in arm-eabi toolchain.

The workaround for this issue, that I used, is simple. I add after
CYG_DATAFLASH_FLASH_DRIVER the dummy function:

CYG_DATAFLASH_FLASH_DRIVER( cyg_eb55_dataflash,
                             0,
                             16 );
 
+void cyg_eb55_dataflash_func(int p)
+{
+}
+

and add reference to this function from the code that 100% will not be removed:
packages/redboot/current/src/flash.c

+typedef void flash_workaround_func(int);
+
+externC flash_workaround_func cyg_eb55_dataflash_func;
+
 int do_flash_init(void)
 {
     int stat, i;
     cyg_flash_info_t info;
+    flash_workaround_func *f;
+
+    f = (flash_workaround_func *)cyg_flash_anonymizer(&cyg_eb55_dataflash_func);
 

Any ideas on that?

-- 
/Evgeniy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] raw output to serial port and dataflash + legacy API  questions
  2009-05-11 17:44 ` [ECOS] raw output to serial port and dataflash + legacy API questions Evgeniy Dushistov
@ 2009-05-11 17:57   ` Andrew Lunn
  2009-05-11 18:35     ` Evgeniy Dushistov
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2009-05-11 17:57 UTC (permalink / raw)
  To: Evgeniy Dushistov; +Cc: Dave Milter, ecos-discuss, ecos-devel

> For example, you write this code in some ".c" file:
> 
> __externC cyg_spi_at91_device_t spi_dataflash_dev0;
> 
> CYG_DATAFLASH_FLASH_DRIVER( cyg_eb55_dataflash,
>                             &spi_dataflash_dev0,
>                             0x08000000,
>                             0,
>                             16 );
> 
> this file contains only definitions of variables,
> no code. For some reasons linker will remove
> such kind of object file in the resulting binary, and also all the stuff like dataflash module, because
> without this file there are no links to dataflash module functions.
> 
> I suppose, this is bug either in build system of ecos, or in arm-eabi toolchain.
> 
> The workaround for this issue, that I used, is simple. I add after
> CYG_DATAFLASH_FLASH_DRIVER the dummy function:
> 
> CYG_DATAFLASH_FLASH_DRIVER( cyg_eb55_dataflash,
>                              0,
>                              16 );
>  
> +void cyg_eb55_dataflash_func(int p)
> +{
> +}
> +

If something is not referenced, the linker will throw it away. It is
unwanted bloat.

To stop this, you need to let the build system know. eg for a serial
driver in the CDL:

       compile       -library=libextras.a   at91_serial.c

              Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] raw output to serial port and dataflash + legacy API  questions
  2009-05-11 17:57   ` Andrew Lunn
@ 2009-05-11 18:35     ` Evgeniy Dushistov
  2009-05-11 19:04       ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Evgeniy Dushistov @ 2009-05-11 18:35 UTC (permalink / raw)
  To: Dave Milter, ecos-discuss, ecos-devel

On Mon, May 11, 2009 at 07:57:43PM +0200, Andrew Lunn wrote:
> > For example, you write this code in some ".c" file:
> > 
> > __externC cyg_spi_at91_device_t spi_dataflash_dev0;
> > 
> > CYG_DATAFLASH_FLASH_DRIVER( cyg_eb55_dataflash,
> >                             &spi_dataflash_dev0,
> >                             0x08000000,
> >                             0,
> >                             16 );
> > 
> > this file contains only definitions of variables,
> > no code. For some reasons linker will remove
> > such kind of object file in the resulting binary, and also all the stuff like dataflash module, because
> > without this file there are no links to dataflash module functions.
> > 
> > I suppose, this is bug either in build system of ecos, or in arm-eabi toolchain.
> > 
> > The workaround for this issue, that I used, is simple. I add after
> > CYG_DATAFLASH_FLASH_DRIVER the dummy function:
> > 
> > CYG_DATAFLASH_FLASH_DRIVER( cyg_eb55_dataflash,
> >                              0,
> >                              16 );
> >  
> > +void cyg_eb55_dataflash_func(int p)
> > +{
> > +}
> > +
> 
> If something is not referenced, the linker will throw it away. It is
> unwanted bloat.
> 

The variable that is not referenced is marked as __attribute__((used)).

So compiler doesn't inform linker that there is no need to throw it
away?

And as you see, actually I not add reference to variable in
workaround, I add function to which add reference.
So reference count to flash driver descriptions hasn't changed,
but linker do not remove it.

-- 
/Evgeniy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] raw output to serial port and dataflash + legacy API  questions
  2009-05-11 18:35     ` Evgeniy Dushistov
@ 2009-05-11 19:04       ` Andrew Lunn
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2009-05-11 19:04 UTC (permalink / raw)
  To: Evgeniy Dushistov; +Cc: Dave Milter, ecos-discuss, ecos-devel

> > If something is not referenced, the linker will throw it away. It is
> > unwanted bloat.
> > 
> 
> The variable that is not referenced is marked as __attribute__((used)).

I _think_ this just stops the warning. The symbol itself is not
changed. This attribute is most often used for parameters passed to a
function where for backward compatibility etc, you don't reference one
of the parameters passed in.

 
> So compiler doesn't inform linker that there is no need to throw it
> away?

I don't think so.

> And as you see, actually I not add reference to variable in
> workaround, I add function to which add reference.
> So reference count to flash driver descriptions hasn't changed,
> but linker do not remove it.

This might suggest you are not using --function-sections and
--data-sections. Using these options the compiler puts each function
and variable into its own section and so allows the linker to do finer
grain garbage discard. Without these options it can only throw away
complete files when all symbols in a file are not used. With these
options it can throw away individual unused functions and variables.

        Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-05-11 19:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <2a382c6e0905070357u76683dacqfe8bd885c9260671@mail.gmail.com>
2009-05-11 17:44 ` [ECOS] raw output to serial port and dataflash + legacy API questions Evgeniy Dushistov
2009-05-11 17:57   ` Andrew Lunn
2009-05-11 18:35     ` Evgeniy Dushistov
2009-05-11 19:04       ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).