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.

AM5716: QSPI flash access fails in U-boot

Part Number: AM5716

I am using Custom Board with Sitara AM5716. I have successfully boot it via U-boot by sending the SPL and U-boot image via UART. I have QSPI Flash memory of part number "S25FS512S" in my board. I want to test the peripheral using u-boot command.

So Output of my sf probe is

=> sf probe
SF: Detected s25fs512s with page size 512 Bytes, erase size 4 KiB, total 64 MiB, mapped at 5c000000

So this implies that the device got detected . But when I try to erase, write and read data, I am getting wrong output.

The commands I tried in u-boot to test QSPI memory is ::

=> mw 90000000 ff 40000
=> mw a0000000 aa 40000
=> sf erase 0 40000
SF: 262144 bytes @ 0x0 Erased: OK
=> sf write 90000000 0 40000
device 0 offset 0x0, size 0x40000
SF: 262144 bytes @ 0x0 Written: OK
=> sf read a0000000 0 40000
device 0 offset 0x0, size 0x40000
SF: 262144 bytes @ 0x0 Read: OK
=> md a0000000 ff
a0000000: 00000000 00000000 00000000 00000000    ................
a0000010: 00000000 00000000 00000000 00000000    ................
a0000020: 00000000 00000000 00000000 00000000    ................
a0000030: 00000000 00000000 00000000 00000000    ................
a0000040: 00000000 00000000 00000000 00000000    ................
a0000050: 00000000 00000000 00000000 00000000    ................
a0000060: 00000000 00000000 00000000 00000000    ................
a0000070: 00000000 00000000 00000000 00000000    ................
a0000080: 00000000 00000000 00000000 00000000    ................
a0000090: 00000000 00000000 00000000 00000000    ................
a00000a0: 00000000 00000000 00000000 00000000    ................
a00000b0: 00000000 00000000 00000000 00000000    ................
a00000c0: 00000000 00000000 00000000 00000000    ................
a00000d0: 00000000 00000000 00000000 00000000    ................
a00000e0: 00000000 00000000 00000000 00000000    ................
a00000f0: 00000000 00000000 00000000 00000000    ................

