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.

TMS570LC4357: Storing data in program flash

Part Number: TMS570LC4357
Other Parts Discussed in Thread: UNIFLASH

Hi,

I've a file(around 2MB) and I need to store it in program flash. I've tried to store data in program flash(writing a small buffer to the start of FLASH1) using F021 Flash API(Fapi_issueProgrammingCommand) and it is working. However, I've problems with reading the data back. I tried to use Fapi_doMarginReadByByte and it ended up with dataEntry. I'm sure that src and dst pointers point to correct locations.

On the other hand, holding a pointer to somewhere in FLASH1 and accessing that data works.

As previously mentioned file is around 2MB and I've some concerns about the timing.

What's the proper way to handle this? 

Thanks in advance.

  • Hi,

    When you program data to flash1, did you enable the ECC generation?

    Fapi_issueProgrammingCommand((.., .., .., .., .., Fapi_AutoEccGeneration);

    The ECC is calculated on 64-bit aligned addresses.

  • In addition to using Flash APIs, CCS or uniflash can be used to load 2MB file to Flash1.

    Typically, the bank erasing time is 300ms, and programming 2MB takes 5.3 seconds for 1st 25 cycles, and 10.6 seconds in the worst case after first 25 cycles.

  • Yes, AutoEccGeneration is enabled while issuing programming command.

  • Did you use the normal mode, and the addresses are aligned to 32-bit or 64-bit boundary? 

  • Yes it's normal mode and I'm trying to read 256bytes of data. However, this arises another question in my mind.

    I'm trying to store an image for another MCU in LC4357's flash. I get the data over ethernet and I keep writing packet payloads to flash. I noticed that when the payload size is not multiple of 32bytes, it writes that one also but consecutive trials fail. An example scenario is below;

    Write 512bytes --> OK

    Write 512bytes --> OK

    Write 511bytes --> OK

    Write 512bytes --> ERROR

    I can handle this by limiting UDP packet size to multiple of 32 and last packet which doesn't have to be multiple of 32 but I want to handle this on LC4357 side of my system. How can I do that?

  • Hi Alperen,

    The flash bank width is 256 bits (32 bytes). The length of data buffer in Flash API (Fapi_issueProgrammingCommand()) cannot exceed the bank width:

    if (SizeInBytes < 32)
        bytes = SizeInBytes;
    else
        bytes = 32;

    511 bytes should be fine. The number of bytes for the last write is 31 bytes. 

  • Yes but next attempts, after writing data that's not multiple of 32, fail. It gets stuck at the following line.

    while(FAPI_GET_FSM_STATUS != Fapi_Status_Success);

  • Does the last write align to 32-bit address? 

  • No, I increment memory pointer wrt to number of written bytes. So, it is not multiple of 32 anymore after writing 31 bits.
    PS: When I aligned the destination address to 32-bits there's no problem, thanks. Can I remove this alignment restriction? I want to store my image without any gap between the data. If there's no way to remove this restriction, I can try different methods to overcome this.

  • The starting address plus the data buffer length cannot exceed the bank data width (32 bytes for TMS570LC43x). for example, programming 4 bytes on a 32 byte wide bank starting at address 0x31 is not allowed.

    The flash state-machine can actually program 32 bytes of data and 4 bytes of ECC in a single operation. It will make programming faster.