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.
Tool/software: Code Composer Studio
Hi,
I am using 28377's F021 flash API function. Now I can earse the .cinit section and update it with function Fapi_issueProgrammingCommand. However, when comes to .text section, after erasing it, the pragram jumps to unknown place. And it says "no source availiable in 0x3fe00a".
Now all the function is runs in RAM through CODESECTION(****, "ramfuncs"). And if I do not erase the old program, every thing runs nomally. The attachment is my map file. Thank you.RAM_management_cpu02.zip
Best Regards!
Yanpo, Li
Besides, I have disabled interrupt before erase operation with DINT.
And as to #programa CODE_SECTION,when I copy all the function from flash to RAM, I find there is still some bytes left in flash. Does this matters or not?
Or should I use the sectioncopy rather function copy?
Yanpo,
0x3FE00A is ITRAP ISR in BootROM as per Table 3-14. Wait Point Addresses for CPU2 in TRM (http://www.ti.com/lit/ug/spruhm8f/spruhm8f.pdf).
That tells that CPU executed an illegal opcode. You may not have moved your application completely to RAM and there are still some accesses to Flash I guess. Check all the code that exists in your .text section in map file and make sure your application is not trying to access them after they are erased in Flash. You can do step execution to figure which exact function is causing this behavior.
Regarding your question on copying flash contents to RAM: When you use memcpy() to copy the contents from Flash to RAM, Flash does not get erased. You need to use API to erase the Flash - memcopy does not do that.
Thanks and regards,
Vamsi
Hi Vamsi,
I check the map file. And I find the rts2800-fpu32.lib CPU timer function and sysCtrl still in flash. I do not know whether this matters. And yes, I use API to erase.
.text 0 0008d570 00000b23
0008d570 00000585 F2837xD_DefaultISR.obj (.text:retain)
0008daf5 0000021a F2837xD_SysCtrl.obj (.text)
0008dd0f 000001d7 rts2800_fpu32.lib : memory.obj (.text)
0008dee6 0000007d F2837xD_CpuTimers.obj (.text)
0008df63 00000046 rts2800_fpu32.lib : boot.obj (.text)
0008dfa9 00000028 F2837xD_PieCtrl.obj (.text)
0008dfd1 00000025 F2837xD_PieVect.obj (.text)
0008dff6 00000021 rts2800_fpu32.lib : memcpy_ff.obj (.text)
0008e017 00000019 : args_main.obj (.text)
0008e030 00000019 : exit.obj (.text)
0008e049 00000018 : ll_aox.obj (.text)
0008e061 00000012 ecatappl.obj (.text)
0008e073 0000000b rts2800_fpu32.lib : u_div.obj (.text)
0008e07e 00000009 : _lock.obj (.text)
0008e087 00000008 : strlen.obj (.text)
Beisdes, I think the configuration of cmd files also matters a lot. Do you think put the text part in RAMGS** part is better or in the local RAM is better? Now my configuration is put text in RAMGS8_12, and others is as the following.
.stack : > RAMM1 ,PAGE = 1
.ebss : >> RAMLS345|RAMD0D1, PAGE = 1
.esysmem : > RAMD0D1 PAGE = 1
.sysmem : > RAMGS13_14 PAGE = 1
Thank you.
Best Regards!
Yanpo, Li
Hi Vamsi,
I tried setp execution. When the program goes to while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}, it falls into "no source available." But I have add F021 flash API.lib into ramfuncs. I do not know why. The following is my map file.
0008be0a 00000259 F021_API_F2837xD_FPU32.lib : FlashStateMachine.obj (.text:__Fapi_setupFlashStateMachine)
0008c063 0000019d : Program.obj (.text:_Fapi_issueProgrammingCommand)
0008c200 000000ad : Read.obj (.text:_Fapi_doMarginRead)
0008c2ad 00000088 : Read.obj (.text:__Fapi_loopRegionForValue)
0008c335 0000007f : Read.obj (.text:__Fapi_checkRegionForValue)
0008c3b4 00000042 : BlankCheck.obj (.text:_Fapi_doBlankCheck)
0008c3f6 00000034 : Init.obj (.text:_Fapi_initializeAPI)
0008c42a 0000002e : Utilities.obj (.text:_Fapi_calculateFletcherChecksum)
0008c458 0000002d : FlashStateMachine.obj (.text:__Fapi_issueFsmCommand)
0008c485 0000002c : Utilities.obj (.text:__Fapi_divideUnsignedLong)
0008c4b1 00000025 : FlashStateMachine.obj (.text:_Fapi_setActiveFlashBank)
0008c4d6 00000022 : FlashStateMachine.obj (.text:_Fapi_isAddressEcc)
0008c4f8 00000022 : FlashStateMachine.obj (.text:__Fapi_setupSectorsForWrite)
0008c51a 00000020 : Async.obj (.text:_Fapi_issueAsyncCommandWithAddress)
0008c53a 0000001a : Utilities.obj (.text:_Fapi_waitDelay)
0008c554 00000016 : Read.obj (.text:_Fapi_flushPipeline)
0008c56a 0000000f : Verify.obj (.text:_Fapi_doVerify)
0008c579 0000000d : Utilities.obj (.text:__Fapi_scaleCycleValues)
0008c586 0000000c : Init.obj (.ebss) [fill = 0]
0008c592 0000000b : Utilities.obj (.text:__Fapi_calculateOtpChecksum)
0008c59d 0000000a : FlashStateMachine.obj (.text:_Fapi_checkFsmForReady)
0008c5a7 00000006 : FlashStateMachine.obj (.text:_Fapi_getFsmStatus)
In fact the detail is if I add a breakpoint in Fapi_checkFsmForReady() then step by step, then it falls into "no source available". And if I do not intert any breakpoint, then the program falls into free(void *userptr) from file memory.c. Does this because memory.c still lies in flash not in RAM? If so, how to move it to ramfuncs?
Besids, I do not know why I can not add InitSysCtrl() into ramfuncs through CODESECTION. in fact it is included in my Hw_init() function. All this function did is to initialize the hardware related parameters. When I add Hw_init in ramfuncs, even when I just finished download the new program in debug mode. It falls into "no source available".
Best regards,
Yanpo,Li
Hi Vamsi,
What I want is to update the program through ethernet(Ethercat FOE), like a bootloader. So first I need to erase the old sector, then write into the new program. And I have finished the program update program in 28069. But in 28069 I first use section copy to copy all the .text section to RAM. As to28377, when I also use "DSP28xxx_SectionCopy_nonBIOS.asm" and "DSP280x_CodeStartBranch.asm" to chieve section copy. I failed. After download program in debug mode( in CPU02, for CPU1 is for other control program), the project falls into no sourcee available derectly. I am not sure whether there is something wrong.
As to step execution Flash API function, in fact, I just use "step over" not "step into" . And even in CCS's example project "flash_programming_CPU02" , when I change the erase sector from sector C to sector D (.text loacates here). when comes to "Fapi_doBlankCheck", it also says "no source available". So I wonder whether use "#program CODE_SECTION(***, "ramfuncs") " is Ok for program update. Or shall I use sectioncopy replace it? If so, how to do? Thank you.
Best regards,
Yanpo, Li
Yanpo,
What I want is to update the program through ethernet(Ethercat FOE), like a bootloader. So first I need to erase the old sector, then write into the new program. And I have finished the program update program in 28069. But in 28069 I first use section copy to copy all the .text section to RAM. As to28377, when I also use "DSP28xxx_SectionCopy_nonBIOS.asm" and "DSP280x_CodeStartBranch.asm" to chieve section copy. I failed. After download program in debug mode( in CPU02, for CPU1 is for other control program), the project falls into no sourcee available derectly. I am not sure whether there is something wrong.
When you used the section copy method for F28377D, did you
(i) make sure to modify the linker command file to have flash load address and RAM run address for the sections that you want "DSP28xxx_SectionCopy_nonBIOS.asm" to copy to RAM? OR Are you using the default linker command files that TI provided?
(ii) make sure to match the names of the symbols that you use in the linker command file (for load address, run address and size) match that of the "DSP28xxx_SectionCopy_nonBIOS.asm"?
(iii) make sure that any of the user defined text sections that have different load (flash) and run (RAM) addresses are added to "DSP28xxx_SectionCopy_nonBIOS.asm" so that they get copied correctly since you may have removed memcpy()?
(iv) make sure to replace any .sect “ramfuncs” (or .sect ".TI.ramfunc") in any of the asm files to .sect “text” so that "DSP28xxx_SectionCopy_nonBIOS.asm" can copy those sections as part of .text section?
(v) make sure to remove any #pragma CODE_SECTION(xx, “ramfuncs”) (or #pragma CODE_SECTION(xx, “.TI.ramfunc”)) so that they get mapped to .text section?
(vi) make sure to remove memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize) since the code gets copied by "DSP28xxx_SectionCopy_nonBIOS.asm" even before reaching _c_int00?
(vii) make sure that there is enough RAM space to copy all of your application to RAM from Flash?
(viii) Also, check this post where Tim Love provided an updated (with bug fixes) "DSP28xxx_SectionCopy_nonBIOS.asm" file: http://e2e.ti.com/support/microcontrollers/c2000/f/171/t/21164#pi316717=2. I am not sure whether Tim Love updated the package released with SPRAAU8 document to reflect this latest file that he posted on the forum. I will check with him offline on that.
As to step execution Flash API function, in fact, I just use "step over" not "step into" . And even in CCS's example project "flash_programming_CPU02" , when I change the erase sector from sector C to sector D (.text loacates here). when comes to "Fapi_doBlankCheck", it also says "no source available". So I wonder whether use "#program CODE_SECTION(***, "ramfuncs") " is Ok for program update. Or shall I use sectioncopy replace it? If so, how to do? Thank you.
Coming to the flash_programming project in TI Controlsuite or C2000Ware: I don't erase sector D since .text is mapped there. However, to explain it in your case, I commented out the "ReleaseFlashPump()" function in Example_CallFlashAPI() and I was able to successfully execute the entire example even when I replaced the Sector C erase code with Sector D erase code. Note that I commented out the ReleaseFlashPump() function since it is mapped to .text section and gets erased when Sector D is erased. Alternatively I could map it to ramfuncs if I don't want to comment it out - it should work that way as well. You might have noticed that the Example_CallFlashAPI() itself is copied to RAM. You can try attached code if you want. Make sure to use the latest C2000Ware examples.
//########################################################################### // // FILE: flash_programming_cpu01.c // // TITLE: Flash Programming Example for F2837xD. // //! \addtogroup dual_example_list //! <h1> Flash Programming </h1> //! //! This example demonstrates F021 Flash API usage. //! // //########################################################################### // $TI Release: F2837xD Support Library v3.01.00.00 $ // $Release Date: Mon May 22 15:43:40 CDT 2017 $ // $Copyright: // Copyright (C) 2013-2017 Texas Instruments Incorporated - http://www.ti.com/ // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the // distribution. // // Neither the name of Texas Instruments Incorporated nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // $ //########################################################################### // // Included Files // #include "F28x_Project.h" #include <string.h> #include "flash_programming_c28.h" // Flash API example header file #include "F021_F2837xD_C28x.h" // // Defines // #define WORDS_IN_FLASH_BUFFER 0xFF // Data/Program Buffer used for testing // the flash API functions #ifdef __TI_COMPILER_VERSION__ #if __TI_COMPILER_VERSION__ >= 15009000 #define ramFuncSection ".TI.ramfunc" #else #define ramFuncSection "ramfuncs" #endif #endif // // Globals // #pragma DATA_SECTION(Buffer,"BufferDataSection"); uint16 Buffer[WORDS_IN_FLASH_BUFFER + 1]; uint32 *Buffer32 = (uint32 *)Buffer; // // Function Prototypes // void Example_Error(Fapi_StatusType status); void Example_Done(void); void Example_CallFlashAPI(void); // // Main // void main(void) { // // Step 1. Initialize System Control: // Enable Peripheral Clocks // This example function is found in the F2837xD_SysCtrl.c file. // InitSysCtrl(); // // Unlock CSM // // If the API functions are going to run in unsecured RAM // then the CSM must be unlocked in order for the flash // API functions to access the flash. // If the flash API functions are executed from secure memory // then this step is not required. // //DcsmZ1Unlock(); // // Step 2. Initialize GPIO: // This example function is found in the F2837xD_Gpio.c file and // illustrates how to set the GPIO to it's default state. // // InitGpio(); // Skipped for this example // // Step 3. Clear all interrupts and initialize PIE vector table: // Disable CPU interrupts // DINT; // // Initialize the PIE control registers to their default state. // The default state is all PIE interrupts disabled and flags // are cleared. // This function is found in the F2837xD_PieCtrl.c file. // InitPieCtrl(); // // Disable CPU interrupts and clear all CPU interrupt flags: // IER = 0x0000; IFR = 0x0000; // // Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR). // This will populate the entire table, even if the interrupt // is not used in this example. This is useful for debug purposes. // The shell ISR routines are found in DSP2802x_DefaultIsr.c. // This function is found in F2837xD_PieVect.c. // InitPieVectTable(); // // Copy time critical code and Flash setup code to RAM // This includes InitFlash(), Flash API functions and any functions that are // assigned to ramfuncs section. // The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart // symbols are created by the linker. Refer to the device .cmd file. // //memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize); // // Call Flash Initialization to setup flash waitstates // This function must reside in RAM // InitFlash(); // // Gain pump semaphore // SeizeFlashPump(); // // Jump to RAM and call the Flash API functions // Example_CallFlashAPI(); } // // Example_CallFlashAPI - This function will interface to the flash API. // Flash API functions used in this function are // executed from RAM // #pragma CODE_SECTION(Example_CallFlashAPI, ramFuncSection); void Example_CallFlashAPI(void) { uint32 u32Index = 0; uint16 i = 0; Fapi_StatusType oReturnCheck; volatile Fapi_FlashStatusType oFlashStatus; Fapi_FlashStatusWordType oFlashStatusWord; EALLOW; // // This function is required to initialize the Flash API based on System // frequency before any other Flash API operation can be performed // oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 200); if(oReturnCheck != Fapi_Status_Success) { // // Check Flash API documentation for possible errors // Example_Error(oReturnCheck); } // // Fapi_setActiveFlashBank function sets the Flash bank and FMC for further // Flash operations to be performed on the bank // oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0); if(oReturnCheck != Fapi_Status_Success) { // // Check Flash API documentation for possible errors // Example_Error(oReturnCheck); } // // Erase Sector C // oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32 *)Bzero_SectorD_start); // // Wait until FSM is done with erase sector operation // while(Fapi_checkFsmForReady() != Fapi_Status_FsmReady){} // // Verify that SectorL is erased. The Erase step itself does a // verify as it goes. This verify is a 2nd verification that can be done. // oReturnCheck = Fapi_doBlankCheck((uint32 *)Bzero_SectorD_start, Bzero_16KSector_u32length, &oFlashStatusWord); if(oReturnCheck != Fapi_Status_Success) { // // Check Flash API documentation for possible errors // If Erase command fails, use Fapi_getFsmStatus() function to get the // FMSTAT register contents to see if any of the EV bit, ESUSP bit, // CSTAT bit or VOLTSTAT bit is set (Refer to API documentation for // more details) // Example_Error(oReturnCheck); } // // Erase Sector B // oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32 *)Bzero_SectorB_start); // // Wait until FSM is done with erase sector operation // while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){} // // Verify that SectorB is erased. The Erase step itself does a verify as // it goes. This verify is a 2nd verification that can be done. // oReturnCheck = Fapi_doBlankCheck((uint32 *)Bzero_SectorB_start, Bzero_16KSector_u32length, &oFlashStatusWord); if(oReturnCheck != Fapi_Status_Success) { // // Check Flash API documentation for possible errors // If Erase command fails, use Fapi_getFsmStatus() function // to get the FMSTAT register contents // to see if any of the EV bit, ESUSP bit, CSTAT bit or VOLTSTAT // bit is set (Refer to API documentation for more details) // Example_Error(oReturnCheck); } // // A data buffer of max 8 words can be supplied to the program function. // Each word is programmed until the whole buffer is programmed or a // problem is found. However to program a buffer that has more than 8 // words, program function can be called in a loop to program 8 words for // each loop iteration until the whole buffer is programmed // // Example: Program 0xFF bytes in Flash Sector C along with auto- // generated ECC // // // In this case just fill a buffer with data to program into the flash. // for(i=0; i <= WORDS_IN_FLASH_BUFFER; i++) { Buffer[i] = i; } for(i=0, u32Index = Bzero_SectorC_start; (u32Index < (Bzero_SectorC_start + WORDS_IN_FLASH_BUFFER)) && (oReturnCheck == Fapi_Status_Success); i+= 8, u32Index+= 8) { oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index,Buffer+i, 8, 0, 0, Fapi_AutoEccGeneration); while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy); if(oReturnCheck != Fapi_Status_Success) { // // Check Flash API documentation for possible errors // Example_Error(oReturnCheck); } // // Read FMSTAT register contents to know the status of FSM after // program command for any debug // oFlashStatus = Fapi_getFsmStatus(); // // Verify the values programmed. The Program step itself does a verify // as it goes. This verify is a 2nd verification that can be done. // oReturnCheck = Fapi_doVerify((uint32 *)u32Index, 4, Buffer32+(i/2), &oFlashStatusWord); if(oReturnCheck != Fapi_Status_Success) { // // Check Flash API documentation for possible errors // Example_Error(oReturnCheck); } } // // Example: Program 0xFF bytes in Flash Sector B with out ECC // Disable ECC so that error is not generated when reading Flash contents // without ECC // Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0x0; for(i=0, u32Index = Bzero_SectorB_start; (u32Index < (Bzero_SectorB_start + WORDS_IN_FLASH_BUFFER)) && (oReturnCheck == Fapi_Status_Success); i+= 8, u32Index+= 8) { oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index, Buffer+i, 8, 0, 0, Fapi_DataOnly); while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy); if(oReturnCheck != Fapi_Status_Success) { // // Check Flash API documentation for possible errors // Example_Error(oReturnCheck); } // // Read FMSTAT register contents to know the status of FSM // after program command for any debug // oFlashStatus = Fapi_getFsmStatus(); // // Verify the values programmed. The Program step itself does a verify // as it goes. This verify is a 2nd verification that can be done. // oReturnCheck = Fapi_doVerify((uint32 *)u32Index, 4, Buffer32+(i/2), &oFlashStatusWord); if(oReturnCheck != Fapi_Status_Success) { // // Check Flash API documentation for possible errors // Example_Error(oReturnCheck); } } // // Erase the sectors that we have programmed above // Erase Sector C // oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32 *)Bzero_SectorC_start); // // Wait until FSM is done with erase sector operation // while(Fapi_checkFsmForReady() != Fapi_Status_FsmReady){} // // Verify that SectorC is erased. The Erase step itself does a verify as // it goes. // This verify is a 2nd verification that can be done. // oReturnCheck = Fapi_doBlankCheck((uint32 *)Bzero_SectorC_start, Bzero_16KSector_u32length, &oFlashStatusWord); if(oReturnCheck != Fapi_Status_Success) { // // Check Flash API documentation for possible errors // If Erase command fails, use Fapi_getFsmStatus() function to get the // FMSTAT register contents // to see if any of the EV bit, ESUSP bit, CSTAT bit or VOLTSTAT bit is // set (Refer to API documentation for more details) // Example_Error(oReturnCheck); } // // Erase Sector B // oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32 *)Bzero_SectorB_start); // // Wait until FSM is done with erase sector operation // while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){} // // Verify that SectorB is erased. The Erase step itself does a verify // as it goes. This verify is a 2nd verification that can be done. // oReturnCheck = Fapi_doBlankCheck((uint32 *)Bzero_SectorB_start, Bzero_16KSector_u32length, &oFlashStatusWord); if(oReturnCheck != Fapi_Status_Success) { // // Check Flash API documentation for possible errors // If Erase command fails, use Fapi_getFsmStatus() function to get // the FMSTAT register contents to see if any of the EV bit, ESUSP bit, // CSTAT bit or VOLTSTAT bit is set (Refer to API documentation // for more details) // Example_Error(oReturnCheck); } // // Enable ECC // Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0xA; EDIS; // // Leave control over flash pump // //ReleaseFlashPump(); // // Example is done here // Example_Done(); } // // Example_Error - For this example, if an error is found just stop here // #pragma CODE_SECTION(Example_Error,ramFuncSection); void Example_Error(Fapi_StatusType status) { // // Error code will be in the status parameter // __asm(" ESTOP0"); } // // Example_Done - For this example, once we are done just stop here // #pragma CODE_SECTION(Example_Done,ramFuncSection); void Example_Done(void) { __asm(" ESTOP0"); } // // End of file //
On your question regarding ramfuncs vs section-copy usage: It depends on your application. From what you are saying, I don't think you plan to keep your application alive when you do the firmware upgrade on the Flash. If that is the case, allocating your firmware updater code to ramfuncs should be fine to execute it from RAM when needed. As I mentioned earlier, you need to figure out the code that your application is trying to fetch/execute from Flash after it is erased.
Thanks and regards,
Vamsi
Hi Vamsi,
I tried to still use ramfuncs rather sectioncopy. However, when I copy all the function into ramfuncs, if i do not do the erase operation everything is nomal. If I do the erase operation, even erase the econst section failed. That means when i erase the econst section, the Fapi_doBlankCheck tell me fail. And if I check the memory, the data is still there. And when I click run or step over after jump to mainloop it fail to function free(). I do not know why. the attachment is my cmd file. Thank you.
Best regards,
Yanpo, Li
Hi Vamsi,
I find the reason why i can not erase any section. For I should add function " SeizeFlashPump()" before "Fapi_initializeAPI". Now I can erase all section. But after I erase .text section, it still fall into no source available. I have closed the interrupt , copied all related function to ramfuncs and added EALLOW and EDIS.
In fact, I also tried in example project "flash-programming-cpu02", I did as you say to comment the function ReleaseFlashPump and copy all the three function from Fapi_UserDefinedFunctions.c to ramfuncs. Then I can erase the .text section. But when comes to my new project this does not work. I do not know why.
In the attachment i attach the flash operation file, hardware initialize file , my map file and my cmd file.
Thank you.1004.files.zip
Best regards,
Yanpo, Li
Yanpo,
As I mentioned, good that you now found that the reason for erase failure is different.
Coming to your original debug: Which function calls the BL_Start() function in your application? Is that function located in RAM or Flash?
Also, do you have watchdog enabled or disabled?
Thanks and regards,
Vamsi
Hi Vamsi,
Yes, from the map file you can see I have put all functions copy to ramfuncs. I do nothing about watchdog. I only see in InitSysCtrl a operation about disable watchdog. Other place I do nothing. Another question, do i need to copy "rts2800_fpu32.lib" to ramfuncs? I am not sure whether it matters.
I have tried another way. That is, do not erase the .text sector, and download the new .text data to another unused sector( like FLASHG). I have checked the download data, it is right. However, when I power off and power on it, the program does not run. I do not know whether this way is OK. Thank you.
Best regards,
Yanpo, Li
Yanpo,
You did not answer the question that I asked in my previous reply: Which function calls the BL_Start() function in your application? May be it is your main() function that is calling BL_Start(). Since you are getting an ITRAP after returning from this function, I guess you are erasing the main() function.
You don't need to copy the rts library to ramfuncs based on what you are trying to accomplish.
Programming something in an unused sector should not effect your application. I am not sure if you are modifying something else by mistake. We can not help debug your application's architecture.
Thanks and regards,
Vamsi
Hi Vamsi,
I have checked which function call it. They are MailboxServiceInd()<----MBX_Main()<---- ECAT_Main() <----MainLoop()<----main(). I have added a breakpoint after MailboxServiceInd() calling it, and program can enter in the breakpoint, it is OK. Then I enter step over mode. When enter in MBX_CheckAndCopyMailbox(), which is included in ECAT_Main() function, it fall into no source available. And ECAT_Main is in my mainloop function which belongs to part of main function. But all these functions i have copied them to ramfuncs, only left main() function. In fact, I can not copy main function into ramfuncs. If I do it, the program falls into no source available just after loading new program. And I am not quite clear about erasing main function.7801.files.zip
the attachment is the related files. ECAT_Main() locates in ecatslv.c, MainLoop locates in ecatappl.c. Thank you.
Yanpo,
I went through your code files at a high level.
Two things to check:
1. Based on the CPU2 map file that you sent earlier, the MBX_CheckAndCopyMailbox() is in shared RAM. Check whether your CPU1 application gave shared RAM access to CPU2 or not. If not given, CPU2 will not be able to load/move code/data in to shared RAM.
2. I see #if(FLASH) condition for your ramfuncs assignment. Should there be a leading underscore like "_FLASH"? Reason I ask is that in the examples that TI provides, we use a leading underscore. In case, you are developing your project from a TI provided example, please note that we use "_FLASH" and not "FLASH".
Thanks and regards,
Vamsi
Hi Vamsi,
1. Yes, I have given the access to CPU2. In fact even I all use local RAM is all the same problem.
2. For FLASH i have define it myself, it is 1.
Best regards,
Yanpo, Li
Hi, Vamsi,
Yes, it is excuted in RAM. The memcpy function is locates in InitSysCtrl(). And when it says no source available, I check the Disassembly, it correspond to "6F00 SB 0, UNC". My compiler version is 6.2.7.
the related disassembly is as following.
3fe004: 0200 MOVB ACC, #0
3fe005: C242 MOVL *-SP[2], XAR6
3fe006: 1E44 MOVL *-SP[4], ACC
3fe007: 1902 SUBB ACC, #2
3fe008: 767FE677 LCR 0x3fe677
3fe00a: 6F00 SB 0, UNC ------------------------here stuck
3fe00b: 761B ASP
3fe00c: FFF0 PUSH RB
3fe00d: 0005 PUSH AR1H:AR0H
3fe00e: ABBD MOVL *SP++, XT
Best regards,
Yanpo, Li
Hi Vamsi,
By compacting the number of function copied to ramfuncs, now I can erase and download the TI-txt file to flash. However, when I finish downloding , power off and restart it, it fail to run.
I have checked every section downloaded in the flash. In fact, even if I only erase and download the same the codestart section or econst function to the related place, when power off and restart it, it also fail to start. I do not know why. the data downloaded is all right. Is there any extra work i need to do after update the program in CPU02?
Besides, if I only download CPU1 and CPU2, then all program is OK , I mean CPU1 can work and boot CPU2 nomally. Thank you.
Best regards,
Yanpo, Li
Yanpo,
Glad that you are now able to program the Flash successfully.
Check the boot mode that you configured for CPU2. May be it is configured for wait boot. CPU2 if configured for wait boot, will be in idle mode after the boot process. CPU1 can wake it up via an IPC interrupt and guide CPU2's further execution (See Table 3-38. C1TOC2IPC Commands Table in TRM).
If you want CPU2 to boot to Flash without entering wait boot, you need to configure the BOOTCTRL.OTP_KEY and BOOTCTRL.OTP_BMODE appropriately (boot to Flash). Check Table 3-8. Get Mode Decoding on CPU2 and Figure 3-7. CPU2 Standalone and Hibernate Boot Flow in TRM (SPRUHM8F). Make sure you programmed the correct values for the above fields.
If you have further questions related to boot, I would suggest you to close this thread and start a new thread.
Thanks and regards,
Vamsi