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.

CCS/RM46L852: jump to prefetchEntry when used Fapi_issueProgrammingCommand

Part Number: RM46L852
Other Parts Discussed in Thread: LAUNCHXL2-RM46, HALCOGEN

Tool/software: Code Composer Studio

Dear team,

My customer uses RM46L852 and has some questions. Please help me to test the code because i do not have the RM46L852 board. 

The code will jump to prefetchEntry when it runs to Fapi_issueProgrammingCommand when using f021 flash api to program flash.

Thanks!

2313.FLASH_TEST (1).rar

  • I forgot to enable flash ecc in HCG before. After enabling it, I found that the flash can be written. But it still jumps to prefetchEntry. The state in FLASH is strange, as shown in the figure, some addresses cannot be loaded, and the LR register is always 0x00000010. So now I can’t locate the error. Please help.

  • Susan Yang said:
    The code will jump to prefetchEntry when it runs to Fapi_issueProgrammingCommand when using f021 flash api to program flash.

    I loaded the FLASH_TEST/Debug/FLASH_TEST.out from the attachment (i.e. didn't recompile) into a LAUNCHXL2-RM46. Debugging found that:

    1. When assembler step through the Fapi_issueProgrammingCommand() call then no abort happens, the flash at address 0xE0000 is programmed with 0x11233212, and Fapi_issueProgrammingCommand() returns Fapi_Status_Success.
    2. When attempt to step over the Fapi_issueProgrammingCommand() call then get a prefetch abort and the flash at address 0xE0000 is programmed with 0x11233212. CP15_INSTRUCTION_FAULT_STATUS is 0x00000409, which from Fault Status and Address Registers means "Synchronous Parity or ECC Error". The CP15_INSTRUCTION_FAULT_ADDRESS is 0x0000000C which is the address of prefetchEntry.

    Not yet sure what the cause is.

  • I noticed that HALCoGen for the project sets HCLK to 220MHz, but the main function passed 160 to Fapi_initializeFlashBanks:

        uint8_t Freq_In_MHz = 160;
    
     //   _enable_IRQ();
    
        a = Fapi_initializeFlashBanks(Freq_In_MHz); /* used for API Rev2.01 */
    

    Correcting Freq_In_MHz to 220 didn't change the behavior.

  • Hi Susan,

    Fapi_UserDefinedFunctions.obj should be copied to RAM too

    Please change the section flashAPI in Linker Cmd file to:

    flashAPI :
    {
            Fapi_UserDefinedFunctions.obj (.text)
            --library= F021_API_CortexR4_BE.lib (.text)
    } load = FLASH_API, run = SRAM, LOAD_START(api_load), RUN_START(api_run), SIZE(api_size)

  • QJ Wang said:
    Fapi_UserDefinedFunctions.obj should be copied to RAM too

    Looking at the project attached by Susan I can't see a Fapi_UserDefinedFunctions.obj being linked as part of project.

    Does the absence of the Fapi_serviceWatchdogTimer() function in the project explain the failure?

  • thank you for your reply,but the Fapi_UserDefinedFunctions.obj Has been included in the cmd file

  • thank you for your reply,the Fapi_UserDefinedFunctions has be included in the lib of F021_API_CortexR4_LE.lib and it has be included for Image ,if i change the flashAPI , The program will report an error:cannot find file "Fapi_UserDefinedFunctions.obj and no matching section

  • sorry i find the Fapi_UserDefinedFunctions has not be included in the lib of F021_API_CortexR4_LE.lib,i make Fapi_UserDefinedFunctions.c in project ,but An error will be reported when linking:warning #10068-D: no matching section ,and the symbol  Fapi_UserDefinedFunctions not in  the .map file

  • sorry i find the Fapi_UserDefinedFunctions has not be included in the lib of F021_API_CortexR4_LE.lib,i make Fapi_UserDefinedFunctions.c in project ,but An error will be reported when linking:warning #10068-D: no matching section ,and the symbol  Fapi_UserDefinedFunctions not in  the .map file6138.FLASH_TEST (1).rar

  • Hello Chester,

    The Fapi_serviceWatchdogTimer() function is called by read functions (API) only. Fapi_issueProgrammingCommand() doesn't call this this function, so the prefetch abort is not caused by absent of Fapi_serviceWatchdogTimer() function.

  • Hello Susan,

    The address you are going to program to is located in Bank 0, so you have to execute all flash API related code from SRAM.

    Fapi_UserDefinedFunctions.c is not part of the Flash API library. Your linker cmd file doesn't allocate this function to RAM.

    Since the Flash APIs are called in main() function, main() should be executed from SRAM too.

  • Since the Flash APIs are called in main() function, main() should be executed from SRAM too.

    I modified the project to place main in RAM by modifying sys_link.cmd, which prevented the project from causing an abort:

       flashAPI :
       {
         sys_main.obj(.text)
    

    However, the F021 Flash API Version 2.01.01 Reference Guide SPNU501G doesn't seem to document the restriction that user functions which call the flash API need to be in RAM.

    The using API section has:

    The description of Fapi_issueProgrammingCommand() has the following:

    I.e. the description of Fapi_issueProgrammingCommand() suggests that calling a flash API function from a function in flash could result in the CPU stalling when the flash API function in RAM attempts to return to the calling function in flash, rather than causing an abort.

  • Let me check, then come back

  • Hello Susan,

    I modified the linker cmd file as below. It works without prefetch abort.

    main() calls Flash APIs. When flash state machine is performing the program operation, the CPU runs the code in flash to checking the state machine status, which may cause problem.