Boot UBIFS from dataflash (nor0)
- November 14, 2022
- 3 replies
- 3244 views
Hi Everybody,
I would like to completely boot kernel 5.10-dunfell (last year) from a 64MB dataflash (nor0). No mmc0 or nand0.
Compiled the correct DTS with TF-A, U-Boot and kernel, I would like to use the following TSV for STM32CubeProgrammer:
#Opt Id Name Type IP Offset Binary
- 0x01 fsbl1-boot Binary none 0x0 tf-a-stm32mp151a-***-mx-usb.stm32
- 0x03 fip-boot Binary none 0x0 fip-stm32mp151a-***-mx-trusted.bin
P 0x04 fsbl1 Binary nor0 0x00000000 tf-a-stm32mp151a-***-mx-nor.stm32
P 0x05 fsbl2 Binary nor0 0x00040000 tf-a-stm32mp151a-***-mx-nor.stm32
P 0x06 fip Binary nor0 0x00080000 fip-stm32mp151a-***-mx-trusted.bin
PDE 0x07 u-boot-env Binary nor0 0x00480000 none
P 0x10 UBI Binary nor0 0x00500000 rootfs.binwhere *** is my project code (obfuscated).
Once started, U-Boot fails to proceed to load rootfs.bin, which contains the kernel, modules and filesystem as a UBI partition. This was produced by Buildroot and it is valid; I checked loop-mounting it with mtdram. The type for UBI is Binary since, as I read somewhere, for big NORs System times out (and it does).
It is read by U-Boot:
STM32MP> mtdparts
SF: Detected mx66l51235l with page size 256 Bytes, erase size 64 KiB, total 64 MiB
device nor0 <nor0>, # parts = 5
#: name size offset mask_flags
0: fsbl1 0x00040000 0x00000000 0
1: fsbl2 0x00040000 0x00040000 0
2: fip 0x00400000 0x00080000 0
3: u-boot-env 0x00080000 0x00480000 0
4: UBI 0x03b00000 0x00500000 0
active partition: nor0,0 - (fsbl1) 0x00040000 @ 0x00000000
defaults:
mtdids : nor0=nor0
mtdparts: mtdparts=nor0:256k(fsbl1),256k(fsbl2),4m(fip),512k(u-boot-env),-(UBI)
STM32MP> ubi part UBI
<...hangs for a lot of time while it expands the image...>
STM32MP> ubi info
UBI: MTD device name: "UBI"
UBI: MTD device size: 59 MiB
UBI: physical eraseblock size: 65536 bytes (64 KiB)
UBI: logical eraseblock size: 65408 bytes
UBI: number of good PEBs: 944
UBI: number of bad PEBs: 0
UBI: smallest flash I/O unit: 1
UBI: VID header offset: 64 (aligned 64)
UBI: data offset: 128
UBI: max. allowed volumes: 128
UBI: wear-leveling threshold: 4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 1
UBI: available PEBs: 0
UBI: total number of reserved PEBs: 944
UBI: number of PEBs reserved for bad PEB handling: 0
UBI: max/mean erase counter: 1/0
STM32MP> ubifsmount ubi:rootfs
STM32MP> ubifsls /
<DIR> 5024 Mon Nov 21 13:18:30 2022 bin
<DIR> 608 Wed Oct 05 12:24:08 2022 dev
<DIR> 1432 Mon Nov 21 13:18:30 2022 etc
<DIR> 1472 Mon Nov 21 13:18:30 2022 lib
<DIR> 160 Wed Oct 05 12:24:08 2022 mnt
<DIR> 232 Wed Oct 19 13:01:42 2022 opt
<DIR> 160 Mon Nov 21 13:18:31 2022 run
<DIR> 160 Wed Oct 05 12:24:08 2022 tmp
<DIR> 160 Wed Oct 05 12:24:08 2022 sys
<DIR> 672 Mon Nov 21 13:18:31 2022 var
<DIR> 480 Mon Nov 21 13:18:31 2022 usr
<DIR> 504 Wed Oct 05 12:24:08 2022 boot
<DIR> 160 Wed Oct 05 12:24:08 2022 proc
<DIR> 3736 Wed Oct 05 16:02:52 2022 sbin
<DIR> 160 Wed Oct 05 12:24:08 2022 root
<LNK> 11 Wed Oct 05 16:02:52 2022 linuxrc
<LNK> 3 Wed Oct 05 16:01:28 2022 lib32
<DIR> 160 Wed Oct 05 12:24:08 2022 mediaA suspect issue is that to insert UBI in mtdparts, since saveenv is not working, I had to modify the U-Boot source code. Otherwise it would default to nor_user in board/st/common/stm32mp_mtdparts.c.
Instead of proceeding with UBI it tries to load kernel from SD-Card. In the U-Boot .config file I put the following setup:
CONFIG_MTDPARTS_NOR0_BOOT="256k(fsbl1),256k(fsbl2),4m(fip),512k(u-boot-env),-(UBI)"the whole U-Boot configuration file is attached. The configuration above should match the TSV.
In no example I have seen in the ST Wiki there is support for completely booting Linux from dataflash.
Is a complete boot from nor0 supported?
Thanks for your help,
Antonio
