This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Copy Flash2Ram example and warning: creating output section ".flashcode" without a SECTIONS specification

Other Parts Discussed in Thread: MSP430F5510

Hallo forum users,

I try to implement the RunningfromRAM_CCE example but this time using the MSP430F5510. I have made the adequate changes but after compiling I get the following warning:

"warning: creating output section ".flashcode" without a SECTIONS specification"

I have uploaded the "main.c" and the linker command file. Please could you tell me where is my mistake?

Thanks a lot in advance,

Stratos

//******************************************************************************
//  MSP430F5510 Demo - Executing code from RAM
//
//  Description: This program demonstrates how a parts of a program can be
//  executed from FLASH and RAM. First, the main program copies the function
//  from Flash to RAM during runtime. The main program executes from Flash and
//  it calls the RAM function and executes in RAM and finally jumps back to
//  Flash. The function first erases flash seg C, then it increments all values
//  in seg C, then it erases seg D, then copies seg C to seg D.
//
//  Important Notes:
//
//  1. CCE automatically generates a new copy of linker file in the project
//     directory. The zip file has the attached required modified linker file.
//     See below on what was added to the linker file.
//
//        MEMORY
//        {
//          ...
//          RAM_MEM         : origin = 0x2400, length = 0x0200
//          FLASH_MEM       : origin = 0x8000, length = 0x01FF
//          ...
//        }
//
//        SECTIONS
//        {
//          ...				    
//          .FLASHCODE : load = FLASH_MEM, run = RAM_MEM
//                                                /* CODE IN FLASH AND WILL BE COPIED
//                                                   TO RAM AT EXECUTION HANDLED BY
//                                                   USER                               */
//          .RAMCODE   : load = FLASH_MEM         /* CODE WILL BE IN RAM                */
//          ...
//        }
//
//  2. Unlike IAR where it can calculate the code size through the segment 
//     call functions, we have to define the allocated memory area that will
//     be copied from FLASH to RAM. In this case, user has to manually define
//     the start address of FLASH and RAM. These memory addresses has to be
//     the same as defined in the linker file origin address of FLASH_MEM and
//     RAM_MEM. The flash_code_size can be changed to however much the final
//     compiled code size is.
//
//          #define flash_start_add 0x8000              // Flash code starting address
//          #define flash_code_size 0x01ff              // Function segment size to be copied
//          #define RAM_start_add   0x2400              // RAM code starting address
//
//
//  3. Erasing and Writing to flash running from RAM requires a few checks of
//     the BUSY flag. See the user guide for the flow diagram.
//
//     while(FCTL3&BUSY);
//
//  ACLK = n/a, MCLK = SMCLK = CALxxx_1MHZ = 1MHz
//  //* Set Breakpoint on NOP in the Mainloop to avoid Stressing Flash *//
//
//
//  W. Goh & M. Morales & A. Dannenberg
//  Texas Instruments Inc.
//  December 2008
//  Built with CCE Version: 3.2.2.1.8
//******************************************************************************

#include "msp430f5510.h"
#include "string.h"

// Define where the code is located in both Flash and RAM
#define flash_start_add 0x8000              // Flash code starting address
#define flash_code_size 0x01ff              // Function segment size to be copied
#define RAM_start_add   0x2400              // RAM code starting address

// Function prototypes
void write_SegC (char value);
void copy_C2D (void);

char value;                                 // 8-bit value to write to seg C

// This function is in flash to be copied to RAM
#pragma CODE_SECTION(write_SegC,".flashcode")
void write_SegC (char value)
{
  char *Flash_ptr;                          // Flash pointer
  unsigned int i;
  
  P1OUT ^= 0x02;
  
  Flash_ptr = (char *) 0x1040;              // Initialize Flash pointer
  while(FCTL3&BUSY);                        // Check BUSY flag; Important if running this code from RAM
  FCTL1 = FWKEY + ERASE;                    // Set Erase bit
  FCTL3 = FWKEY;                            // Clear Lock bit
  
  *Flash_ptr = 0;                           // Dummy write to erase Flash segment
  while(FCTL3&BUSY);                        // Check BUSY flag; Important if running this code from RAM
  FCTL1 = FWKEY + WRT;                      // Set WRT bit for write operation

  for (i=0; i<64; i++)
  {
    while(FCTL3&BUSY);                        // Check BUSY flag; Important if running this code from RAM
    *Flash_ptr++ = value;                   // Write value to flash
  }

  while(FCTL3&BUSY);                        // Check BUSY flag; Important if running this code from RAM
  FCTL1 = FWKEY;                            // Clear WRT bit
  FCTL3 = FWKEY + LOCK;                     // Set LOCK bit
}


