cancel
Showing results for 
Search instead for 
Did you mean: 

still unable to boot from qspi-nand

ASkri.1
Senior

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​ 

18 REPLIES 18
ASkri.1
Senior

I've got following error with spinand-2-128 target:

ERROR: u-boot-stm32mp-extlinux-3.1-r0 do_create_multiextlinux_config: No targets, nothing to do

ERROR: Logfile of failure stored in: /home/screep/Distribution-Package/openstlinux-5.10-dunfell-mp1-21-03-31/build-openstlinuxweston-stm32mp1-duck/tmp-glibc/work/stm32mp1_duck-ostl-linux-gnueabi/u-boot-stm32mp-extlinux/3.1-r0/temp/log.do_create_multiextlinux_config.10485

ERROR: Task (/home/screep/Distribution-Package/openstlinux-5.10-dunfell-mp1-21-03-31/layers/meta-st/meta-st-stm32mp/recipes-bsp/u-boot/u-boot-stm32mp-extlinux.bb:do_create_multiextlinux_config) failed with exit code '1'

Are you sure spinand-2-128 (and spinand_2_128) are correct targets?

BTW, there are only one target enable in machine conf:

# Define the boot device supported

# BOOTDEVICE_LABELS += "sdcard"

# BOOTDEVICE_LABELS += "emmc"

# BOOTDEVICE_LABELS += "nand-4-256"

BOOTDEVICE_LABELS += "spinand-2-128"

If I enable this one for example, build process has begun.

BOOTDEVICE_LABELS += "nand-4-256"

with nand-4-256 I've got following result after load image:

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?)

Thank you in advance

Looking forward for your reply

Bernard PUEL
ST Employee

please try this: EXTRA_UBIFS_SIZE_spinand_2_128 = "0"

Bernard PUEL
ST Employee

On our ST board (EV1), we have both slc NAND and SPI Nand.

"nand-4-256" label is for our slc NAND and "spinand_2_128" label is for our SPI Nand.

Except the overall size, your Spi nand is the same EV1 structure (page/blocks). So it is probably more relevant to start from SPI nand label as a reference.

Bernard PUEL
ST Employee

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

ASkri.1
Senior

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

Bernard PUEL
ST Employee

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.

Bernard PUEL
ST Employee

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

ASkri.1
Senior

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

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

Bernard PUEL
ST Employee

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.