avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Including a binary file as resource


From: Andy Warner
Subject: Re: [avr-gcc-list] Including a binary file as resource
Date: Sun, 19 Dec 2004 21:19:48 -0600
User-agent: Mutt/1.2.5i

On Friday, I rambled on about binary->.text data conversion for avr-gcc:
> [...]
> If we mutate ld.script to be something like:
> 
> OUTPUT_FORMAT("elf32-avr")
> OUTPUT_ARCH(avr:2)
> SECTIONS
> {
>       .text :
>       {
>       *(.data)
>       }
> }
> 
> Which, used with this avr-ld command will create a .o file:
> 
> avr-ld -T ld.script -b binary -o foo.o testdata
> 
> (where "testdata" is the name of the file containing the binary data)
> [...]
> My example hardcodes the effect of the -mcu=xxxx gcc switch
> on the choice of linker arguments (resulting in the hardcoded
> OUTPUT_FORMAT/ARCH statements above.) Can someone more
> versed in the gcc->ld invocation runes help out with
> the avr-gcc line that will let us drop this into a standard
> makefile with $(CC) $(CFLAGS) etc, instead of hardcoding that
> knowledge into ld.script ?

After further investigation, it seems that the OUTPUT_ARCH statement is
unnecessary, at least in my testing. All the (avr) object files I care
about are elf format, so the OUTPUT_ARCH(avr:2) line can be dropped,
making the file generic to all avrs (makes perfect sense to me,
since it doesn't rely on any architecture-specific attributes at all.

So the following ld.script file should work to put binary data
in flash for any avr project:

UTPUT_FORMAT("elf32-avr")
SECTIONS
{
      .text :
      {
      *(.data)
      }
}

with the following command line:

avr-ld -T ld.script -b binary -o <desired object filename> <input filename>

With access to the data via the usual <avr/pgmspace.h> utilities.
-- 
address@hidden

Andy Warner             Voice: (612) 801-8549   Fax: (208) 575-5634


reply via email to

[Prev in Thread] Current Thread [Next in Thread]