[BPI-R3 Mini] Boot from NAND fails

I tried to boot into openwrt from emmc, the lan port resumed, I think it’s related to the driver not yet loaded when using u-boot

Finally, I found the windows notebook, but return as below (keep handshaking…) C:\temp\uartboot>mtk_uartboot -s com3 --aarch64 --payload bpi-r3mini_ram_bl2.bin --fip bpi-r3mini_ram_fip.bin mtk_uartboot - 0.1.1 Using serial port: com3 Handshake…

You have to start the app and then power on the board…

Possibly rooter firmware has no ethernet support in uboot or does not use same kind to load firmware or firmware was not flashed there

Thanks Frank-w, works now. see BPI-R3M> , I think it’s work Apology, I may mixed up the information, may I know again how to do next? Thanks again

The uboot you have now only resises in memory,no storage was touched. So after poweroff you have same state as before.

You can load anything from usb e.g. the openwrt files to do installation steps. Mtd should be compiled in my binary,but ubi i guess is missing. Maybe openwrt also has uboot.bin somewhere too which you could chainload (afaik fip does not work) with go command after loading it. See wiki page above. You could also start openwrt recovery from the uboot prompt, see manual kernel loading steps in my wiki (fatload,bootm with the right bootconf).

uploaded new uboot-binaries which should have the ubi-commands, so it should be possible to execute the commands from openwrt

these should be the needed vars from openwrt bpi-r3 env to install openwrt to nand (need to be defined via setenv)

snand_write_bl2=mtd erase bl2 0x0 0x100000 && mtd write bl2 $loadaddr 0x0 0x40000 && mtd write bl2 $loadaddr 0x40000 0x40000 && mtd write bl2 $loadaddr 0x80000 0x40000 && mtd write bl2 $loadaddr 0xc0000 0x40000
ubi_format=ubi detach ; mtd erase ubi && ubi part ubi
ubi_init=run ubi_format && run ubi_init_bl && run ubi_init_openwrt && run ubi_init_emmc_install
ubi_init_openwrt=run sdmmc_read_recovery && iminfo $loadaddr && run ubi_write_recovery ; run sdmmc_read_production && iminfo $loadaddr && run ubi_write_production
ubi_init_bl=run sdmmc_read_snand_bl2 && run snand_write_bl2 && run sdmmc_read_snand_fip && run ubi_write_fip
ubi_init_emmc_install=run sdmmc_read_emmc_install && run ubi_write_emmc_install
ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi
ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data
ubi_write_fip=run ubi_remove_rootfs ; ubi check fip && ubi remove fip ; ubi create fip 0x200000 static ; ubi write $loadaddr fip 0x200000
ubi_write_emmc_install=ubi check emmc_install && ubi remove emmc_install ; ubi create emmc_install 0x800000 dynamic ; ubi write $loadaddr emmc_install 0x800000
ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize
ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize

not sure where the nand bl2 is loaded from…maybe it can be done in an easier way manually…

Thanks Frank-w, let me try and get back again.

Hi Frank-w, I has been checking the related solution in the forum these days for related topic. And I would like to try below you posted before. https://wiki.fw-web.de/doku.php?id=en:bpi-r3:uboot#nand_flash

And may I know whether you have the files available for bpi-r3 min please? 17019020 bpi-r3.itb 579401 fip_nand.bin 217712 bl2_nand.img

Thanks

Bpi-r3.itb is in releases from my kernel repo. Uboot seems to be missing for r3mini nand…need to add this to my pipeline.

Edit: added and release available

Hi @frank-w, Thanks for your help again. I tried and looks good. if boot from NAND, I can see the u-boot menu with couple of items:

  1. Enter kernel-name to boot from SD/EMMC.
  2. Boot kernel from tftp
  3. boot from sd/emmc
  4. boot kernel from NVME

exit

Moreover, I tried to boot from emmc that included the openwrt snapshot OS. And I store all required bin/fib files into the usb drive. But the OS cannot detect the usb drive under /dev/sda1

May I know the next step please?

Thanks

My uboot (fip) should support usb,but access is different to linux…you have to run command “usb start” first and then you can list with “ls usb 0:1”,load file with “load usb 0:1 $loadaddr file”

In my uboot you can use also use “run useusb” for first 2 commands.

Hi @frank-w Thanks. I would like to know more: bpi-r3mini_spim-nand_bl2.img - is it the u-boot bpi-r3mini_spim-nand_fip.bin - is it the openwrt os? Thanks

No, bl2 is second state bootloader (first after internal bootrom) which loads bl3 (uboot/fip). There is no openwrt or any other linux based userspace. You have to install openwrt from uboot

These 2 files only give you a software console (uboot) to doadditional steps (booting a linux kernel e.g. with initrd or install any os like openwrt)

Thanks @frank-w, got it

If I run the fatload command to load the openwrt factory bin, what is the complete write command and be? seems need the locate like 0x000xxx something Thanks

I cannot help with openwrt.

Yes uboot write command of course need position to save the loaded data :slight_smile:

But openwrt also uses ubi which i’m not familar with.

Thanks @frank-w You already help a lot, appreciated Will try to find the way to work

Hi,

I also have trouble since I boot to nand and did an upgrade of the openwrt in the emmc. I read this thread and some others carefully.

I have an uboot with access to usb flash drive, so no need to play with tftp or mtk_uartboot…

This is what I figured out, how to restore the nand in my r3-mini:

mtd erase spi-nand0

load usb 0:1 $loadaddr bpi-r3mini_spim-nand_bl2.img

mtd write spi-nand0 $loadaddr 0x0 0x100000

load usb 0:1 $loadaddr bpi-r3mini_spim-nand_fip.bin

mtd write spi-nand0 $loadaddr 0x380000 0x200000

These command above are adopted from your wiki @frank-w (Thank you for giving that details.)

But I have a question left: In the section https://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r3:uboot#nand_flash, there’s a line BPI-R3> load usb 0:1 $loadaddr bpi-r3_emmc_2024.04_fip.bin —> is this really the correct image to load to ram? Later it’s copied to nand?

As far as I understand until now it should be a nand-image - that’s why I’m asking and that’s why I changed it in my command above to nand-fip.bin.

What I didn’t find out are the destination addresses or in other words, i wonder if the given address are correct for r3-mini, especially when flashing the fip-image. I asume the 0x0 0x100000 Adress for the bl2-image is correct (?), but is the dimension of the nand in r3-mini the same like in the r3? Can I use these addresses for the fip-image 0x380000 0x200000?

And then another thing that isn’t clear to me - maybe a very stupid question:

ubi - what’s that or what that used for?

Thanks

Sven

I read the datasheet of the r3. Nand is the same. So is it safe to flash the nand with that parameters?

mtd write spi-nand0 $loadaddr 0x0 0x100000 mtd write spi-nand0 $loadaddr 0x380000 0x200000

https://en.wikipedia.org/wiki/UBIFS#UBI