Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Following git repositories used for generating bl2.img and fip.bin file.
#kernel-5.4
1) https://github.com/frank-w/u-boot/tree/2024-04-bpi → for generating uboot.bin files .
2) https://github.com/frank-w/u-boot/tree/mtk-atf → for generating atf flow bootloader files (bl2.img and fip.bin)
#kernel-6.6
1) https://github.com/frank-w/u-boot/tree/2025-01-bpi → for generating uboot.bin files .
2) https://github.com/frank-w/u-boot/tree/mtk-atf-2025→ for generating atf flow bootloader files (bl2.img and fip.bin)

Changes in u-boot env file to make boot-loader compatible in loading kernel and rdkb os at initial boot-up itself.
#kernel-5.4

Code Block
themeEclipse
titleBootloader changes wrt RDKB BPIR4 specific of kernel-5.4 (bl2.patch)
collapsetrue
diff --git a/build.conf b/build.conf
index 217679e5393..7ee955fd48f 100644
--- a/build.conf
+++ b/build.conf
@@ -2,12 +2,11 @@ uploaduser=$USER
 uploadserver=r2
 uploaddir=/var/lib/tftp
 
-board=bpi-r2
 #board=bpi-r64
 #board=bpi-r2pro
 #board=bpi-r3
 #board=bpi-r3mini
-#board=bpi-r4
+board=bpi-r4
 
 #device=emmc
 #device=spi-nand
diff --git a/uEnv_r4.txt b/uEnv_r4.txt
index dc60a382cd2..0ca9b61df4a 100644
--- a/uEnv_r4.txt
+++ b/uEnv_r4.txt
@@ -1,82 +1,19 @@
 board=bpi-r4
 device=mmc
-partition=0:5
+partition_boot=0:3
 bootenv=uEnv.txt
 bootdevice=sd
-
-fit=bpi-r4.itb
-#bootconf="#conf-2"
-#initrd=rootfs.cpio.zst
-
-loadaddr=0x46000000
-uaddr=0x41e00000
 kaddr=0x46000000
-rdaddr=0x48000000
-
-root=/dev/mmcblk0p6 rootfstype=ext4 rootwait
-console=ttyS0,115200n1 earlycon=uart8250,mmio32,0x11000000
-bootopts=debug=7 mem=3G
-
-#version=-v0
-wifi_en=0
-sata_en=0
-
-usb_part=0:1
-
-nvme_boot=0:1
-nvme_root=/dev/nvme0n1p2
-
-#netboot
-ipaddr=192.168.0.19
-netmask=255.255.255.0
-serverip=192.168.0.10
-
-lstftp=if tftp ${loadaddr} ${serverip}:r4-itbfiles.lst;then setexpr listend ${loadaddr} + ${filesize};mw.b ${listend} 00 2;strings ${loadaddr};else echo "tftp download failed";fi
-askkernel=askenv kernelinput "enter kernel-name:";
-askbootnetfit=run lstftp askkernel;if printenv kernelinput; then setenv bootfile "${kernelinput}"; run bootnetfit;fi
-
-askbootnvme=run usenvme; if test "$device" = "nvme"; then run askkernel;if printenv kernelinput; then setenv fit $kernelinput;run newboot;fi;fi
-
-bootnetfit=run buildargs;if tftp $kaddr ${bootfile}; then bootm $kaddr;fi
-bootfile=bpi-r4.itb
-
-checkenv=test -e ${device} ${partition} ${bootenv}
-loadenvfile=if fatload ${device} ${partition} ${loadaddr} ${bootenv};then env import -t ${loadaddr} ${filesize};else echo "fatload (${bootenv}) failed";fi
-loadenv=if run checkenv;then run loadenvfile;fi
-resetenv=env default -a;printenv;
-
-loadkernel=fatload $device $partition $kaddr ${kernel}
-buildargs=setenv bootargs "board=${board} console=${console} root=${root} ${bootopts}
-
-useusb=if usb info; then usb reset;else usb start;fi; if ls usb $usb_part $usb_path; then setenv device usb;setenv partition $usb_part;fi
-usenvme=pci enum; nvme scan;nvme info; if ls nvme $nvme_boot;then setenv device "nvme";setenv partition $nvme_boot;setenv root $nvme_root;else echo "nvme partition not found";fi
-
-useinitrd=setenv bootopts "${bootopts} initrd=${rdaddr},100M";
-checkrd=if printenv initrd;then if fatload ${device} ${partition} ${rdaddr} ${initrd};then run useinitrd;fi;fi
-
-newboot=run checkrd; run setbootconf; run buildargs;if printenv fit;then setenv kernel ${fit};if run loadkernel; then bootm ${kaddr}${bootconf}; fi;fi;
-bootnetfit=run checkrd; run setbootconf;run buildargs;if tftp $kaddr ${bootfile}; then bootm ${kaddr}${bootconf};fi
-
-checkmmc=if mmc partconf 0; then echo "emmc available";mmcdev="emmc";else echo "sd available";mmcdev="sd";fi
-checksata=if test -n "$sata_en" && test $sata_en -eq 1;then setenv satacfg "#sata"; fi
-checkwifi=if test -n "$wifi_en" && test $wifi_en -eq 1;then setenv wificfg "#wifi"; fi
-setbootconf=run checkmmc checksata checkwifi;setenv bootconf "#conf-$mmcdev$version$wificfg$satacfg";printenv bootconf
-
-wrspimnand=if printenv bl2file;then if fatload $device $partition $loadaddr $bl2file;then mtd erase spi-nand0 0x0 0x100000;mtd write spi-nand0 $loadaddr 0x0 0x100000;else echo "loading bl2 $bl2file failed";fi;else echo "bl2file not defined";fi;if printenv fipfile;then if fatload $device $partition $loadaddr $fipfile;then mtd erase spi-nand0 0x580000 0x200000;mtd write spi-nand0 $loadaddr 0x580000 0x200000;else echo "loading fip $fipfile failed";fi;else echo "fipfile not defined";fi
-wremmc=if printenv bl2file;then mmc partconf 0 1 1 1;if fatload $device $partition $loadaddr $bl2file;then mmc erase 0x0 0x400;mmc write ${loadaddr} 0x0 0x400;else echo "loading bl2 $bl2file failed";fi;else echo "bl2file not defined";fi;mmc partconf 0 1 1 0;if printenv fipfile;then if fatload $device $partition $loadaddr $fipfile;then mmc erase 0x3400 0x1000;mmc write ${loadaddr} 0x3400 0x1000;else echo "loading fip $fipfile failed";fi;else echo "fipfile not defined";fi
-
-bootdelay=0
-bootcmd=setenv bootdelay 3; run loadenv;bootmenu;
-
-lskernel=ls ${device} ${partition};
-askkernel=askenv kernelinput "enter kernel name:";
-
-boot0=run lskernel;run askkernel;if printenv kernelinput ;then setenv fit ${kernelinput}; run newboot; fi;
-
-bootmenu_0=1. Enter kernel-name to boot from SD/EMMC.=run boot0
-bootmenu_1=2. Boot kernel from TFTP.=run askbootnetfit
-bootmenu_2=3. Boot from SD/EMMC.=run newboot
-bootmenu_3=4. Boot kernel from NVME.=run askbootnvme
+loadaddr=0x60000000
+bootenv=uEnv.txt
+kernel=fitImage
+fit=mt7988a-bananapi-bpi-r4-sd.dtb
 
