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.

TMS320F28384D: flash_kernel example, erasing flash

Expert 1700 points

Part Number: TMS320F28384D
Other Parts Discussed in Thread: C2000WARE

Hello,

I have a question regarding the flash_kernel example inside the C2000 Ware 04.00.00.00 package. I am looking at the part of the code, which receives from UART data to be written to CPU1 flash, specifically at the function 'copyData()'. Please look at the below code marked in the rectangle. 

I am thinking about a scenario, where we may write flash data across the flash sector borders like e.g. 4 words to S0 and 4 words to S1.

The above code will cause problems in case that the variable 'BlockHeader.DestAddr' holds a value, which is not an integer multiple of 8.

Example:

Let us assume that the variable 'BlockHeader.DestAddr' holds a value of 0x81FFF (which is the last address of CPU1 Flash sector 0). In that case we would write one word inside Sector 0 and seven words inside Sector 1 without erasing Sector 1 before.

I don't know if that situation can occur (how the linker places code inside memory), but maybe the flash erase must be done again based on this if-condition:

sectorAddress = findSector(BlockHeader.DestAddr+7); // +7 since the 'miniBuffer[]' array is of size 8
if(sectorAddress != 0xdeadbeef)
{
   ...

What do you think, is the above scenario valid?

Another question would be also, if the API function 'Fapi_issueProgrammingCommand' (writing to flash) is able to detect if a user wants to program data across flash sector borders and handles this scenario correctly.

Thanks,

Inno

  • Hi Inno,

    Thank you for approaching us.  We will review and get back to you in a day or two.

    Thanks and regards,
    Vamsi

  • Hi Inno,

    Flash API allows programming only within a 128-bit aligned memory boundary.  If the address + length combination crosses this boundary, flash API will return an error. 

    Flash kernels do not program beyond a 128-bit aligned boundary in a single flash API program command.  Also, they do erase all the necessary sectors before program - this check is done in the kernels.

    We suggest users to always align the start address of the sections in the linker cmd file on a 128-bit aligned boundary - this can be done by using ALIGN(8) in C28x linker cmd files - please check the linker cmd files provided in C2000Ware.

    If you have further questions, I can loop in our flash kernel expert.  Let me know.

    Thanks and regards,
    Vamsi

  • Hello,

    If the API returns an error, them I am fine with this behavior. 

    I have one additional information regarding the 'flash_kernel' example inside the C2000 Ware package. I recently received support from your colleague Anu and maybe you could forward the following information to him:

    In the 'flash_kernel' example, the download of the CPU1 flash kernel takes a long time (on my computer it was 7 minutes). I found a way to increase the download speed significantly via experimenting with an own written graphical C#/.Net tool. The bottleneck was, that the PC tool sends one byte to the CPU1 and waits for the CPU1 to echo this byte before sending the next byte.

    What I did for a speed improvement is:

    1) I enabled in my own written CPU1 flash kernel project the UART FIFO via 'SCI_enableFIFO(SCIA_BASE);' That means we now have a buffer available for 16 UART characters in Rx and Tx direction.

    2) Inside my 'sciaGetWordData' function I use from now on 'SCI_readCharBlockingFIFO' or 'SCI_writeCharBlockingFIFO'.

    3) I changed my own written PC tool to work as follows:

       a) In a for-loop I send 16 bytes one after the other.

       b) After sending 16 bytes, I wait for the CPU to echo back all 16 bytes, which I have send before.

       c) Now I compare the array that holds the 16 bytes I have sent with the 16 bytes received.

    The fact that I am sending 16 bytes one after the other without waiting for an echo after ech byte seems to accelerate the PC tool performance significantly. I believe this approach would also be interesting for the C++ tool that TI developed and provides inside the C2000 ware package.

    Thank you very much for clarifying that  the Flash API returns an error when crossing sector boundaries.

    Thanks,

    Inno

  • Inno,

    Thank you for the feedback.  I agree and we are aware of the performance improvements from SCI FIFO usage - I will pass this feedback to Anu (her).  

    In our survey on the requirements for kernel (taken a few years ago), customers preferred echo and hence the kernels are implemented like this.  When FIFO is enabled, instead of echo, checksum can be used - we will log this as an example requirement.    

    Have a great day.

    Thanks and regards,
    Vamsi