How I compiled for the NanoPi-R6C

Whats up NanoPi-R6C owners,

These are the steps I took to compile OpenWRT for the NanoPi-R6C. This is based on PR (16275) that will hopefully get accepted into OpenWRT soon.

I had some issues with the VM from the last write-up, see example below. So I decided to go with Debian 10 (which proved to be stable). No more build errors. It was a better idea to setup networking first, so I could paste most commands over SSH. My build time was under 30 minutes.

Example of the build error(s) I encountered using Debian 11.x or Debian 12.x

Images that I tested:
* debian-11.11.0-amd64-netinst.iso
* debian-12.7.0-amd64-netinst.iso

Build error encountered:

make[3] -C toolchain/gcc/initial compile
    ERROR: toolchain/gcc/initial failed to build.
make -r world: build failed. Please re-run make with -j1 V=s or V=sc for a higher verbosity level to see what's going on
make: *** [/media/build/openwrt/include/toplevel.mk:248: world] Error 1

real	11m31.170s
user	57m9.952s
sys		11m5.442s

Prerequisites:

OS: Debian 10.13 (debian.org), because its stable, small and build compatible.

Download:

VM: VirtualBox (virtualbox.org):

Download:

1. Create a new VM

  1. Create a VM using expert mode
  2. Name and Operating System>Name>> build
  3. Name and Operating System>ISO Image>> debian-10.13.0-amd64-netinst.iso
  4. Name and Operating System>Skip Unattended Installation>> yes
  5. Hard Disk>>Do Not Add a Virtual Hard Disk
  6. Finish
  7. Go into VM settings:
  8. System>Motherboard>Base Memory>> 4096 MB
  9. System>Motherboard>Boot Order>> Disable Floppy
  10. System>Processor>Processors>> 8 (or 4 or 2 or 1)
  11. Storage>Optical Drive>> debian-10.13.0-amd64-netinst.iso
  12. Storage>Controler SATA>Create>> DISK1: 4 GB >Choose
  13. Storage>Controler SATA>Create>> DISK2: 16 GB >Choose
  14. Audio>> Disable Audio
  15. Network>Adapter 1>Advanced>> Disconnect Cable
  16. Network>Adapter 1>Advanced>Port Forwarding>+>>Name: ssh , Host-Port: 2222 , Guest-Port: 22
  17. Shared Folders>+>>$HOME/openwrt named openwrt mounted at /media/shared*, Enable Auto-mount

2. Debian Installation

  1. Start the VM and wait until Debian boots.
  2. Choose "Install"
  3. Choose your language
  4. Let the dhcp-request time-out or press Cancel
  5. Choose "Do not configure the network at this time"
  6. Use hostname: build and set root password
  7. Use username: build and set user password
  8. Partition disks>Manual>sda 4.3gb>New partition>Primary>Done
  9. Partition disks>Manual>sdb 17.2gb>New partition>Primary>Mount point: /media/build>Done
  10. Finish and write changes to disk
  11. Scan another CD>No
  12. Continue without a network mirror>Yes
  13. Install GRUB>Yes>Choose>sda 4.3gb
  14. Continue to reboot

3. Post-Installation steps:

  1. Show the VM window and login as root
  2. List network interfaces
ip link | grep ,
  1. Edit network configuration and add the interface en.*
nano /etc/network/interfaces
auto enp0s3
iface enp0s3 inet dhcp
  1. Connect the cable: VM>Devices>Network>Connect Network Adapter
  2. Restart networking and check if it has an IP address
systemctl restart networking
ip addr | grep dynamic
  1. Edit sources list for updates to work and add:
nano /etc/apt/sources.list
deb http://deb.debian.org/debian buster main non-free
deb-src http://deb.debian.org/debian buster main non-free
  1. Update package lists
apt update
  1. Install and enable SSH, then add user build to sudo group
apt install --yes openssh-server sudo
systemctl enable ssh
systemctl start ssh
usermod -a -G sudo build
exit

4. Login with SSH as user: build

  1. From the HOST open an ssh connection to the VM
