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.

Data placement at an absolute location in Code Composer

Other Parts Discussed in Thread: MSP430I2040

I'm migrating a project from from IAR EW430 6.10 to Code Composer 6. Things have gone very smoothly, but I've run into a problem. In my code I force the version number of the firmware into a specific set of addresses in the loadable image. The address is the same for all firmware in our product line. This allows the host to check the version number of it's most recent image and compare this to the version located on a device in the field. I had this working with the IAR compiler, but I don't seem to be able to do this with CCS. I've defined the addresses in the linker command file successfully, but in order to place the version number in those addresses the code has to run. Is there a way to force a value defined in an include file (version.h - #define MAJOR 1 #define MINOR 2) into the code image? Thanks.

  • Hi Lee,

    I would try the #pragma DATA_SECTION(version, ".mysect"), where version is the constant you have defined for the version number, and .mysect is the section you created in the bottom of your linker command file (under SECTIONS), which in turn is assigned to the addresses you defined in the top of your linker file (under MEMORY).  You can see the MSP430 TI compiler guide for more information: http://www.ti.com/lit/pdf/slau132, especially section 5.15.2 and section 5.11.7. You should be able to see in the map file that this gets placed in non-volatile memory, and I think if you check your generated binary file you'll also see it included so it will get loaded with the code instead of having to have code run.

    Regards,
    Katie

  • Hi Katie,

    I've tried a wide number of variations today and so far I haven't been able to put the version number values into the binary image. I'm looking at a couple of options.

    First, according to the C/C++ compiler users guide (SLAU132J) CCS now supports #pragma LOCATION, similar to IAR. I tried the following code, which worked (using IARs format) in IAR:

    #pragma LOCATION(ver_major,0xFBCA) // CCS syntax
    const unsigned char ver_major = 0x77;

    #pragma LOCATION(ver_minor,0xFBCB)
    const unsigned char ver_minor = FIRMWARE_VERSION_MINOR;

    temp = ver_major; // Force version into binary image
    temp = ver_minor;

    I also tried using

    This didn't seem to work. I'd rather use this than change the linker command file.

    I also tried changing the linker command file as follows:

    FLASH : origin = 0xC000, length = 0x3FD0
    VER_MAJOR : origin = 0xFFD0, length = 0x0001
    VER_MINOR : origin = 0xFFD1, length = 0x0001
    INT00 : origin = 0xFFE0, length = 0x0002


    .ver_major : {} > VER_MAJOR
    .ver_minor : {} > VER_MINOR

    Along with the above pragmas, again with no success.

    Any suggestions would be appreciated. Thanks.

    Lee
  • Sorry, I did also try the #pragma DATA_SECTION with to results as well.
  • Hi Lee,

    Thanks for the reply about what you tried. When it didn't work, did you get some compilation/linker error, or was it just that the values did not show up at the addresses in flash?

    One thing to note is that if the code does not use/reference the constant, it could get optimized out. To prevent this you can use #pragma RETAIN(symbol).

    Here's one that I tried out on i2040 (I am assuming this is the part you use based on previous posts):

    #pragma LOCATION(ver_major, 0xFFD0)
    #pragma RETAIN(ver_major)
    const unsigned char ver_major = 0xAB;
    
    #pragma LOCATION(ver_minor, 0xFFD1)
    #pragma RETAIN(ver_minor)
    const unsigned char ver_minor = 0xCD;

    When I did this, I can see that the version data is properly programmed into the device at the expected addresses, even if my code never references it (and with LOCATION as you mentioned, no linker modification required). I hope this helps to meet your needs.

    You probably already know this, but one important note on MSP430i2040 is that you need to be careful not to overwrite the addresses at 0xFFDC-F because these are used on this part as the JTAG signature. If these addresses have anything in them besides 0x00000000 or 0xFFFFFFFF, then you will get locked out of your part and not be able to get back in (there is no BSL on this part so no getting access that way). Just a reminder since 0xFFD0 is close to that area, and I've seen people miss this before and basically brick their part.

    Regards,

    Katie

  • Hi Katie,

    I'm currently working with the G2553, but this will also be used on the I2041 and others. It looks like everything is where it's supposed to be. The address will be moved for other reasons, but I'll keep your point in mind. thanks for all of your help.

    Regards,

    Lee

**Attention** This is a public forum