Skip to main content
Visitor II
June 7, 2021
Question

still unable to boot from qspi-nand

  • June 7, 2021
  • 16 replies
  • 5585 views

In addition to this question:

https://community.st.com/s/question/0D53W00000pUh4gSAC/tfa-and-uboot-custom-compile-fails

I'm still unable to boot from qspi. I addition to question about I've discovered, that it's necessary to add STM32MP_SPI_NAND=1 option to t-fa build command line

There are two issues:

1.If I add it to commend line as described in wiki I've got following compilation error while compiling TF-A for USB :

arm-ostl-linux-gnueabi-ld.bfd: BL2's RO content has exceeded its limit.

arm-ostl-linux-gnueabi-ld.bfd: section .data VMA [000000002fffa000,000000002fffa543] overlaps section ro VMA [000000002ffea000,000000002fffafff]

arm-ostl-linux-gnueabi-ld.bfd: region `ROM' overflowed by 5444 bytes

....

../Makefile.sdk:190: recipe for target 'tf-usb' failed

2.If I add it only for nand target all ok:

Makefile.sdk line 46:

# Init default config settings

TF_A_DEVICETREE_nand ?= stm32mp157c-ed1 stm32mp157f-ed1 stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1

TF_A_EXTRA_OPTFLAGS_nand ?= STM32MP_SPI_NAND=1 STM32MP_FORCE_MTD_START_OFFSET=0x00200000

# TF_A_EXTRA_OPTFLAGS_nand ?= STM32MP_RAW_NAND=1 STM32MP_FORCE_MTD_START_OFFSET=0x00200000

TF_A_BINARY_nand ?= tf-a

TF_A_MAKE_TARGET_nand ?= all

And I've regenerated UBI image to get it fitted to 128Mb flash

Not I've got following console output while trying to boot qspi:

Download done

STM32MP> NOTICE: CPU: STM32MP157DAB Rev.Z

NOTICE: Model: STMicroelectronics STM32MP157A-DK1 STM32CubeMX board

INFO:  Reset reason (0x14):

INFO:   Pad Reset from NRST

INFO:  PMIC version = 0x21

INFO:  FCONF: Reading TB_FW firmware configuration file from: 0x2ffe3000

INFO:  FCONF: Reading firmware configuration information for: stm32mp_io

INFO:  Using SPI NAND

INFO:   Instance 1

INFO:  Boot used partition fsbl1

NOTICE: BL2: v2.4-r1.0(debug):

NOTICE: BL2: Built : 16:27:52, Jun 7 2021

INFO:  BL2: Doing platform setup

INFO:  RAM: DDR3-DDR3L 16bits 533000Khz

WARNING: Couldn't find property st,phy-cal in dtb

INFO:  Memory size = 0x20000000 (512 MB)

INFO:  BL2: Loading image id 31

ERROR:  mtd_add_extra_offset: Seek error -5

WARNING: Failed to access image id=0 (-5)

WARNING: Failed to obtain reference to image id=31 (-2)

ERROR:  BL2: Failed to load image id 31 (-2)

If I specify both STM32MP_SPI_NAND=1 and STM32MP_RAW_NAND=1 I've got following error:

region `ROM'

arm-ostl-linux-gnueabi-ld.bfd: BL2's RO content has exceeded its limit.

