How to Cross-Compile in openWRT your own tools inkl OPKG Packaging
Setup toolchain and buildroot on my Debian VM: bullseye - kernel 5.9.0-4
Download and setup toolchain enviroment:
#!/bin/bash
#
## ****** Initial setup on debian distos ******
## (c) 2022 - suuhmer / inspired by owrt wiki official
#
apt clean;
apt update && apt upgrade
# install deps:
apt install build-essential gawk gcc-multilib flex git gettext libncurses5-dev libssl-dev python3-distutils rsync unzip zlib1g-dev clang
#
# -----------------------------------------------------------
#
# Clone atm version and pull for changes
git clone https://git.openwrt.org/openwrt/openwrt.git
cd openwrt
git pull
# Select code revision and create a new branch
git branch -a
git tag
git checkout v21.02.2
# Rebasing for Easybox904:
git branch workbranch
git checkout workbranch
git remote add plonkb https://github.com/Plonkbong/openwrt.git
git fetch plonkb xrx200-21.02.2:xrx200-21.02.2
git rebase workbranch xrx200-21.02.2
git checkout workbranch
git merge xrx200-21.02.2
# ADD XBOX DRIVERS
git remote add xbox https://github.com/M95D/openwrt.git
git fetch xbox
git cherry-pick eeed5e79911f26d0d8e768a2ec387e7882f122de -X theirs
# --strategy-option theirs / ours for ourlically changes prefer
git add . && git status -s
# OUTPUT:
# A package/kernel/linux/modules/multimedia.mk
# M package/kernel/linux/modules/usb.mk
# M package/kernel/linux/modules/video.mk
# A target/linux/generic/config-5.10
# A target/linux/generic/config-5.15
# ON Error Conflicts: (merge, cherry-pick)
# git cherry-pick --abort
# LAST RESORT: git reset --hard xbox/master
# Sort and merge uniq:
cd target/linux/generic/
sort -u config-5.4 config-5.15 > config-5.4
# Update the feeds
./scripts/feeds update -a
./scripts/feeds install -a
##
## OLD OLD Adding DVB_CORE / FW
# git clone -b dvbapps --single-branch https://github.com/turris-cz/openwrt-dvb.git package/dvb-core2
# git clone https://github.com/tmn505/openwrt-dvb package/dvb-fwcore
# Continue
make menuconfig
# Configure the firmware image and the kernel
# !! Optional for initramfs- disk !!
make -j $(nproc) kernel_menuconfig
# Build the firmware image
echo "Time begin: $(date)"; echo
time make -j $(($(nproc)+1)) V=sc defconfig download clean world
echo -e "\nTime finished: $(date)\a"; echo
# sysupgrade image in
cd bin/targets/lantiq/xrx200; ls -lah && echo -e "Upgrade now \a"
# See more to upgrade: #Install the sysupgrade file on Router
##
# Create Custom files / configs (eg motd-banner)
mkdir -p files/etc/ ; vi files/etc/banner
# Create a Dir for package:
# mkdir -p <buildroot>/my_packages/<section>/<category>/<package_name>
Error-handling
# Ignore compilation errors
IGNORE_ERRORS=1 make ...
# Ignore all errors including firmware assembly stage
make -i ...
Old Easybox owrt patch
# OLD : OPTIONAL easybox 904 patch
# wget http://arny.tjps.eu/OpenWrt/EasyBox904xDSL/devel/v0.1-EasyBox904xDSL.patch
# patch -p1 < v0.1-EasyBox904xDSL.patch
# make defconfig
# make prereq
Make menuconfig

2. Setup buildroot steps
export PATH=$PATH:staging_dir/host/bin/
export STAGING_DIR=/root/openwrt
# to get Build paramterinfo:
./scripts/config.guess
# Download mycode to cpmpile and run: (to trigger toolchain)
./configure --build=x86_64-unknown-linux-gnu –host=mips-openwrt-linux-uclibc
# make CC=architecture-openwrt-linux-uclibc-gcc LD=architecture-openwrt-linux-uclibc-ld
make
If compilation aborts due to missing header files or shared objects, you might need to override CFLAGS
and LDFLAGS
to point to the staging_dir/target-architecture_uClibc-libcver/usr/include
and …/usr/lib
directories
Install the sysupgrade file on Router
because of dropbear not sftp, so:
cat openwrt-lantiq-xrx200-arcadyan_vgv952cjw33-e-ir-smp-squashfs-sysupgrade.bin | ssh root@192.168.1.2 "cat >> /tmp/owrtup.bin"
#md5sum check on both!
sysupgrade -v /tmp/owrtup.bin
Special xbox tuner install
wget --no-check-certificate https://github.com/cernekee/linux-firmware/blob/master/dvb-usb-dib0700-1.20.fw?raw=true -P /lib/firmware
#
# And dvb-demod-mn88472-02.fw
wget --no-check-certificate https://palosaari.fi/linux/v4l-dvb/firmware/MN88472/02/latest/dvb-demod-mn88472-02.fw -P /lib/firmware