-bootmenu_default=2
+bootmenu_0=1. Load image from sdcard .=run rdkb_bpir4
+bootargs=earlycon console=ttyS0,115200 root=/dev/mmcblk0p4 rootfstype=ext4 rw rootwait  debug=7
+rdkb_bpir4=run rdkb-kernel ;run rdkb-dtb ;run rdkb-run
+rdkb-dtb=fatload mmc 0\:3 ${loadaddr} ${fit}
+rdkb-kernel=fatload mmc 0\:3 ${kaddr} ${kernel} 
+rdkb-run=bootm ${kaddr} - ${loadaddr}
 
+bootcmd=setenv bootdelay 3 ;bootmenu;


Changes in u-boot env file to make boot-loader compatible for passive bank switching in loading kernel and rdkb os at initial boot-up itself (bl2_B.patch).

Code Block
themeEclipse
titleBootloader changes wrt RDKB BPIR4 specific of kernel-5.4 (bl2_B.patch)
collapsetrue
diff --git a/build.conf b/build.conf
index 217679e5393..7ee955fd48f 100644
--- a/build.conf
+++ b/build.conf
@@ -2,12 +2,11 @@ uploaduser=$USER
 uploadserver=r2
 uploaddir=/var/lib/tftp
 
-board=bpi-r2
 #board=bpi-r64
 #board=bpi-r2pro
 #board=bpi-r3
 #board=bpi-r3mini
-#board=bpi-r4
+board=bpi-r4
 
 #device=emmc
 #device=spi-nand
diff --git a/uEnv_r4.txt b/uEnv_r4.txt
index dc60a382cd2..2a4f5a20ba1 100644
--- a/uEnv_r4.txt
+++ b/uEnv_r4.txt
@@ -1,82 +1,28 @@
+# Device info
 board=bpi-r4
 device=mmc
-partition=0:5
+partition_boot=0:7
 bootenv=uEnv.txt
 bootdevice=sd
 
-fit=bpi-r4.itb
-#bootconf="#conf-2"
-#initrd=rootfs.cpio.zst
-
-loadaddr=0x46000000
-uaddr=0x41e00000
+# Memory addresses
 kaddr=0x46000000
-rdaddr=0x48000000
-
-root=/dev/mmcblk0p6 rootfstype=ext4 rootwait
-console=ttyS0,115200n1 earlycon=uart8250,mmio32,0x11000000
-bootopts=debug=7 mem=3G
-
-#version=-v0
-wifi_en=0
-sata_en=0
-
-usb_part=0:1
-
-nvme_boot=0:1
-nvme_root=/dev/nvme0n1p2
-
-#netboot
-ipaddr=192.168.0.19
-netmask=255.255.255.0
-serverip=192.168.0.10
-
-lstftp=if tftp ${loadaddr} ${serverip}:r4-itbfiles.lst;then setexpr listend ${loadaddr} + ${filesize};mw.b ${listend} 00 2;strings ${loadaddr};else echo "tftp download failed";fi
-askkernel=askenv kernelinput "enter kernel-name:";
-askbootnetfit=run lstftp askkernel;if printenv kernelinput; then setenv bootfile "${kernelinput}"; run bootnetfit;fi
-
-askbootnvme=run usenvme; if test "$device" = "nvme"; then run askkernel;if printenv kernelinput; then setenv fit $kernelinput;run newboot;fi;fi
-
-bootnetfit=run buildargs;if tftp $kaddr ${bootfile}; then bootm $kaddr;fi
-bootfile=bpi-r4.itb
-
-checkenv=test -e ${device} ${partition} ${bootenv}
-loadenvfile=if fatload ${device} ${partition} ${loadaddr} ${bootenv};then env import -t ${loadaddr} ${filesize};else echo "fatload (${bootenv}) failed";fi
-loadenv=if run checkenv;then run loadenvfile;fi
-resetenv=env default -a;printenv;
-
-loadkernel=fatload $device $partition $kaddr ${kernel}
-buildargs=setenv bootargs "board=${board} console=${console} root=${root} ${bootopts}
-
-useusb=if usb info; then usb reset;else usb start;fi; if ls usb $usb_part $usb_path; then setenv device usb;setenv partition $usb_part;fi
-usenvme=pci enum; nvme scan;nvme info; if ls nvme $nvme_boot;then setenv device "nvme";setenv partition $nvme_boot;setenv root $nvme_root;else echo "nvme partition not found";fi
-
-useinitrd=setenv bootopts "${bootopts} initrd=${rdaddr},100M";
-checkrd=if printenv initrd;then if fatload ${device} ${partition} ${rdaddr} ${initrd};then run useinitrd;fi;fi
-
-newboot=run checkrd; run setbootconf; run buildargs;if printenv fit;then setenv kernel ${fit};if run loadkernel; then bootm ${kaddr}${bootconf}; fi;fi;
-bootnetfit=run checkrd; run setbootconf;run buildargs;if tftp $kaddr ${bootfile}; then bootm ${kaddr}${bootconf};fi
-
-checkmmc=if mmc partconf 0; then echo "emmc available";mmcdev="emmc";else echo "sd available";mmcdev="sd";fi
-checksata=if test -n "$sata_en" && test $sata_en -eq 1;then setenv satacfg "#sata"; fi
-checkwifi=if test -n "$wifi_en" && test $wifi_en -eq 1;then setenv wificfg "#wifi"; fi
-setbootconf=run checkmmc checksata checkwifi;setenv bootconf "#conf-$mmcdev$version$wificfg$satacfg";printenv bootconf
-
-wrspimnand=if printenv bl2file;then if fatload $device $partition $loadaddr $bl2file;then mtd erase spi-nand0 0x0 0x100000;mtd write spi-nand0 $loadaddr 0x0 0x100000;else echo "loading bl2 $bl2file failed";fi;else echo "bl2file not defined";fi;if printenv fipfile;then if fatload $device $partition $loadaddr $fipfile;then mtd erase spi-nand0 0x580000 0x200000;mtd write spi-nand0 $loadaddr 0x580000 0x200000;else echo "loading fip $fipfile failed";fi;else echo "fipfile not defined";fi
-wremmc=if printenv bl2file;then mmc partconf 0 1 1 1;if fatload $device $partition $loadaddr $bl2file;then mmc erase 0x0 0x400;mmc write ${loadaddr} 0x0 0x400;else echo "loading bl2 $bl2file failed";fi;else echo "bl2file not defined";fi;mmc partconf 0 1 1 0;if printenv fipfile;then if fatload $device $partition $loadaddr $fipfile;then mmc erase 0x3400 0x1000;mmc write ${loadaddr} 0x3400 0x1000;else echo "loading fip $fipfile failed";fi;else echo "fipfile not defined";fi
-
-bootdelay=0
-bootcmd=setenv bootdelay 3; run loadenv;bootmenu;
+loadaddr=0x60000000
 
-lskernel=ls ${device} ${partition};
-askkernel=askenv kernelinput "enter kernel name:";
+# File names on boot partition
+kernel=fitImage    # this is the FIT image (includes kernel + dtb)
+fit=mt7988a-bananapi-bpi-r4-sd.dtb
 
-boot0=run lskernel;run askkernel;if printenv kernelinput ;then setenv fit ${kernelinput}; run newboot; fi;
+# Boot arguments
+bootargs=earlycon console=ttyS0,115200 root=/dev/mmcblk0p8 rootfstype=ext4 rw rootwait debug=7
 
-bootmenu_0=1. Enter kernel-name to boot from SD/EMMC.=run boot0
-bootmenu_1=2. Boot kernel from TFTP.=run askbootnetfit
-bootmenu_2=3. Boot from SD/EMMC.=run newboot
-bootmenu_3=4. Boot kernel from NVME.=run askbootnvme
+rdkb_bpir4=run rdkb-kernel ;run rdkb-dtb ;run rdkb-run
+rdkb-kernel=fatload mmc 0\:7 ${kaddr} ${kernel}
+rdkb-dtb=fatload mmc 0\:7 ${loadaddr} ${fit}
+rdkb-run=bootm ${kaddr} - ${loadaddr}
 
-bootmenu_default=2
+# Boot menu entry
+bootmenu_0=1. Boot RDK-B from Boot B partition.=run rdkb_bpir4
 
+# Boot entry
+bootcmd=setenv bootdelay 3 ;bootmenu;

Changes in ATF's build.sh script.#kernel-6.6

