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.

TMS320F28377D: Running library functions from RAM

Part Number: TMS320F28377D
Other Parts Discussed in Thread: C2000WARE

Hello,

I am trying to use the Flash API to program the flash over CAN. I can get to the point where it starts erasing Flash and then it erases some code that it needs. I suspect it is some of the function calls in the library. Here is a clip from the memory map.

MODULE SUMMARY

       Module                                 code    initialized data   uninitialized data
       ------                                       ----    ----------------   ------------------

    C:/ti/C2000Ware_3_04_00_00_Software/libraries/flash_api/f2837xd/lib/F021_API_F2837xD_FPU32.lib
       FlashStateMachine.obj            727     0                  0                 
       Program.obj                            413     0                  0                 
       Utilities.obj                               114     0                  0                 
       Init.obj                                       52      0                  12                
       Async.obj                                  32      0                  0                 
    +--+--------------------------------+-------+------------------+--------------------+
       Total:                           1338    0                  12  

Although I can't seem to find where these are called. Nevertheless, the linker obviously thinks they are needed.

I've tried a couple of different approaches to get these to load into RAM without any success. I've been through spra958l, spraau8a, and spru513v and not sure I've found a way to put these functions in RAM (I'm probably missing something)

So I have basically 2 questions. The first is do you think these library functions should be in RAM? and second, if so, how would one do that?

            Thanks

                    Dave

  • Dave,

    On this device, flash API functions should be executed from RAM only.

    If you are embedding the flash API in your application, you need to map it to flash for load and RAM for execution (in your linker cmd file).  And then call memcpy() in your application to copy the flash API to RAM - memcpy() should be called before calling any flash API function. 

    Please note a few things to check:

    1) Make sure to not erase the flash API located in the flash.

    2) Please search for "What are the common debug tips that we can consider when Flash API fails to erase or program?" in the flash API usage wiki (https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/951668).

    3) As mentioned in the flash API guide (https://www.ti.com/lit/ug/spnu629a/spnu629a.pdf), flash API execution is interruptible; however, there should not be any read or fetch access from the Flash bank/OTP when an erase or program operation is in progress. Therefore, the Flash API functions, the user application functions that call the Flash API functions, and any ISRs (Interrupt service routines,) must be executed from RAM. For example, the entire code snippet shown below should be executed from RAM and not just the Flash API functions. The reason for this is because the Fapi_issueAsyncCommandWithAddress() function issues the erase command to the FSM, but it does not wait until the erase operation is over. As long as the FSM is busy with the current operation, there should not be a Flash access.

    4) Please take a look at the flash API usage example from C2000Ware (C2000Ware_3_04_00_00\device_support\f2837xd\examples\dual\flash_programming).

    Checkout the linker cmd file used for this example (C2000Ware_3_04_00_00\device_support\f2837xd\examples\dual\flash_programming\cpu01\flash_programming_cpu1_FLASH.cmd).  This shows flash API mapping to flash for load and RAM for execution.

    Below FAQs may help you:

    1. [FAQ] FAQ on Flash API usage for C2000 devices: 

         https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/951668 

    2. [FAQ] FAQ for Flash ECC usage in C2000 devices - Includes ECC test mode, Linker ECC options: 

         https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/951658 

    3.  [FAQ] Flash - How to modify an application from RAM configuration to Flash configuration?: 

         https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/878674 

    Thanks and regards,
    Vamsi

  • Thanks for the quick reply Vamsi, I will look this over an hopefully the solution is in there.

              Dave

  • David,

    Sure, I will keep this thread in pause until you come back with your update.

    Thanks and regards,

    Vamsi

  • Vamsi,

    There is a lot there, this is quite complicated. Let's start with something simple.

    When I tried putting one of the Flash API functions in TI.ramfunc, the compiler doesn't like it. I'm not sure what the proper variables are. From what I understand, putting a function in TI.ramfunc transfers the code to RAM during boot and then modifies the entry code point, so there is no need for the memcopy() in the main code ?

    For example

    //  To Be Run From RAM
    #pragma SET_CODE_SECTION(".TI.ramfunc")

        Uint32  Fapi_initializeAPI(Uint32,Uint32);

    #pragma SET_CODE_SECTION()

    gets this error

    "..\PCKA\138_098_Def-Var.h", line 93: error #148: declaration is incompatible with "Fapi_StatusType Fapi_initializeAPI(Fapi_FmcRegistersType *, uint32)" (declared at line 66 of "C:\ti\C2000Ware_3_04_00_00_Software\libraries\flash_api\f2837xd\include\F021.h")

    Is this the correct direction, and if so, how would I find out how to properly put the function call in TI.ramfunc ?

            Thanks again for your time,

                     Dave

  • Vamsi,

    Another question I'm not sure the answer to. I've been putting my TI.ramfunc declarations in a *.h file. This seems to work fine, but I see other code that puts it in a *.c file. Is there a difference that could be causing some problems?

               Thanks

                       Dave

  • Dave,

    Regarding the error that you mentioned:  I think it is not complaining about the usage of .TI.ramfunc.  It is saying that the return type and the variable type of the parameters used for Fapi_initializeAPI() are incorrect.  Take a look at the variable types used for this function.

    Let us start from simple steps:  Are you able to successfully execute the flash programming example from C2000Ware (C2000Ware_3_04_00_00\device_support\f2837xd\examples\dual\flash_programming)?  If yes, did you go through the entire example and the associated linker command file?

    Thanks and regards,
    Vamsi

  • David,

    Regarding *.h vs *.c files:  It should be fine.  As long as you have extern defined where necessary and you don't get compiler errors/warnings for the functions, it should be fine.  

    Thanks and regards,
    Vamsi

  • David, 

    Do you have any update on this?  Can I consider this as closed?

    Please let me know if you need further help.

    Thanks and regards,
    Vamsi

  • Thanks Vamsi,

    I got pulled off to another project, but you have given me a lot of good information. We can consider this closed and I can open another one if I have further questions.

               Best Regards

                      Dave

  • Dave,

    Thank you for the note.  I will close this for now.

    Best regards,
    Vamsi