Cross compiling for OpenWrt/LEDE mips_24kc_nomips16 #crosscompiling #openwrt #printing
Recently I looked at OpenWrt's list of recommended hardware and when I to my surprise saw an access point available in local webshops on the list, a Xiaomi AX3200, I treated myself to one.
What I didn't think to check was whether the new access point has a usb port.
It doesn't.
Why does that matter? Well, I have this setup where when I tell my computer to print something, it tells the access point to toggle a usb controlled relay, which turns on the printer.
It's pretty neat, if I may say so myself.
However switching from the old access point to the new would leave me without somewhere to plugin and control the usb relay.
But wait, the Genexis Pure ED500 VDSL router I have that connects to the internet, it has a usb port, and it runs a customized version of OpenWrt, maybe I can use that?
Unfortunately it runs a veeery old version of OpenWrt:
* iopsysWRT Version = 4.3.6
* LEDE/OpenWRT Version = Reboot (SNAPSHOT, r0+8411-adc4ef5)
* Linux Kernel Version = 4.9.109+
running opkg update
on it just gave a whole bunch of "404 Not found". And I need the crelay
package.
After searching for a while, I couldn't find it anywhere online. I could find one build for mips_24kc, but not for mips_24kc_nomips16 - there are very few hits for "nomips16".
I tried the package for mips_24kc any way, and after installing the needed libraries: "Bus error".
Ok, so I probably need to (cross) compile it myself. I posted a cry for help on the fediverse, but there were no takers.
Armed with the information from /etc/openwrt_release
:
DISTRIB_ID='LEDE'
DISTRIB_RELEASE='SNAPSHOT'
DISTRIB_REVISION='r0+8411-adc4ef5'
DISTRIB_CODENAME='reboot'
DISTRIB_TARGET='intel_mips/xrx500'
DISTRIB_ARCH='mips_24kc_nomips16'
DISTRIB_DESCRIPTION='LEDE Reboot SNAPSHOT r0+8411-adc4ef5'
DISTRIB_TAINTS='no-all busybox override'
I went searching again, and I found a guide "Cross compiling" on the OpenWrt website, which says to start by setting up the build system as described on "Build system usage".
After a couple of false starts, this is what I did:
- Checked out the
lede-17.01
branch - In
make menuconfig
choose the architechture that looked like it might be mips_24kc, switched to big endian, turned on advanced options, turned off mips16. - Fixed the various problems in building tools and toolchain:
- Fixed tools/m4 compilation by removing
&& SIGSTKSZ < 16384
inc-stack.c
. - Fixed tools/mklibs compilation by adding
HOST_CPPFLAGS += -std=gnu++98
to theMakefile
, as seen in "tools/mklibs: Fix compile with GCC 11" on the openwrt-devel mailing list. - Fixed toolchain/gcc compilation by adding
HOST_CXXFLAGS += -std=gnu++98
andCFLAGS_FOR_TARGET="$(TARGET_CFLAGS)"
incommon.mk
- Fixed cmake-3.7.1 compilation by adding
#include <limits>
incmStandardIncludes.h
as indicated in "‘numeric_limits’ is not a member of ‘std’" on StackOverflow.
- Fixed tools/m4 compilation by removing
- Followed the instructions on "Building a single package" to build
crelay
. - Unpacked the
crelay
,libftdi1
, andhidapi
ipk's and copied the files to the router.
Success!
Now I can switch from the old access point to the new, and still have printing working as smoothly as before.
Do you perhaps have an image to share? Sincerely, MM
- MM 🕜︎ - 2024-05-03
Sure - I have included the tiny script I use to run it directly from /root on the router:
- Adam Sjøgren 🕑︎ - 2024-05-03
For some version of lede, libelf also need to be patched. Just see it here:https://github.com/openwrt/openwrt/commit/a99f88a1866ec082ab635db31a90de618840b165
- fish4terrisa 🕒︎ - 2024-07-01