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.

FlashAPI works on RAM-Version, but fails when running from Flash

Other Parts Discussed in Thread: CONTROLSUITE

Hi,

my project uses Piccolo F28069 (CCS 5.4.0) and I successfully integrated the some of the function calls in the folder "Example_Flash2806x_API" into my own project. As usual I started with a RAM-Version and after some debugging finally everything worked fine:

- erasing all Sectors A-H,

- programming code that I previously downloaded into external SPI-Flash,

- setting up a watchdog to do a SW-Reset.

In the RAM-Version of my project I see that after the watchdog has triggered a reset Software restarts from FLASH, so obviously the right code was put into the right place. (Test: remove debugger an switch power off and on again -> still working). But when I re-build the project for the FLASH-Version to with the corresponding Linker-file the first call of function Flash_Erase( SECTRO_H, &FlashStatus ) fails. (Remark: As shown in the example Code all related function calls have been assigned to 'ramfuncs' and copied into RAM). 

In the Disassembly-View I only see the jump into BootROM but then the function behaves different than in the RAM-Version before. Here are some snapshots:

branch into BootROM:

then another branch:

then the erase-Code (I assume):

Until this point RAM-Version behaves the same as FLASH-Version, but when stepping further the RAM-Version of my project safely returns after a while (to go on erasing the next sector), while the FLASH-Version of my project does NOT. I´m not sure, it seems like a reset has occured, all I see is that the Code restarts completely without anything being erased.

