I’ve bought Banana Pi R2 with plan to make it into my very custom OpenWRT-based router. This is my second type of Linux-friendly board, first one I had were Raspberry Pi 2, 3 and Zero where I am familiar with booting procedure and preparing the custom Linux systems with Buildroot. I’ve played a bit with the booting ecosystem of R2 (100MB for magic bytes, preloader and uboot, BPI-BOOT vfat partition for kernel and uboot config and BPI-ROOT ext4 for rootfs), using files from BPI-files github repository (https://github.com/BPI-SINOVOIP/BPI-files). Thanks to Uboot and boot-root partition scheme I am able to launch Buildroot-compiled system, as long as it consists of kernel (eg. zImage) and root image I can flash to the second partition.
However, after compiling OpenWRT github repo for R2 (https://github.com/BPI-SINOVOIP/BPI-R2-OPENWRT-18.06), the only thing I get *-initramfs-kernel.bin file. I’ve checked beginning of that file and it significantly differs from the files meant to be flashed in case of LEDE repository (BPI-R2 OpenWRT(LEDE) Support). SDMMC_BOOT magic bytes are missing, there is no preloader nor uboot starting with 2048 byte of the file.
After flashing LEDE’s image on the SD card I have no access to partitions where I could possibly put the bin file from my Linux desktop. How are things looking like in case of OpenWRT on Banana Pi? It clearly isn’t the same situation as in case where BPI-BOOT is available, yet the compiled bin file has to be placed in the SD card somehow. I admit I didn’t play nor compile the system with squashfs and jffs2 yet so I’m new to how Linux and OpenWRT handle that. If I had access to uboot configuration file, I guess I could figure it out from the kernel arguments, but as I said, there is no such file - at least not in an easily accessible form.
I’m wondering how one could prepare an SD card from scratch by partitioning it and flashing necessary images from BPI-files repository (either with dd or bpi-tools) and finally use OpenWRT’s bin file to somehow put it on the SD card so that it boots up after plugging into the BPI? How does jffs2 partition handling and configuration look like (specifying size, location on the SD card etc)?
you have to flash the bin/img directly to card, replacing your existing partition sheme
openwrt does not use partitions because Partitiontables are for larger storages (>x GB)…a “normal router” has only a few (maybe 100) MB for storing OS.
that makes it hard to replace kernel or other things in this “image” and imho you cannot use the additional space
Bin file from the OpenWRT 18.06 repo cannot be flashed to the card - it lacks necessary things like the magic bytes and preloader that would make it possible for BPi to recognize and boot it. Unlike LEDE’s repository, the valid bootable img file is not created after compilation of 18.06 repo. I’m looking for a way to create such image manually from scratch, having OpenWRT compiled bin and BPi pre-made images with things like Uboot, preloader, magic bytes etc. I’ve been trying to figure out how it was done in LEDE repo so that after opening Buildroot’s menu (make menuconfig) there is Uboot entry in Bootloader branch which can be chosen and produces img as a result of make, but so far I didn’t find how to do a similar thing with OpenWRT.
I’m not planning to use all the SD card nor emmc size - from what I heard, JFFS doesn’t handle large partitions well, at least in terms of performance. According to boot log, OpenWRT initializes JFFS space during initial boot and after invoking firstboot command. I’m wondering if it’s possible to somehow adjust the size of that space and if not then how it is determined.
I’ve seen your commit in the repository @Jackzeng , thank you guys for your work! Not only I can compile working OpenWRT 18.06 for my R2, now I also know how to assemble all the built files into writeable image - no article nor documentation is a better learning material than a working example. Although the second image I compiled after adding few packages doesn’t seem to go past UBoot (shows the “couldn’t find kernel” error), I’m still looking into it. Thanks again!
There is a small problem. OpenWRT compiled with the new UBoot script doesn’t seem to utilize overlayfs to persist data. There is interesting difference I managed to observe between compiled OpenWRT and LEDE which I downloaded from this forum (BPI-R2 new image: BPI-R2 OpenWrt(LEDE) Souce code : 2018-05-09). The difference is kernel command line, printed after starting kernel. For OpenWRT it is:
I tried to hardcode the latter one in the kernel to be used during bootup (using kernel_menuconfig options) but although the new kernel arguments get displayed on startup, there is no persistence between reboots.
Here is the output for df and mount commands on the compiled OpenWRT: