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.

MSP430FR5994: Enabling IPE using msp430-elf-gcc

Part Number: MSP430FR5994

Hello,

I am using msp430-elf-gcc to create my project for MSP430FR5994. I want to use the IP Encapsulation feature present in my device. But all the documentation, such as SLAA685: MSP Code Protection Features and SLAU367O: device User's Guide, provide guidelines to setup IPE using CCS tools. I would like to do the same using msp430-elf-gcc. It is not sufficient to program the dedicated registers in my C code as IPE has to be setup/enabled at the time of boot process. Rather, it requires to be set in boot code (as described in section 9.6.1 of SLAU367)

I have the following questions on how to set up the following settings using msp430-elf-gcc.

1.In CCS, the linker command file(.cmd) contains a dedicated code section that defines the settings of Memory Protection Unit (MPU). How are the variables defined here mapped to the MPUIP registers on the device?

/****************************************************************************/
/* MPU/IPE SPECIFIC MEMORY SEGMENT DEFINITONS                               */
/****************************************************************************/

#ifdef _IPE_ENABLE
    #define IPE_MPUIPLOCK 0x0080
    #define IPE_MPUIPENA 0x0040
    #define IPE_MPUIPPUC 0x0020

    // Evaluate settings for the control setting of IP Encapsulation
    #if defined(_IPE_ASSERTPUC1)
        #if defined(_IPE_LOCK ) && (_IPE_ASSERTPUC1 == 0x08))
            fram_ipe_enable_value = (IPE_MPUIPENA | IPE_MPUIPPUC |IPE_MPUIPLOCK);
        #elif defined(_IPE_LOCK )
            fram_ipe_enable_value = (IPE_MPUIPENA | IPE_MPUIPLOCK);
        #elif (_IPE_ASSERTPUC1 == 0x08)
            fram_ipe_enable_value = (IPE_MPUIPENA | IPE_MPUIPPUC);
        #else
            fram_ipe_enable_value = (IPE_MPUIPENA);
        #endif
    #else
        #if defined(_IPE_LOCK )
            fram_ipe_enable_value = (IPE_MPUIPENA | IPE_MPUIPLOCK);
        #else
            fram_ipe_enable_value = (IPE_MPUIPENA);
        #endif
    #endif

    // Segment definitions
    #ifdef _IPE_MANUAL                  // For custom sizes selected in the GUI
        fram_ipe_border1 = (_IPE_SEGB1>>4);
        fram_ipe_border2 = (_IPE_SEGB2>>4);
    #else                           // Automated sizes generated by the Linker
        fram_ipe_border2 = fram_ipe_end >> 4;
        fram_ipe_border1 = fram_ipe_start >> 4;
    #endif

    fram_ipe_settings_struct_address = Ipe_settingsStruct >> 4;
    fram_ipe_checksum = ~((fram_ipe_enable_value & fram_ipe_border2 & fram_ipe_border1) | (fram_ipe_enable_value & ~fram_ipe_border2 & ~fram_ipe_border1) | (~fram_ipe_enable_value & fram_ipe_border2 & ~fram_ipe_border1) | (~fram_ipe_enable_value & ~fram_ipe_border2 & fram_ipe_border1));
#endif

#ifdef _MPU_ENABLE
    #define MPUPW (0xA500)    /* MPU Access Password */
    #define MPUENA (0x0001)   /* MPU Enable */
    #define MPULOCK (0x0002)  /* MPU Lock */
    #define MPUSEGIE (0x0010) /* MPU Enable NMI on Segment violation */

    __mpu_enable = 1;
    // Segment definitions
    #ifdef _MPU_MANUAL // For custom sizes selected in the GUI
        mpu_segment_border1 = _MPU_SEGB1 >> 4;
        mpu_segment_border2 = _MPU_SEGB2 >> 4;
        mpu_sam_value = (_MPU_SAM0 << 12) | (_MPU_SAM3 << 8) | (_MPU_SAM2 << 4) | _MPU_SAM1;
    #else // Automated sizes generated by Linker
        #ifdef _IPE_ENABLE //if IPE is used in project too
        //seg1 = any read + write persistent variables
        //seg2 = ipe = read + write + execute access
        //seg3 = code, read + execute only
               mpu_segment_border1 = fram_ipe_start >> 4;
               mpu_segment_border2 = fram_rx_start >> 4;
               mpu_sam_value = 0x1573; // Info R, Seg3 RX, Seg2 RWX, Seg1 RW
        #else
               mpu_segment_border1 = fram_rx_start >> 4;
               mpu_segment_border2 = fram_rx_start >> 4;
               mpu_sam_value = 0x1513; // Info R, Seg3 RX, Seg2 R, Seg1 RW
        #endif
    #endif
    #ifdef _MPU_LOCK
        #ifdef _MPU_ENABLE_NMI
            mpu_ctl0_value = MPUPW | MPUENA | MPULOCK | MPUSEGIE;
        #else
            mpu_ctl0_value = MPUPW | MPUENA | MPULOCK;
        #endif
    #else
        #ifdef _MPU_ENABLE_NMI
            mpu_ctl0_value = MPUPW | MPUENA | MPUSEGIE;
        #else
            mpu_ctl0_value = MPUPW | MPUENA;
        #endif
    #endif
#endif

2. Will IPE work from msp430-elf-gcc?

3. If yes to the previous question, the above code from linker command file defines the register control and protected memory segmentation of MPU segments. How can I set the same settings in the linker description file used in msp430-elf-gcc?

4. Will it suffice to make changes to linker description file to make IPE work? What else must be done to enable IPE from msp430-elf-gcc

Thank you,
Archanaa

  • Hello Archie,

    Ok, it turns out that this feature in CCS is not supported in GCC.

    According to the MSP430 GCC users guide, section 3.7:

    3.7 CCS Compared to MSP430 GCC

    Some CCS features are not supported in MSP430 GCC. These features are:

    • Optimizer Assistant

    • ULP Advisor

    • Memory Protection Unit and Intellectual Property Encapsulation GUI configuration

    • Memory allocation

    To gain access to these features, the TI Compiler must be used.

    Now regarding your question:

    In CCS, the linker command file(.cmd) contains a dedicated code section that defines the settings of Memory Protection Unit (MPU). How are the variables defined here mapped to the MPUIP registers on the device?

     These variables are setup using the CSS GUI: please refer to SLAU157 Section 5 for more details.

  • Hi Dennis,

    Thank you. MSP430 GCC user guide mentiones that Memory Protection Unit and Intellectual Property ExnacpuslationGUI configuration is not available in GCC. It does not explicitly state that MPU and IPE features supported by the device are not supported by GCC. I have enabled MPU from GCC, but I'm unable to do the same with IPE from GCC. I would like to know if there's a way to enable IPE from GCC.

    Also, SLAU157 does not have a chapter 5. Did you mean Chapter 4: Memory Protection Unit and Intellectual Property Encapsulation? Chapter 4 does not say what happens behind the GUI.

  • Hi Archie,

    Our tools team is not providing any further suggestions on this so I thought I would check on your status.  From what I can tell, there are no explicit instructions on how to configure GCC to enable the MPU and IPE features.  However, my thought is you should be able to access the registers directly in your startup code to enable these features.  These registers are described in the MSP430FR58xx59xx USER's guide.

    Also, in regards to the earlier reference to chapter 5, it is located in the Code Composer Studio IDE v8.x here.

**Attention** This is a public forum