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:
- virtualbox-7.0_7.0.20-163906~Debian~bookworm_amd64.deb
- Oracle_VM_VirtualBox_Extension_Pack-7.0.20.vbox-extpack
1. Create a new VM
- Create a VM using expert mode
- Name and Operating System>Name>> build
- Name and Operating System>ISO Image>> debian-10.13.0-amd64-netinst.iso
- Name and Operating System>Skip Unattended Installation>> yes
- Hard Disk>>Do Not Add a Virtual Hard Disk
- Finish
- Go into VM settings:
- System>Motherboard>Base Memory>> 4096 MB
- System>Motherboard>Boot Order>> Disable Floppy
- System>Processor>Processors>> 8 (or 4 or 2 or 1)
- Storage>Optical Drive>> debian-10.13.0-amd64-netinst.iso
- Storage>Controler SATA>Create>> DISK1: 4 GB >Choose
- Storage>Controler SATA>Create>> DISK2: 16 GB >Choose
- Audio>> Disable Audio
- Network>Adapter 1>Advanced>> Disconnect Cable
- Network>Adapter 1>Advanced>Port Forwarding>+>>Name: ssh , Host-Port: 2222 , Guest-Port: 22
- Shared Folders>+>>$HOME/openwrt named openwrt mounted at /media/shared*, Enable Auto-mount
2. Debian Installation
- Start the VM and wait until Debian boots.
- Choose "Install"
- Choose your language
- Let the dhcp-request time-out or press Cancel
- Choose "Do not configure the network at this time"
- Use hostname: build and set root password
- Use username: build and set user password
- Partition disks>Manual>sda 4.3gb>New partition>Primary>Done
- Partition disks>Manual>sdb 17.2gb>New partition>Primary>Mount point: /media/build>Done
- Finish and write changes to disk
- Scan another CD>No
- Continue without a network mirror>Yes
- Install GRUB>Yes>Choose>sda 4.3gb
- Continue to reboot
3. Post-Installation steps:
- Show the VM window and login as root
- List network interfaces
ip link | grep ,
- Edit network configuration and add the interface en.*
nano /etc/network/interfaces
auto enp0s3
iface enp0s3 inet dhcp
- Connect the cable: VM>Devices>Network>Connect Network Adapter
- Restart networking and check if it has an IP address
systemctl restart networking
ip addr | grep dynamic
- 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
- Update package lists
apt update
- 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
- From the HOST open an ssh connection to the VM
ssh -p2222 build@localhost
- Change to user: root
sudo su -
5. Install/Configure VirtualBox Guest environment
- VM>Devices>Insert Guest Additions CD image...
- Install packages for guest additions:
apt install --yes build-essential dkms linux-headers-$(uname -r)
- 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
- 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
- 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
- Reboot the VM: (or Poweroff and export to OVA, now is a good time to save)
reboot
7. Build OpenWRT
- From the HOST open an ssh connection to the VM
ssh -p2222 build@localhost
- Change owner of working directory and enter it
sudo chown build:build /media/build
cd /media/build
- Increase GIT postbuffer
git config --global http.postBuffer 524288000
- 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
- Then follow the OpenWRT build steps
./scripts/feeds update -a
./scripts/feeds install -a
- Configure OpenWRT for the NanoPi-R6C
make menuconfig
* Target System (Rockchip)
* Subtarget (RK33XX/RK35xx boards (64 bit)
* Target Profile (FriendlyARM NanoPi R6c)
* Save
* Exit
- 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
- Our targets and packages can be found in the VM under:
/media/build/openwrt/bin
- 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:~#