Convert smartphone into OpenWrt router

A smartphone is essentially an ARM SBC but with the required radios all in one.

If a phone is boot unlockable and can be flashed.
Why not develope openwrt for phones to function as more capable router than just an Android WiFi hotspot/ tether?

Yes phones vary in specs (instructions and etc). But can't we start with a handful of phones. Repurposing of 4G phones prior to 2015.
And with XDA developers who already have most of the required layouts for the phones.

3 Likes
  • The project chooses not support devices without ethernet.
  • The more codebase that isn't mainline, the less appealing / practical it is to support.

Are you aware of any phones fully / mostly mainlined?

On Android an Ethernet to USB adapter and switch can be used.
4G LTE WWAN will be the internet input.
Or a phone with USB 3.0 an Ethernet adapter can be the WAN.

The Samsung Galaxy Note 3 for instance is a well mainlined developer phone for a long time now. It's even been repurposed as mainboards for drones. Has a capable SOC that is still more powerful than most router CPUs today, 3GB of RAM, USB 3.0, etc. Codes to radios etc, are available on smartphone developer forums.

WiFi pcie cards even today can't function stably as an AP.
And newly released cards which can, cost from $200 to $500 without the mainboard and with inferior components.
Smartphones can already stably host multiple STA for prolonged sessions like an actual router.

1 Like

Well, someone -at this point this inevitably means you- will have to start with the development/ porting work. Talk is cheap, but code/ patches/ pull requests aren't - and code fairies only exist in your dreams.

--
Once you get serious about it, the issues and drawbacks become evident and usually disqualify these devices. Things like current mainline support, maintained drivers, I/O performance (multi-port ethernet, concurrent dualband wifi at decent speeds and range (antenna support), 24/7 capable power supply).

I'm just wondering if there are others interested as well.
And just putting it out there to see :slight_smile:
Everything starts with a dream

1 Like

I'm sure you'll find users who'd consider that to be a good idea at first glance, I very much doubt you'll find anyone capable and willing to provide the necessary code (unless you do it yourself or at least get started).

If you are looking for a smartphone SOC, go with the well supported ipq806x devices, KRAIT300 derived and having all the router specific features a smartphone doesn't have (see above).

To be fair there is more QCM phone SoC support in mainline. There are even some DTS in mainline for phones from Sony and Google.

https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux.git/commit/?h=arm64-for-5.9&id=234d7d6b4cbfab0e900f12658053689bb3376141

These phones should have a fair amount of power, but as normal how well mainline actually works day to day changes per device

1 Like

I'm interested but the effort is to much. Since I am a high level programmer parting drivers is not as easy as creating a web service for me. I would do this if I could.
P.S. if battery, LCD, speakers, microphone or camera isn't working (just one of them) that phone is useless and you will buy a new one. Although that phone is garbage it can be great if you install openwrt on it since LTE and WiFi are fine.
Edit: we can also use some components from Stock os because it's Linux and it has HUGE internal storage (no need for minimal output)

Check with the existing Android ROMs, camera is always an issue at some point, along with wifi, GPS, etc.

You'll face the same issues with closed source drivers they do

Can we run Openwrt on top of Android like using containers or lxc, this will be a win-win and people don't need to write the driver.
Only requirement will be phone need to be rooted

Openwrt is not supported on any mobile phones.

You’re welcome to begin development, though (hint: it would be monumentally complex)

https://openwrt.org/docs/guide-developer/add.new.device

To answer about virtualization, this works in some environments, but it has complications and the capabilities and limitations (including those made by design and/or for security) of the host os and supervisor/hypervisor will make or break the experience.

https://openwrt.org/docs/guide-user/virtualization/start

I already find a project Limbo Virtual Machinery - Virtual Machinery (weebly.com) using which you can run VMs on android

That is described as an emulator, not a true virtualization environment. Because of this, you could possibly get the os to run, but you would almost certainly not have any hope of proper networking , which would almost entirely defeat the purpose.