I was expecting data 'ff' in memory  a0000000  after the sf read command. What could be the issue ? Kindly guide me, where I need to check?

  • I have referred the page you have mentioned. My .config has same configuration for QSPI as in dra7xx_evm_config. So what more should I do ? Issue still persists.
  • This site explains about booting using QSPI Flash . But I am not able to write and read into the Flash itself. Kindly guide me , what I need to do to write and read into s25fs512s Flash memory.
  • Sorry about the delay. I have escalated this query to the software team. They will respond here.
  • Hi,
    I have modified some files in u-boot source files to comment out the read from memory map during serial flash read command and forcibly sending command for read and my current status is :

    U-Boot Console Output:


    => sf probe
    SF: Detected s25fs512s with page size 512 Bytes, erase size 256 KiB, total 64 MiB, mapped at 5c000000
    => sf erase 80000 40000
    SF: 262144 bytes @ 0x80000 Erased: OK
    => mw 90000000 deadbeef 10
    => md 90000000 20
    90000000: deadbeef deadbeef deadbeef deadbeef ................
    90000010: deadbeef deadbeef deadbeef deadbeef ................
    90000020: deadbeef deadbeef deadbeef deadbeef ................
    90000030: deadbeef deadbeef deadbeef deadbeef ................
    90000040: 87ac6eef 9fc8e7a3 fdac8f29 6de86b59 .n......)...Yk.m
    90000050: ef89768b ee74a18d bf2ebc9b e52d43e3 .v....t......C-.
    90000060: fddfddca fb3bbdaa 577df7f7 c6ed3534 ......;...}W45..
    90000070: 5b4d6bc9 b269ff05 b78c7edc 137bd8b0 .kM[..i..~....{.
    => sf write 90000000 80000 10
    device 0 offset 0x80000, size 0x10
    SF: 16 bytes @ 0x80000 Written: OK
    => mw a0000000 0 10
    => md a0000000 20
    a0000000: 00000000 00000000 00000000 00000000 ................
    a0000010: 00000000 00000000 00000000 00000000 ................
    a0000020: 00000000 00000000 00000000 00000000 ................
    a0000030: 00000000 00000000 00000000 00000000 ................
    a0000040: 49fffe5f 8e6d6ffe 2dc97fd5 db6e7f04 _..I.om....-..n.
    a0000050: fa3cefef 57930bdf ca2967e5 f2b378e5 ..<....W.g)..x..
    a0000060: ff919f45 912fa75c d1a80869 f37de2d9 E...\./.i.....}.
    a0000070: f7c9c3e8 eddbff9f 65fc7e71 df7afe77 ........q~.ew.z.
    => sf read a0000000 80000 20
    device 0 offset 0x80000, size 0x20
    SF: 32 bytes @ 0x80000 Read: OK
    => md a0000000 20
    a0000000: efdeadbe efdeadbe efdeadbe ffdeadbe ................
    a0000010: ffffffff ffffffff ffffffff ffffffff ................
    a0000020: 00000000 00000000 00000000 00000000 ................
    a0000030: 00000000 00000000 00000000 00000000 ................
    a0000040: 49fffe5f 8e6d6ffe 2dc97fd5 db6e7f04 _..I.om....-..n.
    a0000050: fa3cefef 57930bdf ca2967e5 f2b378e5 ..<....W.g)..x..
    a0000060: ff919f45 912fa75c d1a80869 f37de2d9 E...\./.i.....}.
    a0000070: f7c9c3e8 eddbff9f 65fc7e71 df7afe77 ........q~.ew.z.
    =>


    So when I am reading back from from Serial Flash, data is 0xefdeadbe instead of 0x deadbeef. What could be the reason ??


    The modification I have done in u-boot source files are ::

    File :: drivers/mtd/spi/spi_flash_ids.c

    quest@TVMDT2175-Ubuntu:~/Nithin/U-Boot_Git/u-boot$ git diff drivers/mtd/spi/spi_flash_ids.c
    diff --git a/drivers/mtd/spi/spi_flash_ids.c b/drivers/mtd/spi/spi_flash_ids.c
    index 262d81e..04e629b 100644
    --- a/drivers/mtd/spi/spi_flash_ids.c
    +++ b/drivers/mtd/spi/spi_flash_ids.c
    @@ -104,7 +104,8 @@ const struct spi_flash_info spi_flash_ids[] = {
    {"s25fl256s_256k", INFO(0x010219, 0x4d00, 256 * 1024, 128, RD_FULL | WR_QPP) },
    {"s25fs256s_64k", INFO6(0x010219, 0x4d0181, 64 * 1024, 512, RD_FULL | WR_QPP | SECT_4K) },
    {"s25fl256s_64k", INFO(0x010219, 0x4d01, 64 * 1024, 512, RD_FULL | WR_QPP) },
    - {"s25fs512s", INFO6(0x010220, 0x4d0081, 128 * 1024, 512, RD_FULL | WR_QPP | SECT_4K) },
    +// {"s25fs512s", INFO6(0x010220, 0x4d0081, 128 * 1024, 512, RD_FULL | WR_QPP | SECT_4K) },
    + {"s25fs512s", INFO6(0x010220, 0x4d0081, 256 * 1024, 256, RD_FULL | WR_QPP) },
    {"s25fl512s_256k", INFO(0x010220, 0x4d00, 256 * 1024, 256, RD_FULL | WR_QPP) },
    {"s25fl512s_64k", INFO(0x010220, 0x4d01, 64 * 1024, 1024, RD_FULL | WR_QPP) },
    {"s25fl512s_512k", INFO(0x010220, 0x4f00, 256 * 1024, 256, RD_FULL | WR_QPP) },


    File :: drivers/mtd/spi/spi_flash.c

    quest@TVMDT2175-Ubuntu:~/Nithin/U-Boot_Git/u-boot$ git diff drivers/mtd/spi/spi_flash.c
    diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
    index 51e28bf..45f77ca 100644
    --- a/drivers/mtd/spi/spi_flash.c
    +++ b/drivers/mtd/spi/spi_flash.c
    @@ -473,7 +473,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
    u32 remain_len, read_len, read_addr;
    int bank_sel = 0;
    int ret = -1;
    -
    +#if 0 //QuEST - Removing Memory map
    /* Handle memory-mapped SPI */
    if (flash->memory_map) {
    ret = spi_claim_bus(spi);
    @@ -487,7 +487,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
    spi_release_bus(spi);
    return 0;
    }
    -
    +#endif
    cmdsz = SPI_FLASH_CMD_LEN + flash->dummy_byte;
    cmd = calloc(1, cmdsz);
    if (!cmd) {
    @@ -516,6 +516,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
    else
    read_len = remain_len;

    + cmd[0] = 0x03;
    spi_flash_addr(read_addr, cmd);

    ret = spi_flash_read_common(flash, cmd, cmdsz, data, read_len);

    U-boot source is the latest from the git repository (git clone git://git.denx.de/u-boot.git). Is it fine ??
    Kindly help me solve the issue .
  • Can you use the latest Processor Linux SDK and test it?

    Steve K.

  • Not working in the latest SDK too. What should I try next ??
  • In the latest Processor SDK I did 'make am57xx_evm_config'
    Copied MLO and u-boot.img to an SD card.
    Booted from the card.
    Entered:
    load mmc 0 0x82000000 MLO
    sf probe
    sf erase 0 0x20000
    sf write 0x82000000 0 0x20000

    I reset the board and entered
    sf probe
    sf read 0x82000000 0 0x20000
    md.l 0x82000000

    And saw MLO
    82000000: 00000040 0000000c 00000000 00000000 @...............
    82000010: 00000000 45534843 4e495454 00005347 ....CHSETTINGS..
    82000020: ffffffff ffffffff ffffffff ffffffff ................
    82000030: ffffffff ffffffff ffffffff ffffffff ................
    82000040: c0c0c0c1 00000100 00000000 00000000 ................
    82000050: 00000000 00000000 00000000 00000000 ................

    Removed the SD Card and reset the board. MLO was booted from QSPI
    U-Boot SPL 2017.01-00444-g17f04deb6736-dirty (Feb 28 2018 - 12:38:15)
    DRA762-GP ES1.0 ABZ package
    Trying to boot from SPI
    ** First descriptor is NOT a primary desc on 1:1 **
    *** Warning - bad CRC, using default environment

    It stopped since I did not flash u-boot.

    Steve K.
  • Did this solve your problem?

    Steve K.
  • No. I modified the u-boot driver code for QSPI flash to bypass the memory map and then it started working.