RDK Resources
[*RDK Preferred*]
Code Management Facility
RDK Forums
[RDK Conferences]
RDK Support
Archives
Papers & Presentations Archive
Papers & Presentations Archive
You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 31 Next »
Bananapi r4 follows a atf (arm-trusted firmware) flow for device bootup, by default flash memory is present in the device which will be loaded with BL1 and BL1 will be having bl2 address to load bl2 and make device up.
Device bootup flow as mentioned below
a)BL1: Bootloader one which will be part of flash memory of bpir4 , it will be holding address for bl2.
b)BL2: Bootloader two need to be generated and loaded in a specified sector so that bl1 can load bl2.
c)fip: Firmware image Package which contains firmware components eg bl31.
d)Kernel: Layer which will be acting between hardware and OS.
e)RDKB : RDKB stack or RDKB OS for user interaction.
"Kernel and rdkb rootfs will be generated as part BPIR4 build instructions"
Used below mentioned git repo for generating bl2.img and fip.bin file.
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)
At initial cloned mentioned git code "https://github.com/frank-w/u-boot/tree/2024-04-bpi" , and made below mentioned changes in u-boot env file to make boot-loader compatible in loading kernel and rdkb os at initial boot-up itself.
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;
After making changes just executed build.sh script file. After complete execution of this script file, we can see u-boot.* files will be generated in specific folder.
heam@Dell-OptiPlex-9020:~/bootloader/u-boot$ ls api build.conf common doc examples include Licenses post System.map u-boot.bin u-boot.lds u-boot.srec uEnv_r3.txt arch build.log config.mk drivers files Kbuild MAINTAINERS README test u-boot.cfg u-boot.map u-boot.sym uEnv_r4.txt board build.sh configs dts fs Kconfig Makefile README.md tools u-boot.dtb u-boot-mtk.bin uEnv_r2pro.txt uEnv_r4.txt.old boot cmd disk env generated_defconfig lib net scripts u-boot u-boot-dtb.bin u-boot-nodtb.bin uEnv_r2.txt uEnv_r64.txt
In other folder clone "https://github.com/frank-w/u-boot/tree/mtk-atf", and copy all u-boot.* files from existing generated folder to this specific folder and make below mentioned changes, then execute build.sh script.
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"
After completion of script execution we can see bl2.img and fip.bin files will be generated in build/mt7988/release path.
heam@Dell-OptiPlex-9020:~/bootloader/atf/u-boot/build/mt7988/release$ ls
bl2 bl2.bin bl2.img bl31 bl31.bin fdts fip.bin lib libc libfdt libwrapper romlib
Generated bl2.img and fip.bin files need to be include in meta-cmf-bananapi layer.
repo init -u https://code.rdkcentral.com/r/manifests -b kirkstone -m rdkb-bpi-extsrc.xml repo sync -j `nproc` --no-clone-bundle --no-tags MACHINE=bananapi4-rdk-broadband BPI_IMG_TYPE=sdmmc source meta-cmf-bananapi/setup-environment-refboard-rdkb bitbake rdk-generic-broadband-image
Image generating steps for BPIR4.
After completion of build go to deploy folder and execute "bpir4_sd_image_creater.sh" script file, to generate final sdcard image.
#!/bin/bash board="bpi-r4" device="sdmmc" OS="rdk-broadband-image" IMGDIR=. IMGNAME=${board}_${device}_${OS} --> Image name format LDEV=`sudo losetup -f` --> Command to find available loob device in pc. REALSIZE=7456 echo "create $IMGNAME.img" dd if=/dev/zero of=$IMGDIR/$IMGNAME.img bs=1M count=$REALSIZE 1> /dev/null 2>&1 LDEV=`sudo losetup -f` DEV=`echo $LDEV | cut -d "/" -f 3` #mount image to loop device echo "run losetup to assign image $IMGNAME.img to loopdev $LDEV ($DEV)" sudo losetup $LDEV $IMGDIR/$IMGNAME.img 1> /dev/null #2>&1 bootstart=17408 bootsize=100 rootsize=6600 bootend=$(( ${bootstart}+(${bootsize}*1024*2)-1 )) rootstart=$(( ${bootend}+1 )) rootend=$(( ${rootstart} + (${rootsize}*1024*2) )) sudo sgdisk -o ${LDEV} sudo sgdisk -a 1 -n 1:34:8191 -A 1:set:2 -t 1:8300 -c 1:"bl2" ${LDEV} sudo sgdisk -a 1 -n 2:13312:17407 -A 2:set:63 -t 2:8300 -c 2:"fip" ${LDEV} sudo sgdisk -a 1024 -n 3:17408:${bootend} -t 3:8300 -c 3:"boot" ${LDEV} sudo sgdisk -a 1024 -n 4:${rootstart}:${rootend} -t 4:8300 -c 4:"rootfs" ${LDEV} sudo losetup -d $LDEV sudo losetup -P $LDEV $IMGDIR/$IMGNAME.img 1> /dev/null #2>&1 sudo dd if=atf/bpi-r4_sdmmc_bl2.img of=${LDEV}p1 conv=notrunc,fsync #1> /dev/null 2>&1 sudo dd if=atf/bpi-r4_sdmmc_fip.bin of=${LDEV}p2 conv=notrunc,fsync #1> /dev/null 2>&1 sudo mkfs.vfat "${LDEV}p3" -n BPI-BOOT #1> /dev/null 2>&1 sudo mkfs.ext4 -O ^metadata_csum,^64bit "${LDEV}p4" -L BPI-ROOT #1> /dev/null 2>&1 sudo mount "${LDEV}p3" /mnt/ sudo cp fitImage /mnt/ sudo cp mt7988a-bananapi-bpi-r4-sd.dtb /mnt/ sudo umount "${LDEV}p3" sudo dd if=rdk-generic-broadband-image-bananapi4-rdk-broadband.ext4 of=${LDEV}p4 sudo losetup -d $LDEV echo "packing image..." gzip $IMGDIR/$IMGNAME.img
Info regarding
script executionbananapi4-rdk-broadband$ ./bpir4_sd_image_creater.sh create bpi-r4_sdmmc_rdk-broadband-image.img run losetup to assign image bpi-r4_sdmmc_rdk-broadband-image.img to loopdev /dev/loop24 (loop24) Creating new GPT entries in memory. Warning: The kernel is still using the old partition table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) The operation has completed successfully. Setting name! partNum is 0 Warning: The kernel is still using the old partition table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) The operation has completed successfully. Setting name! partNum is 1 Warning: The kernel is still using the old partition table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) The operation has completed successfully. Setting name! partNum is 2 Warning: The kernel is still using the old partition table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) The operation has completed successfully. Setting name! partNum is 3 Warning: The kernel is still using the old partition table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) The operation has completed successfully. 480+1 records in 480+1 records out 246069 bytes (246 kB, 240 KiB) copied, 0.165271 s, 1.5 MB/s 562+1 records in 562+1 records out 288153 bytes (288 kB, 281 KiB) copied, 0.0626902 s, 4.6 MB/s mkfs.fat 4.2 (2021-01-31) mke2fs 1.46.5 (30-Dec-2021) Discarding device blocks: done Creating filesystem with 1689600 4k blocks and 422656 inodes Filesystem UUID: 2ec68480-e1a2-4c40-aadb-b739a3edf4af Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Allocating group tables: done Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done 539116+0 records in 539116+0 records out 276027392 bytes (276 MB, 263 MiB) copied, 2.14511 s, 129 MB/s packing image... heam@Dell-OptiPlex-9020:~/Downloads/BPIR4_latest_23_oct/bananapi4-rdk-broadband$ ls atf bpir4_sd_image_creater.sh bpi-r4_sdmmc_rdk-broadband-image.img.gz fitImage fitImage-1-5.4.271+git0+feeb59687b_3fec063b05-r0-bananapi4-rdk-broadband-20241023065547.bin fitImage-bananapi4-rdk-broadband.bin fitImage-its-1-5.4.271+git0+feeb59687b_3fec063b05-r0-bananapi4-rdk-broadband-20241023065547.its fitImage-its-bananapi4-rdk-broadband fitImage-linux.bin-1-5.4.271+git0+feeb59687b_3fec063b05-r0-bananapi4-rdk-broadband-20241023065547.bin fitImage-linux.bin-bananapi4-rdk-broadband hash-summary modules-1-5.4.271+git0+feeb59687b_3fec063b05-r0-bananapi4-rdk-broadband-20241023065547.tgz modules-bananapi4-rdk-broadband.tgz mt7988a-bananapi-bpi-r4-sd-1-5.4.271+git0+feeb59687b_3fec063b05-r0-bananapi4-rdk-broadband-20241023065547.dtb mt7988a-bananapi-bpi-r4-sd-bananapi4-rdk-broadband.dtb mt7988a-bananapi-bpi-r4-sd.dtb rdkb-generic-broadband-image_rdk-next_20241023114221.bin.ext4 rdkb-generic-broadband-image_rdk-next_20241023114221.bin.manifest rdkb-generic-broadband-image_rdk-next_20241023114221.bin.squashfs-xz rdkb-generic-broadband-image_rdk-next_20241023114221.testdata.json rdk-generic-broadband-image-bananapi4-rdk-broadband.ext4 rdk-generic-broadband-image-bananapi4-rdk-broadband.manifest rdk-generic-broadband-image-bananapi4-rdk-broadband.squashfs-xz rdk-generic-broadband-image-bananapi4-rdk-broadband-sysupgrade.bin rdk-generic-broadband-image-bananapi4-rdk-broadband.testdata.json heam@Dell-OptiPlex-9020:~/Downloads/BPIR4_latest_23_oct/bananapi4-rdk-broadband$
After completion of script execution, final image will be generated with "bpi-r4_sdmmc_rdk-broadband-image.img.gz" image name.
Image can be flashed to sdcard using dd command or balenaEtcher.
1)Image generated after execution of script "bpi-r4_sdmmc_rdk-broadband-image.img.gz"can be flashed directly to sdcard using dd command or balenaEtcher.
2)For 2nd time flashing you can follow below mentioned flashing instructions instead if executing script,but use existing sdcard only.
1)copy mentioned files from deploy dir to local pc if using vm(fitImage, mt7988a-bananapi-bpi-r4-sd.dtb, rdkb-generic-broadband-image_rdk-next_20241028072748.bin.ext4) 2)copy fitImage and mt7988a-bananapi-bpi-r4-sd.dtb to 3rd partition heam@Dell-OptiPlex-9020:~/tr69$ sudo mount /dev/sdc3 /mnt/ [sudo] password for heam: heam@Dell-OptiPlex-9020:~/tr69$ cd /mnt/ heam@Dell-OptiPlex-9020:/mnt$ ls fitImage mt7988a-bananapi-bpi-r4-sd.dtb heam@Dell-OptiPlex-9020:/mnt$ sudo rm -rf * heam@Dell-OptiPlex-9020:~/tr69$ sudo cp fitImage mt7988a-bananapi-bpi-r4-sd.dtb /mnt/ 3)Flash rdkb rootfs to 4th partition. heam@Dell-OptiPlex-9020:~/tr69$ sudo dd if=rdkb-generic-broadband-image_rdk-next_20241028072748.bin.ext4 of=/dev/sdc4 541914+0 records in 541914+0 records out 277459968 bytes (277 MB, 265 MiB) copied, 24.6373 s, 11.3 MB/s 4)Remove sdcard and insert into BPIR4 device.5)Latest image will be loaded.
ATF: https://trustedfirmware-a.readthedocs.io/en/latest/
Facing permission issue if i try to automate the script using bbclass.
-losetup utility is working in yocto but permission issue is there when i try to access looping devices.
losetup: /dev/loop7: failed to set up loop device: Permission denied
So, Working on alternative ways for creating sdcard image using wic utility. Simultaneously analysing yocto layers for creating sdcard image based of ATF flow.
-Jira for tracking this issue.
RDKBACCL-429
-
Getting issue details...
STATUS
DISCLAIMER: Please note that the use of the RDK Wiki is subject to its Privacy Policy & Terms of Use. In addition, this Wiki may be accessed by all RDK licensees and their contractors.
Powered by a free Atlassian Confluence Open Source Project License granted to RDKCentral. Evaluate Confluence today.