OpenWrt Installation fails on MikroTik RB5009UG+S+IN

Hi all, i am trying to install openwrt 24.10.5 on a MikroTik RB5009UG+S+IN that uses Router OS 7.22 using this guide: https://openwrt.org/toh/mikrotik/rb5009ug_s_in?s[]=link

I have no wan connection on the router during installation, so instead of using wget to download the openwrt image, i upload the bin file needed in /tmp using scp from my PC.

Evetually i run

sysupgrade /tmp/openwrt-24.10.5-mvebu-cortexa72-mikrotik_rb5009-squashfs-sysupgrade.bin

and wait until the router restarts, expecting openwrt to be installed.

Instead the router does not boot and keeps restarting every ~30 seconds.

Has anyone stumbled across a similar problem?
What can i try next?

Hey, did you run sysupgrade directly from RouterOS, or did you go through the full process first?

  1. Booted the initramfs via TFTP
  2. Installed U-Boot
  3. Wiped the NAND with ubiformat

If something went wrong at any of those steps, no panic — you can always restore RouterOS with Netinstall and start fresh!

Also, the wiki might be a bit behind, but the installation steps for the RB5009 are the same regardless of the version. And while you're at it — there's already a newer stable release available at https://downloads.openwrt.org/releases/25.12.0/targets/mvebu/cortexa72/ , might as well go with that one straight away! :blush:

1 Like

Hi Sm00shed thank you for replying!
I actually followed the wiki instructions here are my exact steps:

  1. I used Tiny PXE server to TFTP boot into the initramfs image. That was successful and i was able to login to luci.

After that, the first thing i did was to login to the router via winscp and transfer u-boot.elf and openwrt-24.10.5-mvebu-cortexa72-mikrotik_rb5009-squashfs-sysupgrade.bin into /tmp.

  1. After the files uploaded, I logged in via ssh and loaded . /lib/functions.sh.

  2. I confirmed that the flash layout was ok by running cat /proc/mtd.

I got:
mtd0: 00800000 00020000 "YAFFS"
mtd1: 00010000 00020000 "ubi"
mtd2: 00fe0000 00010000 "MikroTik"
mtd3: 00001000 00010000 "hard_config"
mtd4: 00001000 00010000 "soft_config"
mtd5: 000059f4 00010000 "dtb_config"
mtd6: 00010000 00010000 "RouterBoot-primary"
mtd7: 00020000 00010000 "u-boot-env"

so then i went ahead and run
yafut -d /dev/mtd$(find_mtd_index "YAFFS") -w -i /tmp/u-boot.elf -o kernel -T

That gave no output, just as the wiki states.

  1. I went ahead and formatted the NAND partition for UBI using
    ubiformat /dev/mtd$(find_mtd_index "ubi") -y

that produced a large output:
ubiformat: mtd1 (nand), size 1065353216 bytes (1016.0 MiB), 8128 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 8127 -- 100 % complete
ubiformat: 8009 eraseblocks are supposedly empty
ubiformat: 8 bad eraseblocks found, numbers: 8120, 8121, 8122, 8123, 8124, 8125, 8126, 8127
ubiformat: warning!: 111 of 8120 eraseblocks contain non-UBI data
ubiformat: warning!: only 0 of 8120 eraseblocks have valid erase counter
ubiformat: erase counter 0 will be used for all eraseblocks
ubiformat: note, arbitrary erase counter value may be specified using -e option
ubiformat: use erase counter 0 for all eraseblocks
ubiformat: formatting eraseblock 8127 -- 100 % complete

The wiki says there won't be any output. In my case there are clearly some warnings, but the format was completed 100% so i moved on.

  1. The last step according to the wiki was to run
    sysupgrade /tmp/openwrt-24.10.5-mvebu-cortexa72-mikrotik_rb5009-squashfs-sysupgrade.bin

So i actually did that, and it logged me out of the ssh session.

After that i expected the router to restart and boot into openwrt.
Instead it was stuck in a bootloop. :sob:

So then i used Netinstall to reinstall RouterOS.
That worked ok and now the router boots into RouterOS.

Do you maybe see something i did wrong that i missed?

I will try again with 25.12.0 and post the results here.

Hi,

thanks for the detailed writeup — that really helps narrow it down.

Your steps were correct procedurally. The most likely cause of the bootloop is a version mismatch between u-boot.elf and the sysupgrade image. The wiki warns about this but does not make it obvious enough.

All files must come from the same release. Direct links for 25.12.0:

# For TFTP boot (steps 1+2):
https://downloads.openwrt.org/releases/25.12.0/targets/mvebu/cortexa72/u-boot-rb5009/u-boot.elf

https://downloads.openwrt.org/releases/25.12.0/targets/mvebu/cortexa72/openwrt-25.12.0-mvebu-cortexa72-mikrotik_rb5009-initramfs-uImage.itb
  sha256: cffa81888f5bca2d6f7b3f0a98ff907df16d54e85124512f2d3bb7d483fcd195