Android does not provide standard services expected by normal Linux userland like multiple users, netfilter, direct network configuration or packet access. You can check lobotomized proot containers in termux for various aarch64 distros - like command line tools accessing files work but nothing else. OpenWRT is that everything else, it is not very useful without network parts.

As emulating on android is new for me so I can't say anything. I am trying to use Limbo to run openwrt.
For the network part, I see that they have some TAP network, will spend sometime to try it if that works or not.
Initially looks like worth to try.
Currently searching for some android phone in my stock which support root.

You will quickly find that you're not going to be able to do anything useful with OpenWrt in the Limbo environment. OpenWrt needs to be much closer to the hardware (ideally bare metal), or at least running in a virtual environment that supports more advanced network interface modes.

I get success in running openwrt on Android emulator and able to directly access usb ethernet in openwrt with all same functionalities. Checked by connecting to my local network and getting IP address from dhcp client and internet.
I can't check WIFI accessibility as it is an emulator.

Now I am trying to replicate the same on an actual android phone, hopefully it will work as same (searching for some android phone to test)
Only requirement is phone need to be rooted.

root@OpenWrt:/# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux 5.15.150 xhci-hcd xHCI Host Controller
Bus 002 Device 002: ID 0bda:8153 Realtek USB 10/100/1000 LAN
Bus 002 Device 001: ID 1d6b:0003 Linux 5.15.150 xhci-hcd xHCI Host Controller

root@OpenWrt:/# ifconfig
br-lan    Link encap:Ethernet  HWaddr 52:54:00:12:34:56
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3456/64 Scope:Link
          inet6 addr: fdd1:3f9e:f0ce::1/60 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:1132 (1.1 KiB)

eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:56
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1158 errors:0 dropped:0 overruns:0 frame:0
          TX packets:551 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1150462 (1.0 MiB)  TX bytes:49425 (48.2 KiB)

eth1      Link encap:Ethernet  HWaddr 00:XX:XX:XX:XX:XX
          inet addr:192.168.0.131  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::2e0:4cff:fee1:d44/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:165 errors:0 dropped:0 overruns:0 frame:0
          TX packets:101 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:25710 (25.1 KiB)  TX bytes:11434 (11.1 KiB)
2 Likes

Please share how to run openwrt on Android, I have normal redmi4x rooted, ready to flash or modify anything until my phone hardbrick.
I looking a way to install openwrt on android about a year ago and didn't found a clue.

Today I able to achieve running Openwrt on real Android Phone (Using OnePlus 9R Android 11). I tested below things

  1. Running openwrt on Android
  2. Using Wifi Hostapd of android and using bridge in Openwrt, using this anyone can connect to Wifi HostSpot and Openwrt will act as router for them (instead of Android Defualt network process) to be used as LAN
  3. Use usb ethernet directly in Openwrt to be used as WAN.

Story:

  1. I started running Android 14 on OnePlus 9R spends approx. 2-3 days and not able to root it (which is main requirnment).
  2. After that I tried running Android 13 on OnePlus 9R, and was easily able to root the phone.
  3. On Android 13 I was not able to use usb-host in qemu due to some issue of lib_usb_release (OTHER) and lib_usb_release(BUSY), what I see that when libusb try to lock usb, it is disabled and re-enabled again which again triggers lib_usb_release(BUSY).
  4. I nearly spent 4-5 days and broking whole phone software by pushing the wrong boot.img for rooting I nearly quit the idea of using usb ethernet directly on openwrt .
  5. But then I thought why not try Android 11. When I ran in then didn't get lib_usb_release issue.
  6. After spending a day, I able to identify how to use android hostapd to be triggered from CLI without dhcp server and then creating bridge. I can use wifi of android in QEMU

I had achieved what I wanted but still see some performance problems with network speed, like on iperf3 test from external system, speed is not going beyond 120 Mbps (but my wifi support 800 Mbps) which is due to utilization of 100% single core by iperf3 process.

Now I will focus my work towards tuning for speed

3 Likes

Publishes the tutorial https://dev.to/varunpalekar/use-android-phone-as-advance-router-using-openwrt-26hf

2 Likes