arm-ostl-linux-gnueabi-ld.bfd: region `ROM' overflowed by 1248 bytes

....

../Makefile.sdk:190: recipe for target 'tf-nand' failed

Could you please give me steps to debug this issue?

@PatrickF​ @Community member​ 

    This topic has been closed for replies.

    16 replies

    Technical Moderator
    September 20, 2021

    Sorry my mistake, we have no external board with SPI NAND (only internal). But still a good ref compared to SLC nand.

    ASkri.1Author
    Visitor II
    September 20, 2021

    Bernard!

    Could you please be more specific - which way to go? Taking into account, that I have custom board with QSPI flash soldered, with TF-A and U-BOOT build for this

    board. I'm successfully booting from QSPI flash, than TF-A starts U-BOOT, U-BOOT trying to mount UBI image and meet this problem:

    Boot over spi-nand0!

    Saving Environment to UBI... ubi0 error: init_volumes: not enough PEBs, required 970, available 944

    ubi0 error: ubi_wl_init: no enough physical eraseblocks (-26, need 1)

    ubi0 error: ubi_attach_mtd_dev: failed to attach mtd4, error -12

    UBI error: cannot attach mtd4

    UBI error: cannot initialize UBI, error -12

    UBI init error 12

    Please check, if the correct MTD partition is used (size big enough?)

    All done with nand-4-256 target.

    Could you please help me to complete this 4-month quest...

    Thank you in advance

    Looking forward for your reply

    Technical Moderator
    September 20, 2021

    Ok it seems the "spinand_2_128" is under work on our latest public release and will be clean up for next release. I need to check with the integration to better help you ... I will come back tomorow.

    Tf-A and u-boot can boot (in raw) so your flash config is ok. What is missing is the ubifs config for your memory and the config is exactly where you were.

    So I think the right config is:

    MKUBIFS_ARGS_nand-4-256 = "--min-io-size 2048 --leb-size 126976 --max-leb-cnt 4096 --space-fixup"

    UBINIZE_ARGS_nand-4-256 = "--min-io-size 2048 --peb-size 128KiB"

    EXTRA_UBIFS_SIZE_spinand_2_128 = "0" (to get first boot, then it will be optimized later on)

    Then Partitions size need also to be adjusted considering the overhead of the ubifs.

    I need to double check with the integration tomorow.

    Technical Moderator
    September 21, 2021

    Hello, confirmed with integration team. The last statement above is the right way to proceed with V3.0.0 release.

    ASkri.1Author
    Visitor II
    September 21, 2021

    Great news :)

    Anyway, I've got QSPI booted after adjusting FS sizes. Great. yeah!!!

    BTW, I have a question about you flash parameters suggested here:

    MKUBIFS_ARGS_nand-4-256 = "--min-io-size 2048 --leb-size 126976 --max-leb-cnt 4096 --space-fixup"

    UBINIZE_ARGS_nand-4-256 = "--min-io-size 2048 --peb-size 128KiB"

    EXTRA_UBIFS_SIZE_spinand_2_128 = "0" (to get first boot, then it will be optimized later on)

    Why max-leb-cnt has 4096 value.

    For 1G (128Mb) flash it should be not more, than 1024 (1024*128=128Mb) and for 2G (256Mb) - 2048. Some mkfs.ubifs requred these values to be "minus one" - 1023 and 2047? Is it typing mistake in your example or 4096 is correct value for 128 or 256Mb flash?

    Anyway thank you very much for your support, that was impressive :)

    ===============================================================

    Hit any key to stop autoboot: 0

    Boot over spi-nand0!

    Scanning ubi 0:...

    Found /extlinux/extlinux.conf

    Retrieving file: /extlinux/extlinux.conf

    234 bytes read in 19 ms (11.7 KiB/s)

    Retrieving file: /splash.bmp

    Failed to load '/splash.bmp'

    There is no valid bmp file at the given address

    1:   OpenSTLinux

    Retrieving file: /uImage

    7457152 bytes read in 807 ms (8.8 MiB/s)

    append: ubi.mtd=UBI rootfstype=ubifs root=ubi0:rootfs rootwait rw console=ttySTM0,115200

    Retrieving file: /stm32mp157a-stm32mp151-dk1-mx.dtb

    54866 bytes read in 23 ms (2.3 MiB/s)

    ## Booting kernel from Legacy Image at c2000000 ...

      Image Name:  Linux-5.10.10

      Created:   2021-01-23 15:04:06 UTC

      Image Type:  ARM Linux Kernel Image (uncompressed)

      Data Size:  7457088 Bytes = 7.1 MiB

      Load Address: c2000040

      Entry Point: c2000040

      Verifying Checksum ... OK

    ## Flattened Device Tree blob at c4000000

      Booting using the fdt blob at 0xc4000000

      XIP Kernel Image

      Loading Device Tree to cffef000, end cffff651 ... OK

    Starting kernel ...

    [  0.000000] Booting Linux on physical CPU 0x0

    [  0.000000] Linux version 5.10.10 (oe-user@oe-host) (arm-ostl-linux-gnueabi-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220) #1 SMP PREEMPT Sat Jan 23 15:04:06 UTC 2021

    [  0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d

    ..................

    Technical Moderator
    September 21, 2021

    Great News !

    Yes you are right, we have put a large value (outside our 256MB snand capacity) not to be limited. We will put less in the next release but even 2047 (for a 256 MB)

    is quite large.

    For the partitions size please be aware of the following:

    In the flash, we will store all boot stage (in raw) and UBI (multivolume ubifs). With your flash the UBI size is then : SPI NAND size - (FSBL1 + FIP1 + FIP2 + Multivolume UBI) = 128MiB - (2 + 4 +4) = 118MiB

    UBI multivolume is made of several partitions: U-boot config, bootfs, vendorfs, rootfs, userfs and UBI overhead. In addition, for each UBIFS partitions the SPI NAND consumes several extra blocks.

    These extra blocks can be adjusted thanks to EXTRA_UBIFS_SIZE_nand-4-256. What we do on our side is we put "0" first and see what is the resulting size on the board. Then with the theoric size compared to the real size, you can calculate this extra blocks size. Doing this on several partitions will help to adjust this value to adjust volumes size.

    For ex on our snand board, we got the "1408" value that is 11 blocs.