# For permanent install (step 7):
https://downloads.openwrt.org/releases/25.12.0/targets/mvebu/cortexa72/openwrt-25.12.0-mvebu-cortexa72-mikrotik_rb5009-squashfs-sysupgrade.bin
  sha256: 616cefec09ba88b28282cd3989e7f1026a897b1abc4781526e2ec77d30ba8aa2

u-boot.elf and sysupgrade.bin must come from the same release. Mixing versions — e.g. u-boot.elf from 24.10.4 with sysupgrade.bin from 24.10.5 — causes incompatible flash layout expectations and results in exactly the bootloop you described.

Note on file transfer — SCP no longer works on current OpenWrt/Dropbear. On Linux, use SSH+cat instead:

cat file | ssh root@192.168.1.1 "cat > /tmp/file"

WinSCP via SFTP works fine.

Step by step for 25.12.0:

  1. Download all three files above, verify sha256sums
  2. TFTP boot using u-boot.elf + initramfs-uImage.itb
  3. Transfer u-boot.elf and sysupgrade.bin to /tmp
  4. . /lib/functions.sh
  5. yafut -d /dev/mtd$(find_mtd_index "YAFFS") -w -i /tmp/u-boot.elf -o kernel -T — no output expected
  6. ubiformat /dev/mtd$(find_mtd_index "ubi") -y — output is normal
  7. sysupgrade /tmp/sysupgrade.bin
  8. SSH session closes immediately — that is expected. Wait 3–5 minutes before reconnecting.

Feel free to report back — happy to help if anything comes up.

Version 25.12.0 works!
Thank you Sm00shed!

By following the exact same steps as before it worked ok.

You were right to point this out:

The most likely cause of the bootloop is a version mismatch between u-boot.elf and the sysupgrade image

Although i did checksums after downloading the files, since i tried both 24.10.4 and 24.10.5 and it failed both times maybe i mistakenly swapped the elf file when uploading.

For anyone else reading this and having trouble installing from a windows environment here are my exact steps to make this work:

  1. I used an unmanmaged simple switch between the windows computer and the RB5009.
    I found that when the router is in a recovery mode trying to boot or whatever windows consider the ethernet cable disconnected and disable the ethernet adapter. So even if you set static ip in windows with the ethernet adapter disabled you are not communicating with the router anymore. This was also a problem for me when trying to use netinstall to restore to Router OS.

  2. I used tinypxeserver https://github.com/erwan2212/tinypxeserver to boot the initramfs via TFTP.
    The wiki (https://openwrt.org/toh/mikrotik/rb5009ug_s_in?s[]=link) explains how to do it in detail. Just be sure to remove the version from your initramfs filename
    ( e.g. openwrt-25.12.0-mvebu-cortexa72-mikrotik_rb5009-initramfs-uImage.itb must be renamed to openwrt-mvebu-cortexa72-mikrotik_rb5009-initramfs-uImage.itb)

  3. If you boot successfully to the initramfs you can download or transfer the u-boot.elf and the sysupgrade.bin to the /tmp folder.

In my case, I used winscp to transfer the files.

Also, maybe irrelevant, but i renamed openwrt-25.12.0-mvebu-cortexa72-mikrotik_rb5009-squashfs-sysupgrade.bin to sysupgrade.bin to avoid large filenames.

After that i did
cd /tmp
And then load the extra functions required by running:
. /lib/functions.sh

After that it's time to do some checksum confirmations
run
sha256sum /tmp/u-boot.elf
and
sha256sum /tmp/sysupgrade.bin
and compare to the checksums for your version (in my case it was 25.12.0 so here https://downloads.openwrt.org/releases/25.12.0/targets/mvebu/cortexa72/sha256sums).
If you use another version just change the 25.12.0 part in the above url to reflect the version you are using.

Optional but maybe useful, you can check the flash layout by running cat /proc/mtd
In my case i got:
dev: size erasesize name
mtd0: 00800000 00020000 "YAFFS"
mtd1: 3f800000 00020000 "ubi"
mtd2: 00fe0000 00010000 "MikroTik"
mtd3: 00001000 00010000 "hard_config"
mtd4: 00001000 00010000 "soft_config"
mtd5: 000059f4 00010000 "dtb_config"
mtd6: 00010000 00010000 "RouterBOOT-primary"
mtd7: 00020000 00010000 "u-boot-env"

Then to be extra careful i checked if the find_mtd_index command, that we will be using next, has loaded by running: find_mtd_index "YAFFS"
It returned 0 in my case because "YAFFS" partition is mtd0 as seen above.

After that i ran
yafut -d /dev/mtd$(find_mtd_index "YAFFS") -w -i /tmp/u-boot.elf -o kernel -T
and
ubiformat /dev/mtd$(find_mtd_index "ubi") -y
as stated in the wiki.
last step is to run sysupgrade /tmp/sysupgrade.bin

You will be disconnected and you have to wait until the router restarts.
Remember to change your static ip, in my case i opted to automatically get ip using dhcp in ethernet adapter settings in windows. Also i had to unplug and plug in again the ethernet cable in order for windows to get an ip.

After that you are hopefully good to go. :victory_hand:

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