Any ideas?

  • Hmm, no one can help?

    Was something wrong in my post, or is it the wrong forum?

    Please comment,

     

    best regards,

    Stefan

  • Hmm, no one can help?

    Was something wrong in my post, or is it the wrong forum?

    Please comment,

     

    Your post seems to have got missed by the team. Now that you've re-highlighted it, I hope the respective expert helps you out. I guess the TMS320F2806x Piccolo Flash API doc didn't help you?

    Can be found here: C:\ti\controlSUITE\libs\utilities\flash_api\2806x\v100\doc

    Regards,

    Gautam

  • It helped me a lot when I started, and I thought that I included all necessary steps according to the do´s and dont´s List. But as I said, everything worked at once in RAM-version, but fails when running out of FLASH.

    regards,

    Stefan

     

  • Hello,

    still no one available?

    In the meantime I worked on other open issues, but this point is still important and very essential for me, so please help...

    best regards,

    Stefan

  • Hey Stefan,

    sorry it took a while to get to this in my list.

    Now you have loaded an application to flash, you main is in flash - it then relocates some of the functions to RAM and one of these functions in RAM calls into erase a flash sector.

    1. Is the problem with any sector or when you try to erase few sectors it doesn't work?

    2. We need to have a function call stack and see where these functions are located (identify if any of them are located in the flash sector you are trying to erase currently)

    3. does the flash API in ROM calls back into any of the flash functions in application? where these call back functions are located - are they erased? - this can be checked by looking at you application MAP file, look for any functions with fl28x or other flash api identifiable string in the function name.

    4. Did your application reserve the RAM needed by BootROM, hope you are not loading any thing into the RAM reserved for ROM. - I guess not since your RAM version works just fine 

    I'll check with the flash API experts if there is a call back from the flash API in ROM to any of the user provided functions while doing erase operations.

    Last time I helped one of the customer with exactly similar thing as yours, but that was on Concerto series, the problem turned out to be 2 and 3. Also he was able to erase few sectors but wasn't able to erase few others so we were able to localize the issue.

     

    Best Regards

    Santosh

  • Hi Santosh,

    1. any sector!  When I examined today it didn´t even come to erase a single sector. As soon as the function Flash_Erase is called it now crashes and reboots.

    2. According to the Linker-Cmd file the stack is located here:  .stack   : > RAMM0, PAGE = 1

    which is confirmed in the map-file:

    .stack     1    00000050    000003b0     UNINITIALIZED

                      00000050    000003b0     --HOLE--

    3. Not sure if I fully understand what you mean here, this is an excerpt from the .map-file:

    003ffebb   _Flash2806x_Program

    003ffebd   _Flash2806x_Erase

    003ffedf   _Flash2806x_Verify

    003ffee7   _Flash2806x_ToggleTest

    003ffef3   _Flash2806x_APIVersionHex

    I think the addresses are in the range of BootROM, which should be correct...?

    The Callback functions are put somewhere in RAML7, where my 'ramfuncs' reside:

    000100b1 _MyCallbackFunction

    00010411   _MyFlashAPI_callbackFunction

    4. I think this line in the Linker-cmd file does what you mean:

    PAGE 1: ....

    BOOT_RSVD   : origin = 0x000000, length = 0x000050

     

    Hope you have an idea....

     

    best regards,

    Stefan

     

  • Stefan Krammes said:
    As soon as the function Flash_Erase is called it now crashes and reboots.

    Can you make sure that there is no interrupt occurs when it enters "erase flash" APIs?

    Best regards,

    Maria

  • I tried to realise your suggestion by putting the DINT macro one line earlier, so it now looks like

    DINT;

    Status = Flash_Erase( SECTOR_B, &FlashStatus );

    But the result is the same...

    I tried to use another API-function like

    if( Flash_APIVersionHex() != 0x0100 )
      asm("    ESTOP0");         // Unexpected API version

    and this does not crash, so I think that even in my buggy FLASH-Version the BootROM is at least accessible and libs are included...

    best regards

    Stefan

     

  • For more details I attached the Map-files from both the RAM-Version and the FLASH-Version.

    Hope this helps you to identify differences.

    6835.Mapfiles.7z

    best regards,

    Stefan

  • Stefan,

    thanks for the MAP files. Before we get into the debug, are you able to run the Example_2806xFlashProgramming project as it is on your set up (the example is under C:\ti\controlSUITE\device_support\f2806x\v136\F2806x_examples_ccsv5\flash_programming)?

    the example erases all the sectors except sector A.

     

    Best Regards

    Santosh

     

  •  

    Before I started integrating API routines into my own project I ran the example named Example_Flash2806x_API.c and it worked well, as usual.

    best regards,

    Stefan

  • Stefan,

    since the program goes into weeds on calling the flash API in ROM, either the stack is getting overwritten or any of the variables needed by flash API ( FlashCallbackVar, FlashScalingVar) in ROM are corrupted or are not initialized or one of the call back function pointers are getting corrupted.

    Before stepping into the ERASE function can you check if above are still good in RAM.

    Also could you compare the MAP files and linker command files from the TI example and the map file from your project and make sure what needs to be in RAM is intact?

    what is your time zone, if possible getting on a webex and call might be helpful, but lets try to debug it a bit more.

     

    Best Regards

    Santosh

  • Santosh,

    to initialise the Flash-Variables I use the Lines

    EALLOW;

    Flash_CPUScaleFactor = SCALE_FACTOR;

    Flash_CallbackPtr = NULL;

    EDIS;

     

    The TI-example also uses some pragma`s like

    #pragma DATA_SECTION(Flash_CPUScaleFactor, "FlashScalingVar");

     Uint32 Flash_CPUScaleFactor;

    #pragma DATA_SECTION(Flash_CallbackPtr, "FlashCallbackVar");

    void (*Flash_CallbackPtr) (void);

    which I don´t use.

    Instead, I use 'F2806x_GlobalVariableDefs.c', which already includes the above lines. In the debugger I see that they contain some values that are not changing after being initialised.

    I just ran the TI-example with my FLASH-Linker file, and it worked. The only thing that I had to comment out were some lines belonging to CLA (scratchpad...). Do you think this makes the difference? For reference I attached the used Linker-file.

    Concerning the Map-files, what functions/libs should I precisely look for? As far as I can see, my own functions are located where they should be.

    best regards,

    Stefan

  • Stefan,

    could you try below initialization in your main ()

       EALLOW;

       Flash_CallbackPtr = &MyCallbackFunction;

       EDIS;

    and define below in your application, like the Flash API example does? 

    /*------------------------------------------------------------------

      Callback function - must be executed from outside flash/OTP

    -----------------------------------------------------------------*/

    #pragma CODE_SECTION(MyCallbackFunction,"ramfuncs");

    void MyCallbackFunction(void)

    {      

    // Toggle pin, service external watchdog etc

        MyCallbackCounter++;  

    asm("    NOP");

    }

    if above doesn't help would you be able to send a zipped version of your application that is failing, I can try to reproduce and debug it.

     

    Best Regards

    Santosh

  • Santosh,

    bad news, it didn´t help. It makes no difference if CallbackFunction() is used or not.

    I tried to prepare my project so you can run it independantly from the specific hardware that I use (like I2C-Port-expander, SPI-DataFLASH, HyperTerminal-Communication...), so I had to remove al lot of Code to make someone else able to run it on a different hardware. Unfortunately this solved the problem, it works now!

    Of course, this is not an option, so I restored the functions one by one until the failure was back again, but the result still makes no sense to me:

    1) To make it work I need to turn off all PWM clocks:  SysCtrlRegs.PCLKCR1.all = 0;

    Since I don´t use interrupts related to ePWMx I have no idea how this can affect an erase-function running from BootROM. All used ePWM-interrupts only start SOC´s which then call CLA-tasks. Anyway, turning off the ePWM clocks before erasinf/programming is fine for me.

    2) To make it work I must not call a certain function related to HyperTerminal communication.

    Here I´m still inverstigating, but no clue so far. I checked the RAM memory, but could not find significant changes like large blocks being altered, so I don´t think that my ramfuncs get corrupted. What I observed when stepping through the BootROM was that MyCallbackFunction() gets called quite often, before the Programm finally crashes. Maybe there´s a chance to put some more information into MyCallbackFunction() then just an up-counter...

     

    best regards,

    Stefan

  • Stefan,

    do you need to do both 1 and 2 above to make it to work or either 1 or 2 gets it to work?

    could you try using DINT (disable interrupts by setting INTM) before calling in the erase function and EINT (Enable interrupts) after?

     

    Best Regards

    Santosh

     

  • Good news, Santosh.

    Your hint with DINT/EINT around the erase function finally led me to the problem:

    My HyperTerminal communciation makes use of Timer2, so when I invoke the user-update rountine, Timer2 gets activated. But I forgot to stop Timer2 when Data-transfer is finished, so it keeps triggering Int´s which can only be serviced as long as Timer2_isr() is existing in FLASH! Putting this isr also into ramfuncs is not necessary for me, I just stopped the Timer before erase starts and it worked. I wasn´t aware of this until setting the DINT, so then I was able to see CPU-register IFR.INT14 being set and not cleared anymore after the Sector containing the isr had been erased.

    The issue with the PWM clocks still remains unclear to me, because even with ePWM clocks running I see no int. requests, which could trigger ints. but as I said, disabling them is the easiest and safest way for me...

     

    So thank you very much for your support & have a nice weekend.

    best regards,

    Stefan