How to install OpenWrt in Asus RT-AC58U?

I need a procedure to install openwrt for the first time in a Asus RT-AC58U router.
I've tried asus firmware update page, but file openwrt-18.06.1-ipq40xx-asus_rt-ac58u-initramfs-fit-uImage.itb upload is unsuscesfull.
Then I renamed file to a shorter name: firmware.itb and also firmware.trx but nothing works.
I've found that it is possible to reboot the router in recovery mode, and tried an "tftp bin put" from my laptop static ip but no connection is done (tried udp port 69 and 9000).
Is there any way to flash official openwrt initial image (at the time this post "openwrt-18.06.1-ipq40xx-asus_rt-ac58u-initramfs-fit-uImage.itb") without using strange images from others webs as some googled pages recommends?
Thanks in advance.

1 Like

The instructions are in the first commit. Unfortunately you need to open it and use a serial cable the first time.;a=commit;h=87c42101cfb001b4bd418d1201fa4d8c822dc77b

Ok. I see.
Once read I've another question that maybe I could answer myself if I get an USB-TTL 3V3 cable.
Let me explain myself:

I understand all git commit instruction steps but point 4:
"4. power up the router and enter the u-boot
choose option 1 to upload the initramfs image. And follow
through the ipv4 setup."

Anybody has seen what u-boot option 1 is? Which steps are required in order to get the initramfs-firmware uploaded?

As long as I've read in Generic Flashing over the Serial Port once you get a serial connection (with "screen" command, for example) you don't have any menu option but a prompt where you need to dump image into memory and then into flash. Am I right? Which memory address should be used there? Which memory values should be used?

Sorry for my ignorance on serial access, u-boot and many other related subjects and many thanks for you patience.

On boot, the u-boot will print the following menu

Please choose the operation:
1: Load System code to SDRAM via TFTP.
2: Load System code then write to Flash via TFTP.
3: Boot System code via Flash (default).
4: Entr boot command line interface.
7: Load Boot Loader code then write to Flash via Serial.
9: Load Boot Loader code then write to Flash via TFTP.

and wait for like 3 seconds. If no number was received it will continue with

3: Boot System code via Flash (default).

and continue as normal

But if you wired up your serial console correctly and hit '1' before the timeout (you can just mash the '1' key as soon as you boot it up. you don't need to wait for the correct moment there), it will open up a new prompt and ask you for your tftp's server's ipv4 (your PC), the client's ipv4 (this RT-AC58U) and for the filename it grabs from the tftp server (not necessarily in this order).

Note: Each of the prompts in "Load System code to SDRAM via TFTP." has a default
value that is encased in "[...]" (i.e.: [RT-AC58U.trx]) . If you just hit enter, it will take the default.

U-Boot Note: The u-boot ethernet driver isn't always reliable and can sometimes
time out... In that case you can hit Ctrl-C to abort and do a retry. (If this doesn't help,
you might need to do a manual power-cycle)


Don't worry about this part. ASUS' integrated this menu option into the u-boot. But if you need to: you can also access the "raw" u-boot shell by pressing '4'. This shell is very useful for recovery purposes, in case the SPI-NAND gets buggered.

Many thanks.

I'll try it as soon as I get the usb serial cable.

In the meanwhile I get the usb-serial cable I've been testing some ideas. I will write it down.

  • Web interface does not allow non-asus firmware (at last when your router firmware is the version released 2018/08/20)
  • Booting in recovery mode(1)(see bellow), if you are connected to via ethernet and your IP (static settings) is you can access with admin user via ssh on port 22 and you can upload files via tftp on port 69.

Unfortunally I've not found how to launch u-boot or something that trigger the firmware install process that upgrade.cgi does via web, and without openwrt firmware installed sysupgrade utility is not available.

I'll keep trying.

(1) you can enter recovery mode having the reset button pressed when you plug the AC-cord and release the button 2/3 sec. after (you can check that you are in recovery because the power led is blinking slowly)

I could package 18.06.1 release for RT-AC58U to TRX format. Download it and install from web interface (for stack firmware from ASUS)

Happy hacking.

Having SSH access might be enough to do it. Can you upload files as well (i.e. via scp/wget/ ... ?) and are the ubi-utils available (i.e: ubinfo, ubimkvol, ubirmvol, ubiupdatevol) in the stock firmware?

Because all that would be necessary to flash the initial OpenWrt installation from the Stock firmware is:

  1. gain SSH access
  2. copy over the sysupgrade.bin image to /tmp (somewhere in memory)
  3. verify the sysupgrade.bin (sha256sum / md5sum / crc32 sum etc...)
  4. extract said sysupgrade.bin (it's a tar.gz file, there might be some noise from gunzip about "Garbage at the end", but that's just the fwtool metadata and usign signature that can be ignored)
  5. delete the linux volume
    (4.5. delete the linux2 volume - not required )
  6. delete the jffs2 volume (might need to be unmounted)
  7. make a new "linux" volume and flash the content of sysupgrade-asus_rt-ac58u/kernel into it.
  8. make a new "rootfs" volume and flash the content of sysupgrade-asus_rt-ac58u/root into it.
  9. make a new "rootfs_data" volume and most importantly: allocate all the remaining space on the flash for it (as this will prevent the u-boot from reformatting the flash)
  10. reboot

everything from step 0 to 9 can be automated by a script. So, if someone is willing to play with this I can give some helpful comments along the way. (Though, I strongly suggest to make a full backup of the whole ubi-partition first and have a serial adapter on standby).

1 Like

Hi @chunkeey,
Yesterday got my router firmware flashed using your first-commit method. It works like a charm. Thank you. I hope you forgive me, but now I don't dare to go back to stock firmware and try this process again, so I can't answer you which tools are available because I didn't look at before. I can't remember if tftp port is open in order to put files on the device, and also I' dont know if ubi-utils are available or need to be uploaded too.

Looking at the sysupgrade scriptable process I've checked my current OpenWrt partition and, maybe I'm wrong, but there are not three partitions mounted. Let me show it:

/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/ubi0_6 on /overlay type ubifs (rw,noatime,ubi=0,vol=6)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)

