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.
Add comment
To avoid spam many websites make you fill out a CAPTCHA, or log in via an account at a corporation such as Twitter, Facebook, Google or even Microsoft GitHub.
I have chosen to use a more old school method of spam prevention.
To post a comment here, you need to:
- Configure a newsreader¹ to connect to the server
- Open the newsgroup called
¹ Such as Thunderbird, Pan, slrn, tin or Gnus (part of Emacs).koldfront.dk
on port1119
using nntps (nntp over TLS).lantern.koldfront
and post a follow up to the article.Or, you can fill in this form: