Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
toh:mikrotik:common [2019/06/07 20:23] – [Long read] change list numbering and some language corrections patrickoceantoh:mikrotik:common [2024/11/03 16:16] (current) – Clarify misleading routeros version restriction base258
Line 1: Line 1:
-====== Common Procedures for Mikrotik RouterBoard Products ======+====== Common Procedures for MikroTik RouterBoard Products ======
  
 This page describes common procedures across MikroTik RouterBoard routers. If you edit / add information about a specific model, please consider linking to this page to avoid repeating common instructions. This page describes common procedures across MikroTik RouterBoard routers. If you edit / add information about a specific model, please consider linking to this page to avoid repeating common instructions.
 +
 +<WRAP alert>
 +OpenWrt is not compatible with the bootloader of RouterOS **v7**. Do NOT upgrade the firmware on your device to RouterOS **v7** or, if you did, downgrade to RouterOS Firmware **v6** before installing OpenWrt.
 +RouterOS doesn't allow to downgrade below factory firmware version, but OpenWrt boots and works fine with 
 +versions up to 6.49.10 or beyond. Confirmed working: 6.47.10 (tested on  SXTsq 5 ac), 6.49.10 (tested on SXTsq 2nD).
 +</WRAP>
  
  
-===== Overview of OpenWrt installation =====+===== Overview of OpenWrt installation: TL;DR =====
  
 **TL;DR** **TL;DR**
-  - Save the license key of RouterOS and (optional) original firmware. +  - (optional) Save the license key of RouterOS and the original firmware
-  - Boot router via network boot (DHCP/TFTP) for testing. OpenWrt isn't installed now, it's working from a RAM image. If it doesn't work, try a different version of OpenWrt.+  - Downgrade to RouterOS v6 if you previously upgraded to v7
 +  - Boot router via network boot (BOOTP/TFTP or DHCP/TFTP) for testing. OpenWrt isn't installed now, it's working from a RAM image. If it doesn't work, try a different version of OpenWrt.
   - If all right, write OpenWrt into flash of the router, then reboot.   - If all right, write OpenWrt into flash of the router, then reboot.
   - Tuning OpenWrt.   - Tuning OpenWrt.
  
-**Long read**+===== Overview of OpenWrt installation: Full text =====
  
 RouterBoards can netboot OpenWrt initramfs .elf (.bin in some instances) images via TFTP. This RAM-based initramfs OpenWrt image is first used to validate the desired OpenWrt version operates properly without overwriting any existing image in the NAND or NOR flash of the RouterBoard. RouterBoards can netboot OpenWrt initramfs .elf (.bin in some instances) images via TFTP. This RAM-based initramfs OpenWrt image is first used to validate the desired OpenWrt version operates properly without overwriting any existing image in the NAND or NOR flash of the RouterBoard.
Line 22: Line 29:
  
 ==== First Things First: Don't Lose Your RouterOS License ==== ==== First Things First: Don't Lose Your RouterOS License ====
 +
 +//Note: this step seems to be optional, at least for routers, since their license is tied directly to the hardware. Still, do this just in case.//
 +
 Before you start installing OpenWrt, save your RouterOS License .key file.  This will allow you to use Mikrotik's NetInstall to re-install RouterOS.\\    Before you start installing OpenWrt, save your RouterOS License .key file.  This will allow you to use Mikrotik's NetInstall to re-install RouterOS.\\   
-Save your license by using Mikrotik WinBox: it's under System->License->Export Key. The Mikrotik WebFig web interface does not export license files, you must use WinBox. 
  
-[[#Saving MikroTik RouterBoard License Key Without Using WinBox|See below]] for other methods to export your license file.+ 
 +  * [[#Saving MikroTik RouterBoard License Key Without Using WinBox|Procedure for Linux and other unix-like OS]]  
 +  * [[#saving_mikrotik_routerboard_license_key_using_winbox_and_windows|Procedure for Windows with winbox]] 
 + 
 + 
 +==== Make sure the bootloader is compatible  ==== 
 + 
 +The bootloader from RouterOS **v7** is not compatible with OpenWrt. If you have it, you will be able to netboot your device and flash OpenWrt, but after it reboots it will go straight to netboot again. 
 +If this happens to you, [[https://wiki.mikrotik.com/wiki/Manual:Netinstall|restore RouterOS using Netinstall]], downgrade to RouterOS **v6**, and install OpenWrt again. 
 + 
 +To check the version of your bootloader from RouterOS, go to System → Routerboard in the web interface or run ''/system routerboard print'' and look for “current firmware”. If the version is below 7, you are all set. If it is 7.*, [[#Downgrading_RouterOS|downgrade RouterOS to v6]] before proceeding. 
 + 
 +If you have already booted an OpenWrt initramfs, to see the bootloader version run ''cat /sys/firmware/mikrotik/hard_config/booter_version''.
  
 ==== Selecting an OpenWrt version  ==== ==== Selecting an OpenWrt version  ====
Line 36: Line 57:
  
 ==== To Test-Drive OpenWrt, Netboot the initramfs File  ==== ==== To Test-Drive OpenWrt, Netboot the initramfs File  ====
 +
 Since an initramfs image is just a temporary image (only loaded into RAM), it is safe to test a particular version of OpenWrt by netbooting (using DHCP/BOOTP/TFTP) and downloading the initramfs image.\\    Since an initramfs image is just a temporary image (only loaded into RAM), it is safe to test a particular version of OpenWrt by netbooting (using DHCP/BOOTP/TFTP) and downloading the initramfs image.\\   
 When you power down your RouterBoard after loading an initramfs file, OpenWrt will simply vanish: a power down and reboot of the RouterBoard will revert to the prior version of firmware that is still in flash of the RouterBoard.   When you power down your RouterBoard after loading an initramfs file, OpenWrt will simply vanish: a power down and reboot of the RouterBoard will revert to the prior version of firmware that is still in flash of the RouterBoard.  
Line 41: Line 63:
 If the RAM-based initramfs version you have selected works for you, feel free to try other versions of OpenWrt, such as Latest release or snapshot.\\  If the RAM-based initramfs version you have selected works for you, feel free to try other versions of OpenWrt, such as Latest release or snapshot.\\ 
 Once you are happy with the RAM-based operation of OpenWrt, proceed to the step of [[#Flash OpenWrt|flashing OpenWrt]] in order to permanently write OpenWrt into your RouterBoard. Once you are happy with the RAM-based operation of OpenWrt, proceed to the step of [[#Flash OpenWrt|flashing OpenWrt]] in order to permanently write OpenWrt into your RouterBoard.
-==== Downloading OpenWrt images ==== 
  
-Images for the latest OpenWrt image can be downloaded from https://downloads.openwrt.org/\\  +NoteMikroTik's bootloader ([[:docs:techref:bootloader:routerboot]]) may have size limitation for TFTP imagesapproximately 7MiB.  If it refuses to accept an initramfs image above that size (it will proceed to boot whatever was already installed in the device), that could be the reason.
-Most OpenWrt supported Routerboards are Atheros-based hardwarein that case, after selecting releasego to the targets/ar71xx/mikrotik folder to see a list of all files available for that release.\\   +
-For example, to download the 18.06.1 OpenWrt images for the (Atheros-basedRB450Gdownload from https://downloads.openwrt.org/releases/18.06.1/targets/ar71xx/mikrotik/ +
- +
  
-After the commit of [[https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=9db9072d6767e5910e01b8962171c89359ab7a14|Introduce sysupgrade + 64MB/Large NAND sysupgrade images]], there is no longer a tar.gz image, but instead there are multiple sysupgrade .bin images, only one of which will be used for any particular RouterBoard model.\\  +==== Downloading OpenWrt images for Mikrotik RouterBoards ====
-This wiki has been updated to reflect this simplifying change used in OpenWrt Version 18 for the Mikrotik RouterBoards.\\  +
-Please refer to older versions of this wiki for instructions on using older releases of OpenWrt such as Chaos Calmer, Barrier Breaker, Attitude Adjustment, etc.+
  
 +The latest OpenWrt images can be downloaded from [[https://downloads.openwrt.org/]]\\ 
 There will be just two images needed to install OpenWrt for any particular Mikrotik RouterBoard hardware platform: There will be just two images needed to install OpenWrt for any particular Mikrotik RouterBoard hardware platform:
   - The specific initramfs image to be downloaded into RAM during an initial netboot of the RouterBoard.   - The specific initramfs image to be downloaded into RAM during an initial netboot of the RouterBoard.
-  - The specific sysupgrade .bin image to be flashed into the Mikrotik router using the LuCI web interface.  The correct sysupgrade .bin file must be selected for the: +  - The specific sysupgrade .bin image to be flashed into the Mikrotik router using the LuCI web interface or with the sysupgrade command.
-    * Type of WiFi (AC vs. non-AC) installed on the RouterBoard.  The 802.11 a/b/g/n WiFi products are 'non-AC': only the 802.11 AC WiFi products are type 'AC'+
-    * Size and type (NAND vs. NOR) of flash on the RouterBoard +
  
 <WRAP leftalign round info 60%> <WRAP leftalign round info 60%>
Line 65: Line 80:
 </WRAP> </WRAP>
    
-The following table explains the general convention of initramfs and sysupgrade file names, but does have exceptions. For example, for the nand-large images, it is quite model-specific whether you use the initramfs.elf or initramfs-lzma.elf image.\\  +==== Netboot of OpenWrt Uses DHCP/BOOTP/TFTP ====
-The above [[toh:views:toh_fwdownload?datasrt=model&dataflt%5BBrand%2A~%5D=mikrotik|link Table of Hardware - Firmware Downloads]], or the wiki for your specific RouterBoard, are the most accurate resources for the correct file names.+
  
-^   Flash Size            sysupgrade .bin File Naming Convention                       ^^^  File Names to Download from OpenWrt.org (Please Verify [[toh:views:toh_fwdownload?datasrt=model&dataflt%5BBrand%2A~%5D=mikrotik|At This Link]])  ^^   RouterBoard Type                 ^ +Routerboards contain the Mikrotik RouterBoot netboot bootloader that will boot over the network and run an OpenWrt initramfs file.  The initramfs file is a single file with the whole OpenWrt package: kernel plus filesystemRouterBoard has at least three flash partitionsbootloader, kernel and ubiThe MikroTik bootloader is preserved even after OpenWrt is installed into NAND or NOR flash.
-^     :::                ^  Image Name Prefix=>  ^  AC Wifi?=>  ^  Image Name Suffix=>     ^ sysupgrade .bin File Name                   ^  initramfs File Name     :::                                                                ^ +
-| 16 MB NOR              | rb-nor-flash-16M      |  -ac-        | squashfs-sysupgrade.bin  | rb-nor-flash-16M-ac-squashfs-sysupgrade.bin | rb-nor-flash-16M-ac-initramfs-kernel.bin                               | RouterBoard with 16 MB NOR (includes AC WiFi)                    | +
-:::                    | :::                    -           | :::                      | rb-nor-flash-16M-squashfs-sysupgrade.bin    | rb-nor-flash-16M-initramfs-kernel.bin                                  | RouterBoard with 16 MB NOR (includes a/b/g/n WiFi)               | +
-| 64 MB NAND             | nand-64m              |  -           :::                      | nand-64m-squashfs-sysupgrade.bin            | vmlinux-initramfs.elf                                                  | RouterBoard with 64 MB NAND (includes a/b/g/n WiFi)              | +
-|128 MB NAND (or larger) | nand-large            |  -ac-        | :::                      | nand-large-ac-squashfs-sysupgrade.bin       | vmlinux-initramfs.elf                                                  | RouterBoard with 128 MB NAND (or larger) (includes AC WiFi)      | +
-|:::                     | :::                    -           | :::                      | nand-large-squashfs-sysupgrade.bin          | vmlinux-initramfs.elf or vmlinux-initramfs-lzma.elf (model-dependent)  | RouterBoard with 128 MB NAND (or larger) (includes a/b/g/n WiFi) |+
  
-Refer to the OpenWrt [[toh:views:toh_available_864|Table Of Hardware-Ideal]] to determine the type and size of flash for your particular RouterBoard.  The type of WiFi may depend on optional WiFi cards you may have installed in your RouterBoard.+=== Mikrotik RouterBoot Boot Protocoleither BOOTP or DHCP === 
 +The RouterBoard RouterBoot supports two different boot protocols when netbooting a RouterBoard:
  
-<WRAP leftalign round important 60%> +  - BOOTP Boot Protocol 
-If you add packages to your installed version of OpenWrt (via opkg or LuCI)be careful to use the packages that are compiled specifically for the version of sysupgrade .bin you have running on your RouterBoard. +    * Is the default boot protocol of RouterBoards.  When using bootpthere is no need to reconfigure the RouterBoards using serial port: you can just force netboot directly using the RouterBoard Reset button
-For example, if you decide to run nightly snapshots, be aware you'll want to also install and run the packages from that specific snapshot each time you update the snapshot, you'll want to update both the sysupgrade .bin AND the packages you are using+    * Not as commonly supported by DHCP/BOOTP/TFTP servers.  You need to select a DHCP/BOOTP/TFTP server that supports rfc951 BOOTP to install OpenWrt using bootp. 
-</WRAP>+    * OpenWRT may be booted via BOOTP on all RouterBoard devices. 
 +  DHCP Boot Protocol 
 +    * Not the default boot protocol of RouterBoards
 +    * Most DHCP/BOOTP/TFTP servers support this protocol. 
 +    * Not all versions of RouterBoot may boot OpenWRT using DHCP.
  
-<WRAP leftalign round important 60%> +=== Run a DHCP/BOOTP/TFTP netboot Server ===
-If you are using a snapshot (e.g. for the RB750Gr3), there is no LuCI contained. The flashing can still be done using SSH as outlined in https://openwrt.org/docs/guide-user/installation/sysupgrade.cli . +
-</WRAP> +
-===== Step-By-Step OpenWrt Installation Process on Routerboard ===== +
-==== TL;DR: simple way for all supported models ==== +
-  - Pre-requisites. First, save the license key. Second, set-up the DHCP and TFTP services/daemons on server/router/PC to netboot with openwrt-*mikrotik*-initramfs-kernel.bin. +
-  - Connect to web interface http://192.168.88.1 +
-  - Go to "System"-"Routerboard". \\Select "Boot ethernet-if fail-nand". \\ Turn on "Force Backup Booter". \\ Click "Apply"+
-  - Go to "System"-"Shutdown" \\ Click "Shutdown" \\ Wait for LEDs off +
-  - Unplug power, plug ethernet cable from DHCP/TFTP server to "WAN" port, plug power cord back in. \\ Wait for beep. +
-  - Connect ethernet cable from your PC with turned on DHCP client to port "2", "3" or "4"+
-  - Establish SSH connection to root@192.168.1.1 \\ You should see OpenWrt banner. Check correct functioning of OpenWrt. \\ If you see no OpenWrt, then OpenWrt didn't boot on the router, so please check DHCP, TFTP — if these are correctly configured, then the test failed and this version of OpenWrt doesn't work on this router. +
-  - If OpenWrt boots OK \\ ''scp openwrt-*mikrotik*-squashfs-sysupgrade.bin root@192.168.1.1:/tmp/'' +
-  - Next, to flash OpenWrt, run following command in the SSH session: \\ ''sysupgrade -n /tmp/openwrt-*-mikrotik*-squashfs-sysupgrade.bin'' \\ the SSH session will close itself, and the RouterBoard will rebooted after flashing. \\ Please wait several minutes until you hear a beep. +
-  - Already establish SSH connection to root@192.168.1.1 (you may need to remove the line with "192.168.1.1" from the file "known_hosts", on the Linux — ''~/.ssh/known_hosts'')\\ You should see an OpenWrt banner — Congratulations, you installed OpenWrt on the MikroTik RouterBoard.+
  
-==== Long read ====+Various TFTP servers for various OS are documented [[:docs:guide-user:troubleshooting:tftpserver#setting_up_tftp_server|here]].
  
-Installing and upgrading OpenWrt on a RouterBoard is basically just a couple steps:  +To comply with the DHCP/BOOTP need of RouterBoot here are some extra detailed instructions.
-  - You first netboot an initramfs image of OpenWrt from your DHCP/BOOTP/TFTP server into the RAM of the RouterBoard.  This is done from the ether1 port (typically the WAN port) of the RouterBoard. +
-  - From that RAM-based running OpenWrt you use the web-based LuCI interface to permanently flash the appropriate sysupgrade .bin file (see above) using LuCI 'Flash image' This is done from a LAN port (typically ether2 or higher) at IP address 192.168.1.1 of the RouterBoard.+
  
-Note the wget2nand utility has been deprecated in this latest release of OpenWrt since the UBI changes to the code now allow direct flashing of the NAND or NOR from the LuCI web interface.+== On Linux or other unix-like OS using dnsmasq ==
  
-The detailed 12 step process below is updated to reflect the new 'UBI' style firmware images of version 18 OpenWrt that now make it very easy to flash the RouterBoard directly from the LuCI web interface.  Many of the board-specific wiki's here in OpenWrt have yet to be updated to reflect this new, simpler process.  Use this description of the Step-By-Step Installation Process to get an idea how relatively simple it is to install and upgrade OpenWrt - and feel free to give it try since the initramfs version of OpenWrt is just a RAM image that will not affect your RouterOS if you decide NOT to flash the permanent sysupgrade.bin file into your RouterBoard.  If you do flash OpenWrt into your RouterBoard, you can revert back to RouterOS at a later time using Mikrotik's NetInstall utility - as long as you saved your RouterOS license file (export your .key license file) before you permanently install (flash) OpenWrt+  * Create the following script using text editor such as vi: vi ~/tftp/loader.sh
  
-To install OpenWrt (works on all OpenWrt supported RouterBoards, using V18 or later OpenWrt):+NoteDon't forget to change USER, IFNAME, IP/DHCP IP-range and file name/folder path for your needs and replace openwrt-19.07-*-initramfs-* with the appropriate filename. 
  
-  - **Download Both OpenWrt files**\\ Download the two OpenWrt files to your PC: the initramfs file (initramfs.elf, initramfs-lzma.elf or initramfs-kernel.bin, depending on model) and the sysupgrade.bin file for your particular RouterBoard.  See the [[toh:views:toh_fwdownload?datasrt=model&dataflt%5BBrand%2A~%5D=mikrotik|Table of Hardware - Firmware downloads]] to determine which initramfs and sysupgrade.bin file to use. +  #!/bin/bash 
-  - Prepare TFTP: +  IFNAME=enp1s0 
-      - If you use ''Windows'': +  /sbin/ip addr replace 192.168.1.10/24 dev $IFNAME 
-          - **Download a DHCP/BOOTP/TFTP Server**\\ Download a DHCP/BOOTP/TFTP server to your Windows PC If you use Tiny PXE, set rfc951=in the [dhcp] section of its config.ini file.  Tiny PXE is BOOTP compatible so it will allow you to easily netboot the RouterBoard using the default settings of the RouterBoard. +  /sbin/ip link set dev $IFNAME up 
-              * If you are instead wanting to re-install RouterOS (rather than install OpenWrt), download a copy of NetInstall from the Mikrotik website. +  /usr/sbin/dnsmasq \ 
-          - **Download PuTTY and Connect Serial COM Port (Optional)**\\ The serial COM port will allow you to see/change activity on the RouterBoard console. Download a copy of PuTTY to your Windows PC so you can open a terminal window on the serial COM port of the RouterBoard.  Use a USB to serial adapter such as a Tripp Lite Keyspan USA-19HS (this RS-232 adapter has Windows drivers for Windows 2000 up to current Windows) and a null modem adapter to connect to the RouterBoard serial port (if it has one).  Baud 115200, no parity, 8 bits, 1 stop bit, no flow control. +  --no-daemon \ 
-       If you use ''Linux'' or other unix-like OS: install tftp server, usually ''tftpd'' or ''in.tftpd''. On normal case the client of SSH already installed in the system. +  --listen-address 192.168.1.10 \ 
-  - If you didn't do this earlier, **run Mikrotik WinBox to Export RouterOS License File (Optional: So you can re-install Mikrotik RouterOS at a later date, if needed)**\\ With existing RouterOS running on your RouterBoard, connect your PC to a LAN port on the RouterBoard (DHCP enabled). Use a web browser to get to the RouterOS login page (default at 192.168.88.1) and download Mikrotik WinBox from your RouterBoard onto your Windows PC.  Do NOT try to use the WebFig browser interface to export your license file: it does not have the license export feature. You must use the WinBox Windows application.  Execute (double click) the downloaded WinBox to run it from your PC.  Use WinBox to export (save) your license .key file to your PC.  This will allow you to restore/re-install RouterOS at a later time using Mikrotik's NetInstall.\\ \\ If you cannot connect to the RouterBoard RouterOS on a LAN port, try resetting the RouterBoard to its default settings: that will ensure you can connect using the ether1 port. Reset the RouterBoard to its default settings by unplugging power, press the Reset button, then plug power back in and continue holding the Reset button for 5 seconds.  Now set your PC to a static IP address of 192.168.88.10.  Move your Ethernet cable to the ether1 (usually WAN) port on the RouterBoard and get WinBox at 192.168.88.1\\ \\ //If you have an old version of RouterOs/WinBox and a newer version of Windows (such as Windows 10), your WinBox may not be compatible with Windows 10.  If so, upgrade your RouterOS so you get a new version of RouterOs/WinBox that is Windows 10 compatible.  The latest WinBox is Windows 10 compatible, but the WinBox version must also be compatible with the RouterOS version so that's why you should consider installing a new RouterOS .npk file (which includes WinBox) if WinBox is not working for you.// +  --bind-interfaces \ 
-  - **Change PC to Static IP 192.168.1.10**\\ Now reconfigure your PC Ethernet to a static IP at 192.168.1.10 (this address is handy so you don't have to change your IP address in subsequent steps). +  -p0 
-  - **Connect to RouterBoard ether1**\\ Connect your Ethernet cable to ether1 port of the RouterBoard, typically the WAN port.  Make sure you are running your Ethernet standalone now, with no connections to your existing LAN. When you run Tiny PXE, you could then have two simultaneous DHCP servers on a LAN which makes for unpredictable results. +  --dhcp-authoritative 
-  - **Run DHCP/BOOTP/TFTP Server**\\ Start up Tiny PXE, select the initiramfs file you previously downloaded as the Boot filename, and select the 192.168.1.10 connection for Option 54 (this will not appear if the RouterBoard is turned off).  Put Tiny PXE Online.  //You may need to to turn off your firewall and run as administrator.// +  --dhcp-range=192.168.1.100,192.168.1.200 
-    * If you are instead wanting to re-install RouterOSrun Mikrotik's NetInstall here Be sure to use the same version netinstall and MIPSBE .npk file for your RouterBoard.  This is where you will import the .key license file you previously exported (if your license is no longer recognized by NetInstall).\\ //You may need to disable all other devices in Windows Network Connections to make sure the only Ethernet/WiFi/Bluetooth adapter you have running is the one connected to ethernet1 of your RouterBoard.  NetInstall sometimes gets confused about which Ethernet adapter to use unless all others are disabled.// +  --bootp-dynamic \ 
-  - **Force RouterBoard to Netboot**\\ Unplug the RouterBoard power jack, press its reset button, and plug the RouterBoard power back in while continuing to press the reset button.  After 10-20 seconds, you will see Tiny PXE download the initramfs file to the RouterBoard (will say DoReadFile in its log window).  You can stop pressing the Reset button once you see DoReadFile occur in Tiny PXE.  If you are connected to the serial COM port, you will be able to watch the OpenWrt boot process as it progresses +  --dhcp-boot=openwrt-19.07-*-initramfs-* \ 
-  - **You Are Almost There: OpenWrt is Now Running From RAM**\\ Now you have OpenWrt running in RAM on your RouterBoard.  You can try it out by running the next two steps, then poke around and decide if you like it.  Since it is only in RAM, if you reboot the RouterBoard without performing the flash (the final step here), this initramfs RAM-based version of OpenWrt will vanish.   +  --log-dhcp \ 
-  **Connect to RouterBoard ether2**\\ Unplug your Ethernet cable from ether1 and plug in to a LAN port on your RouterBoard such as ether2. Some RouterBoards do not enable all LAN ports, so you may need to experiment here.  +  --enable-tftp \ 
-  - **Login to OpenWrt LuCI Web Interface**\\ Use a web browser to open the OpenWrt LuCI web interface at 192.168.1.1.  Login is admin, no password.  It may take a minute or more for OpenWrt to fully boot -- wait until the lights on the LAN port indicate activity.   +  --tftp-root=$(pwd)
-  - **Flash sysupgrade.bin Into RouterBoard**\\ Go to System->Backup/Flash Firmware in LuCI.  Select 'Choose file' under 'Flash new firmware image' Select the sysupgrade.bin file you previously downloaded to your PC.  Press 'Flash image' to permanently install OpenWrt on your RouterBoard.\\ The flash process may take a minute or more to complete, then your RouterBoard will automatically reboot.\\ **Congratulations!** You now have OpenWrt running and flashed into your RouterBoard.  Subsequent upgrades of OpenWrt are as simple as running this step alone (a noted improvement from previous versions of OpenWrt).+
  
-Once you have OpenWrt running, you'll probably want to reset your PC's Ethernet back to DHCP instead of the 'forced' static IP addresses you used during the install of OpenWrt. +  * Make the script executable
-===== Netboot of OpenWrt Uses DHCP/BOOTP/TFTP =====+
  
-Routerboards contain the Mikrotik RouterBoot netboot bootloader that will boot over the network and run an OpenWrt initramfs file.  The initramfs file is a single file with the whole OpenWrt package: kernel plus filesystem. A RouterBoard has at least three flash partitions: bootloader, kernel and ubi. The MikroTik bootloader is preserved even after OpenWrt is installed into NAND or NOR flash.+  $ chmod +x loader.sh
  
-=== Mikrotik RouterBoot Boot Protocol: either BOOTP or DHCP === +  * Copy openwrt-19.07-*-initramfs-* file to the folder where the script is located. 
-The RouterBoard RouterBoot supports two different boot protocols when netbooting a RouterBoard:+  * Run script loader.sh as root
  
-  - BOOTP Boot Protocol +  ./loader.sh 
-    * Is the default boot protocol of RouterBoards When using bootp, there is no need to reconfigure the RouterBoards using serial port: you can just force netboot directly using the RouterBoard Reset button. + 
-    *  Not as commonly supported by DHCP/BOOTP/TFTP servers.  You need to select a DHCP/BOOTP/TFTP server that supports rfc951 BOOTP to install OpenWrt using bootp+==  On Linux or other unix-like OS with generic DHCP/BOOTP/TFTP server ==
-  - DHCP Boot Protocol +
-    * Not the default boot protocol of RouterBoards +
-    * Most DHCP/BOOTP/TFTP servers support this protocol +
-==== Select a DHCP/BOOTP/TFTP netboot Server ====+
  
-Select any of the following choices to set up a RouterBoard compatible netboot DHCP/BOOTP/TFTP server, then proceed to the [[#Methods to set RouterBoard so it will TFTP netboot|next step]].\\  +Copy openwrt-19.07-*-initramfs-* file to your TFTP server location. Set up your BOOTP server to point to your [[:docs:guide-user:troubleshooting:tftpserver#setting_up_tftp_server|TFTP server]] as the next-server and to that file as the bootfile.
-If using Choice 2 or 3, you will need a local copy of the 'openwrt-ar71xx-mikrotik-vmlinux-initramfs.elf' on your Linux system.  For example, to create that file in Linux using the 18.06.1 release (latest as of 11/2018) for an RB450G:+
  
-  wget -c https://downloads.openwrt.org/releases/18.06.1/targets/ar71xx/mikrotik/openwrt-18.06.1-ar71xx-mikrotik-vmlinux-initramfs-lzma.elf 
-  ln -s openwrt-18.06.1-ar71xx-mikrotik-vmlinux-initramfs-lzma.elf openwrt-ar71xx-mikrotik-vmlinux-initramfs.elf 
  
-Choice 1 assumes you are running from a Windows PC and have already downloaded the initramfs file from the [[https://downloads.openwrt.org/|OpenWrt downloads website]] to your Windows PC.\\  +=== On Windows ===
-Choice 2 and 3 assume you are running from Linux. The Linux choices expect the initramfs file to use the above specific name 'openwrt-ar71xx-mikrotik-vmlinux-initramfs.elf'. This is why the above explanation creates a symbolic link to associate the longer release-specific name to the shorter 'generic' name.+
  
-=== Netboot Server Choice - Tiny PXE ===+Reconfigure your PC Ethernet to a static IP at 192.168.1.10
  
-The freeware Tiny PXE software is a (free) example of a DHCP/BOOTP/TFTP server that implements the rfc951 BOOTP capability.  To enable Tiny PXE's rfc951 BOOTP capabilities, rfc951=1 must be set in the [dhcp] section of the Tiny PXE config.ini file.\\  +The freeware [[http://erwan.labalec.fr/tinypxeserver|Tiny PXE server]] is a DHCP/TFTP server that implements the [[rfc>951|RFC951]] BOOTP capability.  To enable Tiny PXE's rfc951 BOOTP capabilities, rfc951=1 must be set in the [dhcp] section of the Tiny PXE config.ini file.\\  
-Select the initramfs file as the Boot file Filename, un-check the gPXE or iPXE Filename option, select the Option 54 IP address for the ethernet cable you have connected to the RouterBoard, and put Tiny PXE Online.\\ +Select the OpenWrt initramfs file as the Boot file Filename, un-check the gPXE or iPXE Filename option, select the Option 54 IP address for the ethernet cable you have connected to the RouterBoard, and put Tiny PXE Online.\\ 
 if you have problems running Tiny PXE, you may need to turn off your firewall, run Tiny PXE as administrator, or disable all other ethernet/bluetooth/wifi in Network Connections. if you have problems running Tiny PXE, you may need to turn off your firewall, run Tiny PXE as administrator, or disable all other ethernet/bluetooth/wifi in Network Connections.
  
 It is especially important to ensure only one DHCP/BOOTP/TFTP server is running on your network while attempting a netboot since BOOTP has no support for Proxy DHCP or authoritative DHCP - so be sure to disconnect from any other routers before running Tiny PXE. It is especially important to ensure only one DHCP/BOOTP/TFTP server is running on your network while attempting a netboot since BOOTP has no support for Proxy DHCP or authoritative DHCP - so be sure to disconnect from any other routers before running Tiny PXE.
  
-=== Netboot Server Choice 2 - Generic DHCP/BOOTP/TFTP server === 
- 
-Copy openwrt-ar71xx-mikrotik-vmlinux-initramfs.elf to your TFTP server location. Set up your DHCP server to point to your TFTP server as the next-server and to that file as the bootfile. 
- 
-=== Netbook Server Choice 3 - dnsmasq === 
- 
-To use dnsmasq:  
- 
-  * Copy openwrt-ar71xx-mikrotik-vmlinux-initramfs.elf to ~/mikrotik/trunk/bin/ar71xx/ \\    
-  * Create the following script using a Linux editor such as vi: vi ~/mikrotik/trunk/bin/ar71xx/loader.sh 
- 
-  #/bin/bash 
-  ifconfig eth0 192.168.1.10 up 
-  sudo dnsmasq -i eth0 --dhcp-range=192.168.1.100,192.168.1.200 \ 
-  --dhcp-boot=openwrt-ar71xx-mikrotik-vmlinux-initramfs.elf \ 
-  --enable-tftp --tftp-root=~/mikrotik/trunk/bin/ar71xx/ -d -u $USER -p0 -K --log-dhcp --bootp-dynamic 
- 
-If your shell don't set the environment variable $USER, please replace it with your user name. 
-Run script loader.sh   
  
 ==== Methods to set RouterBoard so it will TFTP netboot ==== ==== Methods to set RouterBoard so it will TFTP netboot ====
Line 186: Line 154:
 Connect the ethernet 1 port of your routerboard (typically the WAN port) to a network configured to reach the DHCP/BOOTP/TFTP server that you have set up. Connect the ethernet 1 port of your routerboard (typically the WAN port) to a network configured to reach the DHCP/BOOTP/TFTP server that you have set up.
  
-The RouterBoard default boot protocol is BOOTP.  You can change the RouterBoot boot protocol from BOOTP to DHCP by using the COM portRouterOS, or rbcfg from OpenWrt as documented in this list of netboot methods.  +The RouterBoard default boot protocol is BOOTP.  You can change the RouterBoot boot protocol from BOOTP to DHCP by using the COM port or RouterOS, as documented in this list of netboot methods.  //Warning. Not all RouterBoard devices can boot OpenWRT via DHCP.//
  
-The instructions in this wiki tend to assume you have changed the netboot protocol to DHCP since DHCP netboot is readily supported by dnsmasq (the most common DHCP/BOOTP/TFTP server in Linux distributions).\\  +The instructions in this wiki tend to assume you have changed the netboot protocol to DHCP since DHCP netboot is supported by all DHCP servers.\\  
-However, if you have chosen to use a DHCP/BOOTP/TFTP netboot server that supports rfc951 BOOTP (such as Tiny PXEwith rfc951=1 set in the [dhcp] section of the config.ini), any of these netboot methods will work fine without any changes to the Routerboot boot protocol.  +However, if you have chosen to use a DHCP/BOOTP/TFTP netboot server that supports rfc951 BOOTP such as dnsmasq or Tiny PXE (with rfc951=1 set in the [dhcp] section of the config.ini), any of these netboot methods will work fine without any changes to the Routerboot boot protocol.  
  
 When a boot protocol is set in RouterBoot, it is remembered: any of the methods here that force a netboot will then use the BOOTP or DHCP boot protocol previously selected in RouterBoot.    When a boot protocol is set in RouterBoot, it is remembered: any of the methods here that force a netboot will then use the BOOTP or DHCP boot protocol previously selected in RouterBoot.   
Line 199: Line 167:
 Most RouterBoard models generate a short beep when an image begins to netboot or load from flash (unless the RouterBoard has been put in 'silent mode' from the RouterBoot menu). So if you are running without a connection to the serial console COM port to view boot activity from a terminal window, you can use the beep to know when RouterBoot has successfully started to load an image (either a netboot image or the existing flash image). Most RouterBoard models generate a short beep when an image begins to netboot or load from flash (unless the RouterBoard has been put in 'silent mode' from the RouterBoot menu). So if you are running without a connection to the serial console COM port to view boot activity from a terminal window, you can use the beep to know when RouterBoot has successfully started to load an image (either a netboot image or the existing flash image).
  
-If you are using Tiny PXE as your netboot PXE DHCP/BOOTP/TFTP server, you can watch its information/log window to see exactly when Tiny PXE begins uploading the initramfs file to the RouterBoard (TFTPd:DoReadFile shows up in the information/log window): this will be the same time the RouterBoard beeps.+If you are using dnsmasq or Tiny PXE as your netboot PXE DHCP/BOOTP/TFTP server, you can watch its information/log window to see exactly when the DHCP/BOOTP/TFTP server begins uploading the initramfs file to the RouterBoard (TFTPd:DoReadFile shows up in the information/log window): this will be the same time the RouterBoard beeps.
  
 To enable a netboot using the Reset button: To enable a netboot using the Reset button:
Line 207: Line 175:
   - Plug the power jack back in   - Plug the power jack back in
   - Observe activity LED(s). The LED behavior varies across models, but can be a good indicator about the boot process.  See the Mikrotik wiki https://wiki.mikrotik.com/wiki/Manual:RouterBOOT for details.   - Observe activity LED(s). The LED behavior varies across models, but can be a good indicator about the boot process.  See the Mikrotik wiki https://wiki.mikrotik.com/wiki/Manual:RouterBOOT for details.
-  - Release the reset button after you hear the beep (maximum 15 - 20 seconds).+  - Release the reset button after you hear the beep (maximum 15 - 20 seconds) or see the upload in the DHCP/BOOTP/TFTP server logs.
  
 === Method 2 - Use the RouterBoard serial COM port to enable TFTP netboot === === Method 2 - Use the RouterBoard serial COM port to enable TFTP netboot ===
Line 217: Line 185:
 To enable a netboot using the serial COM port: To enable a netboot using the serial COM port:
   - Connect the COM port to a system (terminal server, PC). Set baud to 115200, 8 bits, no parity, 1 stop bit, no flow control.    - Connect the COM port to a system (terminal server, PC). Set baud to 115200, 8 bits, no parity, 1 stop bit, no flow control. 
-  - Open a terminal window (can use software such as PuTTY on Windows to open a terminal window connected to the COM port). If RouterOS or OpenWrt are running you should have an interactive shell. +  - Open a terminal window (can use software such as PuTTY to open a terminal window connected to the COM port). If RouterOS or OpenWrt are running you should have an interactive shell. 
   - Reboot the RouterBoard (unplug power, wait a couple seconds, plug  back in).    - Reboot the RouterBoard (unplug power, wait a couple seconds, plug  back in). 
   - Observe “Press any key within 2 seconds to enter setup”. Press a key in the terminal window.    - Observe “Press any key within 2 seconds to enter setup”. Press a key in the terminal window. 
Line 224: Line 192:
   - Exit from the RouterBoot setup menu to begin the netboot: press 'x'.   - Exit from the RouterBoot setup menu to begin the netboot: press 'x'.
  
-More information at: http://wiki.mikrotik.com/wiki/Manual:Netinstall#OPTIONAL:_Configuring_RouterBOARD_with_COM_port+More information at: [[http://wiki.mikrotik.com/wiki/Manual:Netinstall#OPTIONAL:_Configuring_RouterBOARD_with_COM_port]]
  
 === Method 3 - Use a running RouterOS to enable TFTP netboot === === Method 3 - Use a running RouterOS to enable TFTP netboot ===
Line 233: Line 201:
  
   - System → Routerboard → Settings → Boot device: Try ethernet once then NAND   - System → Routerboard → Settings → Boot device: Try ethernet once then NAND
-  - System → Routerboard → Settings → Boot protocol: DHCP+  - System → Routerboard → Settings → Boot protocol: DHCP (if BOOTP don't supported in your DHCP server)
   - System → Routerboard → Settings → Force Backup Booter: Checked (if supported by your routerboard - !IMPORTANT)   - System → Routerboard → Settings → Force Backup Booter: Checked (if supported by your routerboard - !IMPORTANT)
   Save   Save
    
-Reboot routerboard (on some devices "System --> Reboot" does not perform a correct TFTP boot; you must use instead "System --> Shutdown" and unplug/replug the router). This will boot OpenWrt from TFTP once. The boot protocol setting will stay persistent across reboots, but the next reboot will be again from NAND (the bootloader resets this parameter after booting from TFTP once). Once you have installed OpenWrt, RouterOS will have been deleted, so you will need to use one of the following other methods listed here to netboot from TFTP+Shutdown RouterBoard and next turn power off and on (don't reboot because on some devices "System --> Reboot" does not perform a correct TFTP boot; you must use instead "System --> Shutdown" and unplug/replug the router). This will boot OpenWrt from TFTP once. The boot protocol setting will stay persistent across reboots, but the next reboot will be again from NAND (the bootloader resets this parameter after booting from TFTP once). Once you have installed OpenWrt, RouterOS will have been deleted, so you will need to use one of the previous methods to netboot from TFTP.
- +
-=== Method 4 - Using a running OpenWrt to enable TFTP netboot === +
- +
-The OpenWrt rbcfg utility permits to configure parameters of the routerboard bootloader. Note that this program may not work on all routerboards. +
- +
-  opkg update +
-  opkg install rbcfg +
-   +
-  rbcfg set boot_device ethnand +
-  rbcfg set boot_protocol dhcp +
-  rbcfg apply +
-   +
-Reboot.+
      
  
-===== Flash OpenWrt =====+==== Flash OpenWrt ====
  
 After the DHCP/BOOTP/TFTP netboot of the initramfs image, connect your PC to one of the LAN ports of your RouterBoard.\\   After the DHCP/BOOTP/TFTP netboot of the initramfs image, connect your PC to one of the LAN ports of your RouterBoard.\\  
Line 274: Line 229:
 Congratulations: you have now successfully flashed OpenWrt into your RouterBoard! Congratulations: you have now successfully flashed OpenWrt into your RouterBoard!
  
-==== Manually Flashing OpenWrt ==== 
  
-These instructions are deprecated since wget2nand is no longer used, but left here for reference. Note "rootfs" has become "ubi" in the current OpenWrt release. 
  
-If wget2nand encounters problems, perform its steps manually from shell. +==== When flashing doesn´t work ====
-   +
-  cat /proc/mtd +
-  dev:    size   erasesize  name +
-  mtd0: 00040000 00020000 "booter" +
-  mtd1: 003c0000 00020000 "kernel" +
-  mtd2: 07c00000 00020000 "rootfs"+
  
-The following instructions assume that as shown above, kernel is /dev/mtd1 and rootfs /dev/mtd2. If these numbers are different on your model, appropriately change the following commands.+=== Problems with bad blocks ===
  
-  mtd erase /dev/mtd1 +If you got problems while flashing because of (supposed) bad blocks, you could try to use the netinstall-tool from mikrotik (only windows ... :-().
-  mtd erase /dev/mtd2 +
-  mkdir /mnt/kernel +
-  mkdir /mnt/rootfs +
-  mount /dev/mtdblock1 /mnt/kernel +
-  mount /dev/mtdblock2 /mnt/rootfs +
- +
-Copy kernel & rootfs to routerboard: +
- +
-  scp bin/ar71xx/openwrt-ar71xx-mikrotik-vmlinux-lzma.elf root@192.168.1.1:/tmp +
-  scp bin/ar71xx/openwrt-ar71xx-mikrotik-DefaultNoWifi-rootfs.tar.gz root@192.168.1.1:/tmp +
- +
-Flash kernel & rootfs +
- +
-  mv /tmp/openwrt-ar71xx-nand-vmlinux-lzma.elf /mnt/kernel/kernel +
-  chmod +x /mnt/kernel/kernel +
-  umount /mnt/kernel +
-  cd /mnt/rootfs +
-  tar -xvzf /tmp/openwrt-ar71xx-mikrotik-DefaultNoWifi-rootfs.tar.gz +
-  cd / +
-  umount /mnt/rootfs +
-  sync +
- +
-Reboot+
  
 +It will reduce the number of bad blocks. [[https://wiki.mikrotik.com/wiki/Manual:RouterBOARD_bad_blocks|mikrotik wiki]]
  
 +There is also a nice netinstall-howto [[https://blog.ligos.net/2016-12-27/Recover-A-Broken-Mikroik-Device.html|here]].
      
-===== Initial setup =====+==== Initial setup ====
  
-==== LEDs ====+=== LEDs ===
  
 Check if the LEDs light up according to their desired functions (eg: under RouterOS). LED configuration is found in /etc/config/system. Depending on model, OpenWrt may have initialized the LEDs correctly. If not, the model specific wiki page should explain how to configure LEDs in /etc/config/system. Check if the LEDs light up according to their desired functions (eg: under RouterOS). LED configuration is found in /etc/config/system. Depending on model, OpenWrt may have initialized the LEDs correctly. If not, the model specific wiki page should explain how to configure LEDs in /etc/config/system.
  
-==== Understanding/configuring ports ====+=== Understanding/configuring ports ===
  
 By default, OpenWrt tries to set up wired/wireless interfaces so that there is one routed WAN interface which is typically the first wired ethernet port and the remaining wired ethernet port and wireless interfaces are bridged into a LAN. This setup is partially done under the hood and partially it shows up in /etc/config/network and can be seen via linux CLI commands, for example 'ifconfig -a': By default, OpenWrt tries to set up wired/wireless interfaces so that there is one routed WAN interface which is typically the first wired ethernet port and the remaining wired ethernet port and wireless interfaces are bridged into a LAN. This setup is partially done under the hood and partially it shows up in /etc/config/network and can be seen via linux CLI commands, for example 'ifconfig -a':
Line 331: Line 257:
 ethN.M is a VLAN on a switched ethernet.  ethN.M is a VLAN on a switched ethernet. 
                  
-==== Serial console ====+=== Serial console ===
  
 If you solder the UART pins on the board, you can enable the serial console, adding this line to /etc/inittab: If you solder the UART pins on the board, you can enable the serial console, adding this line to /etc/inittab:
Line 337: Line 263:
   ttyS0::askfirst:/bin/ash --login   ttyS0::askfirst:/bin/ash --login
      
-==== Disable silent-boot mode on RouterBOOT bootloader ====+=== Disable silent-boot mode on RouterBOOT bootloader ===
  
 [[https://wiki.mikrotik.com/wiki/Manual:RouterBOOT|Manual:RouterBOOT]] [[https://wiki.mikrotik.com/wiki/Manual:RouterBOOT|Manual:RouterBOOT]]
Line 351: Line 277:
  
 [[docs:guide-quick-start:walkthrough_login]] [[docs:guide-quick-start:walkthrough_login]]
 +
 +
 +
 +===== Step-By-Step OpenWrt Installation Processes on Routerboard =====
 +==== With a Linux and other unix-like OS ====
 +  * Plug an ethernet cable between the router port 2 and your computer.
 +  * [[#saving_mikrotik_routerboard_license_key_without_using_winbox|Save the license key.]] (optional)
 +  * [[#downloading_openwrt_images_for_mikrotik_routerboards|Download OpenWrt images]] (initramfs and sysupgrade)
 +  * Connect to web interface http://192.168.88.1
 +  * Go to "System"-"Routerboard" then "Settings". \\ At the "boot device" line : Select "try ethernet-if fail-nand". \\ At the "Boot Protocol" line : keep "BOOTP". \\ Tick the  "Force Backup Booter" box. \\ Click "Apply".
 +  * Go to "System"-"Shutdown" \\ Click "Shutdown" 
 +  * Unplug power.
 +  * Create the following script using a text editor such as vi: vi ~/tftp/loader.sh
 +
 +Note: Don't forget to change USER, IFNAME, IP/DHCP IP-range and file name/folder path for your needs and replace openwrt-22.03-*-initramfs-* with the appropriate filename. 
 +
 +  #!/bin/bash
 +  USER=user
 +  IFNAME=enp1s0
 +  /sbin/ip addr replace 192.168.1.10/24 dev $IFNAME
 +  /sbin/ip link set dev $IFNAME up
 +  /usr/sbin/dnsmasq --user=$USER \
 +  --no-daemon \
 +  --listen-address 192.168.1.10 \
 +  --bind-interfaces \
 +  -p0 \
 +  --dhcp-authoritative \
 +  --dhcp-range=192.168.1.100,192.168.1.200 \
 +  --bootp-dynamic \
 +  --dhcp-boot=openwrt-19.07-*-initramfs-* \
 +  --log-dhcp \
 +  --enable-tftp \
 +  --tftp-root=$(pwd)
 +
 +  * Copy openwrt-22.03-*-initramfs-* file to the folder where the script is located.
 +  * Make the script executable 
 +
 +  $ chmod +x loader.sh
 +
 +  * Run script loader.sh as root
 +
 +  # ./loader.sh
 +
 +  * Plug ethernet cable from DHCP/TFTP server to "WAN" port, plug power cord back in.
 +  * In the terminal you ran the script from, wait until you read "dnsmasq-tftp: sent /path/to/file"
 +  * Kill the script (Ctrl + c).
 +  * [[#Flash OpenWrt]]
 +    * Connect ethernet cable from your PC with turned on DHCP client to port "2", "3" or "4".
 +    * Connect to web interface http://192.168.1.1
 +    * Check correct functioning of OpenWrt.
 +    * Go to System->Backup/Flash Firmware
 +    * Click on 'Choose File' under 'Flash new firmware image' Select the sysupgrade .bin file you previously downloaded for your RouterBoard
 +    * Click on 'Flash image' This will flash the sysupgrade .bin file into your RouterBoard and reboot it
 +  * Congratulations, you installed OpenWrt on your MikroTik RouterBoard.
 +
 +==== using SSH instead of LuCI ====
 +
 +  - Pre-requisites. First, save the license key. Second, set-up the DHCP and TFTP services/daemons on server/router/PC to netboot with openwrt-*mikrotik*-initramfs-kernel.bin.
 +  - Connect to web interface http://192.168.88.1
 +  - Go to "System"-"Routerboard". \\ Select "Boot ethernet-if fail-nand". \\ In "Boot Protocol", keep BOOTP (except if your DHCP/BOOTP/TFTP server doesn't support BOOTP __and__ if yourRouteurBoard is able to boot OpenWRT from DHCP, then select “DHCP”). \\ Turn on "Force Backup Booter". \\ Click "Apply".
 +  - Go to "System"-"Shutdown" \\ Click "Shutdown" \\ Wait for LEDs off
 +  - Unplug power, plug ethernet cable from DHCP/TFTP server to "WAN" port, plug power cord back in. \\ Wait for beep (if available on your RouterBoard).
 +  - Connect ethernet cable from your PC with turned on DHCP client to port "2", "3" or "4".
 +  - Establish SSH connection to root@192.168.1.1 \\ You should see OpenWrt banner. Check correct functioning of OpenWrt. \\ If you see no OpenWrt, then OpenWrt didn't boot on the router, so please check DHCP, TFTP — if these are correctly configured, then the test failed and this version of OpenWrt doesn't work on this router.
 +  - If OpenWrt boots OK \\ ''scp openwrt-*mikrotik*-squashfs-sysupgrade.bin root@192.168.1.1:/tmp/''
 +  - Next, to flash OpenWrt, run following command in the SSH session: \\ ''sysupgrade -n /tmp/openwrt-*-mikrotik*-squashfs-sysupgrade.bin'' \\ the SSH session will close itself, and the RouterBoard will reboot after flashing. \\ Please wait several minutes until you hear a beep.
 +  - Already establish SSH connection to root@192.168.1.1 (you may need to remove the line with "192.168.1.1" from the file "known_hosts", on the Linux — ''~/.ssh/known_hosts'')\\ You should see an OpenWrt banner — Congratulations, you installed OpenWrt on the MikroTik RouterBoard.
 +
 +==== Detailed Steps ====
 +
 +Installing and upgrading OpenWrt on a RouterBoard is basically just a couple steps: 
 +  - You first netboot an initramfs image of OpenWrt from your DHCP/BOOTP/TFTP server into the RAM of the RouterBoard.  This is done from the ether1 port (typically the WAN port) of the RouterBoard.
 +  - From that RAM-based running OpenWrt you use the web-based LuCI interface to permanently flash the appropriate sysupgrade .bin file (see above) using LuCI 'Flash image' This is done from a LAN port (typically ether2 or higher) at IP address 192.168.1.1 of the RouterBoard.
 +
 +The detailed 8 steps process below is updated to reflect the new 'UBI' style firmware images of version 18 OpenWrt that now make it very easy to flash the RouterBoard directly from the LuCI web interface.  Many of the board-specific wiki's here in OpenWrt have yet to be updated to reflect this new, simpler process.  Use this description of the Step-By-Step Installation Process to get an idea how relatively simple it is to install and upgrade OpenWrt - and feel free to give it a try since the initramfs version of OpenWrt is just a RAM image that will not affect your RouterOS if you decide NOT to flash the permanent sysupgrade.bin file into your RouterBoard.  If you do flash OpenWrt into your RouterBoard, you can revert back to RouterOS at a later time using [[https://wiki.mikrotik.com/wiki/Manual:Netinstall|Mikrotik's NetInstall utility]] - as long as you saved your RouterOS license file (export your .key license file) before you permanently install (flash) OpenWrt. (For non-windows users, [[https://help.mikrotik.com/docs/display/ROS/Upgrading+and+installation#heading-Netinstall|MikroTik claims that it runs on Linux with Wine (superuser permissions are required)]].
 +
 +To install OpenWrt (works on all OpenWrt supported RouterBoards, using V18 or later OpenWrt):
 +
 +  - **Download both OpenWrt files**\\ Download the two OpenWrt files to your PC: the initramfs file (initramfs.elf, initramfs-lzma.elf or initramfs-kernel.bin, depending on model) and the sysupgrade.bin file for your particular RouterBoard.  See [[#Downloading OpenWrt images for Mikrotik RouterBoards|above]] to determine which initramfs and sysupgrade.bin file to use.
 +  - If you didn't do this earlier, **save the RouterOS License File (Optional: So you can re-install Mikrotik RouterOS at a later date, if needed).**\\ If you run ''Windows'' in your PC: [[#saving_mikrotik_routerboard_license_key_using_winbox_and_windows|see below.]]\\ If you run ''any other OS'' in your PC: [[#saving_mikrotik_routerboard_license_key_without_using_winbox|see below below.]] 
 +  - **[[#methods_to_set_routerboard_so_it_will_tftp_netboot|Force RouterBoard to Netboot]]**
 +  - **[[#run_a_dhcpbootptftp_netboot_server|Run DHCP/BOOTP/TFTP Server]]**\\ Then connect to RouterBoard ether1 \\
 +    * If you are instead wanting to re-install RouterOS, [[https://wiki.mikrotik.com/wiki/Manual:Netinstall|run Mikrotik's NetInstall]] here.  Be sure to use the same version netinstall and MIPSBE .npk file for your RouterBoard.  This is where you will import the .key license file you previously exported (if your license is no longer recognized by NetInstall).\\ //You may need to disable all other devices in Windows Network Connections to make sure the only Ethernet/WiFi/Bluetooth adapter you have running is the one connected to ethernet1 of your RouterBoard.  NetInstall sometimes gets confused about which Ethernet adapter to use unless all others are disabled.//
 +  - **You Are Almost There: OpenWrt is Now Running From RAM**\\ Now you have OpenWrt running in RAM on your RouterBoard.  You can try it out by running the next two steps, then poke around and decide if you like it.  Since it is only in RAM, if you reboot the RouterBoard without performing the flash (the final step here), this initramfs RAM-based version of OpenWrt will vanish.  
 +  - **Connect to RouterBoard ether2**\\ Unplug your Ethernet cable from ether1 and plug in to a LAN port on your RouterBoard such as ether2. Some RouterBoards do not enable all LAN ports, so you may need to experiment here. 
 +  - **Login to OpenWrt LuCI Web Interface or via SSH**\\ Use a web browser to open the OpenWrt LuCI web interface at 192.168.1.1.  Login is admin, no password.  It may take a minute or more for OpenWrt to fully boot -- wait until the lights on the LAN port indicate activity. If you can't reach the LuCI web interface the initramfs image might be without LuCI. [[:toh:mikrotik:common#using_ssh_instead_of_luci | You need SSH in that case.]] Username is root and there is no password.
 +  - **Flash sysupgrade.bin Into RouterBoard**\\ Go to System->Backup/Flash Firmware in LuCI.  Select 'Choose file' under 'Flash new firmware image' Select the sysupgrade.bin file you previously downloaded to your PC.  Press 'Flash image' to permanently install OpenWrt on your RouterBoard.\\ The flash process may take a minute or more to complete, then your RouterBoard will automatically reboot.\\ **Congratulations!** You now have OpenWrt running and flashed into your RouterBoard.  Subsequent upgrades of OpenWrt are as simple as running this step alone (a noted improvement from previous versions of OpenWrt). If you used SSH in the previous step you can flash the RouterBoard with the ''sysupgrade'' command.
 +
 +Once you have OpenWrt running, you'll probably want to reset your PC's Ethernet back to DHCP instead of the 'forced' static IP addresses you used during the install of OpenWrt.
 +
 +
  
 ===== Additional procedures ===== ===== Additional procedures =====
Line 358: Line 375:
 If your model is not yet supported by trunk, you need to download compile and patch OpenWrt sources. Always check if the model specific wiki instructions could already be obsolete and the necessary patches have already been integrated before embarking into compilation. If your model is not yet supported by trunk, you need to download compile and patch OpenWrt sources. Always check if the model specific wiki instructions could already be obsolete and the necessary patches have already been integrated before embarking into compilation.
  
-Full instructions are at [[:doc:howto:buildroot.exigence]] The following is a mostly a cheat sheet specifically for routerboards.+Full instructions are at [[docs:guide-developer:toolchain:install-buildsystem|Build system – Installation]]The following is a mostly a cheat sheet specifically for routerboards.
  
 OpenWrt sources are available via two release management systems, svn and git. If the model specific instructions specified one, use that, otherwise use git (faster). OpenWrt sources are available via two release management systems, svn and git. If the model specific instructions specified one, use that, otherwise use git (faster).
Line 425: Line 442:
  
 Warning: once you run "make", it will copy files from the 'target' directory over to 'build_dir' directory including downloading additional software/patches. If you modify/patch files in 'target' after a 'make', those changes will not propagate into 'build_dir'. To experiment with different patches, you either need to modify files in build_dir directly, or run 'make clean' before every make run. Warning: once you run "make", it will copy files from the 'target' directory over to 'build_dir' directory including downloading additional software/patches. If you modify/patch files in 'target' after a 'make', those changes will not propagate into 'build_dir'. To experiment with different patches, you either need to modify files in build_dir directly, or run 'make clean' before every make run.
 +
 +==== Routerboard configuration ====
 +
 +Routerboard bootloader settings are available in the Devicetree at ''/sys/firmware/mikrotik''.
 +
 +For example, to see the current silent-boot setting, you can run:
 +
 +  # cat /sys/firmware/mikrotik/soft_config/silent_boot 
 +  [off] on
 +
 +and to turn it on, run ''echo on > /sys/firmware/mikrotik/soft_config/silent_boot''.
 +
 +==== Saving MikroTik RouterBoard License key using WinBox and Windows ====
 +
 +See [[http://wiki.mikrotik.com/wiki/Manual:License]].
 +
 +With existing RouterOS running on your RouterBoard, connect your PC to a LAN port on the RouterBoard (DHCP enabled). Use a web browser to get to the RouterOS login page (default at 192.168.88.1) and download Mikrotik WinBox from your RouterBoard onto your Windows PC. Do NOT try to use the WebFig browser interface to export your license file: it does not have the license export feature. You must use the WinBox Windows application. Execute (double click) the downloaded WinBox to run it from your PC. Use WinBox to export (save) your license .key file to your PC. This will allow you to restore/re-install RouterOS at a later time using Mikrotik's NetInstall.
 +
 +If you cannot connect to the RouterBoard RouterOS on a LAN port, try resetting the RouterBoard to its default settings: that will ensure you can connect using the ether1 port. Reset the RouterBoard to its default settings by unplugging power, press the Reset button, then plug power back in and continue holding the Reset button for 5 seconds. Now set your PC to a static IP address of 192.168.88.10. Move your Ethernet cable to the ether1 (usually WAN) port on the RouterBoard and get WinBox at 192.168.88.1
 +
 +If you have an old version of RouterOs/WinBox and a newer version of Windows (such as Windows 10), your WinBox may not be compatible with Windows 10. If so, upgrade your RouterOS so you get a new version of RouterOs/WinBox that is Windows 10 compatible. The latest WinBox is Windows 10 compatible, but the WinBox version must also be compatible with the RouterOS version - so that's why you should consider installing a new RouterOS .npk file (which includes WinBox) if WinBox is not working for you.
  
 ==== Saving MikroTik RouterBoard License Key Without Using WinBox ==== ==== Saving MikroTik RouterBoard License Key Without Using WinBox ====
Line 430: Line 468:
 It's a good idea to save your RouterOS license .key file (export your license) before starting an install of OpenWrt. It's a good idea to save your RouterOS license .key file (export your license) before starting an install of OpenWrt.
  
-A simple method is to use the Mikrotik WinBox Windows application, as discussed at the top of this wikiSee [[http://wiki.mikrotik.com/wiki/Manual:License]]. +A simple method is to use the Mikrotik WinBox Windows application, as discussed at the top of this page.
 Otherwise, boot RouterOS and export the key to a file: Otherwise, boot RouterOS and export the key to a file:
 <code>/system license output</code> <code>/system license output</code>
Line 449: Line 486:
 Copy contents, alternative 3: download files from web interface. Example Copy contents, alternative 3: download files from web interface. Example
 <code>http://192.168.88.1/webfig/#Files</code> <code>http://192.168.88.1/webfig/#Files</code>
 +
 +Copy contents, alternative 4: download files via scp. Example
 +<code>scp admin@192.168.88.1:/RJ15-ERX5 ./RJ15-ERX5</code>
  
 The differences between the obtained key file and a key exported with Winbox are that the //SoftwareID// line is not present in the latter, and there are no empty lines, so you should probably delete all the empty lines in your file prior to import it for a new installation; the //SoftwareID// line should not bother the installer (untested). The differences between the obtained key file and a key exported with Winbox are that the //SoftwareID// line is not present in the latter, and there are no empty lines, so you should probably delete all the empty lines in your file prior to import it for a new installation; the //SoftwareID// line should not bother the installer (untested).
Line 472: Line 512:
  
 Be sure to use Mikrotik WinBox to export your license key before installing OpenWrt. Be sure to use Mikrotik WinBox to export your license key before installing OpenWrt.
 +
 +==== Downgrading RouterOS ====
 +
 +  - [[https://mikrotik.com/download|Download]] RouterOS v6 for the correct architecture (ARM for armv7 devices, ARM64 for armv8 devices, etc.).
 +  - Upload the .npk file using FTP, SCP, or at http://192.168.88.1/webfig/#Files.
 +  - Run the ''/system package downgrade'' command or press the “Downgrade” button at System → Packages in the web interface.
 +  - After the device reboots, it will have donwgraded the RouterOS itself, but not the bootloader yet. To downgrade the bootloader, confusingly, run the ''/system routerboard upgrade'' command or press the “Upgrade” button at System → Routerboard.
 +  - Reboot and then run ''/system routerboard print'' or go to System → Routerboard in the web interface to make sure that you have the “current version” that you expect.
 +
 +==== Manually Flashing OpenWrt with wget2nand (deprecated)====
 +
 +These instructions are deprecated since wget2nand is no longer used, but left here for reference. Note "rootfs" has become "ubi" (and allow direct flashing of the NAND or NOR from the LuCI web interface) in the current OpenWrt release.
 +
 +If wget2nand encounters problems, perform its steps manually from shell.
 +  
 +  cat /proc/mtd
 +  dev:    size   erasesize  name
 +  mtd0: 00040000 00020000 "booter"
 +  mtd1: 003c0000 00020000 "kernel"
 +  mtd2: 07c00000 00020000 "rootfs"
 +
 +The following instructions assume that as shown above, kernel is /dev/mtd1 and rootfs /dev/mtd2. If these numbers are different on your model, appropriately change the following commands.
 +
 +  mtd erase /dev/mtd1
 +  mtd erase /dev/mtd2
 +  mkdir /mnt/kernel
 +  mkdir /mnt/rootfs
 +  mount /dev/mtdblock1 /mnt/kernel
 +  mount /dev/mtdblock2 /mnt/rootfs
 +
 +Copy kernel & rootfs to routerboard:
 +
 +  scp bin/ar71xx/openwrt-ar71xx-mikrotik-vmlinux-lzma.elf root@192.168.1.1:/tmp
 +  scp bin/ar71xx/openwrt-ar71xx-mikrotik-DefaultNoWifi-rootfs.tar.gz root@192.168.1.1:/tmp
 +
 +Flash kernel & rootfs
 +
 +  mv /tmp/openwrt-ar71xx-nand-vmlinux-lzma.elf /mnt/kernel/kernel
 +  chmod +x /mnt/kernel/kernel
 +  umount /mnt/kernel
 +  cd /mnt/rootfs
 +  tar -xvzf /tmp/openwrt-ar71xx-mikrotik-DefaultNoWifi-rootfs.tar.gz
 +  cd /
 +  umount /mnt/rootfs
 +  sync
 +
 +Reboot
      
 ===== Notes ===== ===== Notes =====
  
-==== Patchworks ====+=== Patchworks ===
  
-Router model specific pages may refer to http://patchwork.openwrt.org/patch/4773/raw/ URLs. That patchwork server was decommissioned in 2014. See https://dev.openwrt.org/ticket/17785 and https://lists.openwrt.org/pipermail/openwrt-devel/2014-December/029786.html.+Router model specific pages may refer to [[http://patchwork.openwrt.org/patch/4773/raw/]] URLs. That patchwork server was decommissioned in 2014. See [[https://dev.openwrt.org/ticket/17785]] and [[https://lists.openwrt.org/pipermail/openwrt-devel/2014-December/029786.html]].
  
-The new patch server is https://patchwork.ozlabs.org. Patch numbers for the old server seemingly can not be translated to the new patchwork server so they are not accessible anymore. In general, all patches from the old patchserver should have already been integrated into trunk.+The new patch server is [[https://patchwork.ozlabs.org]]. Patch numbers for the old server seemingly can not be translated to the new patchwork server so they are not accessible anymore. In general, all patches from the old patchserver should have already been integrated into trunk.
  
-==== Rumors ====+=== Rumors ===
  
-Some wiki pages claim that parallel compilation with -j N mail fail OpenWrt build. This seems not to be a problem for >= 14.07 and AR71XX builds as for RouterBoards, parallel compile seems to work fine.+Some wiki pages claim that parallel compilation with -j N may fail OpenWrt build. This seems not to be a problem for >= 14.07 and AR71XX builds as for RouterBoards, parallel compile seems to work fine.
  
 Some wiki pages claim that you need to put paths into the OpenWrt build tree into your .bashrc so that compilation works correctly. This does not seem to be the case anymore. No problems encountered. Some wiki pages claim that you need to put paths into the OpenWrt build tree into your .bashrc so that compilation works correctly. This does not seem to be the case anymore. No problems encountered.
  
-==== Links ====+=== Links ===
  
 [[https://patchwork.ozlabs.org/patch/419857/ | Routerboard 951G Switch Fix]] [[https://patchwork.ozlabs.org/patch/419857/ | Routerboard 951G Switch Fix]]
  • Last modified: 2024/11/03 16:16
  • by base258