[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Using Named Address spaces.
From: |
Thomas, George |
Subject: |
Re: [avr-gcc-list] Using Named Address spaces. |
Date: |
Wed, 13 Mar 2013 22:15:51 +0000 |
Hi Erik,
Thank You for sending down the patch.
Some of the doubts about the patch are :
1. If __flash5 is used then for placing the code we get only 0x50000
to the rest of the flash for storing code (.text) . How can we make use
of the space before in a case where __flash1 - 4 are absent ?
2. If the linker scripts are made generic (Adding in scripttempl/avr.sc),
can we control the number of flashN sections in the linker scripts as
per the size of flash in the device ?
> Could you please show what the compiler does with __memx?ยน
> If it places successive hunks of __memx into successive .flashN input
> sections, then it is already handled by the new script, I anticipate.
>
> So far, we are lacking any concrete requirements for __memx, AFAICT.
> If you read the two long related threads, you'll see that we haven't
> gotten around to clarifying how that one big address space should
> behave.
Adding my understanding of memx (courtesy :
http://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html#AVR%20Named%20Address%20Spaces)
The __memx qualifier can be use to load and access variables in 24 bit address
spaces which linearizes flash and RAM. If the high bit of the address is set,
data is read from RAM using the lower two bytes as RAM address. The loading
from flash works by making use of the ELPM instruction available in AVR.
How it does this ?
After loading the addresses to the registers r30, r31 (Z) and highest bits in
r21 the function is called to load the value to the location r22, r23.
00000238 <__xload_2>:
238: 57 fd sbrc r21, 7
23a: 05 c0 rjmp .+10 ; 0x246 <__xload_2+0xe>
23c: 5b bf out 0x3b, r21 ; 59
23e: 67 91 elpm r22, Z+
240: 77 91 elpm r23, Z+
242: 1b be out 0x3b, r1 ; 59
244: 08 95 ret
246: 61 91 ld r22, Z+
248: 71 91 ld r23, Z+
24a: 08 95 ret
Uses a combination of RAMPZ (0x3b) and Z (r30, r31) for doing the work.
The sbrc instruction checks if the location is a program memory or RAM.
(checking high bits)
Also .progmemx.data is the section the data falls into (So as per current
linker scripts goes in flash)
As far as I understand __memx is a qualifier that is intended to be used
primarily as a pointer to access
data rather than to store data. (unification of RAM and FLASH)
- George -
- [avr-gcc-list] Using Named Address spaces., Thomas, George, 2013/03/12
- Re: [avr-gcc-list] Using Named Address spaces., Weddington, Eric, 2013/03/12
- Re: [avr-gcc-list] Using Named Address spaces., Erik Christiansen, 2013/03/13
- Re: [avr-gcc-list] Using Named Address spaces.,
Thomas, George <=
- Re: [avr-gcc-list] Using Named Address spaces., Georg-Johann Lay, 2013/03/14
- Re: [avr-gcc-list] Using Named Address spaces., Erik Christiansen, 2013/03/15
- Re: [avr-gcc-list] Using Named Address spaces., Erik Christiansen, 2013/03/17
- Re: [avr-gcc-list] Using Named Address spaces., Erik Christiansen, 2013/03/18
- Re: [avr-gcc-list] Using Named Address spaces., Thomas, George, 2013/03/18
- Re: [avr-gcc-list] Using Named Address spaces., Thomas, George, 2013/03/18