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/TMS570LC4357: it can't erase the flash after read data from flash

Part Number: TMS570LC4357

Tool/software: Code Composer Studio

hello sir

I meet a strange problem, as following:

I erase a blank flash first, and write data into one sector of the flash successfully. 

if I directly to erase the sector, it can success to erase it.

if I read data from the sector of the flash, then erase the sector, it failed to erase the sector. I didn't modiry any code about the flash handle.

about the flash handle code, please see the attachment.

2072.flash_handle.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* flash_handle.c
*
* Created on: 2019��12��4��
* Author: Waite
*/
#include <stdio.h>
#include "flash_handle.h"
void OSTimeDly (uint32_t ticks);
/* The partition table of TMS570LC4357 */
struct Sector_List gSector_List[SECTOR_NUM] =
{
/* Bank ID Sector ID low Address Sector Size */
{Fapi_FlashBank0, 0, 0x00000000, 16 * 1024},
{Fapi_FlashBank0, 1, 0x00004000, 16 * 1024},
{Fapi_FlashBank0, 2, 0x00008000, 16 * 1024},
{Fapi_FlashBank0, 3, 0x0000C000, 16 * 1024},
{Fapi_FlashBank0, 4, 0x00010000, 16 * 1024},
{Fapi_FlashBank0, 5, 0x00014000, 16 * 1024},
{Fapi_FlashBank0, 6, 0x00018000, 32 * 1024},
{Fapi_FlashBank0, 7, 0x00020000, 128 * 1024},
{Fapi_FlashBank0, 8, 0x00040000, 128 * 1024},
{Fapi_FlashBank0, 9, 0x00060000, 128 * 1024},
{Fapi_FlashBank0, 10, 0x00080000, 256 * 1024},
{Fapi_FlashBank0, 11, 0x000C0000, 256 * 1024},
{Fapi_FlashBank0, 12, 0x00100000, 256 * 1024},
{Fapi_FlashBank0, 13, 0x00140000, 256 * 1024},
{Fapi_FlashBank0, 14, 0x00180000, 256 * 1024},
{Fapi_FlashBank0, 15, 0x001C0000, 256 * 1024},
{Fapi_FlashBank1, 0, 0x00200000, 128 * 1024},
{Fapi_FlashBank1, 1, 0x00220000, 128 * 1024},
{Fapi_FlashBank1, 2, 0x00240000, 128 * 1024},
{Fapi_FlashBank1, 3, 0x00260000, 128 * 1024},
{Fapi_FlashBank1, 4, 0x00280000, 128 * 1024},
{Fapi_FlashBank1, 5, 0x002A0000, 128 * 1024},
{Fapi_FlashBank1, 6, 0x002C0000, 128 * 1024},
{Fapi_FlashBank1, 7, 0x002E0000, 128 * 1024},
{Fapi_FlashBank1, 8, 0x00300000, 128 * 1024},
{Fapi_FlashBank1, 9, 0x00320000, 128 * 1024},
{Fapi_FlashBank1, 10, 0x00340000, 128 * 1024},
{Fapi_FlashBank1, 11, 0x00360000, 128 * 1024},
{Fapi_FlashBank1, 12, 0x00380000, 128 * 1024},
{Fapi_FlashBank1, 13, 0x003A0000, 128 * 1024},
{Fapi_FlashBank1, 14, 0x003C0000, 128 * 1024},
{Fapi_FlashBank1, 15, 0x003E0000, 128 * 1024},
{Fapi_FlashBank7, 0, 0xF0200000, 4 * 1024},
{Fapi_FlashBank7, 1, 0xF0201000, 4 * 1024},
{Fapi_FlashBank7, 2, 0xF0202000, 4 * 1024},
{Fapi_FlashBank7, 3, 0xF0203000, 4 * 1024},
{Fapi_FlashBank7, 4, 0xF0204000, 4 * 1024},
{Fapi_FlashBank7, 5, 0xF0205000, 4 * 1024},
{Fapi_FlashBank7, 6, 0xF0206000, 4 * 1024},
{Fapi_FlashBank7, 7, 0xF0207000, 4 * 1024},
{Fapi_FlashBank7, 8, 0xF0208000, 4 * 1024},
{Fapi_FlashBank7, 9, 0xF0209000, 4 * 1024},
{Fapi_FlashBank7, 10, 0xF020A000, 4 * 1024},
{Fapi_FlashBank7, 11, 0xF020B000, 4 * 1024},
{Fapi_FlashBank7, 12, 0xF020C000, 4 * 1024},
{Fapi_FlashBank7, 13, 0xF020D000, 4 * 1024},
{Fapi_FlashBank7, 14, 0xF020E000, 4 * 1024},
{Fapi_FlashBank7, 15, 0xF020F000, 4 * 1024},
{Fapi_FlashBank7, 16, 0xF0210000, 4 * 1024},
{Fapi_FlashBank7, 17, 0xF0211000, 4 * 1024},
{Fapi_FlashBank7, 18, 0xF0212000, 4 * 1024},
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hello Waite,

    After your read operation, what is the value of the FMC status register? When you erasing the sector, what error message did you get? 

  • hello

    FLASH_CONTROL_REGISTER->FmStat.u32Register = 0 

    I printf the register, it is 0.

    I find that, if I operate the bank7 (EEPROM),  it is ok, it didn't happen the problem.

    if I operate the bank0 and bank1, it will happen the problem.

  • Did you change the flash wait state when you read the data from the flash? Actually flash reading operation should not impact the erase/write operations (your functions) 

  • hello sir

    I resoved the problem.

    I disabled the cache , then it is OK.

    can you tell me the relevance between the internal FLASH and the Cache?

    Or you can advice me some document?

  • Hello Waite,

    The MPU settings don't impact the execution of F021 Flash APIs. How do you read the flash?

    Can you do your test using this code:

    readData[0] = *(uint32_t *)0x0200000;
    readData[1] = *(uint32_t *)0x0200004;
    readData[2] = *(uint32_t *)0x0200008;
    readData[3] = *(uint32_t *)0x020000c;
    readData[4] = *(uint32_t *)0x0200010;
    readData[5] = *(uint32_t *)0x0200014;

    status = Fapi_BlockErase(1, 0x0200000, 64);

  • Hello Waite,

    The MPU settings (cacheable, WH, or WB) for flash region don't affect flash write operation using flash API. The Flash write API uses flash state machine rather than the CPU. The CPU writes data to flash wrapper register, and the flash state machine programs the state to flash address. 

    Reading data from flash is affected by the MPU settings. If the flash region is cacheable, if the cache hit occurs, the data in the cahce will be returned. To make sure the data is read from flash, you need to clean the cache before reading operation.