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.

run code from SRAM in MSP432 using IAR IDE

Other Parts Discussed in Thread: SEGGER, MSP-FET, MSP-GANG

Hi, I want to locate my code to SRAM and  excute in  it , i have changed the icf file as below:

so i want to store my code to 0x20000000-0x20001FFF,and using 0x20002000-0x20003FFF  for data(real RAM) 

 After doing that the runtine do not excuted as expecte,why this happened?  

so i want to ask TI's employee, whether we can do it or not?

or is there any other methods to realize it ?

1、start debugger

2、sigle step   error ocurrs

/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x20000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x20000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x20001FFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20002000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20003FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x1000;
define symbol __ICFEDIT_size_heap__ = 0x2000;
/**** End of ICF editor section. ###ICF###*/

define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];

define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };

initialize by copy { readwrite };
do not initialize { section .noinit };

place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in RAM_region { readwrite,
block CSTACK, block HEAP };

  • Hi Kissn Liu,

     This is how I do it:

    My linker file:

    /*###ICF### Section handled by ICF editor, don't touch! ****/
    /*-Editor annotation file-*/
    /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
    /*-Specials-*/
    define symbol __ICFEDIT_intvec_start__ = 0x00000000;
    /*-Memory Regions-*/
    define symbol __ICFEDIT_region_ROM_start__   = 0x00000000;
    define symbol __ICFEDIT_region_ROM_end__     = 0x0003FFFF;
    
    define symbol __ICFEDIT_region_RAM_start__   = 0x01000000;
    define symbol __ICFEDIT_region_RAM_end__     = 0x0100FFFF;
    
    //define symbol __ICFEDIT_region_RAM_start__   = 0x20000000;
    //define symbol __ICFEDIT_region_RAM_end__     = 0x2000FFFF;
    
    /*-Sizes-*/
    define symbol __ICFEDIT_size_cstack__   = 0x1000;
    define symbol __ICFEDIT_size_heap__     = 0x2000;
    define symbol __ICFEDIT_size_RAM_reserved__     = 0x0400;
    define symbol __ICFEDIT_size_ROM_reserved__     = 0x0400;
    
    /**** End of ICF editor section. ###ICF###*/
    
    define memory mem with size = 4G;
    define region ROM_region   = mem:[from __ICFEDIT_region_ROM_start__   to __ICFEDIT_region_ROM_end__];
    define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];
    
    // define region RAM_reserverd_region   = mem:[from __ICFEDIT_region_RAM_reserved_start__   to __ICFEDIT_region_RAM_reserved_end__];
    
    define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };
    define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__     { };
    
    define block RAMRESERVED with alignment = 8, size = __ICFEDIT_size_RAM_reserved__     { };
    
    initialize by copy { rw, section .romtoram };
    
    initialize by copy { readwrite };
    do not initialize  { section .noinit };
    
    place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
    
    place in ROM_region   { readonly };
    //place in ROM_region   { readonly,
    //                        block ROMRESERVED };
    place in RAM_region   { readwrite,
                            block CSTACK, block HEAP, block RAMRESERVED };

    And my test code:

    //*****************************************************************************
    //
    // Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without
    // modification, are permitted provided that the following conditions
    // are met:
    //
    //  Redistributions of source code must retain the above copyright
    //  notice, this list of conditions and the following disclaimer.
    //
    //  Redistributions in binary form must reproduce the above copyright
    //  notice, this list of conditions and the following disclaimer in the
    //  documentation and/or other materials provided with the
    //  distribution.
    //
    //  Neither the name of Texas Instruments Incorporated nor the names of
    //  its contributors may be used to endorse or promote products derived
    //  from this software without specific prior written permission.
    //
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    //
    // MSP432 main.c
    //
    //****************************************************************************
    #include <stdbool.h>
    #include <stdint.h>
    #include <string.h>
    #include "msp432.h"
    #include "driverlib.h"
    #include "demo_sysctl.h"
    
    //***** Definitions *****
    
    //***** Function Prototypes *****
    void functionRunInRam (void);
    
    //***** Global Data *****
    
    
    
    /***********************************************************
      Function:
     */
    void main(void)
    {
    	MAP_WDT_A_holdTimer();
    	MAP_Interrupt_disableMaster();                // Disabling master interrupts      
    
    	// P1.0 as output
    	MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
    
    	// Run from SRAM Region in the CODE Zone Memory MAP 0x01000000 to 0x01100000
    	// Refer to the DataSheet, CODE Zone Memory Map Section
    
    	// In the linkerfile, defining SRAM Region in the CODE Zone
    	functionRunInRam();
    
    	while(1);
    }
    
    /***********************************************************
      Function:
    
       The following function is defined in ROM, but it will be
       run in RAM.
     */
    #pragma location=".romtoram"
    __root void functionRunInRam (void)
    {
    	while (1)                               // continuous loop
    	{
    		P1OUT ^= BIT0;                      // Blink P1.0 LED
    		SysCtlDelay(2000000);
    	}
    }
    

    In your case you may just need to modify your linker file to use the Code Zone area:

    from:

    define symbol __ICFEDIT_region_ROM_start__ = 0x20000000;
    define symbol __ICFEDIT_region_ROM_end__ = 0x20001FFF;

    to:

    define symbol __ICFEDIT_region_ROM_start__ = 0x01000000;
    define symbol __ICFEDIT_region_ROM_end__ = 0x01001FFF;

    Please give this a try and let me know if you have further questions.

    Best regards,

     David

  • yes, i have found this solution before you reply,but thank you all the seen.

    and i have some more question about MSP432

    1 it seems that msp432 have two blocks SRAM,one from 0x01000000-0x0100FFFF(64KB),the other is from 0x20000000(64KB),  the user guid says that 0x2000 0000 can not be used for instruction fection,so it can not be used to store code

    but the user guid says it 0x20000000-0x2000FFFF can be used for instruction fetch

    2、another question ,in user guid, it mentioned that SRAM memory is divided into 8KB banks that can individually be powered down. so did it refer to 0x01000000-0x0101FFFF  0r 0x20000000-0x2000FFFF?

    and why  the sram space from 0x01000000 to 0x0101FFFF  do not add to IAR's icf file ?

    3、and there may be a small mistaken in datasheet, MSP432P401x's flash is 256KB,so the address should be 0x00004000 not 0x00400000

  • i used jlink to program flash sectors and information sectors

    my jlink software is J-Link V5.11a from segger website

    and here is my problem:

    1、program and erase flash sector is OK

    2、erase information sector is OK, but program information sector have problems:

    but when i changed the data at 0x00200000 to FF,it can be programed 

    my j-flash project settings  just  as  below:

    why this happened ?

    is there any other tool that i can directly program information sectors?

  • Hi Kissn Liu,

    Kissn Liu said:
    1 it seems that msp432 have two blocks SRAM,one from 0x01000000-0x0100FFFF(64KB),the other is from 0x20000000(64KB),  the user guid says that 0x2000 0000 can not be used for instruction fection,so it can not be used to store code

    It is the same block. The SRAM memory is aliased in both Code as well as SRAM memory zones. This enables fast, single cycle execution of code from the SRAM, as the Cortex-M4 processor pipelines instruction fetches to memory zones other than the Code space.

    Kissn Liu said:
    but the user guid says it 0x20000000-0x2000FFFF can be used for instruction fetch

    This needs to get corrected in the user's guide

    Kissn Liu said:
    2、another question ,in user guid, it mentioned that SRAM memory is divided into 8KB banks that can individually be powered down. so did it refer to 0x01000000-0x0101FFFF  0r 0x20000000-0x2000FFFF?

    Again, it is the same memory block.

    Kissn Liu said:
    and why the sram space from 0x01000000 to 0x0101FFFF  do not add to IAR's icf file ?

    *###ICF### Section handled by ICF editor, don't touch! ****/
    /*-Editor annotation file-*/
    /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
    /*-Specials-*/
    define symbol __ICFEDIT_intvec_start__ = 0x01000000;
    /*-Memory Regions-*/
    define symbol __ICFEDIT_region_ROM_start__   = 0x0;
    define symbol __ICFEDIT_region_ROM_end__     = 0x0;
    define symbol __ICFEDIT_region_RAM_start__   = 0x01000020;
    define symbol __ICFEDIT_region_RAM_end__     = 0x01001FFF;
    /*-Sizes-*/
    define symbol __ICFEDIT_size_cstack__   = 0x100;
    define symbol __ICFEDIT_size_heap__     = 0x000;

    Latest IAR 7.50.x version now uses that sram space

    Regards,

     David

  • Hi Kissn Liu,

    Let me look into this, because I'm not that familiar with that tool.

    In the meantime you can use IAR to program the Info section. Please take a look at the section "Erasing the Bootstrap Loader" in this document www.ti.com/.../slau574

    Thanks,

    David
  • Hi Kissn Liu,

    I forgot to ask you, what are you trying to store in the Info section area??

    Thanks,

    David

  • hi DavidL
    i just want to secure IP protect area,so i would like to write flashmailbox through programer tool like jflash, msp-fet etc ,because i do not want to secure or update the IP protect area by user application.
    but the pity is :
    (1) Jflash can write/erase/read main flash sectors separately,but it can not write flashmailbox
    (2) MSP-FET can program the MSP432 once through BSL ,becasue it can not enter bsl entry as the standard BSL,after the code has been write to the flash and it can no longer enter BSL

    so would the jflash support flashmailbox write and erase afterwards?
    ( and i think jflash is a nice tool to program the msp432 becasue it can operate sectors separately.)
  • Hi Kissn Liu,

    You should take a look a the MSP-GANG www.ti.com/.../MSP-GANG

    If my understanding is correct it supports all features via Boot-Override-Mailbox, therefore you can write/erase/read main flash + write to the mailbox.

    Hopefully this helps.

    David

  • Hi Kissn Liu,

    I'm marking the thread closed due to inactivity, but you can always use "reject answer" or simply post back to re-open it if you need more help on this issue.

    Regards,

    David

**Attention** This is a public forum