Howto build 19.07.3 openwrt image for bpi r2

prerequisites:

  • 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 https://git.openwrt.org/openwrt/openwrt.git
  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 gzip 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
    • 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. edit ./target/linux/mediatek/image/gen_mtk_mmc_img.sh in first line: /bin/sh -> /bin/bash
  3. if you have config files from previous running version, put them with full path to ./files/ (for instance ./files/etc/config/network)
  4. make
  5. gunzip ./build_dir/target…/linux_m…/tmp/openwrt-mediatek-bpi_bananapi-r2-squashfs-img.gz (the dots indicating tab key)
  6. insert sd-card
  7. sudo dd if=./build_dir/target…/linux_m…/tmp/openwrt-mediatek-bpi_bananapi-r2-squashfs-img of=/dev/sdb (note the dash in -img!)
  8. insert sd card in your board and boot under uart control. if all is running, type mount_root, add root password and modify the settings along your needs (for instance I had to install the luci translations afterwards)
  9. you can easily transfer the card image to mmc using u-boot option “transfer from sd to mmc”
1 Like

Have you modified https://github.com/openwrt/openwrt/blob/master/target/linux/mediatek/image/gen_mtk_mmc_img.sh ? 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)

e.g.

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

works also with version 19.07.4