WARNING! Use this only with Ubiquiti UniFi AP! You may break your device!
If you are trying to flash OpenWRT to Ubiquiti UniFi AP updated to 4.0.15 or greater, process will finish with an error. Device goes into infinite blinking and will not boot after power reset. Standard recovery to stock flash makes device work again, but... We want OpenWRT. We have an issue with stock firmware: Apple mobile devices don't connect to AP at all. Sometimes We were able to connect, but this APs are aimed for public usage, you don't want to tell your customers something like this: "to connect to our shared WiFi network, please, touch you nouse with your right hand middle finger, keeping your left hand fingers crossed". Customers just want to select your free office network, thats all they are ready to do. In one of our offices we were able to flash OpenWRT on UniFi AP (without any troubles) and problems were gone. "Yeah! Let's flash OpenWRT to all APs we have!". But... Only one of our APs was not updated to recent stock firmware... What's going on? Why can't we flash the same firmware to same APs with the same HW as the first one? Let's try to figure out.
We've opened AP case and attach serial console to its serial port:
Warning! Please keep +3.3 pin unconnected!
Connect UBL-to-TTL (i'm using cheap CP2102 converter ) to your PC (i'm using linux, so... sorry ) and run serial console:
$ ls -lh /dev/ttyUSB*
/dev/ttyUSB0
$ screen /dev/ttyUSB0 115200
Then, start flashing AP as we always do: Switch power off, hold button and power on device. At this point you should see messages in your console. If you don't, then... You made connection in wrong way, try to redo connection. Or... Your AP is dead.
As a results, flash procedure finished with error: no partition named rootfs (sorry, i did not save original message).
What?.. Okay, let's break boot procedure by pressing any button in screen during early boot stages. You have olny 1 second to do this. print out available partitons:
ar7240> mtdparts
device nor0 , # parts = 5
#: name size offset mask_flags
0: u-boot 0x00040000 0x00000000 0
1: u-boot-env 0x00010000 0x00040000 0
2: kernel 0x00760000 0x00050000 0
3: cfg 0x00040000 0x007b0000 0
4: EEPROM 0x00010000 0x007f0000 0
.....
mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),7552k(kernel),256k(cfg),64k(EEPROM)
...
Eah, no rootfs partiton there...
Let's try this procedure with our first AP:
device nor0 , # parts = 6
#: name size offset mask_flags
0: u-boot 0x00040000 0x00000000 0
1: u-boot-env 0x00010000 0x00040000 0
2: kernel 0x00100000 0x00050000 0
3: rootfs 0x00660000 0x00150000 0
4: cfg 0x00040000 0x007b0000 0
5: EEPROM 0x00010000 0x007f0000 0
active partition: nor0,0 - (u-boot) 0x00040000 @ 0x00000000
defaults:
mtdids : nor0=ar7240-nor0
mtdparts: mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),1024k(kernel),6528k(rootfs),256k(cfg),64k(EEPROM)
Reconnect the second AP and recreate same partitons as on the first device:
ar7240> mtdparts del nor0,4
ar7240> mtdparts del nor0,3
ar7240> mtdparts del nor0,2
ar7240> mtdparts add nor0 0x00100000@0x00050000 kernel
ar7240> mtdparts add nor0 0x00660000@0x00150000 rootfs
ar7240> mtdparts add nor0 0x00040000@0x007b0000 cfg
ar7240> mtdparts add nor0 0x00010000@0x007f0000 EEPROM
ar7240> setenv mtdparts mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),1024k(kernel),6528k(rootfs),256k(cfg),64k(EEPROM)
ar7240> saveenv
ar7240> reset
After that connect AP to you PC with internet cable (do not detach console if you want to see flash process progress) and flash device with TFTP client:
- Download OpenWRT firmware (https://openwrt.org/toh/ubiquiti/unifi, ...-factory.bin)
- save firmware to file, lets say fw.bin
- Prepare tftp client:
$ cd
$ tftp 192.168.1.20
tftp> binary
tftp> trace
tftp> put fw.bin
do not hit enter on the last command, just type it and go to the next point
3) Poweroff device
4) hold reset button
5) poweron device. do not release reset button
6) at the same time hit enter in tfpt client console
7) You can release reset buttononce you see the progress in tftp console
Check device serial console in screen. AP will flash and reboot. That's all.