// This function is in flash to be copied to RAM
#pragma CODE_SECTION(copy_C2D,".flashcode")
void copy_C2D (void)
{
  char *Flash_ptrC;                         // Segment C pointer
  char *Flash_ptrD;                         // Segment D pointer
  unsigned int i;

  Flash_ptrC = (char *) 0x1040;             // Initialize Flash segment C pointer
  Flash_ptrD = (char *) 0x1000;             // Initialize Flash segment D pointer
  while(FCTL3&BUSY);                        // Check BUSY flag; Important if running this code from RAM
  FCTL1 = FWKEY + ERASE;                    // Set Erase bit
  FCTL3 = FWKEY;                            // Clear Lock bit
  *Flash_ptrD = 0;                          // Dummy write to erase Flash segment D
  while(FCTL3&BUSY);                        // Check BUSY flag; Important if running this code from RAM
  FCTL1 = FWKEY + WRT;                      // Set WRT bit for write operation

  for (i=0; i<64; i++)
  {
    while(FCTL3&BUSY);                        // Check BUSY flag; Important if running this code from RAM
    *Flash_ptrD++ = *Flash_ptrC++;          // copy value segment C to segment D
  }
  
  while(FCTL3&BUSY);                        // Check BUSY flag; Important if running this code from RAM
  FCTL1 = FWKEY;                            // Clear WRT bit
  FCTL3 = FWKEY + LOCK;                     // Set LOCK bit
}


//Copy function from Flash to RAM
void copy_flash_to_RAM(void)
{
  unsigned char *flash_start_ptr;           // Initialize pointers
  unsigned char *RAM_start_ptr;

  flash_start_ptr = (unsigned char *)flash_start_add;
  RAM_start_ptr = (unsigned char *)RAM_start_add;
  
  // Copy flash function to RAM 
  memcpy(RAM_start_ptr,flash_start_ptr,flash_code_size);
}


int main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WatchDog timer
  //if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)                                     
  //{  
  //  while(1);                               // If calibration constants erased
                                            // do not load, trap CPU!!
  //}   
  //BCSCTL1 = CALBC1_1MHZ;                    // Set DCO to 1MHz
  //DCOCTL = CALDCO_1MHZ;
  //FCTL2 = FWKEY + FSSEL_1 + FN1;            // MCLK/3 for Flash Timing Generator
  P1DIR |= 0x03;
  P1OUT |= 0x00;
  value = 0;
  
  copy_flash_to_RAM();                      // call function to copy from flash to RAM
    
  // Parts of this while loop executes from Flash. The write_SegC and copy_C2D
  // is executed from RAM. The program basically will execute from FLASH until
  // it calls write_SegC function which will jump the program to RAM.
  // After executing write_SegC in RAM, it will jump back to flash to continue
  // executing. When copy_C2D is called, it jumps to RAM and back to Flash when
  // done.
  while(1)
  {
  	  int i;
  	  
      P1OUT ^= 0x01;
      for(i=0;i<20000;i++);                 // This portion executes from FLASH
      write_SegC(value++);                  // This portion of the code is executed from RAM
      copy_C2D();                           // This portion of the code is executed from RAM
      __no_operation();                     // Jumps back to FLASH here. Set breakpoint here
  }
}



/******************************************************************************/
/* lnk_msp430f5510.cmd - LINKER COMMAND FILE FOR LINKING MSP430F5510 PROGRAMS     */
/*                                                                            */
/*   Usage:  lnk430 <obj files...>    -o <out file> -m <map file> lnk.cmd     */
/*           cl430  <src files...> -z -o <out file> -m <map file> lnk.cmd     */
/*                                                                            */
/*----------------------------------------------------------------------------*/
/* These linker options are for command line linking only.  For IDE linking,  */
/* you should set your linker options in Project Properties                   */
/* -c                                               LINK USING C CONVENTIONS  */
/* -stack  0x0100                                   SOFTWARE STACK SIZE       */
/* -heap   0x0100                                   HEAP AREA SIZE            */
/*                                                                            */
/*----------------------------------------------------------------------------*/


/****************************************************************************/
/* SPECIFY THE SYSTEM MEMORY MAP                                            */
/****************************************************************************/

