Add support for MikroTik RB5009UG

Yeah, they have prepared this thing for spinning out a couple of versions with the same PCB.
PoE is missing completely, it appears to use one of their MCU-s again and SPI along with UART for communication.

That U700 is a huge BGA, its the size of the main CPU esentialy

1 Like

The RB750Gr3 did have replacement U-boot instructions at one point. I think it called for a SPI programmer which most people probably don't have, at least I don't. Would it be worth it to have the FSF try to get the source code?

I was going to port my bootloader from rb3011 to rb5009. this is exactly what should solve this problem.
I also have the hope that it will be possible to configure the RouterBoot to load the ELF kernel from the NOR flash drive. To do this, we need to carefully study the difference in the parameters of the Hard configs for NOR and NAND Mikrotik devices.

But that is an issue as your loader will pretty much newer be accepted into OpenWrt, that was the reason we went the appending DTB route for IPQ40xx basically.
Why not simply utilize U-boot when Armada 7040 is fully supported there?

The variant with U-Boot also seems to be not bad - we'll see. Now the main thing is to somehow launch an ELF image (even packed in YAFFS) from the NOR flash drive.

I honestly prefer U-boot as its a standard thing and we can easily upstream and get it included in OpenWrt.

BTW MikroTik just shared ROS v7 GPL:

Obviously all of the juicy stuff is missing like the switch driver itself which to me looks like it was picked from Marvell-s SDK.

What are they doing here:

mdio_regs = ioremap(0xf212a200, 0x100);
writel(is_type("5009") ? 0x612 : 0x610, mdio_regs + 4);

It's the MDIO(SMI) MISC configuration register, it looks like they are enabling a fast MDC clock, it sets the clock to be divided by 16 instead of 128 and disabling MDC invert

3 Likes

I wonder when will we see RB5006?

Yeah, it looks like it should be arriving soon.
The MVPP2 source looks interesting as it exposes the port map they are using but the fun stuff like 8081 ops and SFP GPIO-s are external and not included.

But they have included the kernel configs so we can build kernel modules and poke at stuff.

Yes, this is already something. Now it will be easier with RB5009 research.

Yes, I think RB5006 will be on armada v3(Armada 88F3720?) and it will have 5 ethernet ports and one sfp. Something like https://www.gl-inet.com/products/gl-mv1000/
Also in the kernel patch there is a mention of IPQ6018, is it worth waiting for the devices soon on it too?

I assume they are getting into low-end 802.11ax if IPQ6018 is coming, I have seen that the RouterBoot for it is already in ROS v7.

Ahh, Mikrotik has masked exporting symbols based on arch.
So on arm64 there is no of_mdio_find_bus() despite OF_MDIO being enabled.
Why Mikrotik, why?

That's indeed unsympathetic, but on the other hand not having a way back to stock due to lost ROS license also doesn't sound great, if that should be true.

For now stuck with my FB7490 its working well but for someone loving open source and the full flexibility... Whatever happy you are working on so many interesting platforms!

@adron Bad news, I tried writing the u-boot ELF to the NAND boot partition, and RouterBoot won't boot that, so I assume it requires YAFFS packing once again.

Heck, it's not happy even after packing it into YAFFS.
I am looking a the boot partition dump, there is actually a lot of binary data before the kernel itself, and at the start, there is a header of sorts and then binary chunks.

The YAFFS kernel is only at offset 0x2937f0

This doesn't look like anything I have seen so far

2 Likes

And my YAFFS section with the kernel starts with offset 0x293000 on /dev/mtdblock0.
By the way, it is available in the RouterOS itself. Try to replace it in the RouterOS with your ELF u-boot (so that all the YAFFS work will be taken over by the RouterOS).

In total, as I wrote above, the native RouterOS kernel can be very easily replaced in a jailbroken RouterOS. For testing, I replaced the native RouterOS kernel with a modified jailbreak kernel:

/ # mount | grep flash/boot
/dev/mtdBoot on /flash/boot type yaffs (rw,noatime,nodiratime)
/ # cd /flash/boot
/flash/boot # ls
VERSION     kernel      lost+found
/flash/boot # nc 172.20.1.77 1111 > ./kernel
sync

And now always, when I load RouterOS from a NAND flash drive, I have a telnet x.x.x.x 22111 - TFTP boot is no longer needed for this!

So...I propose a scheme like this:
The new RB5009 must be launched once via tftp using jailbreak.
Then, using jailbroken RouterOS, the native kernel is replaced by the ELF image of U-BOOT in the /flash/boot
No more changes required!
Then OpenWRT is installed as standard, via the U-BOOT Web interface. Free 15 megabytes of NOR flash drive is used for OpenWRT.
RouterOS remains on the NAND flash drive.
In this case, we do not need any kernel2minor and other dances with a tambourine! It also greatly simplifies the commit to upstream.

4 Likes

My RB50009UG also arrived. Can I do something to help you, or test stuff?

2 Likes

Could it be possible to pack the jailbreak into a npk that one can Netinstall ?

I was using OpenWrt and nandwrite to write the files, even writing the stock boot part dump doesn't work so I am doing something wrong.
I will use Netinstall and try again.

I am all for using the jailbreak to install U-boot, but I want to use the NAND for OpenWrt and not the NOR, why would you even buy RB5009 if you are going to limit yourselves to 15MB of slow NOR?
And if you replace the kernel with U-boot then there is no need for kernel2minor as U-boot can just boot a normal UBI OpenWrt image on the NAND.

Using ROS to flash the U-boot ELF works, but MikroTik managed to use a misconfigured ATF so it reports 2GB of RAM which U-boot then happily reads and updates the DTB with it.
So this needs to be overriden

3 Likes

If it is used simply as a router, then NOR is more than enough. But of course, no one forbids you to use the NAND. Let's figure it out: /flash/boot size is only ~8MB. So if you do not touch this space, then you can use the rest of the NAND for UBI.
So, we have two pieces of NAND:
0x00000000 - 0x007FFFFF - RouterBoard NAND Boot - size: 0x00800000 - 8.388.608 Bytes
0x00800000 - 0x3F7FFFFF - RouterBoard NAND Main - size: 0x3f800000 - 1065.353.216 Bytes or ~ 1Gb
After writing U-Boot ELF to /flash/boot, the space 0x00800000 - 0x3F7FFFFF can be freely used by OpenWRT for UBI.

Yeah, that was my idea simply utilize the remaining space for OpenWrt as there is almost 1GB left