Howto build 19.07.3 openwrt image for bpi r2


  • Linux system for build root with all necessary modules according to Openwrt Project Build system
  • plus these modules: libjansson-dev liblzma-dev libldap2-dev libcap-dev libpam0g-dev libsnmp35 python2.7-dev swig (Ubuntu 20.04 LTS)
  • mini sd card 4 GB
  • uart cable
  1. mkdir /openwrt; cd /openwrt
  2. git clone
  3. cd openwrt
  4. ./scripts/feeds update -a
  5. ./scripts/feeds install -a
  6. make menuconfig
  • 6.1. Target system: - Mediatek Ralink ARM
  • 6.2. Subtarget: MT7623
  • 6.3. Target Profile (Bpi Banana Pi R2)
  • 6.4. Target Images: select Ramdisk, squashfs, ext4 and tar.gz images
  • 6.5. image configuration: under “Separate feed repositories” Enable desired packages (luci, routing, telephony)
  • 6.6. Base system: I have added block-mount, blockd and mtd
  • 6.7. boot loaders: mt7623n-preloader and u-boot-mt7623n_bpir2
  • 6.8 LuCI
    • 6.8.1. Collections: luci
    • 6.8.2. Modules: luci-base, -mod-network, -mod-status, -mod-system also select approbiate translations
    • 6.8.3. Applications as required (ddns, firewall, openvpn, opkg)
  • 6.9. network/vpn openvpn-openssl (used by me, most hidden)
  1. close menuconfig (esc, esc, save)
  2. if you have config files from previous running version, put them with full path to ./files/ (for instance ./files/etc/config/network)
  3. make
  4. gunzip ./build_dir/target…/linux_m…/tmp/openwrt-mediatek-mt723-bananapi_bpi-r2-sdcard.img.gz (the dots indicating tab key)
  5. insert sd-card, note: umount eventually automounted volumes
  6. sudo dd if=./build_dir/target…/linux_m…/tmp/openwrt-mediatek-mt723-bananapi_bpi-r2-sdcard.img of=/dev/sdb
  7. insert sd card in your board and boot under uart control. if all is running, connect with telnet or serial, add root password and modify the settings along your needs (for instance I had to install the luci translations afterwards)
  8. you can easily transfer the card image to mmc using u-boot option “transfer from sd to mmc” during reboot (with serial connection only)
1 Like

Have you modified ? At least on ubuntu host “echo -e” is not working in /bin/sh (=dash,needs to be changed to bash).

Sorry, forgot it. Also other issue: you have to create ext4 image, because the image creation scripts needs the size of rootfs and this value is only available while creating ext4

Howto edited

you need a writeable rootfs to change settings. Afaik default is ro rootfs with rw squashfs overlay. But this overlay (i guess it’s a file needs to be mounted) have to lay somewhere on a partition/mtd block…idk if squashfs is dynamically resized or have fixed size. Maybe @dwmw2 can change script to allow squashfs too. Else ext4fs should be default. Btw. Does mtd work (you wrote you have it enabled)? Afair there was an issue where rootfs not found if defined in mtd-block.

The dash in img filename (openwrt-mediatek-bpi_bananapi-r2-squashfs-img) is strange too and obviosly wrong. On a quick look maybe

needs to be .img.gz (additional dot)

you need a writeable rootfs to change settings

that´s why I wrote mount_root. In my test´s the root passwd stays permanent, also my additions to luci and the led configuration

Wondered about mount_root command…i guess root (ext4) is also mounted ro and mount_root mounts it rw ro allow changes temporarily.

I see any ext4 filesystem:

root@BananaPi:/# mount
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/loop0 on /overlay type f2fs (rw,lazytime,noatime,background_gc=on,discard,no_heap,user_xattr,inline_xattr,inline_data,inline_dentry,flush_merge,extent_cache,mode=adaptive,active_logs=6,alloc_mode=reuse,fsync_mode=posix)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,noatime,mode=700)
mountd(pid836) on /tmp/run/blockd type autofs (rw,relatime,fd=7,pgrp=1,timeout=30,minproto=5,maxproto=5,indirect)

how to check? mtd -? gives output, but as I see, dangerous commands only :slight_smile:

Have not done anything with mtd, only have seen it in previous images and such with 5.4 had problem find rootfs.

Imho mtd partitions are defindes in dts and mounted via cmdline

howto edited again: adding correct build root and some formatting

requires root-permissions on standard system…better will be ./openwrt or ~/openwrt :slight_smile: or maybe a directory in /usr/src which does also require root-permissions for create and changing owner/group (to allow clone/build as normal user)

correct, I would prefer ~/openwrt. Reason for me were shortening pathnames, but the build system has it´s own long and deep path structure. It´s a battle you are in every case the loser.

On an ext[234] filesystem you can create a symlink to deeper directory if you need it multiple times (e.g. builddir with toolchain)


ln -s build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-mediatek_mt7623/ builddir

works also with version 19.07.4

edited again:

  • removed mount_root (yes Frank, you are right!)

  • added some hints regarding burn into emmc

The flashing steps can be consolidated if you use a utility like Balena etcher which can flash compressed images. Also marking the ramdisk target is unnecessary.

I can also add that I did all of this via WSL2 on windows (Ubuntu 20.04) and worked great.

But otherwise, your steps are exactly the steps I followed.


does this build support DSA (Distributed Switch Architecture) or is there a way to patch it?

check if you see it during boot:

dmesg | grep dsa

or if you see all 4 lan + 1 wan interfaces here:

ls -l /sys/class/net

If you use 5.4 you could get patches from my 5.4-main branch and add them to yout patches-5.4 dir

root@BananaPi:/# dmesg | grep dsa
[    1.544986] libphy: dsa slave smi: probed
[    1.549281] mt7530 mdio-bus:00 wan (uninitialized): PHY [dsa-0.0:00] driver [Generic PHY]
[    1.558237] mt7530 mdio-bus:00 lan0 (uninitialized): PHY [dsa-0.0:01] driver [Generic PHY]
[    1.567234] mt7530 mdio-bus:00 lan1 (uninitialized): PHY [dsa-0.0:02] driver [Generic PHY]
[    1.576216] mt7530 mdio-bus:00 lan2 (uninitialized): PHY [dsa-0.0:03] driver [Generic PHY]
[    1.585139] mt7530 mdio-bus:00 lan3 (uninitialized): PHY [dsa-0.0:04] driver [Generic PHY]

I would like to provide switch functions. Which modules should I add before make?

my actual build uses version 5 uname -r reports 5.4.70