Code Block
themeEclipse
titleChanges in atf (fipBootloader changes wrt RDKB BPIR4 specific of kernel- 6.6 (bl2.patch)
collapsetrue
diff --git a/build.shconf b/build.shconf
index 6939bd1ee87217679e5393..8837ddf1517145f40152e2 100755100644
--- a/build.shconf
+++ b/build.shconf
@@ -32,913 +32,812 @@ export LANGuploaduser=C$USER
 export ARCHuploadserver=arm64r2
 export CROSS_COMPILE=aarch64-linux-gnu-uploaddir=/var/lib/tftp
 
-board="bpi-r3"r2
 #board=bpi-r64
 #board=bpi-r2pro
 #board=bpi-r3
 #board="bpi-r64"r3mini
-#board="bpi-r4"
+board="bpi-r4"
 
-#device=emmc
+device="sdmmc"
 #device="emmc"
 #device="spim-nand"

Building bl2.img and fip.bin in case of not having access to artifactory repository

...

sdmmc
 #device=spi-nand
 #device=spi-nor
diff --git a/uEnv_r4.txt b/uEnv_r4.txt
index 883c47b8b7b..c6f373dee51 100644
--- a/uEnv_r4.txt
+++ b/uEnv_r4.txt
@@ -1,83 +1,19 @@
 board=bpi-r4
 device=mmc
-partition=0:5
+partition_boot=0:3
 bootenv=uEnv.txt
 bootdevice=sd
-
-fit=bpi-r4.itb
-#bootconf="#conf-2"
-#initrd=rootfs.cpio.zst
-
-loadaddr=0x46000000
-uaddr=0x41e00000
-kaddr=0x46000000
-rdaddr=0x48000000
-
-root=/dev/mmcblk0p6 rootfstype=ext4 rootwait
-console=ttyS0,115200n1 earlycon=uart8250,mmio32,0x11000000
-bootopts=debug=7
-
-#version=-v0
-wifi_en=0
-sata_en=0
-
-usb_part=0:1
-
-nvme_boot=0:1
-nvme_root=/dev/nvme0n1p2
-
-#netboot
-ipaddr=192.168.0.19
-netmask=255.255.255.0
-serverip=192.168.0.10
-
-lstftp=if tftp ${loadaddr} ${serverip}:r4-itbfiles.lst;then setexpr listend ${loadaddr} + ${filesize};mw.b ${listend} 00 2;strings ${loadaddr};else echo "tftp download failed";fi
-askkernel=askenv kernelinput "enter kernel-name:";
-askbootnetfit=run lstftp askkernel;if printenv kernelinput; then setenv bootfile "${kernelinput}"; run bootnetfit;fi
-
-askbootnvme=run usenvme; if test "$device" = "nvme"; then run askkernel;if printenv kernelinput; then setenv fit $kernelinput;run newboot;fi;fi
-
-bootnetfit=run buildargs;if tftp $kaddr ${bootfile}; then bootm $kaddr;fi
-bootfile=bpi-r4.itb
-
-checkenv=test -e ${device} ${partition} ${bootenv}
-loadenvfile=if fatload ${device} ${partition} ${loadaddr} ${bootenv};then env import -t ${loadaddr} ${filesize};else echo "fatload (${bootenv}) failed";fi
-loadenv=if run checkenv;then run loadenvfile;fi
-resetenv=env default -a;printenv;
-
-loadkernel=fatload $device $partition $kaddr ${kernel}
-buildargs=setenv bootargs "board=${board} console=${console} root=${root} ${bootopts}
-
-useusb=if usb info; then usb reset;else usb start;fi; if ls usb $usb_part $usb_path; then setenv device usb;setenv partition $usb_part;fi
-usenvme=pci enum; nvme scan;nvme info; if ls nvme $nvme_boot;then setenv device "nvme";setenv partition $nvme_boot;setenv root $nvme_root;else echo "nvme partition not found";fi
-
-useinitrd=setenv bootopts "${bootopts} initrd=${rdaddr},100M";
-checkrd=if printenv initrd;then if fatload ${device} ${partition} ${rdaddr} ${initrd};then run useinitrd;fi;fi
-
-newboot=run checkrd; run setbootconf; run buildargs;if printenv fit;then setenv kernel ${fit};if run loadkernel; then bootm ${kaddr}${bootconf}; fi;fi;
-bootnetfit=run checkrd; run setbootconf;run buildargs;if tftp $kaddr ${bootfile}; then bootm ${kaddr}${bootconf};fi
-
-checkmmc=if mmc partconf 0; then echo "emmc available";mmcdev="emmc";else echo "sd available";mmcdev="sd";fi
-checksata=if test -n "$sata_en" && test $sata_en -eq 1;then setenv satacfg "#sata"; fi
-checkwifi=if test -n "$wifi_en" && test $wifi_en -eq 1;then setenv wificfg "#wifi"; fi
-check2g5=if test -n "$is2g5" && test $is2g5 -eq 1;then setenv variant "-2g5"; fi
-setbootconf=run check2g5;run checkmmc;run checksata;run checkwifi;setenv bootconf "#conf-base$variant#ov-$mmcdev$version$wificfg$satacfg";printenv bootconf
-
-wrspimnand=if printenv bl2file;then if fatload $device $partition $loadaddr $bl2file;then mtd erase spi-nand0 0x0 0x100000;mtd write spi-nand0 $loadaddr 0x0 0x100000;else echo "loading bl2 $bl2file failed";fi;else echo "bl2file not defined";fi;if printenv fipfile;then if fatload $device $partition $loadaddr $fipfile;then mtd erase spi-nand0 0x580000 0x200000;mtd write spi-nand0 $loadaddr 0x580000 0x200000;else echo "loading fip $fipfile failed";fi;else echo "fipfile not defined";fi
-wremmc=if printenv bl2file;then mmc partconf 0 1 1 1;if fatload $device $partition $loadaddr $bl2file;then mmc erase 0x0 0x400;mmc write ${loadaddr} 0x0 0x400;else echo "loading bl2 $bl2file failed";fi;else echo "bl2file not defined";fi;mmc partconf 0 1 1 0;if printenv fipfile;then if fatload $device $partition $loadaddr $fipfile;then mmc erase 0x3400 0x1000;mmc write ${loadaddr} 0x3400 0x1000;else echo "loading fip $fipfile failed";fi;else echo "fipfile not defined";fi
-
-bootdelay=0
-bootcmd=setenv bootdelay 3; run loadenv;bootmenu;
-
-lskernel=ls ${device} ${partition};
-askkernel=askenv kernelinput "enter kernel name:";
-
-boot0=run lskernel;run askkernel;if printenv kernelinput ;then setenv fit ${kernelinput}; run newboot; fi;
-
-bootmenu_0=1. Enter kernel-name to boot from SD/EMMC.=run boot0
-bootmenu_1=2. Boot kernel from TFTP.=run askbootnetfit
-bootmenu_2=3. Boot from SD/EMMC.=run newboot
-bootmenu_3=4. Boot kernel from NVME.=run askbootnvme
-
-bootmenu_default=2
-
+kaddr=0x42000000
+loadaddr=0x60000000
+bootenv=uEnv.txt
+kernel=fitImage
+fit=mt7988a-bananapi-bpi-r4.dtb
+ 
+bootmenu_0=1. Load image from sdcard .=run rdkb_bpir4
+bootargs=earlycon console=ttyS0,115200 root=/dev/mmcblk0p4 rootfstype=ext4 rw rootwait  debug=7
+rdkb_bpir4=run rdkb-kernel ;run rdkb-dtb ;run rdkb-run
+rdkb-dtb=fatload mmc 0\:3 ${loadaddr} ${fit}
+rdkb-kernel=fatload mmc 0\:3 ${kaddr} ${kernel}
+rdkb-run=bootm ${kaddr} - ${loadaddr}
+ 
+bootcmd=setenv bootdelay 3 ;bootmenu;
Code Block
titleBootloader changes wrt RDKB BPIR4 specific of kernel- 6.6 (bl2_B.patch)
collapsetrue
diff --git a/build.conf b/build.conf
index 217679e5393..145f40152e2 100644
--- a/build.conf
+++ b/build.conf
@@ -2,13 +2,12 @@ uploaduser=$USER
 uploadserver=r2
 uploaddir=/var/lib/tftp
 
-board=bpi-r2
 #board=bpi-r64
 #board=bpi-r2pro
 #board=bpi-r3
 #board=bpi-r3mini
-#board=bpi-r4
+board=bpi-r4
 
-#device=emmc
+device=sdmmc
 #device=spi-nand
 #device=spi-nor
diff --git a/uEnv_r4.txt b/uEnv_r4.txt
index 883c47b8b7b..c6f373dee51 100644
--- a/uEnv_r4.txt
+++ b/uEnv_r4.txt
@@ -1,83 +1,19 @@
 board=bpi-r4
 device=mmc
-partition=0:5
+partition_boot=0:7
 bootenv=uEnv.txt
 bootdevice=sd
-
-fit=bpi-r4.itb
-#bootconf="#conf-2"
-#initrd=rootfs.cpio.zst
-
-loadaddr=0x46000000
-uaddr=0x41e00000
-kaddr=0x46000000
-rdaddr=0x48000000
-
-root=/dev/mmcblk0p6 rootfstype=ext4 rootwait
-console=ttyS0,115200n1 earlycon=uart8250,mmio32,0x11000000
-bootopts=debug=7
-
-#version=-v0
-wifi_en=0
-sata_en=0
-
-usb_part=0:1
-
-nvme_boot=0:1
-nvme_root=/dev/nvme0n1p2
-
-#netboot
-ipaddr=192.168.0.19
-netmask=255.255.255.0
-serverip=192.168.0.10
-
-lstftp=if tftp ${loadaddr} ${serverip}:r4-itbfiles.lst;then setexpr listend ${loadaddr} + ${filesize};mw.b ${listend} 00 2;strings ${loadaddr};else echo "tftp download failed";fi
-askkernel=askenv kernelinput "enter kernel-name:";
-askbootnetfit=run lstftp askkernel;if printenv kernelinput; then setenv bootfile "${kernelinput}"; run bootnetfit;fi
-
-askbootnvme=run usenvme; if test "$device" = "nvme"; then run askkernel;if printenv kernelinput; then setenv fit $kernelinput;run newboot;fi;fi
-
-bootnetfit=run buildargs;if tftp $kaddr ${bootfile}; then bootm $kaddr;fi
-bootfile=bpi-r4.itb
-
-checkenv=test -e ${device} ${partition} ${bootenv}
-loadenvfile=if fatload ${device} ${partition} ${loadaddr} ${bootenv};then env import -t ${loadaddr} ${filesize};else echo "fatload (${bootenv}) failed";fi
-loadenv=if run checkenv;then run loadenvfile;fi
-resetenv=env default -a;printenv;
-
-loadkernel=fatload $device $partition $kaddr ${kernel}
-buildargs=setenv bootargs "board=${board} console=${console} root=${root} ${bootopts}
-
-useusb=if usb info; then usb reset;else usb start;fi; if ls usb $usb_part $usb_path; then setenv device usb;setenv partition $usb_part;fi
-usenvme=pci enum; nvme scan;nvme info; if ls nvme $nvme_boot;then setenv device "nvme";setenv partition $nvme_boot;setenv root $nvme_root;else echo "nvme partition not found";fi
-
-useinitrd=setenv bootopts "${bootopts} initrd=${rdaddr},100M";
-checkrd=if printenv initrd;then if fatload ${device} ${partition} ${rdaddr} ${initrd};then run useinitrd;fi;fi
-
-newboot=run checkrd; run setbootconf; run buildargs;if printenv fit;then setenv kernel ${fit};if run loadkernel; then bootm ${kaddr}${bootconf}; fi;fi;
-bootnetfit=run checkrd; run setbootconf;run buildargs;if tftp $kaddr ${bootfile}; then bootm ${kaddr}${bootconf};fi
-
-checkmmc=if mmc partconf 0; then echo "emmc available";mmcdev="emmc";else echo "sd available";mmcdev="sd";fi
-checksata=if test -n "$sata_en" && test $sata_en -eq 1;then setenv satacfg "#sata"; fi
-checkwifi=if test -n "$wifi_en" && test $wifi_en -eq 1;then setenv wificfg "#wifi"; fi
-check2g5=if test -n "$is2g5" && test $is2g5 -eq 1;then setenv variant "-2g5"; fi
-setbootconf=run check2g5;run checkmmc;run checksata;run checkwifi;setenv bootconf "#conf-base$variant#ov-$mmcdev$version$wificfg$satacfg";printenv bootconf
-
-wrspimnand=if printenv bl2file;then if fatload $device $partition $loadaddr $bl2file;then mtd erase spi-nand0 0x0 0x100000;mtd write spi-nand0 $loadaddr 0x0 0x100000;else echo "loading bl2 $bl2file failed";fi;else echo "bl2file not defined";fi;if printenv fipfile;then if fatload $device $partition $loadaddr $fipfile;then mtd erase spi-nand0 0x580000 0x200000;mtd write spi-nand0 $loadaddr 0x580000 0x200000;else echo "loading fip $fipfile failed";fi;else echo "fipfile not defined";fi
-wremmc=if printenv bl2file;then mmc partconf 0 1 1 1;if fatload $device $partition $loadaddr $bl2file;then mmc erase 0x0 0x400;mmc write ${loadaddr} 0x0 0x400;else echo "loading bl2 $bl2file failed";fi;else echo "bl2file not defined";fi;mmc partconf 0 1 1 0;if printenv fipfile;then if fatload $device $partition $loadaddr $fipfile;then mmc erase 0x3400 0x1000;mmc write ${loadaddr} 0x3400 0x1000;else echo "loading fip $fipfile failed";fi;else echo "fipfile not defined";fi
-
-bootdelay=0
-bootcmd=setenv bootdelay 3; run loadenv;bootmenu;
-
-lskernel=ls ${device} ${partition};
-askkernel=askenv kernelinput "enter kernel name:";
-
-boot0=run lskernel;run askkernel;if printenv kernelinput ;then setenv fit ${kernelinput}; run newboot; fi;
-
-bootmenu_0=1. Enter kernel-name to boot from SD/EMMC.=run boot0
-bootmenu_1=2. Boot kernel from TFTP.=run askbootnetfit
-bootmenu_2=3. Boot from SD/EMMC.=run newboot
-bootmenu_3=4. Boot kernel from NVME.=run askbootnvme
-
-bootmenu_default=2
-
+kaddr=0x42000000
+loadaddr=0x60000000
+bootenv=uEnv.txt
+kernel=fitImage
+fit=mt7988a-bananapi-bpi-r4.dtb
+ 
+bootmenu_0=1. Load image from sdcard .=run rdkb_bpir4
+bootargs=earlycon console=ttyS0,115200 root=/dev/mmcblk0p8 rootfstype=ext4 rw rootwait  debug=7
+rdkb_bpir4=run rdkb-kernel ;run rdkb-dtb ;run rdkb-run
+rdkb-dtb=fatload mmc 0\:7 ${loadaddr} ${fit}
+rdkb-kernel=fatload mmc 0\:7 ${kaddr} ${kernel}
+rdkb-run=bootm ${kaddr} - ${loadaddr}
+ 
+bootcmd=setenv bootdelay 3 ;bootmenu;


Changes in ATF's build.sh script.

Code Block
themeEclipse
titleChanges in atf (fip.patch)
collapsetrue
diff --git a/build.sh b/build.sh
index 6939bd1ee87..8837ddf1517 100755
--- a/build.sh
+++ b/build.sh
@@ -3,9 +3,8 @@ export LANG=C
 export ARCH=arm64
 export CROSS_COMPILE=aarch64-linux-gnu-
 
-board="bpi-r3"
 #board="bpi-r64"
-#board="bpi-r4"
+board="bpi-r4"
 device="sdmmc"
 #device="emmc"
 #device="spim-nand"

Building bl2.img and fip.bin in case of not having access to artifactory repository

Build instruction to create bl2.img and fip.bin in local linux machine(Ubuntu 22.04).
#Kernel-5.4

Code Block
titleBuilding BL2 and FIP binaries of kernel-5.4 in local machine (Ubuntu 22.04)
collapsetrue
### Prerequisite packages
$ sudo apt-get install gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu libc6-armhf-cross u-boot-tools make gcc swig python3-pyelftools flex

### Building u-boot binaries
$ mkdir BL2 && cd BL2
$ git clone https://github.com/frank-w/u-boot.git -b 2024-04-bpi
$ cd u-boot
$ git apply bl2.patch ## See above - patch content is provided in above block.
$ make mt7988a_bpir4_sd_defconfig
$ export CROSS_COMPILE=aarch64-linux-gnu-
$ ./build.sh

### Building FIP binary
$ cd ../..
$ mkdir FIP && cd FIP
$ git clone https://github.com/frank-w/u-boot.git -b mtk-atf
$ cd u-boot
$ git apply fip.patch ## See above - patch content is provided in above block.

### Copy all u-boot.* files for creating fip.bin
$ cp ../../BL2/u-boot/u-boot.* .
$ ./build.sh


### Both bl2.img and fip.bin are present folder ./build/mt7988/release
$ cd ./build/mt7988/release
$ ls bl2.img fip.bin

### Renaming binaries as per Yocto's wks file
$ mv bl2.img bpi-r4_sdmmc_bl2.img
$ mv fip.bin bpi-r4_sdmmc_fip.bin
Code Block
titleBuilding BL2 and FIP binaries for Passive Bank kernel-5.4 in local machine (Ubuntu 22.04)
collapsetrue
### Prerequisite packages
$ sudo apt-get install gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu libc6-armhf-cross u-boot-tools make gcc swig python3-pyelftools flex

### Building u-boot binaries
$ mkdir BL2 && cd BL2
$ git clone https://github.com/frank-w/u-boot.git -b 2024-04-bpi
$ cd u-boot
$ git apply bl2_B.patch ## See above - patch content is provided in above block.
$ make mt7988a_bpir4_sd_defconfig
$ export CROSS_COMPILE=aarch64-linux-gnu-
$ ./build.sh

### Building FIP binary
$ cd ../..
$ mkdir FIP && cd FIP
$ git clone https://github.com/frank-w/u-boot.git -b mtk-atf
$ cd u-boot
$ git apply fip.patch ## See above - patch content is provided in above block.

### Copy all u-boot.* files for creating fip.bin
$ cp ../../BL2/u-boot/u-boot.* .
$ ./build.sh


### Both bl2.img and fip.bin are present folder ./build/mt7988/release
$ cd ./build/mt7988/release
$ ls bl2.img fip.bin

### Renaming binaries as per Yocto's wks file
$ mv bl2.img bpi-r4_sdmmc_bl2_B.img
$ mv fip.bin bpi-r4_sdmmc_fip.bin_sdmmc_fip_B.bin


#Build instruction to create bl2.img and fip.bin for Passive Bank in local linux machine(Ubuntu 22.04).kernel-6.6

Code Block
titleBuilding BL2 and FIP binaries for Passive Bank of kernel6.6 in local machine (Ubuntu 22.04)
collapsetrue
### Prerequisite packages
$ sudo apt-get install gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu libc6-armhf-cross u-boot-tools make gcc swig python3-pyelftools flex

### Building u-boot binaries
$ mkdir BL2 && cd BL2
$ git clone https://github.com/frank-w/u-boot.git -b 20242025-0401-bpi
$ cd u-boot
$ git apply bl2_B.patch ## See above -if patch contentset isnot providedapplying, inplease abovedo block.manually
$ make mt7988a_bpir4_sd_defconfig
$ export CROSS_COMPILE=aarch64-linux-gnu-
$ ./build.sh
 
### Building FIP binary
$ cd ../..
$ mkdir FIP && cd FIP
$ git clone https://github.com/frank-w/u-boot.git -b mtk-atf-2025
$ cd u-boot
$ git apply fip.patch ## See above -if patch contentset isnot providedapplying, inplease abovedo block.manually
 
### Copy all u-boot.* files for creating fip.bin
$ cp ../../BL2/u-boot/u-boot.* .
$ ./build.sh
 
 
### Both bl2.img and fip.bin are present folder ./build/mt7988/release
$ cd ./build/mt7988/release
$ ls bl2.img fip.bin
 
### Renaming binaries as per Yocto's wks file
$ mv bl2.img bpi-r4_sdmmc_bl2_B.img
$ mv fip.bin bpi-r4_sdmmc_fip_B.bin

...

Code Block
titleBuilding BL2 and FIP binaries for kernel6Passive Bank kernel-6.6 in local machine (Ubuntu 22.04)
collapsetrue
### Building u-boot binaries
$ mkdir BL2 && cd BL2
$ git clone https://github.com/frank-w/u-boot.git -b 2025-01-bpi
$ cd u-boot
$ git apply kernel_6-6_bl2_B.patch ## if patch set not applying, please do manually
$ make mt7988a_bpir4_sd_defconfig
$ export CROSS_COMPILE=aarch64-linux-gnu-
$ ./build.sh
 
### Building FIP binary
$ cd ../..
$ mkdir FIP && cd FIP
$ git clone https://github.com/frank-w/u-boot.git -b mtk-atf-2025
$ cd u-boot
$ git apply fip.patch ## if patch set not applying, please do manually
 
### Copy all u-boot.* files for creating fip.bin
$ cp ../../BL2/u-boot/u-boot.* .
$ ./build.sh
 
 
### Both bl2.img and fip.bin are present folder ./build/mt7988/release
$ cd ./build/mt7988/release
$ ls bl2.img fip.bin
 
### Renaming binaries as per Yocto's wks file
$ mv bl2.img bpi-r4_sdmmc_bl2_B_6-6.img
$ mv fip.bin bpi-r4_sdmmc_fip_B_6-6.bin


Bring Bring bpi-r4_sdmmc_bl2.img, bpi-r4_sdmmc_fip.bin, bpi-r4_sdmmc_bl2_B.img and bpi-r4_sdmmc_fip_B.bin files under meta-cmf-bananapi/meta-rdk-mtk-bpir4/recipes-bsp/trusted-firmware-a/files directory.In meta-cmf-

bananapi/meta-rdk-mtk-bpir4/recipes-bsp/trusted-firmware-a/bootloader_prebuild.bb, comment SRC_URI lines with artifcatory repo and uncomment alternate SRC_URI to load bpi-r4_sdmmc_bl2.img and bpi-r4_sdmmc_fip.bin from meta-cmf-bananapi/meta-rdk-mtk-bpir4/recipes-bsp/trusted-firmware-a/files directory.

...

Code Block
themeRDark
titleBPIR4 2nd time flashing instructions.
collapsetrue
1) bzip2 -d <Path to ImageName.wic.bz2>
2) sudo -E bmaptool copy --nobmap <Path to ImageName.wic> <Path to SD card device file>

DRAM configurations

  • TBD

...