cancel
Showing results for 
Search instead for 
Did you mean: 

STM32MP131C – SPI-NAND bad blocks at block 0 and DFU flashing fails on brand-new custom board

GaneshKPhytec
Associate III

Hi ST community,

We are bringing up a brand-new custom board based on STM32MP131C (Rev.Y) and are facing an issue while flashing SPI-NAND over USB DFU.

Boot status

  • TF-A (BL2/BL31) boots correctly

  • OP-TEE OS boots and hands off to normal world

  • U-Boot starts normally and detects SPI-NAND

So the full boot chain up to U-Boot looks healthy.

SPI-NAND details

  • Part: GigaDevice GD5F4GM8UExxG

  • Size: 512 MiB

  • Block size: 128 KiB

  • Page size: 2048

  • OOB: 128

Detected correctly by U-Boot.

Issue description

When flashing over USB DFU from U-Boot, erase/write operations fail due to many bad blocks at very low addresses, including block 0.

Example output:
Marking bad block at 0x00000000 (-5)
Skipping bad block at 0x00020000
Skipping bad block at 0x00040000
Skipping bad block at 0x00060000
Limit reached 0x80000 while erasing at offset 0x80000
Error: DFU write error

Because of this, DFU flashing fails consistently.

Are there specific U-Boot or TF-A configurations recommended for SPI-NAND on STM32MP13?
Please find the attached patches which all for the spi-nand configuration done in the yocto (scarthgap). 

Software versions

  • TF-A: v2.10-stm32mp1-r2.0

  • OP-TEE: 4.0.0-dev

  • U-Boot: 2023.10-stm32mp-r.

    Please do let me know if you need more information.

    Thanks & Regards
    Ganesh.K

8 REPLIES 8
GaneshKPhytec
Associate III

Hi, Also please find the attached text file having the full log related to flashing over usb and also debug console while flashing the spi-nand.

Thanks & Regards

Ganesh.K

PatrickF
ST Employee

Hi,

not sure it is the root cause of bad block, but only SPI-NAND with embedded ECC are supported on STM32MP1 platforms (i.e. data are always considered as error free and TF-A and uBoot must be set accordingly).

https://wiki.st.com/stm32mpu/wiki/STM32_MPU_ROM_code_overview#Boot_from_parallel_--serial_NAND

PatrickF_0-1769586215775.png

 

Here, bad block might come from communication issue with the SPI NAND (HW issue, too high frequency, etc...)

Regards.

 

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.
NEW ! Sidekick STM32 AI agent, see here
GaneshKPhytec
Associate III

Hi patrickF,

  Thank you for the quick reply.
I have done the same modifications on the STM32mp135 soc and its working fine with same part number(GD5F4GM8UExxG). now we are working with STM32MP131C soc. is there anything I need to change related to serial nand flash.
Also attached the patches related to both tfa and uboot. Can you please verify and guide us which part i m missing here.
Also please let me know if you need any additional information.

 

Thanks & Regards

Ganesh K 

Main difference between MP131C and MP135F is CPU max frequency and voltage and some interface removed in MP131C (2nd Ethernet, Display, Camera, etc...).

PatrickF_0-1769605994472.png
That differences should not affect SPI-NAND.

Maybe look for an issue with working frequency (e.g. too fast QUADSPI).

I cannot help on patches and SW as I'm not software expert.

Did you look at SPI-NAND board signal integrity ?

Regards.

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.
NEW ! Sidekick STM32 AI agent, see here
GaneshKPhytec
Associate III

Hi PatrickF, 

We found one issue with the input voltage 3v3 is dropping while erasing the flash. now given direct 3v3 to spi-nand. now bad block error is not coming. but its stopping in the middle of the flash.

debug console log:
Error: ethernet@5800a000 address not set.
Hit any key to stop autoboot: 0
Boot over usb0!
DFU alt info setting: done
#
UPLOAD ... done
Ctrl+C to exit ...
#
FlashLayout received, size = 699
DOWNLOAD ... OK
Ctrl+C to exit ...
#
UPLOAD ... done
Ctrl+C to exit ...
spi-nand: spi_nand GD5F4GM8@0: GigaDevice SPI NAND was found.
spi-nand: spi_nand GD5F4GM8@0: 512 MiB, block size: 128 KiB, page size: 2048, OOB size: 128
Erasing metadata1 on spi-nand0: Erasing 0x00100000 ... 0x0017ffff (4 eraseblock(s))
done
Erasing metadata2 on spi-nand0: Erasing 0x00180000 ... 0x001fffff (4 eraseblock(s))
done
Erasing fip-b1 on spi-nand0: Erasing 0x00a00000 ... 0x00dfffff (32 eraseblock(s))
done
Erasing fip-b2 on spi-nand0: Erasing 0x00e00000 ... 0x011fffff (32 eraseblock(s))
done
DFU alt info setting: done
#
UPLOAD ... done
Ctrl+C to exit ...
E/TC:0 Panic 'Watchdog' at /usr/src/debug/optee-os-stm32mp/4.0.0-stm32mp-r2/core/drivers/stm32_iwdg.c:218 <stm32_iwdg_it_handler>
E/TC:0 TEE load address @ 0xde000000
E/TC:0 Call stack:
E/TC:0 0xde003b3d
E/TC:0 0xde01b6b7
E/TC:0 0xde00c201
E/TC:0 0xde01b235
E/TC:0 0xde009547
E/TC:0 0xde000388

flashing log: 

ganesh@PHYTEC:~/Downloads/myd-yf13x$ STM32_Programmer_CLI -c port=usb1 -w flashlayout_myir-image-core/opteemin/FlashLayout_nand-2-128-512_myb-stm32mp135x-512m-opteemin.tsv
-------------------------------------------------------------------
STM32CubeProgrammer v2.20.0
-------------------------------------------------------------------

 

USB speed : High Speed (480MBit/s)
Manuf. ID : STMicroelectronics
Product ID : DFU in HS Mode @Device ID /0x501, @Revision ID /0x1003
SN : 003400143034511937373733
DFU protocol: 1.1
Board : --
Device ID : 0x0501
Device name : STM32MP13xx
Device type : MPU
Revision ID : --
Device CPU : Cortex-A7

Start Embedded Flashing service

 

Opening and parsing file: tf-a-myb-stm32mp135x-512m-opteemin-programmer-usb.stm32


Memory Programming ...
File : tf-a-myb-stm32mp135x-512m-opteemin-programmer-usb.stm32
Size : 86.52 KB
Partition ID : 0x01

Download in Progress:
[==================================================] 100%

File download complete
Time elapsed during download operation: 00:00:00.748

RUNNING Program ...
PartID: :0x01

Reconnecting the device ...

USB speed : High Speed (480MBit/s)
Manuf. ID : STMicroelectronics
Product ID : DFU @Device ID /0x501, @Revision ID /0x1003, @Name /STM32MP131C Rev.Y,
SN : 003400143034511937373733
DFU protocol: 1.1
Board : --
Device ID : 0x0501
Device name : STM32MP131C Rev.Y
Device type : MPU
Device CPU : Cortex-A7
Start operation done successfully at partition 0x01


Opening and parsing file: fip-myb-stm32mp135x-512m-opteemin-programmer-usb.bin


Memory Programming ...
File : fip-myb-stm32mp135x-512m-opteemin-programmer-usb.bin
Size : 1.42 MB
Partition ID : 0x03

Download in Progress:
[==================================================] 100%

File download complete
Time elapsed during download operation: 00:00:02.073

RUNNING Program ...
PartID: :0x03

Reconnecting the device ...

