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

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

Re: [avr-gcc-list] linker issue, resolving a pointer as uint32_t


From: Torsten Mohr
Subject: Re: [avr-gcc-list] linker issue, resolving a pointer as uint32_t
Date: Tue, 28 Jun 2005 00:45:42 +0200
User-agent: KMail/1.8

Hi,

i've been testing and re-casting values for quite some time now.

Is there a possibility to put a pointer into flash memory and from
that pointer tell where in flash it is pointing to (to my understanding
this is 99% of the sense of a pointer)?

Can i then somehow tell if this pointer is in the lower or the upper
64k of my ATmega128?

Is there any other way to describe a memory location in flash?
Maybe with some clever inline assembler (lo(), mid(), hi()?)?
Maybe with some attribute added to the pointer?

It would be also ok if i could describe the memory location with a
struct that consists of the pointer and the necessary value for
RAMPZ, if this one can be resolved somehow by the linker.

Is the linker at some level capable of resolving this?  It somehow
has to be able to do this, it can resolve calls between the lower
and upper 64k, so the information must be available somewhere.


In binutils/bfd/cpu-avr.c avr5 addr_bits is set to 22, is this a hint?
But it seems to be 16 bits anywhere.


In elf32-avr.c, only BFD_RELOC_AVR_CALL seems to be of type
2, which means "long".
But also if i cast the values to be a function pointer, it does not
work:

typedef void (*fptr)(void);
...
  fptr begin;
  fptr end;
...
  (fptr)&app_info + sizeof(APP_INFO),
  (fptr)&app_info_end,
...


Has anybody got a hint for me?


Best regards,
Torsten.


> i'd like to put some structure into an application that the bootloader
> can use to check if the application is valid or not.
>
> For this i define a structure APP_INFO:
> typedef struct {
>   uint32_t magic;
>   uint32_t version;
>   uint32_t begin;  // a pointer
>   uint32_t end;  // apointer
>   uint16_t crc;
>   unsigned char username[8];
>   unsigned char linktime[32];
> } APP_INFO;
>
>
> In the application i fill in the values like this:
>
> const uint32_t app_info_end __attribute__ ((section(".fini0"))) =
> APP_INFO_END;
>
> const APP_INFO app_info __attribute__ ((section(".vectors"))) = {
>   APP_INFO_MAGIC,
>   1,
>   &app_info + sizeof(APP_INFO),
>   &app_info_end,
>   0xadde,
>   "a_____b",
>   "c_____________________________d"
> };
>
> This results in an error at link time, the members .begin and .end
> can't be resolved at load time.
>
> But when i change their type to "void*", it all works fine.
>
>
> When the application becomes larger, the member .end may become
> larger than 16 bits, so i'd like to store at least this value with 32 bits.
> Actually, i'd still like to store both values as 32 bits, as they should
> become arguments to pgm_read_byte_far.
>
> I don't understand why the values can't be stored as uint32_t, can
> somebody please explain this to me?  To my understanding the
> linker should be able to resolve this.
>
>
> Is there a way to store the values as 32 bits?
>
> The size of a pointer (sizeof) seems to be two bytes.  This is not enough
> to describe a memory location properly anyway.  Is there another type
> that i can use to describe a memory location in flash in 128k ?
>
>
> Best regards,
> Torsten.
>
>
> _______________________________________________
> AVR-GCC-list mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/avr-gcc-list




reply via email to

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