MEMORY
{
    SFR                     : origin = 0x0000, length = 0x0010
    PERIPHERALS_8BIT        : origin = 0x0010, length = 0x00F0
    PERIPHERALS_16BIT       : origin = 0x0100, length = 0x0100
    RAM                     : origin = 0x2600, length = 0x0E00
    RAM_MEM                 : origin = 0x2400, length = 0x01FF
    INFOA                   : origin = 0x1980, length = 0x0080
    INFOB                   : origin = 0x1900, length = 0x0080
    INFOC                   : origin = 0x1880, length = 0x0080
    INFOD                   : origin = 0x1800, length = 0x0080
    FLASH_MEM               : origin = 0x8000, length = 0x01FF
    FLASH                   : origin = 0x8200, length = 0x7D80
    INT00                   : origin = 0xFF80, length = 0x0002
    INT01                   : origin = 0xFF82, length = 0x0002
    INT02                   : origin = 0xFF84, length = 0x0002
    INT03                   : origin = 0xFF86, length = 0x0002
    INT04                   : origin = 0xFF88, length = 0x0002
    INT05                   : origin = 0xFF8A, length = 0x0002
    INT06                   : origin = 0xFF8C, length = 0x0002
    INT07                   : origin = 0xFF8E, length = 0x0002
    INT08                   : origin = 0xFF90, length = 0x0002
    INT09                   : origin = 0xFF92, length = 0x0002
    INT10                   : origin = 0xFF94, length = 0x0002
    INT11                   : origin = 0xFF96, length = 0x0002
    INT12                   : origin = 0xFF98, length = 0x0002
    INT13                   : origin = 0xFF9A, length = 0x0002
    INT14                   : origin = 0xFF9C, length = 0x0002
    INT15                   : origin = 0xFF9E, length = 0x0002
    INT16                   : origin = 0xFFA0, length = 0x0002
    INT17                   : origin = 0xFFA2, length = 0x0002
    INT18                   : origin = 0xFFA4, length = 0x0002
    INT19                   : origin = 0xFFA6, length = 0x0002
    INT20                   : origin = 0xFFA8, length = 0x0002
    INT21                   : origin = 0xFFAA, length = 0x0002
    INT22                   : origin = 0xFFAC, length = 0x0002
    INT23                   : origin = 0xFFAE, length = 0x0002
    INT24                   : origin = 0xFFB0, length = 0x0002
    INT25                   : origin = 0xFFB2, length = 0x0002
    INT26                   : origin = 0xFFB4, length = 0x0002
    INT27                   : origin = 0xFFB6, length = 0x0002
    INT28                   : origin = 0xFFB8, length = 0x0002
    INT29                   : origin = 0xFFBA, length = 0x0002
    INT30                   : origin = 0xFFBC, length = 0x0002
    INT31                   : origin = 0xFFBE, length = 0x0002
    INT32                   : origin = 0xFFC0, length = 0x0002
    INT33                   : origin = 0xFFC2, length = 0x0002
    INT34                   : origin = 0xFFC4, length = 0x0002
    INT35                   : origin = 0xFFC6, length = 0x0002
    INT36                   : origin = 0xFFC8, length = 0x0002
    INT37                   : origin = 0xFFCA, length = 0x0002
    INT38                   : origin = 0xFFCC, length = 0x0002
    INT39                   : origin = 0xFFCE, length = 0x0002
    INT40                   : origin = 0xFFD0, length = 0x0002
    INT41                   : origin = 0xFFD2, length = 0x0002
    INT42                   : origin = 0xFFD4, length = 0x0002
    INT43                   : origin = 0xFFD6, length = 0x0002
    INT44                   : origin = 0xFFD8, length = 0x0002
    INT45                   : origin = 0xFFDA, length = 0x0002
    INT46                   : origin = 0xFFDC, length = 0x0002
    INT47                   : origin = 0xFFDE, length = 0x0002
    INT48                   : origin = 0xFFE0, length = 0x0002
    INT49                   : origin = 0xFFE2, length = 0x0002
    INT50                   : origin = 0xFFE4, length = 0x0002
    INT51                   : origin = 0xFFE6, length = 0x0002
    INT52                   : origin = 0xFFE8, length = 0x0002
    INT53                   : origin = 0xFFEA, length = 0x0002
    INT54                   : origin = 0xFFEC, length = 0x0002
    INT55                   : origin = 0xFFEE, length = 0x0002
    INT56                   : origin = 0xFFF0, length = 0x0002
    INT57                   : origin = 0xFFF2, length = 0x0002
    INT58                   : origin = 0xFFF4, length = 0x0002
    INT59                   : origin = 0xFFF6, length = 0x0002
    INT60                   : origin = 0xFFF8, length = 0x0002
    INT61                   : origin = 0xFFFA, length = 0x0002
    INT62                   : origin = 0xFFFC, length = 0x0002
    RESET                   : origin = 0xFFFE, length = 0x0002
}

/****************************************************************************/
/* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY                              */
/****************************************************************************/

SECTIONS
{
    .bss       : {} > RAM                /* GLOBAL & STATIC VARS              */
    .sysmem    : {} > RAM                /* DYNAMIC MEMORY ALLOCATION AREA    */
    .stack     : {} > RAM (HIGH)         /* SOFTWARE SYSTEM STACK             */

    .text      : {} > FLASH              /* CODE                              */   
    .flashcode : load = FLASH_MEM, run = RAM_MEM
                                                                            
    .ramcode   : load = FLASH_MEM        /* CODE WILL BE IN RAM                  */
    .cinit     : {} > FLASH              /* INITIALIZATION TABLES             */
    .const     : {} > FLASH              /* CONSTANT DATA                     */
    .cio       : {} > RAM                /* C I/O BUFFER                      */

    .pinit     : {} > FLASH              /* C++ CONSTRUCTOR TABLES            */

    .infoA     : {} > INFOA              /* MSP430 INFO FLASH MEMORY SEGMENTS */
    .infoB     : {} > INFOB
    .infoC     : {} > INFOC
    .infoD     : {} > INFOD

    .int00   : {} > INT00                /* MSP430 INTERRUPT VECTORS          */
    .int01   : {} > INT01
    .int02   : {} > INT02
    .int03   : {} > INT03
    .int04   : {} > INT04
    .int05   : {} > INT05
    .int06   : {} > INT06
    .int07   : {} > INT07
    .int08   : {} > INT08
    .int09   : {} > INT09
    .int10   : {} > INT10
    .int11   : {} > INT11
    .int12   : {} > INT12
    .int13   : {} > INT13
    .int14   : {} > INT14
    .int15   : {} > INT15
    .int16   : {} > INT16
    .int17   : {} > INT17
    .int18   : {} > INT18
    .int19   : {} > INT19
    .int20   : {} > INT20
    .int21   : {} > INT21
    .int22   : {} > INT22
    .int23   : {} > INT23
    .int24   : {} > INT24
    .int25   : {} > INT25
    .int26   : {} > INT26
    .int27   : {} > INT27
    .int28   : {} > INT28
    .int29   : {} > INT29
    .int30   : {} > INT30
    .int31   : {} > INT31
    .int32   : {} > INT32
    .int33   : {} > INT33
    .int34   : {} > INT34
    .int35   : {} > INT35
    .int36   : {} > INT36
    .int37   : {} > INT37
    .int38   : {} > INT38
    .int39   : {} > INT39
    .int40   : {} > INT40
    .int41   : {} > INT41
    .int42   : {} > INT42
    .int43   : {} > INT43
    .int44   : {} > INT44
    .int45   : {} > INT45
    .int46   : {} > INT46
    .int47   : {} > INT47
    .int48   : {} > INT48
    .int49   : {} > INT49
    .int50   : {} > INT50
    .int51   : {} > INT51
    .int52   : {} > INT52
    .int53   : {} > INT53
    .int54   : {} > INT54
    .int55   : {} > INT55
    .int56   : {} > INT56
    .int57   : {} > INT57
    .int58   : {} > INT58
    .int59   : {} > INT59
    .int60   : {} > INT60
    .int61   : {} > INT61
    .int62   : {} > INT62
    .reset   : {} > RESET              /* MSP430 RESET VECTOR               */
}

/****************************************************************************/
/* INCLUDE PERIPHERALS MEMORY MAP                                           */
/****************************************************************************/

-l msp430f5510.cmd

  • Hi forum users,

    the above code works fine after all. When I cleaned the project, the old linker command file was still opened as window in CCE, I corrected a typo and I tried compiling it again. BUT I did not notice that a new linker command file was generated. Of cource, the new linker command file had not the adequate changes and correctly gave me back this warning.

    Problem solved or not existed after all!

    Thanks!

**Attention** This is a public forum