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.

[FAQ] C2000-SAFETI-DIAGNOSTICS-LIB: F2837x/F2807x Software Diagnostic Library in EABI

Part Number: C2000-SAFETI-DIAGNOSTICS-LIB
Other Parts Discussed in Thread: C2000WARE

Tool/software:

How can I use the C2000-SAFETI-DIAGNOSTICS-LIB in an EABI project when existing .lib files are COFF ABI?

  • For now there is no If you wish to use the C2000-SAFETI-DIAGNOSTICS-LIB in an EABI project, for now you will need to take a few steps to migrate the library to EABI yourself as there is currently no officially released EABI version

    First, note that the C2000-SAFETI-DIAGNOSTICS-LIB is for F2807x and F2837x devices only. Support for F2800x, F2838x, and F28Px devices are already available for EABI in C2000Ware under the libraries/diagnostic/.

    It will also help to acquaint yourself with COFF to EABI migration in general. Please see the C2000 Migration from COFF to EABI page for details. These steps also assume you have some familiarity with C2000Ware and the structure of the SDL.

    STEP 1. At the root of the SDL directory, there is a CCS folder (e.g. \libraries\diagnostic\f2837xd\ccs) that contains a .projectspec for a static library project that can be used to rebuild the SDL .lib files. Start by importing this project into CCS and updating the project properties to set the output format to EABI.

    Note that the project has 4 different build configurations that will all need to be updated to EABI. Alternatively you can add new build configs for EABI if you want to retain the ability to build COFF libraries, although you'll want to update the archiver settings to give the output file a unique name (e.g. F2837xD_Diagnostic_STL_CPU1_DEBUG_EABI.lib)

    STEP 2. The SDL has a dependency on the Driverlib and the SFO (HRPWM calibration) libraries. You will similarly need EABI versions of these libraries. The easiest way to do this is to get them from a newer version of C2000Ware where they have already been migrated. Versions newer than C2000Ware 3.00.00 should have support for this.

    STEP 3. The majority of the changes you will need to make to port the library are related to assembly code. The migration guide mentioned above describes these update in the Assembly Code Changes section. In the .asm files in the library source folder, you will need to remove the COFF underscores from the function labels. You can either remove them outright (e.g. find _STL_CRC_calculate and replace with"STL_CRC_calculate) or use a conditional name mapping using the compiler's __TI_EABI__ predefined symbol. Here's an example of what this looks like in stl_crc_s.asm:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    .if __TI_EABI__
    .asg STL_CRC_calculate, _STL_CRC_calculate
    .asg STL_CRC_calculateLowBytes, _STL_CRC_calculateLowBytes
    .asg STL_CRC_init, _STL_CRC_init
    .asg STL_CRC_reset, _STL_CRC_reset
    .endif
    .global _STL_CRC_calculate
    .global _STL_CRC_calculateLowBytes
    .global _STL_CRC_init
    .global _STL_CRC_reset
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


    Repeat for the functions in the other .asm files, stl_hwbist_s.asm, stl_march_s.asm, etc...
            
    STEP 4. In addition to the above assembly file changes, there are a few additional changes that need to be made to the STL_HWBIST module. One is what the migration guide refers to in the Conditional Linking: Section Removal or Retention section. Since the STL_HWBIST_restoreContext function is placed at address 0x00000000 and called after a HWBIST reset rather than called by the application code, the linker may try to remove it, thinking it is unused. To prevent this, the RETAIN pragma can be used on the function in stl_hwbist.c like below:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    #ifdef __TI_EABI__
    #pragma RETAIN(STL_HWBIST_restoreContext);
    #endif
    #pragma CODE_SECTION(STL_HWBIST_restoreContext, "hwbist");
    void STL_HWBIST_restoreContext(void)
    {
    ...
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


    You will also need to make a change to the include file stl_hwbist.h to address the underscore removal performed in STEP 3. See the updated #defines below:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    #ifdef __TI_EABI__
    #define STL_HWBIST_REF_HANDLE_RESET_FXN __asm(" .ref STL_HWBIST_handleReset")
    #define STL_HWBIST_LCR_HANDLE_RESET_FXN __asm(" LCR STL_HWBIST_handleReset")
    #else
    #define STL_HWBIST_REF_HANDLE_RESET_FXN __asm(" .ref _STL_HWBIST_handleReset")
    #define STL_HWBIST_LCR_HANDLE_RESET_FXN __asm(" LCR _STL_HWBIST_handleReset")
    #endif
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


    STEP 5. You should now be able to use the library project (imported in STEP 1) to build the .lib files. Make sure you rebuild all the build configurations.

    STEP 6. You can now test out the new .lib files in an EABI project. If you are using the STA to test them, make sure you also update the STA project properties and update the linked libraries (SDL, SFO, Driverlib, etc...) to the EABI versions. You'll also need to make similar updates to the linker command files to remove underscores (e.g. _HwbistLoadStart -> HwbistLoadStart) and change section names as described in the EABI migration guide (e.g. .econst -> .const).

    For the STL_SP module, note that there are some changes in how the stack-related symbols are named. Here's an example of how to correct it in the STA projects sta_tests.c file:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    #ifndef __TI_EABI__
    STA_User_spObj.startAddress = (uint32_t)_symval(&_stack);
    STA_User_spObj.endAddress = (uint32_t)_symval(&_STACK_END);
    #else
    STA_User_spObj.startAddress = (uint32_t)_symval(&__stack);
    STA_User_spObj.endAddress = (uint32_t)_symval(&__TI_STACK_END);
    #endif
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX