STM32CubeProgrammer Fails to Program NAND on QSPI due to unexpected MTD Size
Hello! I am trying to get CubeProgrammer to flash a NAND on a custom board.
UBOOT detects the NAND chip and mtdparts lists the following:
STM32MP> sf probe
STM32MP> mtdparts
device spi-nand0 <spi-nand0>, # parts = 4
#: name size offset mask_flags
0: fsbl 0x00200000 0x00000000 0
1: ssbl1 0x00200000 0x00200000 0
2: ssbl2 0x00200000 0x00400000 0
3: UBI 0x1fa00000 0x00600000 0
active partition: spi-nand0,0 - (fsbl) 0x00200000 @ 0x00000000
defaults:
mtdids : spi-nand0=spi-nand0
mtdparts: mtdparts=spi-nand0:2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)It looks as though the FSBL partition size is 0x00200000 and it located at 0x0; however, when I attempt to use cube programmer with this TSV:
#Opt Id Name Type IP Offset Binary
- 0x01 fsbl1-boot Binary none 0x0 arm-trusted-firmware/tf-a-stm32mp157c-viper-serialboot.stm32
- 0x03 ssbl-boot Binary none 0x0 bootloader/u-boot-stm32mp157c-viper-trusted.stm32
P 0x04 fsbl1 Binary spi-nand0 0x00000000 arm-trusted-firmware/tf-a-stm32mp157c-viper-trusted.stm32
P 0x05 fsbl2 Binary spi-nand0 0x00040000 arm-trusted-firmware/tf-a-stm32mp157c-viper-trusted.stm32
P 0x06 ssbl Binary spi-nand0 0x00080000 bootloader/u-boot-stm32mp157c-viper-trusted.stm32I get the following output. Note i have enabled some debug messages while I was trying to figure out what was going on so there maybe extra output than you would expect to see normally.
U-Boot 2021.01-rc3 (Dec 21 2020 - 20:40:01 +0000)
CPU: STM32MP157CAD Rev.B
Model: Toxic Performance Viper MK1
Board: stm32mp1 in trusted mode (toxicperformance;stm32mp157-viper-mk1)
stm32_smc: Failed to exec svc=82001003 op=1 in secure mode (err = -3)
DRAM: 512 MiB
Clocks:
- MPU : 650 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
In: serial
Out: serial
Err: serial
invalid MAC address in OTP 00:00:00:00:00:00
stm32_smc: Failed to exec svc=82001003 op=1 in secure mode (err = -3)
Net: No ethernet found.
Hit any key to stop autoboot: 0
Boot over usb0!
flash layout =
- 0x01 fsbl1-boot Binary none 0x0
- 0x03 ssbl-boot Binary none 0x0
P 0x04 fsbl1 Binary spi-nand0 0x00000000
P 0x05 fsbl2 Binary spi-nand0 0x00040000
P 0x06 ssbl Binary spi-nand0 0x00080000
spi-nand0
MTD device spi-nand0: size=536870912 erasesize=262144
available address = 0x0..0x20000000
erase size = 0x40000
full_update = 1
id : Opt Phase Name target.n dev.n addr size part_off part_size
01 : 1 04 fsbl1 00.1 04.00 00000000 00040000 00000000 00200000
Error: fsbl1 (0x4): Bad size for partition 1 (fsbl) at 0x0 = 0x40000 <> 0x200000 expected
DFU alt info setting: dfu_alt_add(ram, NULL,@FlashLayout/0x00/1*256Ke) result 0
dfu_alt_add(virt,241,@virtual/0xf1/1*512Be) result 0
dfu_alt_add(virt,242,@OTP/0xf2/1*512Be) result 0
dfu_alt_add(virt,244,@PMIC/0xf4/1*8Be) result 0
doneLine 39 has the error message that the size was incorrect. Been fighting this for a couple days now and really would appreciate a hint here!
The end goal is to load this flash with the entire image and boot linux from it but right now I am just trying to get the bootloaders to work.
One final note, I am using the 2021.01 version of u-boot because the 2020 version of u-boot does not have support for the Toshiba NAND part and the 2021 version does.
here is the output of MTD list to show the detected SPI NAND part
STM32MP> mtd list
List of MTD devices:
* spi-nand0
- device: tc58cyg2s0hraig@0
- parent: spi@58003000
- driver: spi_nand
- type: NAND flash
- block size: 0x40000 bytes
- min I/O: 0x1000 bytes
- OOB size: 256 bytes
- OOB available: 126 bytes
- 0x000000000000-0x000020000000 : "spi-nand0"
- 0x000000000000-0x000000200000 : "fsbl"
- 0x000000200000-0x000000400000 : "ssbl1"
- 0x000000400000-0x000000600000 : "ssbl2"
- 0x000000600000-0x000020000000 : "UBI"Thanks!
