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