MSPM33-SDK: EEPROM management

Part Number: MSPM33-SDK
Other Parts Discussed in Thread: MSPM33C321A, SYSCONFIG

Hello,

I use the µc MSPM33C321A, and I would like to manage EEPROM.

I do not want to use example, which manage EEPROM in Type_A or Type_B, I want to manage myself the EEPROM.

So I need to know, the following points:

1 - Does it modify the makefile or other to declare the EEPROM memory ?

2 - How to intialize the EEPROM memory (if necessary), which function(s) used ?

3 - Which function used to read 8 bits in EEPROM memory ?

4 - Which function used to write 8 bits in EEPROM memory ?

5 - Which function used to erase a sector ?

6 - EEPROM memory is always 32Kb, means 32 sectors ?

Have a nice day

  • Hi 
    1. Does it modify the makefile or other to declare the eeprom memory?
    No, you do not need to modify the Makefile. Instead, you must configure your Linker Command File . You must ensure that the 32KB data flash region starting at its designated memory address is marked as reserved or designated as a specific section so that the compiler does not place executable application code or standard RAM variables there
    I will reply the other question later.
    I do not want to use example, which manage EEPROM in Type_A or Type_B
    May I know why you don't use EEPROM emulation?
    how many data you will save and how long you will update these data?
  • Hello,

    ok for Linker Command File modification, but could you tell me how to do, what write ?

    I do not want use the Type_A or B because I will have a EEPROM management, very specific, I means I have lot of structures to save, but independantly managed,, any will be redondant, other no. And the examples are not adapted.

  • 1. What to Write in your Linker Command File (.cmd)
    Open your project's .cmd file (typically found in the root directory of your Code Composer Studio project) and update both the MEMORY and SECTIONS blocks
    +++++++++++++++++++++++++++++++++++++++++++++++++++++
    MEMORY
    {
    /* Existing Main Flash and SRAM definitions (Keep these as they are) */
    FLASH (RX) : origin = 0x00000000, length = 0x00100000 /* Example 1MB Main Flash */
    SRAM (RWX) : origin = 0x20000000, length = 0x00040000 /* Example 256KB SRAM */

    /* ADD THIS LINE: Define the physical MSPM33 Data Flash region */
    DATA_FLASH (RW) : origin = 0x80000000, length = 0x00008000 /* 32KB high-endurance region */
    }

    SECTIONS
    {
    /* Existing sections like .text, .cinit, .data, etc. go here */

    /* ADD THIS BLOCK: Map your custom EEPROM section to the new memory area */
    .eeprom_section : > DATA_FLASH, type = NOLOAD
    }
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++
    • origin = 0x80000000: This points directly to the starting boundary of the physical MSPM33 Data Flash.
    • length = 0x00008000: Allocates the full 32KB area for your EEPROM variables.
    • type = NOLOAD: Directs the debugger/programmer not to overwrite or erase this block when you flash new code, preserving your saved non-volatile data.
    2. What to Write in Your C Source Code
    To link a structure or array directly into this newly isolated memory space, use the section attribute in your variable declaration:
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #include <stdint.h>

    // Define a macro for easy section assignment
    #define EEPROM_STORAGE __attribute__((section(".eeprom_section")))

    // Example structure for your application settings
    typedef struct {
    uint32_t boot_count;
    uint8_t device_mode;
    char serial_number[16];
    } AppSettings;

    // Place the structure into the dedicated Data Flash area
    volatile const AppSettings my_eeprom_data EEPROM_STORAGE;
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Notes: 
    • Flash Sector Grids: The flash erase granularity for MSPM family devices is handled in 1KB sectors. Ensure your software driver erases the exact sector boundaries within the 0x80000000 block before modifying any bytes.
    • SysConfig Generation: If your project automatically generates code via Texas Instruments SysConfig, ensure that "Linker file generation" doesn't overwrite your manual changes. If it does, disable auto-generation for the .cmd file within the SysConfig interface. refer to MSPM0G3507: Linker Command File 

    Thanks!

  • Hello,

    first question about cmd file

    You requested me to add:

    DATA_FLASH (RW) : origin = 0x80000000, length = 0x00008000 /* 32KB high-endurance region */

    but I have:

    SRAM (RWX) : origin = 0x30000000, length = 0x0003FFFF
    DATA (R) : origin = 0x80000000, length = 0x00007FFF
    BCR_CONFIG (R) : origin = 0x80101800, length = 0x000003FF
    BSL_CONFIG (R) : origin = 0x80101C00, length = 0x000003FF

    That means it will be a conflict with DATA, BCR_CONFIG and BSL_CONFIG.

    How can do because DATA and DATA_FLASH are in same place ? 

    And what to do of DATA, BCR_CONFIG and BSL_CONFIG ?

    Thanks

  • Hi 

    I will check the detailed and feedback early of next week

    Thanks

  • Hello,

    do you have news ?

    Thanks

  • There is no conflict with bcr_config and bsl_config because they are located at a higher address space (0x8010xxxx) that does not overlap with the data flash region. The region named data (r) in your original file and the requested data_flash (rw) refer to the exact same physical 32KB high-endurance flash memory on MSPM33C321A.
    How to Modify Your Linker Command (.cmd) File
    You do not need to keep both data and data_flash. Simply replace or modify the existing data region definition. MSPM0G3507: Linker Command File 
    1. Modify the data region: Rename data (r) to data_flash (rw) and ensure the length is set to 0x00008000 (full 32KB).
    2. Leave configuration regions alone: Keep bcr_config and bsl_config exactly as they are. They reside in the separate NONMAIN flash area and are required for the device to boot safely
    Updated MEMORY Directive Example
    Update the MEMORY block in your .cmd file to look like this:
    MEMORY
    {
    sram (rwx) : origin = 0x30000000, length = 0x0003ffff
    data_flash (rw) : origin = 0x80000000, length = 0x00008000 /* 32kb high-endurance region */
    bcr_config (r) : origin = 0x80101800, length = 0x000003ff
    bsl_config (r) : origin = 0x80101c00, length = 0x000003ff
    /* Include your standard FLASH/MAIN program memory regions here as well */
    }
    What to Do Next in the SECTIONS Directive
    To map your EEPROM emulation variables to this newly defined space, add a section placement inside the SECTIONS block of your file https://software-dl.ti.com/ccs/esd/documents/sdto_cgt_Linker-Command-File-Primer.html
    SECTIONS
    {
    /* Maps your EEPROM data variables to the high-endurance flash */
    .TI.eeprom : {} > data_flash
    }
    In your C code, you can then place your EEPROM emulation array into this section using compiler attributes (such as #pragma DATA_SECTION or __attribute__((section(".TI.eeprom")))).
    Thanks
  • Hello,

    thanks a lot for all these information, but I have again some questions:

    ******************************************************************************************

    Question 1 : Do you confirm, the modification are correct ?

    In device_linker.cmd file :

    Before

    MEMORY
    {
    FLASH (RX) : origin = 0x10000000, length = 0x000FFFFF
    SRAM (RWX) : origin = 0x30000000, length = 0x0003FFFF
    DATA (R) : origin = 0x80000000, length = 0x00007FFF
    BCR_CONFIG (R) : origin = 0x80101800, length = 0x000003FF
    BSL_CONFIG (R) : origin = 0x80101C00, length = 0x000003FF
    }

    SECTIONS
    {
    .intvecs: palign(16) {} > 0x10000000
    .text : palign(16) {} > FLASH
    .const : palign(16) {} > FLASH
    .cinit : palign(16) {} > FLASH
    .pinit : palign(16) {} > FLASH
    .rodata : palign(16) {} > FLASH
    .ARM.exidx : palign(16) {} > FLASH
    .init_array : palign(16) {} > FLASH
    .binit : palign(16) {} > FLASH
    .TI.ramfunc : load = FLASH, palign(16), run=SRAM, table(BINIT)

    .vtable : > SRAM
    .args : > SRAM
    .data : > SRAM
    .bss : > SRAM
    .sysmem : > SRAM
    .stack : > SRAM (HIGH)

    .BCRConfig : {} > BCR_CONFIG
    .BSLConfig : {} > BSL_CONFIG

    .DataBank : palign(16) {} > DATA

    }

    Now

    MEMORY
    {
    FLASH (RX) : origin = 0x10000000, length = 0x000FFFFF
    SRAM (RWX) : origin = 0x30000000, length = 0x0003FFFF
    /* DATA (R) : origin = 0x80000000, length = 0x00007FFF*/
    DATA_FLASH (RW) : origin = 0x80000000, length = 0x00008000 /* 32KB high-endurance region */
    BCR_CONFIG (R) : origin = 0x80101800, length = 0x000003FF
    BSL_CONFIG (R) : origin = 0x80101C00, length = 0x000003FF
    }

    SECTIONS
    {
    .intvecs: palign(16) {} > 0x10000000
    .text : palign(16) {} > FLASH
    .const : palign(16) {} > FLASH
    .cinit : palign(16) {} > FLASH
    .pinit : palign(16) {} > FLASH
    .rodata : palign(16) {} > FLASH
    .ARM.exidx : palign(16) {} > FLASH
    .init_array : palign(16) {} > FLASH
    .binit : palign(16) {} > FLASH
    .TI.ramfunc : load = FLASH, palign(16), run=SRAM, table(BINIT)
    .eeprom_section : > DATA_FLASH, type = NOLOAD                                /* <-- Add here */

    .vtable : > SRAM
    .args : > SRAM
    .data : > SRAM
    .bss : > SRAM
    .sysmem : > SRAM
    .stack : > SRAM (HIGH)

    .BCRConfig : {} > BCR_CONFIG
    .BSLConfig : {} > BSL_CONFIG

    .DataBank : palign(16) {} > DATA

    }

    ******************************************************************************************

    Question 2 : About eeprom declaration in SECTION

    first answer, you tell to add :

    .eeprom_section : > DATA_FLASH, type = NOLOAD

    and in last:

    .TI.eeprom : {} > DATA_FLASH

    So which one is the good one, and for second, that means when I will reflash the SW, this section will be reflash to ? Due to no "NOLOAD"

    ******************************************************************************************

    Question 3 : EEPROM declartion

    you tell me to declare like this:

    #pragma DATA_SECTION

     or

     __attribute__((section(".TI.eeprom"))))

    Does it declare all EEPROM, means 32Kb ?

    Or Can I declare like this:

    __attribute__ ((section(".TI.eeprom"))) uint8_t EEPROM_Memory[32768];

    Thanks

  • Hello,

    other point, now, when I compile, I have this

    [13]warning #10247-D: creating output section ".text" without a SECTIONS specification
    [14]warning #10247-D: creating output section ".data" without a SECTIONS specification
    [15]warning #10247-D: creating output section ".bss" without a SECTIONS specification
    [16]warning #10247-D: creating output section ".cinit" without a SECTIONS specification
    [17]warning #10247-D: creating output section ".rodata" without a SECTIONS specification
    [18]warning #10247-D: creating output section ".intvecs" without a SECTIONS specification
    [19]warning #10247-D: creating output section ".stack" without a SECTIONS specification
    [20]warning #10210-D: creating ".stack" section with default size of 0x800; use the -stack option to change the default size

    Thanks

  • Hi Sebastien Le Diour

    I will check the detailed later. discuss and feedback in the early of next week

    Thanks