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.

TDA4VM: add the ability to write/erase OSPI Flash in SBL

Part Number: TDA4VM
Other Parts Discussed in Thread: UNIFLASH

I used sdk 7.2,boot mode : ospi + emmc;

I call Board_flashRead, Board_flashEraseBlk returned successfully,But when I call Board_flashWrite and it doesn't return, the program hangs there,How should I solve this problem?

The code is shown below:

  • Hi,

    Is the intention to just erase the flash? Can you use UNIFLASH tool for that purpose? If yes, please follow the instructions at https://e2e.ti.com/support/processors-group/processors/f/processors-forum/943810/tda4vm-how-to-use-uniflash-easeing-emmc-flash/3514788#3514788. The steps mentioned in the e2e are for erasing eMMC, to erase OSPI just change the device ID (argument after -d) from 4 to 3.

    -e argument specifies the size of region to be erased.

    Fullscreen
    1
    2
    3
    4
    5
    # This will send the flash programmer over UART and then send the sysfw
    dslite.bat --mode processors -c COM7 -f C:\ti\uniflash_5.3.1\processors\FlashWriter\j721e_evm\uart_j721e_evm_flash_programmer_release.tiimage -i 0
    # This will erase the OSPI, here size is in Bytes (in HEX)
    dslite.bat --mode processors -c COM7 -d 3 -e 7c0000
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Uniflash doc: https://software-dl.ti.com/jacinto7/esd/processor-sdk-rtos-jacinto7/07_03_00_07/exports/docs/pdk_jacinto_07_03_00_29/docs/userguide/jacinto/board/uniflash.html 

    Regards,

    Karan

  • It's not just about erase Flash,I want to write read some partition in Flash, erase that partition, and then write new data to that partition,and in that case, call Board_flashWrite, and then the program hangs there。Are we sure the Board_flashWrite function works in SBL?

  • Hi,

    I see from the code snippet you attached, that you have made some changes on the SDK.

    Can you provide me a patch of your changes on top of SDK7.2?

    Regards,

    Karan

  • Based on your hardware, add the Board_FlashWrite function to my picture above and test if it works properly.

    thank you!

  • Hi,

    Can you provide a patch of your changes which I can use to check this on the EVM?

    Regards,

    Karan

  • diff --git a/modules/pdk/pdk_jacinto_07_01_05_14/packages/ti/boot/sbl/src/ospi/sbl_ospi.c b/modules/pdk/pdk_jacinto_07_01_05_14/packages/ti/boot/sbl/src/ospi/sbl_ospi.c index b91f776..726fa12 100755 --- a/modules/pdk/pdk_jacinto_07_01_05_14/packages/ti/boot/sbl/src/ospi/sbl_ospi.c +++ b/modules/pdk/pdk_jacinto_07_01_05_14/packages/ti/boot/sbl/src/ospi/sbl_ospi.c @@ -231,6 +231,7 @@ int32_t SBL_ReadSysfwImage(void **pBuffer, uint32_t num_bytes) #if defined(SIM_BUILD) || defined(SOC_J7200) ospi_cfg.phyEnable = false; #endif + ospi_cfg.phyEnable = false; /* Set the default SPI init configurations */ OSPI_socSetInitCfg(BOARD_OSPI_NOR_INSTANCE, &ospi_cfg); @@ -242,10 +243,16 @@ int32_t SBL_ReadSysfwImage(void **pBuffer, uint32_t num_bytes) h = Board_flashOpen(BOARD_FLASH_ID_MT35XU256ABA1G12, BOARD_OSPI_NOR_INSTANCE, NULL); #endif + uint8_t buf[11]; + memset(buf, 0x00, sizeof(buf)); + int writemode = 0; if (h) { SBL_ADD_PROFILE_POINT; + SBL_log(SBL_LOG_ERR, "test\n"); + Board_flashWrite(h, 0x1380000, buf, sizeof(buf), (void *)&writemode); + SBL_log(SBL_LOG_ERR, "SBL\n"); #if defined(SIM_BUILD) || defined(SOC_J7200) /* Disable PHY pipeline mode */

  • Hi,

    I'm sorry but I am not able to understand the diff from your response.

    One thing that I see as an issue is that the writeMode you are using should be 1 not 0. See pdk*/packages/ti/drv/spi/test/ospi_flash/src/main_ospi_flash_test.c#757 and pdk*/packages/ti/board/src/flash/nor/nor.h#107

    You can refer the OSPI Unit Test for the correct sequence. Source code at pdk*/packages/ti/drv/spi/test/ospi_flash/.

    Regards,

    Karan

  • i set writeMode value to 1, I test found that the Board FlashWrite did not return properly。I refer to the routine you said,Board_FlashWrite does not return properly。

  • Add the following code to line 249 of the sbl_ospi.c file and test it to see if it works.

            uint8_t buf[11];
            memset(buf0x00sizeof(buf));
            int writemode = 1retsector = 0page = 0;

            ret = Board_flashRead(h0x1380000bufsizeof(buf), (void *)&writemode);
            if(ret != 0){
                SBL_log(SBL_LOG_ERR"read error\n");
            } else {
                SBL_log(SBL_LOG_ERR"read success\n");
            }

            ret = Board_flashOffsetToSectorPage(h0x1380000, &sector, &pagefalse);
            if(ret != BOARD_FLASH_EOK){
                SBL_log(SBL_LOG_ERR"addr error, ret = %d\n"ret);
                return ret;
            } else {
                SBL_log(SBL_LOG_ERR"Board_flashOffsetToSectorPage success\n");
            }

            ret = Board_flashEraseBlk(hsector);
            if(ret != BOARD_FLASH_EOK) {
                SBL_log(SBL_LOG_ERR"erase error, sector = %x, ret = %d\n"sectorret);
                return ret;
            } else {
                SBL_log(SBL_LOG_ERR"Board_flashEraseBlk success\n");
            }

            SBL_log(SBL_LOG_ERR"test\n");
            Board_flashWrite(h0x1380000bufsizeof(buf), (void *)&writemode);
            SBL_log(SBL_LOG_ERR"SBL\n");
  • Have you made any progress?

  • Hi,

    We will try to reproduce this at our end tomorrow & get back to you on this.

    In future for any pdk related diff sharing. Please do the following:

    cd $PSDKRA_PATH/pdk_jacinto_07_03_00_29
    git init
    git add .

    The above will create a pdk git repository.

    After that you can jus give us the diff output easily:
    git diff path_to_file > diff

    And share it. This will make it very easy for us to apply the diff directly to test & reproduce.

    Best Regards,
    Keerthy

  • Have you made any progress?

  • Hi,

    I will try this and have an update for you shortly.

    Regards,

    Karan

  • I am able to replicate the issue, I see the below logs from your test:

    No prints after test.

    Regards,

    Karan

  • so how can we solve this problem?

  • is there any progress

  • Hi,

    Apologies for delay, I will have an update for you by end of this week.

    Regards,

    Karan

  • Hi,

    Can you take reference from the board_diag_ospi application? That has the sequence for writing, reading and erasing the flash. Run that from the SBL as an application and do not integrate the code in SBL as that will increase the size of the SBL. I tried that and it doesn't fit in the OCM RAM.

    Use the default OSPI SBL and then flash the board_diag_ospi_mcu1_0_release.appimage at 0x100000.

    Build the app using:

    cd pdk/packages/ti/build/

    make board_diag_ospi

    Source code: pdk/packages/ti/board/diag/ospi/src/ospi_test.c

    Regards,

    Karan

    • Verify that the board_diag_ospi application is working properly?

  • Verify that the board_diag_ospi application is working properly?

  • Hi,

    Yes, I verified that the board_diag_ospi works with SBL. See below logs:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    SBL Revision: 01.00.10.00 (May 29 2021 - 10:39:59)
    TIFS ver: 21.1.1--v2021.01a (Terrific Lla
    *********************************************
    * OSPI FLASH Test *
    *********************************************
    OSPI NOR device ID: 0x5b1a, manufacturer ID: 0x2c
    Verifying the OSPI Flash first page...
    OSPI NOR Flash first page verification Successful
    Writing Tuning Data to the Flash
    Tuning Data Programming Successful
    OSPI NOR Flash verification Successful
    OSPI Flash Test Passed!
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    You can build the test as:

    cd pdk/packages/ti/build

    make board_diag_ospi

    You can use the below uniflash steps to flash to OSPI. Modify paths accordingly.

    Fullscreen
    1
    2
    3
    4
    5
    sudo ./dslite.sh --mode processors -c /dev/ttyUSB1 -f /home/karan/ti/uniflash_6.1.0/processors/FlashWriter/j721e_evm/uart_j721e_evm_flash_programmer_release.tiimage -i 0
    sudo ./dslite.sh --mode processors -c /dev/ttyUSB1 -f /home/karan/sdk7_3/ti-processor-sdk-rtos-j721e-evm-07_03_00_07/pdk_jacinto_07_03_00_29/packages/ti/boot/sbl/binary/j721e_evm/ospi/bin/sbl_ospi_img_mcu1_0_release.tiimage -d 3 -o 0
    sudo ./dslite.sh --mode processors -c /dev/ttyUSB1 -f /home/karan/sdk7_3/ti-processor-sdk-rtos-j721e-evm-07_03_00_07/pdk_jacinto_07_03_00_29/packages/ti/drv/sciclient/soc/V1/tifs.bin -d 3 -o 80000
    sudo ./dslite.sh --mode processors -c /dev/ttyUSB1 -f /home/karan/sdk7_3/ti-processor-sdk-rtos-j721e-evm-07_03_00_07/pdk_jacinto_07_03_00_29/packages/ti/binary/board_diag_ospi/bin/j721e_evm/board_diag_ospi_mcu1_0_release.appimage -d 3 -o 100000
    sudo ./dslite.sh --mode processors -c /dev/ttyUSB1 -f /home/karan/sdk7_3/ti-processor-sdk-rtos-j721e-evm-07_03_00_07/pdk_jacinto_07_03_00_29/packages/ti/board/src/flash/nor/ospi/nor_spi_patterns.bin -d 3 -o 3FE0000
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Regards,

    Karan