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
Olivier GALLIEN
ST Employee

Hi @ASkri.1​ ,

I confirm that you can't build tf-a combining STM32MP_SPI_NAND=1 and STM32MP_RAW_NAND=1 or STM32MP_SPI_NAND=1 and STM32MP_USB_PROGRAMMER = 1

Those combination exceed the max authorized size.

But your trial with only STM32MP_SPI_NAND=1 trigged that this setup was not present in our delivery and maybe require some tuning.

I will ask some expert and come back

Olivier

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Hi, Olivier! I just want to point, that building with STM32MP_SPI_NAND=1 is not the main purpose... I just want to get qspi boot ok. According to TF-A src it is necessary to set this def. Thank you in advance Looking forward for your reply вт, 8 июн. 2021 г. в 14:55, ST Community :
ASkri.1
Senior

Hi!

Do you have any news on this issue?

Thank you in advance

Looking forward for your reply

Bernard PUEL
ST Employee

Hello,

ST does not deliver a ready to use configuration for the snand because we don't have any board reference to provide to the customers.

snand was a change request during the project but many customers are using it now. It is clear for us we need to improve all the documentation around this use case that is now tested on every delivery internally.

Some snand can be booted from Rom code but for TF-a, some parameters need to be provisioned from the OTP (this is the standard way of working) but in your case you may force the snand config of your memory directly in TF-A code.

I/ First of all, print the config Tf-a is seeing:

in drivers/mtd/nand/spi_nand.c:

VERBOSE("SPI_NAND Detected ID 0x%x 0x%x\n", id[0], id[1]);

VERBOSE("Page size %i, Block size %i, size %lli\n",

spinand_dev.nand_dev->page_size,

spinand_dev.nand_dev->block_size,

spinand_dev.nand_dev->size);

Replace VERBOSE by INFO to see the trace in the console.

II/ configure the snand:

In ./plat/st/stm32mp1/stm32mp1_boot_device.c:static int get_data_from_otp(struct nand_device *nand_dev, bool is_slc)

you will see the different parameters TF-a needs from the OTP.

You can patch on a first step the values from your snand memory:

nand_dev->page_size

nand_dev->block_size

nand_dev->nb_planes

I think this is the issue here but if still not working, please give your snand reference.

Hi, Bernard! Thank you very much for your help - there is big step ahead, now I can boot from qspi and start u-boot. But there are still a lot of questions: 1. TF-A read's flash ID as : INFO: SPI_NAND Detected ID *0xff* 0x2c 0x14 0x2c According to source code it's expecting flash mfr id on zero byte, but 0xff read. Flash type is MT29F1G01ABAFDWB and it has 0x2c 0x14 flash id. Seems that it is not fully correct. After adjusting stm32mp1_boot_device.c in following way: static int get_data_from_otp(struct nand_device *nand_dev, bool is_slc) { uint32_t nand_param; nand_dev->page_size=0x800; nand_dev->block_size = 64U * nand_dev->page_size; nand_dev->nb_planes=1; nand_dev->size = 1024*nand_dev->block_size; return 0; ... I've got following info message INFO: Page size 2048, Block size 131072, size 134217728 and u-boot loads ok It is a strange idea to read QSPI parameters from OTP instead of reading flash parameter pages. I've read https://wiki.st.com/stm32mpu/wiki/STM32MP15_ROM_code_overview and know, that ROM code supports ONFI compatible flashes. I'm not expecting that TF-A cant... Sorry for this :( Now u-boot can't load UBI image with following error: ubi0 error: ubi_attach_mtd_dev: failed to attach mtd4, error -22 Please check the attached boot log below. According mtdparts command nand has UBI partition: STM32MP> mtdparts device spi-nand0 , # parts = 4 #: name size offset mask_flags 0: fsbl 0x00200000 0x00000000 0 1: fip1 0x00400000 0x00200000 0 2: fip2 0x00400000 0x00600000 0 3: UBI 0x07600000 0x00a00000 0 Thank you in advance Looking forward for your reply 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 INFO: SPI_NAND Detected ID 0xff 0x2c 0x14 0x2c INFO: Page size 2048, Block size 131072, size 134217728 NOTICE: BL2: v2.4-r1.0(debug): NOTICE: BL2: Built : 17:13:23, Jun 17 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 INFO: Loading image id=31 at address 0x2ffff000 INFO: Image id=31 loaded: 0x2ffff000 - 0x2ffff226 INFO: FCONF: Reading FW_CONFIG firmware configuration file from: 0x2ffff000 INFO: FCONF: Reading firmware configuration information for: dyn_cfg INFO: FCONF: Reading firmware configuration information for: stm32mp1_firewall INFO: BL2: Loading image id 4 INFO: Loading image id=4 at address 0x2ffc5000 INFO: Image id=4 loaded: 0x2ffc5000 - 0x2ffd847c WARNING: Not a known TEE, use default loading options. INFO: BL2: Skip loading image id 21 INFO: BL2: Skip loading image id 22 INFO: BL2: Loading image id 23 INFO: Loading image id=23 at address 0xc0500000 INFO: Image id=23 loaded: 0xc0500000 - 0xc0512a91 INFO: BL2: Loading image id 26 INFO: Loading image id=26 at address 0x2ffc0000 INFO: Image id=26 loaded: 0x2ffc0000 - 0x2ffc4258 INFO: BL2: Loading image id 5 INFO: Loading image id=5 at address 0xc0100000 INFO: Image id=5 loaded: 0xc0100000 - 0xc01cf9d8 NOTICE: BL2: Booting BL32 INFO: Entry point address = 0x2ffc5000 INFO: SPSR = 0x1d3 NOTICE: SP_MIN: v2.4-r1.0(debug): NOTICE: SP_MIN: Built : 16:52:37, Jun 7 2021 INFO: ARM GICv2 driver initialized INFO: Set calibration timer to 60 sec INFO: ETZPC: UART1 (3) could be non secure INFO: ETZPC: SPI6 (4) could be non secure INFO: ETZPC: CRYP1 (9) could be non secure INFO: ETZPC: I2C6 (12) could be non secure INFO: SP_MIN: Initializing runtime services INFO: SP_MIN: Preparing exit to normal world U-Boot 2020.10-stm32mp-r1 (Jun 07 2021 - 20:24:04 +0300) CPU: STM32MP157DAB Rev.Z Model: STMicroelectronics STM32MP157A-DK1 STM32CubeMX board Board: stm32mp1 in trusted mode (st,stm32mp157a-stm32mp151-dk1-mx) DRAM: 512 MiB Clocks: - MPU : 800 MHz - MCU : 208.878 MHz - AXI : 266.500 MHz - PER : 24 MHz - DDR : 533 MHz WDT: Started with servicing (32s timeout) NAND: 0 MiB MMC: STM32 SD/MMC: 0 Loading Environment from UBI... ubi0 error: validate_ec_hdr: bad VID header offset 4096, expected 2048 ubi0 error: validate_ec_hdr: bad EC header Erase counter header dump: magic 0x55424923 version 1 ec 0 vid_hdr_offset 4096 data_offset 8192 image_seq 531387333 hdr_crc 0x5b0dc81e erase counter header hexdump: ubi0 error: ubi_io_read_ec_hdr: validation failed for PEB 0 ubi0 error: ubi_attach_mtd_dev: failed to attach mtd4, error -22 UBI error: cannot attach mtd4 UBI error: cannot initialize UBI, error -22 UBI init error 22 Please check, if the correct MTD partition is used (size big enough?) ** Cannot find mtd partition "UBI" In: serial Out: serial Err: serial invalid MAC address in OTP 00:00:00:00:00:00 stm32 vrefbuf timed out: -110 adc@0: can't enable vdd-supply!adc_measurement: single shot failed for adc@0 [18]! Net: Error: ethernet@5800a000 address not set. No ethernet found. Hit any key to stop autoboot: 0 Boot over spi-nand0! Saving Environment to UBI... ubi0 error: validate_ec_hdr: bad VID header offset 4096, expected 2048 ubi0 error: validate_ec_hdr: bad EC header Erase counter header dump: magic 0x55424923 version 1 ec 0 vid_hdr_offset 4096 data_offset 8192 image_seq 531387333 hdr_crc 0x5b0dc81e erase counter header hexdump: ubi0 error: ubi_io_read_ec_hdr: validation failed for PEB 0 ubi0 error: ubi_attach_mtd_dev: failed to attach mtd4, error -22 UBI error: cannot attach mtd4 UBI error: cannot initialize UBI, error -22 UBI init error 22 Please check, if the correct MTD partition is used (size big enough?) ** Cannot find mtd partition "UBI" Failed (1) ubi0 error: validate_ec_hdr: bad VID header offset 4096, expected 2048 ubi0 error: validate_ec_hdr: bad EC header Erase counter header dump: magic 0x55424923 version 1 ec 0 vid_hdr_offset 4096 data_offset 8192 image_seq 531387333 hdr_crc 0x5b0dc81e erase counter header hexdump: ubi0 error: ubi_io_read_ec_hdr: validation failed for PEB 0 ubi0 error: ubi_attach_mtd_dev: failed to attach mtd4, error -22 UBI error: cannot attach mtd4 UBI error: cannot initialize UBI, error -22 UBI init error 22 Please check, if the correct MTD partition is used (size big enough?) STM32MP> mtdparts device spi-nand0 , # parts = 4 #: name size offset mask_flags 0: fsbl 0x00200000 0x00000000 0 1: fip1 0x00400000 0x00200000 0 2: fip2 0x00400000 0x00600000 0 3: UBI 0x07600000 0x00a00000 0 active partition: spi-nand0,0 - (fsbl) 0x00200000 @ 0x00000000 defaults: mtdids : spi-nand0=spi-nand0 mtdparts: mtdparts=spi-nand0:2m(fsbl),4m(fip1),4m(fip2),-(UBI) STM32MP> �?р, 16 июн. 2021 г. в 10:58, ST Community :
Bernard PUEL
ST Employee

This is good job !

I/ INFO: SPI_NAND Detected ID *0xff* 0x2c 0x14 0x2c: The issue is from the read_id function from TF-A that does not take into account the Dummy Byte present in this Micro memory for this command. But this has no impact on the behavior because this ID code is not used at all for a Micron memory.

Then, No issue here.

II/ from your logs:

"Loading Environment from UBI... ubi0 error: validate_ec_hdr: bad VID header

offset 4096, expected 2048"

We can see the UBI FS is configured for 4K block size (that is EV1 ST NAND default block size) instead of 2K for your memory. Probably you did not update on Yocto these configurations for your device. After you do that, I think i will be ok.

I will check If I can find the right link to follow but it is self explained at list in Yocto recipe.

ASkri.1
Senior

Hi, Bernard!

Thank you very much for your reply. Sorry, for very long aswer, I was little busy with other projects... Anyway I've come back, there are some steps forward and still some issues. First, about VID header offset, There are options availabla in machine.cfg file:

MKUBIFS_ARGS_nand_4_256 = "--min-io-size 2048 --leb-size 126976 --max-leb-cnt 1024 --space-fixup"

UBINIZE_ARGS_nand_4_256 = "--min-io-size 2048 --peb-size 128KiB"

EXTRA_UBIFS_SIZE_nand_4_256 = "2304"

So, I can adjust UBI image parameters.

That prpblem WAS, that these parameters are not taken into account until full rebuild, with deleting of build-openstlinuxweston-stm32mp1-duck folder. bitbale -c cleanall not helps... Is it ok? Do you have an Idea how to fix this issue without full image rebiult.

After adjusting parameters that mutch my flash I've got following other error during boot:

U-Boot 2020.10-stm32mp-r1 (Jun 07 2021 - 20:24:04 +0300)

CPU: STM32MP157DAB Rev.Z

Model: STMicroelectronics STM32MP157A-DK1 STM32CubeMX board

Board: stm32mp1 in trusted mode (st,stm32mp157a-stm32mp151-dk1-mx)

DRAM: 512 MiB

Clocks:

- MPU : 800 MHz

- MCU : 208.878 MHz

- AXI : 266.500 MHz

- PER : 24 MHz

- DDR : 533 MHz

WDT:  Started with servicing (32s timeout)

NAND: 0 MiB

MMC:  STM32 SD/MMC: 0

Loading Environment from UBI... ubi0 error: vtbl_check: too large reserved_pebs 6180, good PEBs 944

ubi0 error: vtbl_check: volume table check failed: record 4, error 9

Volume table record 4 dump:

    reserved_pebs  6180

    alignment    1

    data_pad    0

    vol_type    1

    upd_marker   0

    name_len    6

    name      rootfs

    crc       0xd79b6bc3

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

944 is a partition size in LEB

But what is 6180?

How to fix this?

Thank you in advance

Looking forward for your reply

Bernard PUEL
ST Employee

Hello,

The variables you modified are not for snand, you need to modify these ones:

./meta-st/meta-st-stm32mp/conf/machine/include/st-machine-common-stm32mp.inc:MKUBIFS_ARGS_spinand_2_128 = "--min-io-size 2048 --leb-size 126976 --max-leb-cnt 4096 --space-fixup"

./meta-st/meta-st-stm32mp/conf/machine/include/st-machine-common-stm32mp.inc:UBINIZE_ARGS_spinand_2_128 = "--min-io-size 2048 --peb-size 128KiB"

./meta-st/meta-st-stm32mp/conf/machine/include/st-machine-common-stm32mp.inc:EXTRA_UBIFS_SIZE_spinand_2_128 = "1408"

ASkri.1
Senior

Ok, thank you very much.

But how to deal with following variables:

DEVICE_BOARD_ENABLE_NAND  += "${@bb.utils.contains('BOOTDEVICE_LABELS', 'spinand_2_128', '${CUBEMX_DTB}', '', d)}"

FLASHLAYOUT_TYPE_LABELS_spinand_2_128 = "${@bb.utils.contains('BOOTDEVICE_LABELS', 'spinand_2_128', '${CUBEMX_DTB}', '', d)}"

BOOTFS_PARTITION_SIZE = "8192"

IMAGE_ROOTFS_MAXSIZE = "58968"

ROOTFS_PARTITION_SIZE = "${IMAGE_ROOTFS_MAXSIZE}"

USERFS_PARTITION_SIZE = "1024"

VENDORFS_PARTITION_SIZE = "10240"

?