USB speed : High Speed (480MBit/s)
Manuf. ID : STMicroelectronics
Product ID : USB download gadget@Device ID /0x501, @Revision ID /0x1003, @Name /STM32MP131C Rev.Y,
SN : 003400143034511937373733
DFU protocol: 1.1
Board : --
Device ID : 0x0501
Device name : STM32MP131C Rev.Y
Device type : MPU
Device CPU : Cortex-A7
Start operation done successfully at partition 0x03

Flashlayout Programming ...
[==================================================] 100%
Running Flashlayout Partition ...

Reconnecting the device ...

USB speed : High Speed (480MBit/s)
Manuf. ID : STMicroelectronics
Product ID : USB download gadget@Device ID /0x501, @Revision ID /0x1003, @Name /STM32MP131C Rev.Y,
SN : 003400143034511937373733
DFU protocol: 1.1
Board : --
Device ID : 0x0501
Device name : STM32MP131C Rev.Y
Device type : MPU
Device CPU : Cortex-A7
Flashlayout partition started successfully


Opening and parsing file: tf-a-myb-stm32mp135x-512m-opteemin-spinand.stm32


Memory Programming ...
File : tf-a-myb-stm32mp135x-512m-opteemin-spinand.stm32
Size : 90.56 KB
Partition ID : 0x04

Download in Progress:
[==================================================] 100%

File download complete
Time elapsed during download operation: 00:00:00.074

RUNNING Program ...
PartID: :0x04


Error: Start operation failed at partition 0x04
Error: TSV flashing service failed
......
Tried with reducing the frequency to 10Mhz, previously 66Mhz is there tried both but same issue. Any inputs on this?

 

Thanks & Regards

Ganesh.K

GaneshKPhytec
Associate III

Hi PatrickF,
One more update,

After fixing the power supply, now we can able to start the flashing and there is no bad blocking error but its stopped in the middle. Please check the attached text files which is having the logs for both debug console and flashing tool log.

Also tried to change the Frequency of spi clock like 33,66,99,104MHz but still same results.
Where else i need to check to resolve this issue.

 

Thanks & Regards

Ganesh.K

Hi @GaneshKPhytec 

maybe an USB issue (power integrity, signal integrity or HSE frequency issue) ?

Regards.

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.
NEW ! Sidekick STM32 AI agent, see here
GaneshKPhytec
Associate III

Hi PatrickF,

But I can copy the same file into ram but failing the same file in to the NAND:

RUNNING Program ...
PartID: :0x07
Start operation done successfully at partition 0x07


Opening and parsing file: fip-stm32mp131c-cabctrl-optee-spinand.bin


Memory Programming ...
File : fip-stm32mp131c-cabctrl-optee-spinand.bin
Size : 1.73 MB
Partition ID : 0x08

Download in Progress:
[=== ] 6%

Error: failed to download Sector[0]
Error: failed to download the File
Error: Download partition 0x08 failed
Error: TSV flashing service failed

ToRAM:
********

USB speed : High Speed (480MBit/s)
Manuf. ID : STMicroelectronics
Product ID : DFU @Device ID /0x501, @Revision ID /0x1003, @Name /STM32MP131C Rev.Y,
SN : 003300073034511937373733
DFU protocol: 1.1
Board : --
Device ID : 0x0501
Device name : STM32MP131C Rev.Y
Device type : MPU
Device CPU : Cortex-A7
Start operation done successfully at partition 0x01


Opening and parsing file: fip-stm32mp131c-cabctrl-optee-programmer-usb.bin


Memory Programming ...
File : fip-stm32mp131c-cabctrl-optee-programmer-usb.bin
Size : 1.73 MB
Partition ID : 0x03

Download in Progress:
[==================================================] 100%

File download complete
Time elapsed during download operation: 00:00:03.132

RUNNING Program ...
PartID: :0x03

Reconnecting the device ...
...
I m not sure, how it will be USB issue..
Please correct me If i wrong.


Thanks & Regards
Ganesh.K