Bananapi BPI-R3 bootloader

Hy ^^ I will try when i receive the R3. Thanks again for all your help.

Hy. I have received my r3 :slight_smile: I have tried with openwet, to be sure that thé board works. All fine ^^

I have tried with my OS, it doesn’t work like you think ^^

I will work on it

I forgotten the error code : BL2 failed to laod image id 3 (-2)

look if you have a fip-partition and flash fip to it, if it does not work try rebuilding uboot/fip

Hy :slight_smile:

When i checked the partitions of my SDcard ( fdisk -l), i have :

/    dev/sdb1                 34     424      391 195,5K  0 Vide  ==> BL2

    /dev/sdb2                425    1676     1252   626K  0 Vide ==>fip

    /dev/sdb3    *          1677  185996   184320    90M  c W95 FAT32 (LBA) ==> boot

    /dev/sdb4             185997 2541198  2355202   1,1G  f Étendue W95 (LBA) 
    /dev/sdb5             185998  902797   716800   350M 83 Linux ==>rootfs (buildroot)

    /dev/sdb6             902799 2541198  1638400   800M 83 Linux ==>Partition i created for Storage

Hy again ^^

I have tried to install manually.

first, thank to this link, i have done another gpt.

python mtk_gpt.py --i example/mt7986-sd.json --o gpt.gpt

In the mt7986-sd.json there is :

{
	"bl2" : {
		"start": 1024,
		"end" : 8191,
		"attributes": 4,
		"uuid" : "{19a4763a-6b19-4a4b-a0c4-8cc34f4c2b8a}"
	},

	"u-boot-env" : {
		"start": 8192,
		"end" : 9215,
		"uuid" : "{19a4763a-6b19-4a4b-a0c4-8cc34f4c2ab9}"
	},

	"factory" : {
		"start": 9216,
		"end" : 13311,
		"uuid" : "{8142c1b2-1697-41d9-b1bf-a88d76c7213f}"
	},

	"fip": {
		"start": 13312,
		"end" : 17407,
		"uuid" : "{18de6587-4f17-4e08-a6c9-d9d3d424f4c5}"
	},

	"kernel" : {
		"start": 17408,
		"end" : 82943,
		"uuid" : "{971f7556-ef1a-44cd-8b28-0cf8100b9c7e}"
	},

	"rootfs" : {
		"start": 82944,
		"end" : 607231,
		"uuid" : "{309a3e76-270b-41b2-b5d5-ed8154e7542b}"
	}
}

dd if=gpt.gpt of=/dev/sdb ==> ton install the gpt dd if=bl2.img of=/dev/sdb1 ==> for the bl2 dd if=fip.bin of=/dev/sdb4 ===> for the fip dd if=boot.vfat of=/dev/sdb5 ==> for partition with kernel, extlinux files dd if=rootfs.ext4 of=/dev/sdb6 ==> for partition rootfs

But i don’t know what i must put for : u-boot-env and factory. Can i delete the partition factory?

i have this error :

fit=bpi-r3.itb
failed to load 'bpi-r3.itb :frowning:

Yes,my uboot tries to load this file from boot partitition by default. Please do not delete any partitions.

That means uboot (fip) is correctly loaded.

See uEnv_r3.txt for more…starting from bootcmd variable. It tries to load uEnv.txt from boot partition first to overwrite builtin variables and then show bootmenu.