Hope this helps.

PS.- I want help to openwrt and this router too. First of all I think that router toh page needs a boots and I want to try it, because with a first look I never though I will be soldering a serial port connector. :sweat_smile: (I know, I know, if this works, serial port access could not be needed). But not only installation process is not documented, router page also needs more info to be placed but my forum user don't allow me to login there. Quite strange. What should I do? Thanks in advance.

Hope you understand that I never use apps (or firmwares) from unknown sources.

That's why I ask for the process you followed to get file converted and if it is possible to incorporate to the official openwrt build process given that official .itb file can't not be directly uploaded to stock router and yours seems to.

Was this a misunderstanding :confused: ? The procedure in the previous post is only ever useful for the stock asus' firmware. Because on the openwrt installation you can just use sysupgrade to flash a new image.

The sad part about this is that the early, out-of-tree RT-AC58U images had a "easy install" .itb that could be flashed through the webui. (It required a second sysupgrade for the real installation though). However, this was also the reason why the RT-AC58U was not accepted back then so I removed it.

I looked at mounted partitions because I didn't understand steps 6, 7 & 8. But using ubinfo -a I see partitions 4, 5 and 6 with those names: linux, rootfs and rootfs_data and now I understand the new 'to-be-tested' install procedure. Excuse me.

Is there any reason we can't use one of those older builds to flash via webui and then sysupgrade to the latest Openwrt?

I guess they would require the "-F" force option for sysupgrade, but there was also a big problem caused by a serious upstream bug in the essential ubi-tools of the mtd-utils package. This was introduced by commit:

and only fixed by:

So every image generated between will have a defunct sysupgrade unless the mtd-utils package is updated (through --force-reinstall) manually.

1 Like

Understood. I'm going to take a look at the recovery mode approach @rtac58u-user mentioned this weekend. Assuming the stock image has the appropriate ubi-utils, where do I need to look to find the correct sizes for the linux, rootfs, and rootfs_data partitions?

Oops, "ubi partition" is not the right name. It should have been "ubi volume" (will fix it).
("In a sense, UBI may be compared to the Logical Volume Manager". )

The "linux" volume size is the file size of sysupgrade-asus_rt-ac58u/kernel file.
And likewise the "rootfs" volume size is the file size of sysupgrade-asus_rt-ac58u/root file.

rootfs_data should allocate all remaining free space of the ubi volume (ubimkvol has a special parameter --maxavsize / -m for this). You only need to create the rootfs_data volume, there's no need to format or fill it. Just make sure to use up all the space.

the ubimkvol utility will round-up any size values to the next Logical Erase Block size (~124 KiB on the RT-AC58U).

A great place to look how to deal with ubimkvol is in nand_upgrade_prepare_ubi()

and nand_upgrade_tar() for how to fill a volume:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.