Add support for MikroTik RB5009UG

Minimum is included by default, so its up to you to include packages you want.
Only I2C bitbang and yafut are included extra by default.

1 Like

A question while compilation takes place.
Once converted to upstreamable state (if everything goes well) will we be able to install packages later with opkg from OpenWrt main (I suppose this should be merged to main before that and we will be able to sysupgrade via auc later too).

You can already install packages that dont require kernel modules to be installed, as prebuilt kmods wont work

1 Like

It's built on top of main, and main is 6.6 only for mvebu. So: yes.

1 Like

@Borromini
I've asked about the kernel version because actually I've never been able to run 6.6 properly on this device - installed nor initram.
I have this issue on it.
I even bought an USB LAN adapter for my Laptop just to be able to test on it as a router but I simply get general failure/unidentified network with kernel 6.6.
Booting from Robimarko's initram image gave the same result for me - a PC never gets an IP address. Manually assigning one doesn't help either. Unfortunately I don't have a serial connection on it.
I still have a build with kernel 6.1 that runs OK and can boot from initram too.
So my question is, can I run all commands from my initram 6.1 image?

@robimarko
I've made a second try. This time the device booted from your initramfs image.
Here is what I've done.
First i got this error.

root@OpenWrt:~# yafut -d /dev/mtd0 -w -i /tmp/u-boot.elf -o kernel -T
file_driver_yaffs.c:87: file_yaffs_open_for_writing: unable to open 'kernel' for writing: error -28 (No space left on device)

Then I tried second time and it went without any output.

root@OpenWrt:~# yafut -d /dev/mtd0 -w -i /tmp/u-boot.elf -o kernel -T
root@OpenWrt:~#
root@OpenWrt:~# ubiformat /dev/mtd1 -y
ubiformat: error!: please, first detach mtd1 (/dev/mtd1) from ubi0
root@OpenWrt:~# ubidetach -p /dev/mtd1
root@OpenWrt:~# ubiformat /dev/mtd1 -y
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: 8120 eraseblocks have valid erase counter, mean value is 0
ubiformat: 8 bad eraseblocks found, numbers: 8120, 8121, 8122, 8123, 8124, 8125, 8126, 8127
ubiformat: formatting eraseblock 8127 -- 100 % complete

root@OpenWrt:~# cat /sys/firmware/mikrotik/soft_config/boot_device
eth flasheth ethonce flash [cfg] cfgonce

root@OpenWrt:~# sysupgrade -n /tmp/sysupgrade.bin
Tue Dec 20 04:26:40 UTC 2095 upgrade: Commencing upgrade. Closing all shell sessions.

After this it looks like the device is in a bootloop.
The system LED doesn't blink with the normal boot frequency patterns.

Where you using the Adrons AUX loader before?

Because, it seems like the whole NAND was wiped so thus there was no YAFFS.
I wrote the instructions for board that have not been messed, I would advise reinstalling ROS with Netinstall and retrying.

BTW, I finally figured out what Adron did to fixup UART in RouterBoot and managed to patch the current RouterBoot 7.15 to also have working UART (MikroTik is still plainly disabling UART in RouterBoot but in a bit different way).

2 Likes

Yep, I installed previously OpenWrt using instructions from Adron's github readme

wget https://github.com/adron-s/aux-loader2/raw/main/releases/2.xx-latest/rbt-with-aux-for-mtd5.bin \
  -O- | mtd write - RouterBOOT
echo cfg > /sys/firmware/mikrotik/soft_config/boot_device
echo 1 > /sys/firmware/mikrotik/soft_config/commit

wget https://github.com/adron-s/openwrt-rb5009/releases/download/rb5009-20220209/openwrt-mvebu-cortexa72-mikrotik_rb5009-squashfs-sysupgrade.bin \
  -O- > /tmp/fw.bin && sysupgrade /tmp/fw.bin

I restored the device with Netinstall.
I try to load your image following the procedure from here using the reset button but the Tiiny PXE server doesn't upload it to device.
The RB5009 takes IP from Pxe server but looks like the image is not requested/recognized.

I've done this before more than 20 times trying to figure out the kernel 6.6 issues and it was working but only with 6.1 images. Unwillingly I became an expert in Netinstall restoring and booting from initramfs images.

Update - I've tried several times to boot from 6.6 initram image unsuccessfully.
But this time I tried issuing the commands from RouterOS.

/system/routerboard/settings/set boot-device=try-ethernet-once-then-nand
/system/reboot

I had to restore the device with Netinstall few months ago when I first tried and failed to run 6.6 successfully.
Currently it is running RouterOS 7.14 after Netinstall restoring for second time.
I don't really know what is wrong with kernel 6.6 but I cannot connect to device.
At the same time the 6.1 images I compiled few months ago boot perfectly fine and don't have any issues but they miss yafut.
If anyone has working 6.6 image I can try to install it and see if it works.
I compiled my 6.6 image from upstreamable branch with default settings adding only Luci.

I remain at disposal to try other things as suggested.

Does RouterBoot fetch the image or not?

Cause it really sounds it doesnt even get it via TFTP, let alone boot

I was able to boot from the image and perform the whole setup. I suspect that the missing cable in WAN port makes troubles during boot.
But is this OK after sysupgrade.

root@RB5009:~# cat /sys/firmware/mikrotik/soft_config/boot_device
eth [flasheth] ethonce flash cfg cfgonce

In Adron's readme it is stated that it should be cfg in order to boot from NOR.
I set it to cfg but after a reboot I'm in a bootloop again.
Looks like I will have to start from Netinstall for the third time.

Yes, you want to boot from NAND, not NOR since U-Boot installed in place of the ROS kernel on NAND

My mistake, sorry. So [flasheth] was OK but I wrongfully set it to eth cfg.
@robimarko
I meant cfg not eth.

eth will just make it constantly try and load image via networking

I booted the initramfs and issued

root@RB5009:~# uname -a
Linux RB5009 6.6.32 #0 SMP Mon Jun 10 10:25:27 2024 aarch64 GNU/Linux
root@RB5009:~# cat /sys/firmware/mikrotik/soft_config/boot_device
eth flasheth ethonce flash [cfg] cfgonce
root@RB5009:~# echo flasheth > /sys/firmware/mikrotik/soft_config/boot_device
root@RB5009:~# cat /sys/firmware/mikrotik/soft_config/boot_device
eth [flasheth] ethonce flash cfg cfgonce
root@RB5009:~# echo 1 > /sys/firmware/mikrotik/soft_config/commit
root@RB5009:~# cat /sys/firmware/mikrotik/soft_config/boot_device
eth [flasheth] ethonce flash cfg cfgonce
root@RB5009:~# reboot

@robimarko
Finally everything is OK. Boots and works OK with kernel 6.6. I even tried to boot it without any cable attached (I had issue previously booting without cable attached) and it is completely OK.
Thanks a lot and apologies to everyone for the long and distracting posts.

1 Like

So if I understand right, anyone running OpenWrt on it already should revert to stock, which will overwrite the hacked RouterBOOT, correct? And we can then replace the newer RouterBOOT with your patched one to get UART again?

Yes, you should reinstall ROS so that the original NAND partitioning is restored, but it will not replace RouterBoot if you already installed the patched one.

I was working on patching 7.15 RouterBoot to gain some knowledge on how to do it and also because 7.2rc1 RouterBoot is not the best one

1 Like

OK. So Adron's version is still good to boot your tree as well, just outdated (7.2 RC vs 7.15)? I'm not seeing any RouterBOOT binaries on your site, so I suppose the patched one you're referring to is still Adron's.

Just getting my ducks in a row before I kill our internet and my wife and daughter start screaming at me because they can't watch Netfix on the flatscreen :angel:.

1 Like

Yes, his patched RouterBoot still works fine, I used it until yesterday, it just boots U-Boot anyway.

I did not post the changes for 7.15 yes, I will most likely just fork his repo and adapt the binary patching script to work on 7.15 so its reproducible.
I managed to patch it in Ghidra late last night so it will take some time.

1 Like

No rush, when I read your announcement yesterday, I read it as if you were offering your own RouterBOOT already. Just wanted to clear up any confusion about that.

Thanks for all the work and the love you've shown this piece of hardware :slight_smile:.

1 Like

I would not call it mine, I was just able to figure out how Adron patched it and then figure out what MikroTik changed in the newer version.
It was quite a learning experience using Ghidra to binary patch stuff.

I will add a partition exposing the primary RouterBoot so it can be easily replaced from OpenWrt.
I have pushed the patched RouterBoot 7.15:
https://public.robimarko.eu/70x0-7.15-uart.fwf

3 Likes