Writing const data to hard address

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

Writing const data to hard address

Jump to solution
2,738 Views
Dekabrist
Contributor I

Hi,

I write next code:

 

#pragma define_section config_data1 ".x_config1" RW  //  
#pragma define_section config_data2 ".x_config2" RW  //
//
#pragma section config_data1 begin
const struct cfg sConfig1 =
{
CFG_VALID_KEY,
(FRAC16(1/1.074)),  
(316*8)   
};
#pragma section config_data1 end
//
#pragma section config_data2 begin
struct cfg sConfig2;
#pragma section config_data2 end

 

Then, I insert to linker command file new memory segments x_CFG_1 & x_CFG_2:

 

MEMORY {
        # I/O registers area for on-chip peripherals
        .x_Peripherals (RW)   : ORIGIN = 0x0C00, LENGTH = 0
        .x_CoreRegs    (RW)   : ORIGIN = 0xFF80, LENGTH = 0

        # List of all sections specified in the "Build options" tab
        #Internal vector boot area.
        .p_Interruptsboot  (RWX) : ORIGIN = 0x00008000, LENGTH = 0x0004
        .p_Interrupts  (RWX) : ORIGIN = 0x00000000, LENGTH = 0x00000080
        .p_Code  (RWX) : ORIGIN = 0x00000080, LENGTH = 0x00001F80
        .x_Data  (RW) : ORIGIN = 0x00000040, LENGTH = 0x000003C0
        .x_CWRegisters  (RW) : ORIGIN = 0x00000030, LENGTH = 0x00000010

        #Other memory segments - size of .x_internal_ROM = 2048 - (.x_CFG_1 + .x_CFG_2)
        .x_internal_ROM  (RW)  : ORIGIN = 0x00001000, LENGTH = 0x0600
        .p_internal_RAM  (RWX) : ORIGIN = 0x00007C00, LENGTH = 0x0400
  #Configuration areas from data flash
  .x_CFG_1 (RW) : ORIGIN = 0x00001600, LENGTH = 0x100
  .x_CFG_2 (RW) : ORIGIN = 0x00001700, LENGTH = 0x100
}

 

and sections:

 

   #******************* Configuration data flash sections         
        .x_config1 :
        {
         mcl.c (FsConfig1)
        } > .x_CFG_1
       
  .x_config2 :
        {
       
        } > .x_CFG_2
       
        #****************** End Configuration data flash sections

 

Linker warnings:

 

FsConfig1 (.x_config1) in file mcl.c is referenced but has not been written

check your linker command file

 

idem for sConfig2

 

How can I write FsConfig1 to section .x_config1 under compiling?

Labels (1)
Tags (1)
0 Kudos
1 Solution
609 Views
trytohelp
NXP Employee
NXP Employee

Hi,

 

Just created an example for DSC Simulator.

See attachement.

 

Pascal

View solution in original post

0 Kudos
5 Replies
609 Views
Dekabrist
Contributor I

Thank Your for reference & example.

I working with DSP56F801 (CodeWarrior for DSC56800E v8.2.3), may be You have example for this core?

0 Kudos
610 Views
trytohelp
NXP Employee
NXP Employee

Hi,

 

Just created an example for DSC Simulator.

See attachement.

 

Pascal

0 Kudos
609 Views
trytohelp
NXP Employee
NXP Employee

Hi,

 

I don't have this example for DSP56F801.

Howevwe you can create an example for the DSP56F801 via the project wizard and just change the main.c and modify the cmd file.

 

Regards

Pascal

0 Kudos
609 Views
Dekabrist
Contributor I

I'm read jes & CrasyCat dialog about this problem in Coldfire and find working variant:

 

c file:

 

#pragma define_section _config_data1 ".x_config1" R  //  
#pragma define_section _config_data2 ".x_config2" R  //
//
#pragma section _config_data1 begin
const struct cfg sConfig1 =
{
CFG_VALID_KEY,
(FRAC16(1/1.074)),  
(316*8)   
};
#pragma section _config_data1 end
//
#pragma section _config_data2 begin
struct cfg sConfig2;
#
pragma section _config_data2 end

 

.cmd linker file:

 

 

 #Configuration areas from data flash
  .x_CFG_1 (RW) : ORIGIN = 0x00001600, LENGTH = 0x100
  .x_CFG_2 (RW) : ORIGIN = 0x00001700, LENGTH = 0x100

 

 

 

FORCE_ACTIVE {sConfig1, sConfig2}

 

  #******************* Configuration data flash sections ****************#
       
        .config_data1 :
        {
          *(.x_config1)
        } > .x_CFG_1
       
  .config_data2 :
        {
         *(.x_config2)
        } > .x_CFG_2
       
        #****************** End Configuration data flash sections***************#

 

This variant working with next linker warnings:

 

The symbol "sConfig1" was forced in the link with "FORCE_ACTIVE" clause but no definition could be found

 

idem for "sConfig2"

 

 

0 Kudos
609 Views
trytohelp
NXP Employee
NXP Employee

Hi,

 

Some times  ago I created an example using this pragma.

May be this can help you.

See description below and refer to the attached project.

 

Description:

Attached you will find an example explaining how to put specific variable in specific memory area.

This project has been create with the wizard.

I change the following:

1# /* 1. Define the section */

#pragma define_section mysection ".mysection.data" RW

2# /* 2. Add variables in this section*/

__declspec(mysection) int a[10] = {'0','1','2','3','4','5','6','7','8','9'};

__declspec(mysection) int b[10];

3# /* 3. Code using variables */

int i;

for (i=0;i<10;i++)

b[i]=a[i];

4# /* 4. in the lcf file we must create a new memory section */ MEMORY {

code (RX) : ORIGIN = 0x00000410, LENGTH = 0x0003FBF0

MY_RAM (RWX) : ORIGIN = 0x00800000, LENGTH = 0x00000100

userram (RWX) : ORIGIN = 0x00801000, LENGTH = 0x00007000

}

5# /* 5. add a new section using MY_RAM */

.my_section:

{

* (.mysection.data)

}>MY_RAM

 

Regards

Pascal

0 Kudos