Banana PI R4 - Attempts to install created image from Frank-w on EMMC

I create an image from Frank-w (BPI-Router-Images):

Settings:

imgfile=bpi-r4_emmc.img.gz

skipkerneldownload=1

kernelfile=bpi-r4_6.12.32-main.tar.gz

Next:

./buildimg.sh bpi-r4 bookworm 6.12.32

I try to transfer it to EMMC:

echo 0 > /sys/block/mmcblk0boot0/force_ro

cd /mnt/sda1

dd if=bpi-r4_emmc_bl2.img of=/dev/mmcblk0boot0

gunzip -c bpi-r4_bookworm_6.12.32-main.img.gz | dd bs=512 conv=notrunc,fsync of=/dev/mmcblk0

dd if=bpi-r4_emmc_fip.bin of=/dev/mmcblk0p4

mmc bootpart enable 1 1 /dev/mmcblk0

at the same time, if I create an image from bpi-r4_sdmmc.img.gz and write it to the SD card - everything works.

How to transfer the image to EMMC correctly?

Looks right so far. I’m not sure about the mmc bootpart command as i always did this from uboot. You did this after booting initrd from nand? You cannot access emmc after booting from sdcard because both share the emmc controller,but it looks like emmc itself is available. It would be interesting how far boot process goes,so please show bootlog (debug uart).

After running this build from SD card, another problem occurred. The build damaged the NAND bootloader. I understand that this is a result of using a UBI device. So until I restore the bootloader, I have no way to make changes to the EMMC sector.

Previous EMMC boot log:

NOTICE: BL2: v2.12.0(release):d50bccad1-bpi-r4-emmc

NOTICE: BL2: Built : 08:35:20, Jun 17 2025
NOTICE: WDT: Cold boot
NOTICE: WDT: disabled
NOTICE: CPU: MT7988
NOTICE: EMI: Using DDR unknown settings
NOTICE: EMI: Detected DRAM size: 4096 MB
NOTICE: EMI: complex R/W mem test passed
NOTICE: LVTS: Enable thermal HW reset
ERROR: Failed to initialize GPT partitions
ERROR: FIP boot source initialization failed with -2
PANIC at PC : 0x0000000000205da4

Have not tried ubi yet,only added the options. Also do nothing with nand (no write access). Normal bl2 should load fip from fip gpt partition. Wonder about the gpt error. Maybe you have to use the sgdisk workaround to update the backup gpt.

https://wiki.fw-web.de/doku.php?id=en:bpi-r3:start#partition_layout

i noticed, this check of the second table was removed at some point in ATF. But not sure if Exsoiner’s version has this check or not.

Backup table is never written by image because it is at the end of disk and image build process does not know how big the later disk is. It can only write the main gpt. The sgdisk uses the main gpt and writes the backup.

Why should atf change the gpt?

I guess I should make my statement more clear:

I meant this is removed in later versions:

But anyway, it only changed, so never mind my statement :wink:

They just moved it, still checking.

Edit:

But it will only use it, if the primary gpt is invalid.

I understand that there is no access from Linux, but there is access from the bl2 bootloader, or am I wrong?

This is what corrupts the NAND memory when executed:

[ 8.603751] mtdblock: MTD device ‘bl2’ is NAND, please consider using UBI block devices instead.
[ 8.604058] mtdblock: MTD device ‘ubi’ is NAND, please consider using UBI block devices instead.
[ 0.879017] spi-nand spi0.0: Winbond SPI NAND was found.
[ 0.884336] spi-nand spi0.0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
[ 0.892643] 2 fixed-partitions partitions found on MTD device spi0.0
[ 0.899015] OF: Bad cell count for /soc/spi@11007000/spi_nand@0/partitions
[ 0.905889] OF: Bad cell count for /soc/spi@11007000/spi_nand@0/partitions
[ 0.913023] Creating 2 MTD partitions on “spi0.0”:
[ 0.917813] 0x000000000000-0x000000200000 : “bl2”
[ 0.924553] 0x000000200000-0x000008000000 : “ubi”
[ 1.013483] ubi0: attaching mtd1
[ 1.847318] ubi0: scanning is finished
[ 1.916460] ubi0: attached mtd1 (name “ubi”, size 126 MiB)

Log is from linux,so it creates the ubifs and this breaks my current spi format.

Perhaps it would be better to remove the ubi.mtd= from the kernel command line and use the userspace tool `ubiattach’ to attach the ubi-device, only when needed.

But perhapse attaching ubi is still safe, but the corruption is started when the ubifs is mounted on a ubi-volume on the ubi-device…

1 Like

This is clear. I did not build the kernel, I used the ready one from your BPI-Router-Linux repository. In this case, the question is, how to disable the use of UBI? Rebuild the kernel myself by disabling the options related to UBI?

If i would find time i would change nand to ubi too like openwrt does. Was not aware that linux recreates ubi and so breaks nand.

Basicly ubi only starts after bl2,so fip gets overridden as it should be inside ubi. So you have to flash bl2 with ubi support and (somehow) get fip into the ubifs.

Need to look how this can be done and then change my image creation code.

Disabling ubi in kernel can be done by either disabling ubi options or changing devicetree dropping the ubi partition.

ubiformat -y /dev/mtd0
ubiattach -p /dev/mtd0
ubimkvol /dev/ubi0 -n 0 -N fip  -s 1MiB   -t static
ubiupdatevol /dev/ubi0_0 fip.bin

In a nutshell.

But check the devicenumbers for correctness :wink:

Creating an ubifs, for U-Boot loading kernel files , is a bit harder… I’ll post a new post for an example usage I’ve been working on.

1 Like

You mean inside uboot? Maybe creating from linux (sdcard) and only loading in uboot is easier.

Would be great if you post such thread. Also looked for a way to load fit and initrd from spi nand/nor. Ubi would be a generic way without fixed offsets.

Thats what I mean, and that is why I needed to have R3 (and probably R4) writing to nand from linux fixed. See: