Hi, I installed openwrt on RB951g-2hnd. I don’t know if it’s an appropriate topic here, but I’m desperate. So I want to upgrade firmware. But sysupgrade doesn’t work for mikrotik device. I have to boot from initramfs to be able to rewrite partitions data (rootfs + kernel). I have serial access to uart, but unfortunately there’re no bios options. The only option I see is install routerOs, change boot device and go on. But here’s a tricky part I have changed boot protocol to bootp and netinstall doesn’t see my router now ( just before this operation netinstall found routerboard perfectly) Is there anything I can do from openwrt to change boot device or upgrade system in another way? Thanks in advance!
Anyone?))
Maybe you can use follow Technique.
http://manio.skyboo.net/mikrotik/
Netinstall is for install routeros from tftp.
http://wiki.mikrotik.com/wiki/Manual:Netinstall
I hope you take a backup of your license.
On devices that come without a serial port, even if you solder one on, I don’t think RouterBOOT gives you a menu. It knows what board model it is running on and probably isn’t going to do anything with the serial port if it is not a model that normally comes with one. (This is just a guess on my part; I haven’t tried it nor researched it. But MikroTik’s RouterOS kernel disables the Atheros SoC’s built-in UART on specific models, so I would not be shocked if they do the same thing in RouterBOOT, too.)
There is a utility for OpenWRT called “rbcfg” that allows you to change boot options in RouterBOOT from within OpenWRT. Assuming you are running a stock build of a recent version of OpenWRT, if you have the rbcfg package installed, you should be able to run “rbcfg set boot_device eth” (equivalent to “ethernet” in RouterOS or option “e - boot over Ethernet” in RouterBOOT) or “rbcfg set boot_device ethnand” (equivalent to “try-ethernet-once-then-nand” in RouterOS or option “1 - boot Ethernet once, then NAND” in RouterBOOT) to do what you want.
Alternatively, instead of messing with RouterBOOT options, you can do a one-time boot from ethernet by holding down the reset button on your RB951 while you power it on. You will see the ACT light start to blink after a while, and then a little bit later it will attempt to get an IP via BOOTP followed by TFTP boot. Don’t release the button until the etherboot has finished. Doing this will allow you both to use Netinstall as well as to boot an OpenWRT initramfs kernel via ethernet. Once you have booted OpenWRT via ethernet, you can use ‘wget2nand’ to perform your upgrade.
Finally, it has been my experience that one does not need to be concerned about backing up their RouterOS license on RouterBoards before formatting the NAND and installing OpenWRT on them. Unlike on RouterOS for x86, the license key does not appear to be tied to the storage device, but somehow to the board itself, as can be seen if you use the new RouterOS and RouterBOOT “partitions” feature (whereas re-partitioning an x86 RouterOS hard drive would result in the license key no longer being valid, even if you had backed it up). If you scrub a RouterBoard’s NAND completely, either via RouterBOOT NAND format or even “flash_eraseall” under OpenWRT, the Software-ID and license key will still be intact the next time that you do a Netinstall of RouterOS. I suspect that unlike on x86, the Software-ID is either computed based off of the board serial number or MAC address(es), or it is stored on the small 64Kbyte SPI flash chip that RouterBOOT lives on, and same for the license key itself. So they cannot be lost by messing with the NAND.
– Nathan
Holding the reset button before plugging in power, will load the backup loader, which has default settings, including the correct boot mode.
Thanks for the response, but holding reset doesn’t work, I have the output of a serial port, and there’s just a kernel boot log. So netinstall can’t find the router with the pressed down reset button either. I’ll try NathanA’s suggestion via rbcfg command today
Netinstall doesn’t “find” a router that has its reset button held down. Netinstall finds a router that is running the Netinstall software, which it gets by netbooting it from your PC.
Netinstall works exactly like netbooting OpenWRT does: the Netinstall software on your PC runs a BOOTP server and a TFTP server, and when you hold down the reset button, this causes the router to try to netboot instead of boot from NAND. Netboot consists of 1) getting an IP via BOOTP, and 2) downloading a kernel over the network via TFTP into RAM and executing that. The kernel that Netinstall offers via TFTP contains a special RouterOS installer program, but other than that, the process is exactly the same.
Make sure that you are holding the reset button in BEFORE you power up the router, and make sure that you KEEP holding it in until RouterBOOT starts the netboot process. The fact that you are still seeing kernel boot logs from the kernel stored on the NAND makes me think you either are not pressing the button early enough, or you are letting go of it prematurely.
Also, netboot from a RouterBoard can only happen over a specific ethernet port. It is different for every model, but on most boards, including your 951, you can only netboot from ether1, so make sure that the cable between your 951 and your PC is plugged into ether1 on the RouterBoard.
– Nathan
Thanks awfully! It turns out that router tries to boot from ethernet but netinstall doesn’t provide dhcp server for some reason s and it fails, but doesn’t matter already. I can run vmlinux-initramfs with being held reset button. That’s answered my question, that was very kind of you to post me descriptive manuals that explained a lot.
Unfortunately I even have issues with tftpboot now (Do I need running both dnsmasq and tftpd?)
Here’s my conf.
/etc/dnsmasq.conf
interface=enp2s0
dhcp-range=192.168.1.100,192.168.1.119,12
dhcp-host=d4:ca:6d:92:a4:7e,192.168.1.101
enable-tftp
tftp-root=/srv/tftp
dhcp-boot=openwrt-ar71xx-mikrotik-vmlinux-initramfs.elf,boothost,192.168.1.10
: ifconfig
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.10
:ls /srv/tftp/
openwrt-ar71xx-mikrotik-vmlinux-initramfs.elf
: systemctl status tftpd
● tftpd.service - hpa's original TFTP daemon
Loaded: loaded (/etc/systemd/system/tftpd.service; static; vendor preset: disabled)
Active: active (running) since Tue 2015-02-10 22:53:32 EET; 3min 44s ago
Main PID: 30664 (in.tftpd)
CGroup: /system.slice/tftpd.service
└─30664 /usr/sbin/in.tftpd -s /srv/tftp/
Next I run it:
sudo ifconfig enp2s0 192.168.1.10 up
sudo systemctl start tftpd
sudo dnsmasq -i enp2s0 -d -u test -p0 -K --log-dhcp --bootp-dynamic
And reboot the router with reset held down, but router floods with requests in dnsmasq log.
dnsmasq-dhcp: 3595606023 available DHCP range: 192.168.1.100 -- 192.168.1.119
dnsmasq-dhcp: 3595606023 vendor class: Mips_boot
dnsmasq-dhcp: 3595606023 DHCPDISCOVER(enp2s0) d4:ca:6d:92:a4:7e
dnsmasq-dhcp: 3595606023 tags: enp2s0
dnsmasq-dhcp: 3595606023 DHCPOFFER(enp2s0) 192.168.1.114 d4:ca:6d:92:a4:7e
dnsmasq-dhcp: 3595606023 requested options: 1:netmask, 3:router
dnsmasq-dhcp: 3595606023 bootfile name: openwrt-ar71xx-mikrotik-vmlinux-initramfs.elf
dnsmasq-dhcp: 3595606023 server name: boothost
dnsmasq-dhcp: 3595606023 next server: 192.168.1.10
dnsmasq-dhcp: 3595606023 sent size: 1 option: 53 message-type 2
dnsmasq-dhcp: 3595606023 sent size: 4 option: 54 server-identifier 192.168.1.10
dnsmasq-dhcp: 3595606023 sent size: 4 option: 51 lease-time 2m
dnsmasq-dhcp: 3595606023 sent size: 4 option: 58 T1 1m
dnsmasq-dhcp: 3595606023 sent size: 4 option: 59 T2 1m45s
dnsmasq-dhcp: 3595606023 sent size: 4 option: 1 netmask 255.255.255.0
dnsmasq-dhcp: 3595606023 sent size: 4 option: 28 broadcast 192.168.1.255
dnsmasq-dhcp: 3595606023 sent size: 4 option: 3 router 192.168.1.10
dnsmasq-dhcp: 109765576 available DHCP range: 192.168.1.100 -- 192.168.1.119
.... thousands time more
dnsmasq-dhcp: 3472001688 available DHCP range: 192.168.1.100 -- 192.168.1.119
dnsmasq-dhcp: 3472001688 vendor class: Mips_boot
dnsmasq-dhcp: 3472001688 DHCPREQUEST(enp2s0) 0.0.0.0 d4:ca:6d:92:a4:7e
dnsmasq-dhcp: 3472001688 DHCPNAK(enp2s0) 0.0.0.0 d4:ca:6d:92:a4:7e wrong network
dnsmasq-dhcp: 3472001688 broadcast response
dnsmasq-dhcp: 3472001688 sent size: 1 option: 53 message-type 6
dnsmasq-dhcp: 3472001688 sent size: 4 option: 54 server-identifier 192.168.1.10
dnsmasq-dhcp: 3472001688 sent size: 13 option: 56 message 77:72:6f:6e:67:20:6e:65:74:77:6f:72:6b
dnsmasq-dhcp: 3472001688 available DHCP range: 192.168.1.100 -- 192.168.1.119
dnsmasq-dhcp: 3472001688 vendor class: Mips_boo
.... thousands time more
No matter what parameters I enter, rbcfg can’t parse mtd
root@OpenWrt:/tmp# rbcfg get boot_device
unable to find configuration
It looks like rbcfg doesn’t support mikrotik either.
root@OpenWrt:/tmp# cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00020000 "booter"
mtd1: 003c0000 00020000 "kernel"
mtd2: 07c00000 00020000 "rootfs"
main.c rbcfg
err = sscanf(dev, "mtd%d: %08x", &mtd_num, erase_size);
if (err != 2)
break;
sprintf(dev, "/dev/mtdblock%d", mtd_num);
p.s. The reason I want to upgrade openwrt so badly:
Mikrotik is running halfbroken openwrt firmware now, which I compiled using builroot and half of demons including dnsmasq are trying to access /tmp/their.files (for example /tmp/dnsmasq.d which do not exist) and fail to run. So I wanna try already compiled rootfs.
Thanks for your help and spent time!
I have never actually tried to use it; I just read about it. Stock OpenWRT on most RouterBoards apparently supports access to the SPI flash through the MTD layer, whereas I primarily use custom kernels based off of MikroTik’s own patches which do not have this feature, so I have been unable to try this utility. I assumed that you were using stock OpenWRT yourself.
Netinstall remembers the “Boot Server enabled” checkbox setting (behind the “Net booting” button), and I have noticed that sometimes if you start Netinstall with the boot server disabled, and you go in and check the box, the built-in BOOTP server does not seem to start properly (a bug, I think). So I check the box, close the application, and start it again, and that seems to work.
Also, make sure that if you are running Windows Vista or newer (7, 8, 8.1, 10) that you run Netinstall as Administrator, otherwise it won’t have enough permissions from the system to do things like run a BOOTP server.
Well, as I said before, you need both BOOTP (to give the device an IP address and the name of the image to request via TFTP) and TFTPD (to serve the file to the device). Whether you use dnsmasq for BOOTP or something else, like ISC DHCPD, is of no consequence as long as the DHCP server that you choose to use supports the configuration that you want. It sounds like dnsmasq also has built-in tftpd, so I suppose you can use that, too, or disable it and use a separate tftpd…your choice.
I have actually never bothered trying to set up dnsmasq to do this, so I can’t advise you there without doing some additional research. But it is very easy to use another RouterOS router to do this:
/ip address add address=192.168.1.10/24 interface=ether2
/ip pool add name=pool1 ranges=192.168.1.100-192.168.1.119
/ip tftp add ip-addresses=192.168.1.0/24
/ip dhcp-server network add address=192.168.1.0/24 boot-file-name=openwrt-ar71xx-mikrotik-vmlinux-initramfs.elf
/ip dhcp-server add name=server1 interface=ether2 address-pool=pool1 bootp-support=dynamic disabled=no
Upload your openwrt-ar71xx-mikrotik-vmlinux-initramfs.elf to your host RouterOS router, plug your OpenWRT RouterBoard into ether2, boot it up while holding down the reset button, and voila.
If you don’t have a second or spare MikroTik router, install x86 RouterOS on a spare PC or in a VM. You can do so without buying a license key, and you will get a 24-hour demo/trial license, which should be enough time for you to fix your 951.
– Nathan
I allways use dnsmasq with very long one liner, like this for make it easy for recovering devices.
Because dnsmasq supports dhcp and tftp. Simply shortest the best or ??
I can see some logs directly on screen instead of reading from log files in /var/log.
Just copy the boot file to the current working directory.
And start dnsmasq as no-deamon.
sudo dnsmasq --no-daemon --conf-dir= --conf-file= --no-hosts --no-resolv --interface=eth0 --dhcp-range=192.168.1.101,192.168.1.101,1h --dhcp-host=d4:ca:6d:92:a4:7e,192.168.1.101 --enable-tftp --tftp-root=$(pwd) --dhcp-boot=openwrt-ar71xx-nand-vmlinux-initramfs-lzma.elf
Thanks it worked, I just had only 12s and that was the issue.
Unfortunately I have another issue now.
So I booted on vmlinux and network worked fine without any issues, I was able to copy files over ssh and firmware them and didn’t even notice anything suspicious. When I rebooted to just firmwared router I found out that my laptop didn’t acquire an ip address from dhcp router’s server. I logged via serial and system works properly. I uncomment wifi in /etc/network/wifi, and surprisingly I’m able to connect the router via wifi, ping, scp files etc. I reboot the router with serial connected and noticed that there are no kernel errors, nor logread errors either. ps shows that all required processes seem to be running.
So I dig a bit deeper. I run tcpdump on openwrt and wireshark on my laptop (previusly scp package over wifi (cause it’s the only working thing in my network) and installed it).My laptop sends packages to mikrotik including dhcprequest, but router’s tcpdump shows only included in the code section bellow. ps. I’m using bleeding edge (latest developers revision)).
I also tried to firmware the router from downloads.openwrt.org image but it has the same issue (vmlinux-initramfs works on it too) . What should I try next? I don’t even know where I should be looking for, because there’re no errors. I also had been running openwrt on this device before (12.04), but I had some issues with rebooting every 5 hours nevertheless network worked perfectly. Seems like rebooting issue is gone now.
[09:34:15.779328 IP6 fe80::d6ca:6dff:fe92:a47e > ff02::1: HBH ICMP6, multicast listener querymax resp delay: 10000 addr: ::, length 24
09:34:15.869302 IP6 fe80::d6ca:6dff:fe92:a47e > ff02::1:ff00:0: HBH ICMP6, multicast listener reportmax resp delay: 0 addr: ff02::1:ff00:0, length 24
09:34:19.719294 IP6 fe80::d6ca:6dff:fe92:a47e > ff05::1:3: HBH ICMP6, multicast listener reportmax resp delay: 0 addr: ff05::1:3, length 24
09:34:22.059297 IP6 fe80::d6ca:6dff:fe92:a47e > ff02::2: HBH ICMP6, multicast listener reportmax resp delay: 0 addr: ff02::2, length 24
09:34:23.479305 IP6 fe80::d6ca:6dff:fe92:a47e > ff02::1:ff92:a47e: HBH ICMP6, multicast listener reportmax resp delay: 0 addr: ff02::1:ff92:a47e, length 24
09:34:23.559283 IP6 fe80::d6ca:6dff:fe92:a47e > ff02::1:ff00:1: HBH ICMP6, multicast listener reportmax resp delay: 0 addr: ff02::1:ff00:1, length 24
09:34:24.139291 IP6 fe80::d6ca:6dff:fe92:a47e > ff02::1:2: HBH ICMP6, multicast listener reportmax resp delay: 0 addr: ff02::1:2, length 24
I’m not sure if I am understanding you correctly, but I think you are trying to tell us that everything works perfectly except that you aren’t getting an IP address from the DHCP server on the router? And that tcpdump seems to show that the router is not even receiving your DHCP request?
If so, unfortunately, this is not a RouterOS problem, but probably an OpenWRT bleeding edge problem, and so it would be best for you to ask your question on the OpenWRT forums instead of here. If I had to guess, something changed in the Atheros ethernet driver, which introduced a bug when trying to use the ethernet ports on the 951G and possibly other router models as well, but I don’t know.
You could try giving your computer a static IP in the same range that the DHCP server is handing out IPs from, and see if you can communicate with the router via ethernet after you do that. If that doesn’t even work, then this is definitely a bug in the Atheros ethernet support. I would try downgrading to the last stable release of OpenWRT that supports your model of router. If you have a recent 951G with a MAC that starts with 4c:5e:0c then you may need to build your own copy of OpenWRT after applying the patch from http://patchwork.ozlabs.org/patch/419857/. Other than that, I have no ideas, and you should take it up with OpenWRT; sorry.
– Nathan
I finally gave up on installing openwrt, Just want to switch back to stock routerOS.
Unfortunately winbox refuses to detect my router. Still dnsmasq works fine (both with pressed reset button on startup). Is there routerOs initramfs (that’s packed to netinstall windows tool) image? So I bootp it via dnsmasq and then winbox would see my router. Or maybe there’s a way I could manually unpack routeros-mipsbe-6.32.2.npk to mtblock1+mtblock2?
p.s. Thank you for the answers you already provided they helped me a lot.
Ok i finally found the reason. Initramfs wasn’t the key of success It turns out that ethernet ports only work if router was booted with pressed reset button. This is really bizarre…