ssh -p2222 build@localhost
  1. Change to user: root
sudo su -

5. Install/Configure VirtualBox Guest environment

  1. VM>Devices>Insert Guest Additions CD image...
  2. Install packages for guest additions:
apt install --yes build-essential dkms linux-headers-$(uname -r)
  1. Install Guest Additions and add user build to group vboxsf
mount /dev/cdrom /media/cdrom
cd /media/cdrom
bash VBoxLinuxAdditions.run --nox11
usermod -a -G vboxsf build
  1. Check if the VM shared folder specified in 1.17 exists
ls -ld /media/shared
drwxrwx--- 1 root vboxsf 4096 Sep  8 17:16 /media/shared

6. Install the build environment

  1. Install these packages:
apt install --yes \
 build-essential clang flex bison g++ gawk gcc-multilib g++-multilib gettext \
 git libncurses5-dev libssl-dev python3-setuptools rsync swig unzip \
 zlib1g-dev wget unzip bzip2 perl python3 file python3-pyelftools libfdt-dev \
 libf2fs-dev libftdi-dev python3-dev
  1. Reboot the VM: (or Poweroff and export to OVA, now is a good time to save)
reboot

7. Build OpenWRT

  1. From the HOST open an ssh connection to the VM
ssh -p2222 build@localhost
  1. Change owner of working directory and enter it
sudo chown build:build /media/build
cd /media/build
  1. Increase GIT postbuffer
git config --global http.postBuffer 524288000
  1. Clone the NanoPi-R6C repository referred to by the PR (16275)
    ( this will change in the future )
git clone https://github.com/antnyfls/openwrt -b nanopi-r6c
cd openwrt
  1. Then follow the OpenWRT build steps
./scripts/feeds update -a
./scripts/feeds install -a
  1. Configure OpenWRT for the NanoPi-R6C
make menuconfig
* Target System (Rockchip)
* Subtarget (RK33XX/RK35xx boards (64 bit)
* Target Profile (FriendlyARM NanoPi R6c)
* Save
* Exit
  1. Start building OpenWRT
time make -j$(nproc)

8. Post build

    • Build time for me was under 30 minutes.
real	22m29.946s
user	134m30.024s
sys		10m15.423s
  1. Our targets and packages can be found in the VM under:
/media/build/openwrt/bin
  1. Our targets and packages can be copied to the HOST with:
rsync -av /media/build/openwrt/bin/ /media/shared

9. (optional) Writing the sdcard under Linux

pv openwrt-rockchip-armv8-friendlyarm_nanopi-r6c-squashfs-sysupgrade.img.gz | zcat | sudo dd bs=10M oflag=sync of=/dev/sdcard

That's it.

(could not attach the boot.log because it exceeded the 32000 character limit)

BusyBox v1.36.1 (2024-09-03 05:41:36 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r27301-3f10567c2e
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:~#
1 Like

When building I get a warning:

WARNING: Makefile 'package/feeds/telephony/freeswitch/Makefile' has a dependency on 'libpcre', which does not exist

this can be solved by patching the Makefile of freeswitch

sed -i.bak 's,+libpcre,&2,' package/feeds/telephony/freeswitch/Makefile

Can anyone explain why there is trailing garbage in my build ?

zcat openwrt-rockchip-armv8-friendlyarm_nanopi-r6c-squashfs-sysupgrade.img.gz > /dev/null

zcat warning:

gzip: openwrt-rockchip-armv8-friendlyarm_nanopi-r6c-squashfs-sysupgrade.img.gz: decompression OK, trailing garbage ignored

it's supposed to be there - Decompression OK, trailing garbage ignored - #3 by slh

1 Like

OK, just making sure it was nothing I did :laughing:

Today I tested:

In conclusion:

As of now I'm seriously doubting if anything other than Debian 10.x is a good base for building OpenWRT inside VirtualBox. Tips and suggestions are very welcome.

(yes, I read the install-buildsystem page)

could get a free cloud host with one of the big cloud providers.
building will take longer, but it's free.

1 Like