[Top][All Lists]

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

Re: [avr-libc-dev] [Patch] Include a device info note section in gcrt1.S

From: Joerg Wunsch
Subject: Re: [avr-libc-dev] [Patch] Include a device info note section in gcrt1.S
Date: Mon, 11 Aug 2014 16:26:22 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

As Senthil Kumar Selvaraj wrote:

> I figured it's easier and less error-prone to embed this information
> here and then consume it everywhere else. I have a patch for
> binutils, for example, that uses the information in the note section
> to print percentage of memory used - like what the WinAVR port of
> avr-size does, but without the hardcoding.

I like that idea much more than Eric Weddington's hack.

I think the AVR is ultimately not the only device which might this be
a concern of; all flash-based controllers can probably benefit from
it.  Thinking a little more about the layout of that device
information (so it can e.g. be applied to all flash-based ARM
controllers as well) would IMHO much increase the likelihood of this
being accepted as a general solution by the binutils folks.  After
all, Atmel could go ahead, and apply it to their own ARM devices as
a first example. ;-)

> +    .section .note.gnu.avr.deviceinfo, "", @note
> +#define NOTE_NAME "AVR"
> +#ifdef __AVR_DEVICE_NAME__
> +#else
> +    #define DEVICE_NAME ""
> +#endif
> +    .long .L__note_name_end - .L__note_name_start
> +    .long .L__desc_end - .L__desc_start
> +    .long 1 ; Type 1 - this is the only known note type for AVR.
> +.L__note_name_start:
> +    .asciz NOTE_NAME
> +.L__note_name_end:
> +.L__desc_start:
> +    .long .L__device_name_end - .L__device_name_start
> +.L__device_name_start:
> +    .asciz DEVICE_NAME
> +.L__device_name_end:
> +#ifdef PROGMEM_SIZE
> +    .long PROGMEM_SIZE
> +#elif FLASHEND > 0
> +    .long FLASHEND + 1
> +#else
> +    .long FLASHEND
> +#endif
> +#ifdef RAMSIZE
> +    .long RAMSIZE
> +#elif RAMEND > 0
> +    .long RAMEND - RAMSTART + 1
> +#else
> +    .long RAMEND
> +#endif
> +#ifdef EEPROM_SIZE
> +    .long EEPROM_SIZE
> +#elif E2END > 0
> +    .long E2END + 1
> +#else
> +    .long E2END
> +#endif
> +.L__desc_end:
> +    .balign 4
> +

Few things come to mind:

* Start out with those parts of the information that have a fixed
  size, i.e. the sizes of the memory regions, and move the variable
  parts behind.  That way, the initial part can be described as a C

* Wouldn't we also need start addresses?  In particular, if you think
  beyond the horizon towards ARMs, their flash usually doesn't start
  at 0, but even for the AVR, the RAM starts at a device-dependent
  address.  Providing on the the size information without the start is
  not very useful.  (OTOH, information that can already be derived
  from other sources in the ELF file doesn't need to be duplicated.)

* For the strings, add an offset (or index) table.  That way, in order
  to read the second string, you don't have to traverse the first one.
  Thus, the actual string array somewhat resembles an ELF string

* Please add a patch that explains the layout in the documentation,

cheers, Joerg               .-.-.   --... ...--   -.. .  DL8DTL

Never trust an operating system you don't have sources for. ;-)

reply via email to

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