no_init in Coldfire CW6.3 LCF linker command file?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

no_init in Coldfire CW6.3 LCF linker command file?

Jump to solution
455 Views
dougpaulsen
Contributor IV

It seems like it should be straightforward, but I'm having difficultly understanding how to declare un-initialized RAM in LCF-type linker files. 

 

The use of the NO_INIT keyword in PRM linker files is discussed here and there in the forums and I've used it in other 8-bit CW projects, but my current interest is for Coldfire processors.  Under CW 6.3, these deploy a LCF linker command file.  I not been able to locate any documentation indicating the NO_INIT (or similar) keyword is valid there.

 

Obviously, there are a few variables which would be vary helpful to persist over a PIN reset.  The CW default is for all un-initialized variables to be cleared to zero, which I understand and appreciate.  This is my first Coldfire project, but other experiences with other micro/compiler combinations make declaring un-initialized variables quite easy.  One wonders why CW makes it so obtuse in the case of Coldfire processors.  Is there perhaps a hardware restraint?

 

Regardless, I would appreciate any comments/directions on setting up uninitialized segments in LCF files.

 

Thanks!

Doug

Labels (1)
1 Solution
259 Views
dougpaulsen
Contributor IV

Okay!

I managed to piece together a working solution out of a lot of research.

First, I modified the my LCF linker command file as follows:

MEMORY

{

   ....

   NVRAM       (RW)  : ORIGIN = 0x00800000, LENGTH = 0x00000100

   ....

}

SECTIONS

{

   ....

  .no_init :

  {

    *(.no_init)

  } > NVRAM

   .... 

}

Then, within my code, I declared my persistent data (in this case, a clock structure) as follows:

#pragma define_section NO_INIT ".no_init" ".no_init"

__declspec(NO_INIT) volatile T_CLK     tClk;   //uninitialized!

Now, at least in preliminary tests, my clock will survive a PIN reset to keep counting, but of course I'll have to do something specific on any other reset (POR, COP, etc.),  but I'm willing to deal with that.

Good luck to all in your non-CW 6.3, non-MCF51 implementations.  I've had to experiment with a number of community posts to come up with the above.  Some of the offerings seemed to do nothing.  Others produced linker error messages I just don't care to deal with.  LCF documentation was marginally helpful (I thank whomever I ripped off the above from, wherever you are).


View solution in original post

1 Reply
260 Views
dougpaulsen
Contributor IV

Okay!

I managed to piece together a working solution out of a lot of research.

First, I modified the my LCF linker command file as follows:

MEMORY

{

   ....

   NVRAM       (RW)  : ORIGIN = 0x00800000, LENGTH = 0x00000100

   ....

}

SECTIONS

{

   ....

  .no_init :

  {

    *(.no_init)

  } > NVRAM

   .... 

}

Then, within my code, I declared my persistent data (in this case, a clock structure) as follows:

#pragma define_section NO_INIT ".no_init" ".no_init"

__declspec(NO_INIT) volatile T_CLK     tClk;   //uninitialized!

Now, at least in preliminary tests, my clock will survive a PIN reset to keep counting, but of course I'll have to do something specific on any other reset (POR, COP, etc.),  but I'm willing to deal with that.

Good luck to all in your non-CW 6.3, non-MCF51 implementations.  I've had to experiment with a number of community posts to come up with the above.  Some of the offerings seemed to do nothing.  Others produced linker error messages I just don't care to deal with.  LCF documentation was marginally helpful (I thank whomever I ripped off the above from, wherever you are).