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.

Flash to one particular location

Hi,

 

I want to write a value in a particular location  of flash say address x in flash).

 The situation is: already a software exists in the flash. This software reads location 'x' and takes some descision. My idea is to update only this location x through some means so that i can change behaviour of software without disturbing other locations in flash.

Below is the code in a .c file. The project has no other files other than this .c file and has no other code than shown below:

#pragma DATA_SECTION(LocationX,"LocationXInFlashB");
const unsigned int LocationX= 0x05;

I changed the linker command file to reserve a location out of flash B sector with name: LocationXInFlashB

Project is set for --> No auto initialization mode so that linker does not complain for NOT having a main routine.

 

With this i'm able to get a .out file.

But when i try to flash this .out file i get a error "No sections were found that map to flash"

Please help me in resolving this issue!

Also, I this a good method to write a particular location in flash?

If not what other methods can be used?

 

 

 

  • Forgot to mention that i use F28335, Spectrum Digital 510 usb emulator, CCS v3.3 CGT 5.13

  • Krishna Devale said:

    I changed the linker command file to reserve a location out of flash B sector with name: LocationXInFlashB



    Do you also have a SECTIONS specification in the linker command file that allocates this LocationXInFlashB section to the desired memory location, something like what is shown below? It sounds like you may be missing this step.

    MEMORY
    {

      PAGE 1:    FLASHB_1: origin = 0x337000, length = 0x001000
      ...
      ...
    }

    SECTIONS
    {
      
    LocationXInFlashB : > FLASHB_1,  PAGE=1
    }

     

     

      

        

  • Hi,

     

    yes I do have sections specification in linker command file. Below is the linker command file:

     

    Command File:

    /*
    // TI File $Revision: /main/10 $
    // Checkin $Date: July 9, 2008   13:43:56 $
    //###########################################################################
    //
    // FILE: F28335.cmd
    //
    // TITLE: Linker Command File For F28335 Device
    //
    //###########################################################################
    // $TI Release: DSP2833x/DSP2823x C/C++ Header Files V1.31 $
    // $Release Date: August 4, 2009 $
    //###########################################################################
    */

    /* ======================================================
    // For Code Composer Studio V2.2 and later
    // ---------------------------------------
    // In addition to this memory linker command file,
    // add the header linker command file directly to the project.
    // The header linker command file is required to link the
    // peripheral structures to the proper locations within
    // the memory map.
    //
    // The header linker files are found in <base>\DSP2833x_Headers\cmd
    //  
    // For BIOS applications add:      DSP2833x_Headers_BIOS.cmd
    // For nonBIOS applications add:   DSP2833x_Headers_nonBIOS.cmd   
    ========================================================= */

    /* ======================================================
    // For Code Composer Studio prior to V2.2
    // --------------------------------------
    // 1) Use one of the following -l statements to include the
    // header linker command file in the project. The header linker
    // file is required to link the peripheral structures to the proper
    // locations within the memory map                                    */

    /* Uncomment this line to include file only for non-BIOS applications */
    /* -l DSP2833x_Headers_nonBIOS.cmd */

    /* Uncomment this line to include file only for BIOS applications */
    /* -l DSP2833x_Headers_BIOS.cmd */

    /* 2) In your project add the path to <base>\DSP2833x_headers\cmd to the
       library search path under project->build options, linker tab,
       library search path (-i).
    /*========================================================= */

    /* Define the memory block start/length for the F28335 
       PAGE 0 will be used to organize program sections
       PAGE 1 will be used to organize data sections

        Notes:
              Memory blocks on F28335 are uniform (ie same
              physical memory) in both PAGE 0 and PAGE 1. 
              That is the same memory region should not be
              defined for both PAGE 0 and PAGE 1.
              Doing so will result in corruption of program
              and/or data.
             
              L0/L1/L2 and L3 memory blocks are mirrored - that is
              they can be accessed in high memory or low memory.
              For simplicity only one instance is used in this
              linker file.
             
              Contiguous SARAM memory blocks can be combined
              if required to create a larger memory block.
     */


    MEMORY
    {
    PAGE 0:    /* Program Memory */
               /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE1 for data allocation */

       ZONE0       : origin = 0x004000, length = 0x001000     /* XINTF zone 0 */
       RAML0       : origin = 0x008000, length = 0x001000     /* on-chip RAM block L0 */
       RAML1       : origin = 0x009000, length = 0x001000     /* on-chip RAM block L1 */
       RAML2       : origin = 0x00A000, length = 0x001000     /* on-chip RAM block L2 */
       RAML3       : origin = 0x00B000, length = 0x001000     /* on-chip RAM block L3 */
       ZONE6       : origin = 0x0100000, length = 0x100000    /* XINTF zone 6 */
       ZONE7A      : origin = 0x0200000, length = 0x00FC00    /* XINTF zone 7 - program space */
       FLASHH      : origin = 0x300000, length = 0x008000     /* on-chip FLASH */
       FLASHG      : origin = 0x308000, length = 0x008000     /* on-chip FLASH */
       FLASHF      : origin = 0x310000, length = 0x008000     /* on-chip FLASH */
       FLASHE      : origin = 0x318000, length = 0x008000     /* on-chip FLASH */
       FLASHD      : origin = 0x320000, length = 0x008000     /* on-chip FLASH */
       FLASHC      : origin = 0x328000, length = 0x008000     /* on-chip FLASH */
       FLASHA      : origin = 0x338000, length = 0x007F80     /* on-chip FLASH */
       CSM_RSVD    : origin = 0x33FF80, length = 0x000076     /* Part of FLASHA.  Program with all 0x0000 when CSM is in use. */
       BEGIN       : origin = 0x33FFF6, length = 0x000002     /* Part of FLASHA.  Used for "boot to Flash" bootloader mode. */
       CSM_PWL     : origin = 0x33FFF8, length = 0x000008     /* Part of FLASHA.  CSM password locations in FLASHA */
       OTP         : origin = 0x380400, length = 0x000400     /* on-chip OTP */
       ADC_CAL     : origin = 0x380080, length = 0x000009     /* ADC_cal function in Reserved memory */
      
       IQTABLES    : origin = 0x3FE000, length = 0x000b50     /* IQ Math Tables in Boot ROM */
       IQTABLES2   : origin = 0x3FEB50, length = 0x00008c     /* IQ Math Tables in Boot ROM */ 
       FPUTABLES   : origin = 0x3FEBDC, length = 0x0006A0     /* FPU Tables in Boot ROM */
       ROM         : origin = 0x3FF27C, length = 0x000D44     /* Boot ROM */       
       RESET       : origin = 0x3FFFC0, length = 0x000002     /* part of boot ROM  */
       VECTORS     : origin = 0x3FFFC2, length = 0x00003E     /* part of boot ROM  */

    PAGE 1 :   /* Data Memory */
               /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE0 for program allocation */
               /* Registers remain on PAGE1                                                  */
      
       BOOT_RSVD   : origin = 0x000000, length = 0x000050     /* Part of M0, BOOT rom will use this for stack */
       RAMM0       : origin = 0x000050, length = 0x0003B0     /* on-chip RAM block M0 */
       RAMM1       : origin = 0x000400, length = 0x000400     /* on-chip RAM block M1 */
       RAML4       : origin = 0x00C000, length = 0x001000     /* on-chip RAM block L1 */
       RAML5       : origin = 0x00D000, length = 0x001000     /* on-chip RAM block L1 */
       RAML6       : origin = 0x00E000, length = 0x001000     /* on-chip RAM block L1 */
       RAML7       : origin = 0x00F000, length = 0x001000     /* on-chip RAM block L1 */
       ZONE7B      : origin = 0x20FC00, length = 0x000400     /* XINTF zone 7 - data space */
       FLASHB_ORG  : origin = 0x330000, length = 0x0000E6     /* on-chip FLASH */
       FLASHB_ONEFLAG  : origin = 0x3300E6, length = 0x000001     /* on-chip FLASH */
       FLASHB_CONT  : origin = 0x3300E7, length = 0x007F19     /* on-chip FLASH */
    }

    /* Allocate sections to memory blocks.
       Note:
             codestart user defined section in DSP28_CodeStartBranch.asm used to redirect code
                       execution when booting to flash
             ramfuncs  user defined section to store functions that will be copied from Flash into RAM
    */
     
    SECTIONS
    {
     
       /* Allocate program areas:
       .cinit              : > FLASHA      PAGE = 0
       .pinit              : > FLASHA,     PAGE = 0
       .text               : > FLASHA      PAGE = 0
       codestart           : > BEGIN       PAGE = 0
       ramfuncs            : LOAD = FLASHD,
                             RUN = RAML0,
                             LOAD_START(_RamfuncsLoadStart),
                             LOAD_END(_RamfuncsLoadEnd),
                             RUN_START(_RamfuncsRunStart),
                             PAGE = 0

       csmpasswds          : > CSM_PWL     PAGE = 0
       csm_rsvd            : > CSM_RSVD    PAGE = 0
      
       // Allocate uninitalized data sections:
       .stack              : > RAMM1       PAGE = 1
       .ebss               : > RAML4       PAGE = 1
       .esysmem            : > RAMM1       PAGE = 1

       //Initalized sections go in Flash
       // For SDFlash to program these, they must be allocated to page 0
       .econst             : > FLASHA      PAGE = 0
       .switch             : > FLASHA      PAGE = 0     

       // Allocate IQ math areas:
       IQmath              : > FLASHC      PAGE = 0                 
       IQmathTables     : > IQTABLES,  PAGE = 0, TYPE = NOLOAD
      

      
       FPUmathTables    : > FPUTABLES, PAGE = 0, TYPE = NOLOAD */
       LocationXInFlashB    : > FLASHB_ONEFLAG, PAGE = 1, TYPE = NOLOAD


    }

    /*
    //===========================================================================
    // End of file.
    //===========================================================================
    */

     

    Below is the code i have:

    #pragma DATA_SECTION(OneFlag,"LocationXInFlashB");
    const unsigned int OneFlag = 0x05;

     

    Project file:

    ; Code Composer Project File, Version 2.0 (do not modify or remove this line)

    [Project Settings]
    ProjectDir="E:\SGS\Users\DevaleKrishna\SplFlashOneFlag\"
    ProjectType=Executable
    CPUFamily=TMS320C28XX
    Tool="Compiler"
    Tool="CustomBuilder"
    Tool="DspBiosBuilder"
    Tool="Linker"
    Config="Debug"
    Config="Release"

    [Source Files]
    Source="flash.c"
    Source="F28335.cmd"

    ["Compiler" Settings: "Debug"]
    Options=-g -pdsw225 -fr"$(Proj_dir)\Debug" -d"_DEBUG" -v28

    ["Compiler" Settings: "Release"]
    Options=-pdsw225 -o3 -fr"$(Proj_dir)\Release" -d"LARGE_MODEL" -ml -v28

    ["Linker" Settings: "Debug"]
    Options=-a -m".\Debug\OneFlagFlash.map" -o".\Debug\OneFlagFlash.out" -w

    ["Linker" Settings: "Release"]
    Options=-c -m".\Release\OneFlagFlash.map" -o".\Release\OneFlagFlash.out" -w -x

    ["F28335.cmd" Settings: "Debug"]
    LinkOrder=1

    ["F28335.cmd" Settings: "Release"]
    LinkOrder=1

     

     

     

     

  • You have the section specified as a NOLOAD section which means it will not be placed in the output file and will not be loaded onto the target. 

       LocationXInFlashB    : > FLASHB_ONEFLAG, PAGE = 1, TYPE = NOLOAD

    Remove the TYPE=NOLOAD and give it a try.

  • The section qualifier NOLOAD, and other qualifiers like it, is described in this wiki article.

    Thanks and regards,

    -George

  • Thanks Aarti and George. After removing qualifier NO_LOAD I'm able to flash. :)

     

    I need just one more help. I've shared the code, linker command file and project file in earlier post. From that will you be able to tell me whether after flashing the out file generated it will update only the location i'm iterested in i.e 0x3300e6 or any chances of writing into other flash locations. The reason is i dont want to screw up other loactions which already has some content.

     

    regards,

    Krishna

  • The Flash programmer checks that the flash sector is erased before it programs. If the location that this data is getting programmed to has been erased when the code was previously programmed then it will be able to program it. However if you want to change the same location at a later time, you would need to erase and then program. Also, since you want to avoid erasing other parts of the code, make sure that this data is in a separate flash sector where nothing else is allocated, as the minimum range you can choose to erase is a flash sector.