public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] place thread stack into CCM memory on STM32
@ 2014-10-16 14:01 Oleg Uzenkov
  2014-10-17 12:02 ` Oleg Uzenkov
  0 siblings, 1 reply; 4+ messages in thread
From: Oleg Uzenkov @ 2014-10-16 14:01 UTC (permalink / raw)
  To: eCos Discussion


Hi Everyone,

STM32 controllers have CCM (Closely Coupled Memory) memory which acts as 
RAM.

At present I do not use it. But I would like to.

I am developing eCos application in C++. I have something like this in 
the header file:

   class A :
   {
   public:
    A ();
    virtual ~A ();
   ..
   protected:

     cyg_thread    _thread;
     char    _thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL] 
__attribute__((section(".ccm")));
   ...

As you can see, I want to place thread stack into CCM section (using 
__attribute__((section("<name>"))).

But I do not know how to do it in a correct way. Please help! :-)

The Memory layout file I use has got:

..
SECTIONS
{
     SECTIONS_BEGIN
     USER_SECTION (ccm, ccm, 0x10000000, LMA_EQ_VMA)
..

And cortexm.ld file has got a macro for USER_SECTION:

#define USER_SECTION(_name_, _region_,  _vma_, _lma_) \
     ._name_ _vma_ : _lma_ \
     { __ ## _name_ ## _start = ABSOLUTE (.); \
      *(._name_*) \
     __ ## _name_ ## _end = ABSOLUTE (.); } \
     > _region_


When I compile the project I get an error:
error: section attribute not allowed for '_thread_stack'

Do I specify attribute in the correct place?

My be I cannot do it for class members but only for global variables?

I would appreciate any help on this.

Oleg







     ...




-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* Re: [ECOS] place thread stack into CCM memory on STM32
  2014-10-16 14:01 [ECOS] place thread stack into CCM memory on STM32 Oleg Uzenkov
@ 2014-10-17 12:02 ` Oleg Uzenkov
  2014-10-17 14:25   ` Sergei Gavrikov
  0 siblings, 1 reply; 4+ messages in thread
From: Oleg Uzenkov @ 2014-10-17 12:02 UTC (permalink / raw)
  To: eCos Discussion


>
> Hi Everyone,
>
> STM32 controllers have CCM (Closely Coupled Memory) memory which acts 
> as RAM.
>
> At present I do not use it. But I would like to.
>
> I am developing eCos application in C++. I have something like this in 
> the header file:
>
>   class A :
>   {
>   public:
>    A ();
>    virtual ~A ();
>   ..
>   protected:
>
>     cyg_thread    _thread;
>     char    _thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL] 
> __attribute__((section(".ccm")));
>   ...
>
> As you can see, I want to place thread stack into CCM section (using 
> __attribute__((section("<name>"))).
>
> But I do not know how to do it in a correct way. Please help! :-)
>
> The Memory layout file I use has got:
>
> ..
> SECTIONS
> {
>     SECTIONS_BEGIN
>     USER_SECTION (ccm, ccm, 0x10000000, LMA_EQ_VMA)
> ..
>
> And cortexm.ld file has got a macro for USER_SECTION:
>
> #define USER_SECTION(_name_, _region_,  _vma_, _lma_) \
>     ._name_ _vma_ : _lma_ \
>     { __ ## _name_ ## _start = ABSOLUTE (.); \
>      *(._name_*) \
>     __ ## _name_ ## _end = ABSOLUTE (.); } \
>     > _region_
>
>
> When I compile the project I get an error:
> error: section attribute not allowed for '_thread_stack'
>
> Do I specify attribute in the correct place?
>

Ok,  it appears that it is possible to specify 
__attribute__((section("<name>"))) for class's member methods.

It can also be specified for file level or global level variables and 
functions.

But unfortunately there is no directive to place the whole class into a 
specific memory region.

As to working with STM32 I managed to place thread stacks into CCM 
section (why waist it!) by declaring stack as a file level variable:

static char  _thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL] 
CYGBLD_ATTRIB_SECTION(".ccm");

Make sure to specify (NOLOAD) for .ccm section in mlt_ file:
USER_SECTION (ccm, ccm, 0x10000000 (NOLOAD), LMA_EQ_VMA)

Otherwise the binary will be enormous.

Oleg



> My be I cannot do it for class members but only for global variables?
>
> I would appreciate any help on this.
>
> Oleg
>
>
>
>
>
>
>
>     ...
>
>
>
>


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* Re: [ECOS] place thread stack into CCM memory on STM32
  2014-10-17 12:02 ` Oleg Uzenkov
@ 2014-10-17 14:25   ` Sergei Gavrikov
  2014-10-17 15:45     ` Sergei Gavrikov
  0 siblings, 1 reply; 4+ messages in thread
From: Sergei Gavrikov @ 2014-10-17 14:25 UTC (permalink / raw)
  To: Oleg Uzenkov; +Cc: eCos Discussion

On Fri, 17 Oct 2014, Oleg Uzenkov wrote:

> Ok,  it appears that it is possible to specify
> __attribute__((section("<name>"))) for class's member methods.

Really?

  https://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html says

  You may use the section attribute with initialized or uninitialized
  global variables.

IMO, your C++ style (rejected) is not very good. Look, please, on the
eCos kernel's tests in C++ (those *.cxx tests are examples to follow).
In a fact that C++ coding style is something likes EC++. I would say it
is Embedded C++ style from eCos gurus.

Find kernel/current/tests/testaux.hxx and tests/*.cxx code.

On 64K aside. I would try to "move" eCos heap (__heap1) in .ccm segment.
Then all dynamic stuff will be live in .ccm segment. Benefits: 1) you
will get more space for eCos program (code+data) ~120K; 2) you will get
64K room for all dynamically allocated objects (just allocate the
buffers for thread's stacks); 3) no mess with 'section' attribute.
Drawback(s): 1) if you won't use 'new' or 'malloc' (will you?) then .ccm
will be waste. I seems for me (not tested, I have no STM target) you have
only to re-define the heap's size in mlt*h (set it 64K) and move __heap1
label in mlt*ldi (put __heap1 after .ccm section). Well, this is just an
idea, perhaps, I miss something and it will not work, but you can try
it.

Sergei

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* Re: [ECOS] place thread stack into CCM memory on STM32
  2014-10-17 14:25   ` Sergei Gavrikov
@ 2014-10-17 15:45     ` Sergei Gavrikov
  0 siblings, 0 replies; 4+ messages in thread
From: Sergei Gavrikov @ 2014-10-17 15:45 UTC (permalink / raw)
  To: Sergei Gavrikov; +Cc: eCos Discussion

On Fri, 17 Oct 2014, Sergei Gavrikov wrote:

> On Fri, 17 Oct 2014, Oleg Uzenkov wrote:
>
> > Ok,  it appears that it is possible to specify
> > __attribute__((section("<name>"))) for class's member methods.
>
> Really?
>
>   https://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html says
>
>   You may use the section attribute with initialized or uninitialized
>   global variables.

Excuse too hasty response. It seemed for me you managed relocation that
_thread_stack[] and I cited FM on variable attributes.

Sergei

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

end of thread, other threads:[~2014-10-17 15:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-16 14:01 [ECOS] place thread stack into CCM memory on STM32 Oleg Uzenkov
2014-10-17 12:02 ` Oleg Uzenkov
2014-10-17 14:25   ` Sergei Gavrikov
2014-10-17 15:45     ` Sergei Gavrikov

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).