By   October 24, 2014

How to auto start Wifi hotspot on Android 4.4.4

I got a broken Nexus-7 and wanted to use it as a router up at DebtRidge. I wanted it to come up as a wifi hotspot automatically when booted. This means the ‘hostapd’ daemon needs to be started automatically. So here’s what I did.

  • Unlock the bootloader
  • Root the tablet and install SuperSU
  • install busybox
  • install init.d

The above is outside the scope of this article. There’s already lots of fine articles that tell you how to do all that.

Once you can get a terminal prompt or adb shell and su, you can proceed.

  • setup the Wifi hotspot in Settings. This will generate a file called /data/misc/wifi/hostapd.conf. It looks something like this:

Since init.d is run in /data/, it runs too early in the boot process for hostapd to start. Another issue is that hostapd won’t run if Wifi is enabled. However, if Wifi hasn’t been enabled, the wlan driver isn’t loaded and hostapd isn’t able to bind to wlan0 because it doesn’t exist. So I had to find a way to load the wifi drivers so that hostapd would come up.

I discovered that I can run “svc wifi enable” to install the drivers and bring up the wlan0 interface. Then “svc wifi disable” would bring down the wlan0 interface but leave the drivers installed. At this point, hostapd was perfectly happy.

So to bring this all together, I needed a script that could be launched at boot time that would delay the starting to hostapd until later in the boot process. Here’s what I did.

mount -o rw,remount /system
cd /system/etc/init.d
cat > 50hostapd
/data/ &
chmod 755 50hostapd

Now install the following script as /data/

while true; do
    su -c svc wifi enable
    sleep 1
    netcfg | grep wlan0 && break
    sleep 10
su -c svc wifi disable
sleep 2
/system/bin/hostapd -e /data/misc/wifi/entropy.bin /data/misc/wifi/hostapd.conf &


chmod 755 /data/

and you should be good to go.

root@deb:/ # ps | grep hostapd
wifi      1282  1     2416   1000  c0138fe4 b6ee46d8 S /system/bin/hostapd