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.

[FAQ] AM62x, AM62Px, AM62D-Q1, AM64x, AM243x: 4KB Sector Erase Fails

Part Number: PROCESSOR-SDK-AM62X

Tool/software:

Greetings,

When working with a flash part like S25HL512T or S28HS512T, one will come across Uniform vs Hybrid mode.

The points which this FAQ covers is:

  1. What is Uniform vs Hybrid Mode for the flash.
  2. Which mode does MCU PLUS SDK AM6xx Flash drivers work on.
  3. How to switch from one mode to another.

NOTE: This FAQ applies for AM64x, AM62x, AM243x, AM62Dx

Regards,

Vaibhav

  • Flash Datasheet which you can refer: 

    S28HS512T: Datasheet

    S25HL512T: Datasheet

  • What is Uniform vs Hybrid Mode for the flash.

    There are two modes/configurations in which the flash part can be set.

    In the context of the two flashes mentioned, these configurations are Hybrid and Uniform mode.

    Please note that the writes and read operations are independent of the two configurations mentioned.

    But the difference lies in how erase is operated.

    When in Uniform mode:

    1. The sector size is 256 KB, hence we call it a block. So, one way to think of it is Block size > Sector Size.
    2. When we perform sector erase, we are essentially doing block erase of 256 KB.
    3. So at a time, a 256 KB block will be erased and therefore you can see all values in the erased 256 KB area to be set as 0xFF.

    When in Hybrid mode:

    1. The sector size is a mix of 256 KB and 4 KB. So the 256 KB can be referred as Block and the 4 KB space can be considered as Sector.
    2. When we perform sector erase, we can perform either:
      1. Block erase of 256 KB, or,
      2. Sector erase of 4 KB.

    One combination of Uniform mode is:

    All the possible combinations of Hybrid mode are:

  • Which mode does MCU PLUS SDK AM6xx Flash drivers work on.

    The MCU PLUS SDK Flash drivers operates on the flash being set to Uniform mode.

    Before we look at how we switch from one mode to another, it is very important to understand why we want to do so.

    One major reason can be as follows:

    Assume for the write operation the number of bytes to be programmed or written to the flash is just under 4 KB. Then in this case, we would firstly, erase the space to be written to before writing. Assume, the flash is in Uniform mode, hence everytime for programming just under 4 KB data, we need to erase 256 KB of data which would not make a lot of sense.

    Hence, switching to Hybrid mode, allows few spaces to be of size 4 KB. So, let us suppose we want to program 3 KB of data, hence, erasing a sector of size 4 KB makes more sense here.


    Let us look at how we can switch from one to another in the next response.

  • Please Note:

    Sometimes during flash power on/off, the TB4KBS bit might be set back from 1 to 0.

    It should be good to consider the protection bit, which is PLPROT.

    When PLPROT is set to 1, then the bits highlighted in the table description below are protected from being erased or programmed.

  • Here is a code snippet to enable:

    1. Hybrid Configuration, sets UNHYSA to 0.

    2. TB4KBS sets to 1, meaning top 32 * 4 KB Sectors are enabled.

    int32_t Flash_quirkSpansionUNHYSAEnable(Flash_Config *config)
    {
        int32_t status = SystemP_SUCCESS;
        uint8_t regData = 0x00;
        uint32_t write = 0;
    
        /* Hybrid Sector Enable */
        status = Flash_norOspiRegRead(config, 0x65, 0x00800004, &regData);
    
        if(status == SystemP_SUCCESS)
        {
            if((regData & ((uint8_t)(1 << 3))) == 1)
            {
                /* Clear UNHYSA bit */
                regData &= ~(1 << 3);
                write = 1U;
            }
            else
            {
                /* No action */
            }
        }
    
        if(write)
        {
            status = Flash_norOspiRegWrite(config, 0x71, 0x04, regData);
        }
        /* Top Address Range selection for 4KB Sector Block */
        regData = 0x0;
        status = Flash_norOspiRegRead(config, 0x65, 0x00800002, &regData);
    
        /* Set TB4KBS Bit */
        regData |= (1 << 2);
        status = Flash_norOspiRegWrite(config, 0x71, 0x02, regData);
    
        return status;
    }