You can disable the bootcmd (with # before) in the builtin environment (need recompile/reflash) or exit the menu while booting to uboot console. Or you overwrite bootmenu_default and/or the bootmenu entries. The fit variable is picked by newboot and device/partition defines where to load it

uboot-env is if uboot writes his environment direct to mmc (not via file).this is afaik (if not done via offset in any header by vendor) not yet configured in my uboot. Please only touch last 2 partitions,not the first 4.

Factory is imho for firmware or a recovery system. Currently unused.

1 Like

Hy,

I only touche the two last partitions, like you advise me.

I have tried with bootcmd :

MMC:   mmc@11230000: 0
Loading Environment from MMC... unable to read ssr
unable to read ssr
*** Warning - bad CRC, using default environment

In:    serial@11002000
Out:   serial@11002000
Err:   serial@11002000
Net:
Warning: ethernet@15100000 (eth0) using random MAC address - 32:6a:16:0b:54:f7
eth0: ethernet@15100000
Hit any key to stop autoboot:  0

  *** U-Boot Boot Menu ***

      1. Enter kernel-name to boot from SD/EMMC.
      2. Boot from SD/EMMC.
      U-Boot console


  Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit
            extlinux/

0 file(s), 1 dir(s)

enter kernel name: Image-rescue
kernelinput=Image-rescue
## Error: "initrd" not defined
fit=Image-rescue
Failed to load 'Image-rescue'
RescueOS>

You have a file named Image-rescue on the boot-partition ( 0:5 )? In your putput i see only a folder extlinux…if Your file is located there you have to add this in front to your filename

E.g. extlinux/Image-rescue

It needs to be a fit. To load image.gz and dtb separately you have to change newboot function

If you want to use distroboot,you have to change config and drop my environment

1 Like

Thank you to answer me :slight_smile:

Yes the kernel image is : extlinux/Image-rescue ( the Name is for my project).

I use Image for kernel, note image.gz,is it possible? If not, i have image.gz so i can adapt.

I search to load Image and dtb separately.

I wll search in the config where i must modify to enable it. Configuration of uboot?

Thank again

you have to do fatload for Image(.gz) and dtb separately

Why don’t you want to use fit?

as i said, if you want to use distroboot, you have to enable it and disable default environment file.

but i have not tested distroboot yet, as with environment we can do some tricks like sd/emmc and nand/nor detection in uboot to load the right dt-overlay. afaik this is not possible in distroboot

hy :slight_smile:

I need to load separately dtb and Image, for the management of my board ( various rootfs with various kernel and dtb).

I have tried to modify the configuration of uboot : here the defconfig

Now i have the error distro_bootcmd

it’s going step by step :slight_smile:

i think i have a clue

https://github.com/lexa2/u-boot/commit/9167ee7db6f2a640bd40d2feb495a6aaf0b61fb6

i think i must adapt this patch for mt7986, what do you think?

Looks good,i’ve seen distroboot on r2pro uboot (and still use it on this board). And noticed that it needs some environment vars which are set in code and overridden by default env file which i use on mtk boards.

Hy;

Finally, i wil ltry with system fit ( by searching, i have found how to do the fit and i can put script in for select the rootfs )

But when i boot, i have an error : new format image overwritten - must reset the board to recover

here the config of the fit :

/dts-v1/;

 

/ {

description = "Simple image with single Linux kernel and FDT blob for GLMF";

#address-cells = <1>;

 

images {

kernel {

description = "Kernel";

data = /incbin/("Image-rescue");

type = "kernel";

arch = "arm64";

os = "linux";

compression = "none";

load = <0x46000000>;

entry = <0x46000000>;


};

fdt-1 {

description = "Flattened Device Tree blob";

data = /incbin/("dtb-rescue.dtb");

type = "flat_dt";

arch = "arm64";

compression = "none";

};

};

 

configurations {

default = "conf-1";

conf-1 {

description = "configuration 1 (Kernel & dtb)";

kernel = "kernel";

fdt = "fdt-1";

};

};

};

And here the config for the gpt editor :

	{
	"bl2" : {
		"start": 1024,
		"end" : 8191,
		"attributes": 4,
		"uuid" : "{19a4763a-6b19-4a4b-a0c4-8cc34f4c2b8a}"
	},

	"u-boot-env" : {
		"start": 8192,
		"end" : 9215,
		"uuid" : "{19a4763a-6b19-4a4b-a0c4-8cc34f4c2ab9}"
	},

	"factory" : {
		"start": 9216,
		"end" : 13311,
		"uuid" : "{8142c1b2-1697-41d9-b1bf-a88d76c7213f}"
	},

	"fip": {
		"start": 13312,
		"end" : 17407,
		"uuid" : "{18de6587-4f17-4e08-a6c9-d9d3d424f4c5}"
	},

	"kernel" : {
		"start": 17408,
		"end" : 201728,
		"uuid" : "{971f7556-ef1a-44cd-8b28-0cf8100b9c7e}"
	},

	"rootfs" : {
		"start": 201729,
		"end" : 1018929,
		"uuid" : "{309a3e76-270b-41b2-b5d5-ed8154e7542b}"
	}
}

Why not use my bpi-r3.its? It builds in the dto too.

You can fully compile all with my build.sh (or look there how i do it)

But i’m not sure distroboot can handle fit and how. R2pro used Image+fdt. It’s your choice.

As far as your uboot gets loaded your partition table is right. You have to tell uboot where (mmc 0:5 points to your/our kernel partition on first and only mmc controller) next stage (linux kernel) is located and which files should get loaded (filenames and type).

1 Like

Hy :slight_smile:First, thank you.

Thanks to your help, i succeeded to do my fit img (for kernel and dtb). When i flash the rootfs directly in the partition 6, it boots and it works :slight_smile: :slight_smile:

Curious as i am , i tried to include the rootfs (rootfs.cpio.gz) in the fit , it fails

## Error: "initrd" not defined
fit=diagbox.itb
75427660 bytes read in 7556 ms (9.5 MiB/s)
## Loading kernel from FIT Image at 46000000 ...
   Using 'conf-1' configuration
   Trying 'kernel' kernel subimage
     Description:  Kernel
     Type:         Kernel Image
     Compression:  gzip compressed
     Data Start:   0x460000c0
     Data Size:    9023926 Bytes = 8.6 MiB
     Architecture: AArch64
     OS:           Linux
     Load Address: 0x44000000
     Entry Point:  0x44000000
     Hash algo:    sha1
     Hash value:   db19bf77644b49dd92e368d44d550ee7622c4975
   Verifying Hash Integrity ... sha1+ OK
## Loading ramdisk from FIT Image at 46000000 ...
   Using 'conf-1' configuration
   Trying 'ramdisk' ramdisk subimage
     Description:  ramdisk
     Type:         RAMDisk Image
     Compression:  gzip compressed
     Data Start:   0x4689fec8
     Data Size:    66382645 Bytes = 63.3 MiB
     Architecture: AArch64
     OS:           Linux
     Load Address: unavailable
     Entry Point:  unavailable
     Hash algo:    sha1
     Hash value:   ae12420ae644183a5c56ce63f35ded3fcc38ee29
   Verifying Hash Integrity ... sha1+ OK
WARNING: 'compression' nodes for ramdisks are deprecated, please fix your .its file!
## Loading fdt from FIT Image at 46000000 ...
   Using 'conf-1' configuration
   Trying 'fdt' fdt subimage
     Description:  Flattened Device Tree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x4689b36c
     Data Size:    19100 Bytes = 18.7 KiB
     Architecture: AArch64
     Load Address: 0x47000000
     Hash algo:    sha1
     Hash value:   2fba374f801b81c839aa55c2f3c7182b44d4a4f3
   Verifying Hash Integrity ... sha1+ OK
Error: fdt overwritten
Could not find a valid device tree
RescueOS>

Here,the config for create the fit ( i have worked thanks to yours) :slight_smile:

/dts-v1/;
/ {
	description = "Kernel et dtb pour RescueOS";

	#address-cells = <1>;
	images {
		kernel {
			description = "Kernel";
			data = /incbin/("Image.gz");
			type = "kernel";
			arch = "arm64";
			os = "linux";
			compression = "gzip";
			load = <0x44000000>;
			entry = <0x44000000>;
			hash-1 {
				algo = "sha1";
			};
		};
		fdt {
			description = "Flattened Device Tree blob";
			data = /incbin/("diagbox.dtb");
			type = "flat_dt";
			arch = "arm64";
			load = <0x47000000>;
			compression = "none";
			hash-1 {
				algo = "sha1";
			};
		};
		ramdisk {
			description = "ramdisk";
			data = /incbin/("rootfs.cpio.gz");
			type = "ramdisk";
			arch = "arm64";
			os = "linux";
			compression = "gzip";
			hash-1 {
				algo = "sha1";
			};
		};
	};
 
	configurations {
		default = "conf-1";
		conf-1 {
			description = "Configuration";
			kernel = "kernel";
			fdt = "fdt";
			ramdisk = "ramdisk";
			hash-1 {
				algo = "sha1";
			};
		};
	};
};

And here,the config for the gpt :

{
	"bl2" : {
		"start": 1024,
		"end" : 8191,
		"attributes": 4,
		"uuid" : "{19a4763a-6b19-4a4b-a0c4-8cc34f4c2b8a}"
	},

	"u-boot-env" : {
		"start": 8192,
		"end" : 9215,
		"uuid" : "{19a4763a-6b19-4a4b-a0c4-8cc34f4c2ab9}"
	},

	"factory" : {
		"start": 9216,
		"end" : 13311,
		"uuid" : "{8142c1b2-1697-41d9-b1bf-a88d76c7213f}"
	},

	"fip": {
		"start": 13312,
		"end" : 17407,
		"uuid" : "{18de6587-4f17-4e08-a6c9-d9d3d424f4c5}"
	},

	"kernel" : {
		"start": 17408,
		"end" : 293888,
		"uuid" : "{971f7556-ef1a-44cd-8b28-0cf8100b9c7e}"
	},

	"rootfs" : {
		"start": 293889,
		"end" : 1342465,
		"uuid" : "{309a3e76-270b-41b2-b5d5-ed8154e7542b}"
	},

	"data" : {
		"start": 1342466,
		"end" : 6585346,
		"uuid" : "{309a3e76-270b-41b2-b5d5-ed8154e7542b}"
	}
}

Thanks again for all your help

maybe you have to relocate the initrd when using in fit…i changed position of fdt to apply the dtbo’s for nor/nand.but you can use standalone initrd by defining the initrd variable and calling newboot…you can take out the initrd address from there as it was working also after the relocation of base fdt

1 Like

Hy I succeeded ^^ I have delete the Line with adresse load for the dts, in the config of the fit.

My r3 boots with my custom Linux.

A lot thanks you for your help.