| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision |
| toh:mikrotik:common [2023/01/28 19:00] – [Methods to set RouterBoard so it will TFTP netboot] bikepunk | toh:mikrotik:common [2023/09/25 21:57] – [Common Procedures for MikroTik RouterBoard Products] 532910 |
|---|
| |
| <WRAP alert> | <WRAP alert> |
| OpenWrt is not compatible with the bootloader of RouterOS **v7**. Do NOT upgrade your device to RouterOS v7 or, if you did, downgrade to RouterOS **v6** before installing OpenWrt. | OpenWrt is not compatible with the bootloader of RouterOS **v7** or **v6.46** or above. Do NOT upgrade the firmware on your device past RouterOS **v6.45.8** or, if you did, downgrade to RouterOS Firmware **v6.45.8** or earlier before installing OpenWrt. |
| | |
| | This isn't fully true, while the first part looks correct: v7 RouterBoot doesn't work with OpenWrt, the second is not: my SXTsq 5 ac has v6.47.10 factory firmware, RouterOS doesn't allow to downgrade main firmware below factory, but openwrt boots and works fine with it! |
| </WRAP> | </WRAP> |
| |
| - 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 === |
| Save | Save |
| | |
| 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 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. |
| | |
| |
| 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. | |
| | |
| 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 | |
| |
| ===== When flashing doesn´t work ===== | ===== When flashing doesn´t work ===== |
| |
| |
| ===== 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''. | |
| |
| |
| ===== Step-By-Step OpenWrt Installation Processes on Routerboard ===== | ===== Step-By-Step OpenWrt Installation Processes on Routerboard ===== |
| ==== With a Linux and other unix-like OS ==== | ==== With a Linux and other unix-like OS ==== |
| * [[#saving_mikrotik_routerboard_license_key_without_using_winbox|Save the license key.]] | * 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) | * [[#downloading_openwrt_images_for_mikrotik_routerboards|Download OpenWrt images]] (initramfs and sysupgrade) |
| * Connect to web interface http://192.168.88.1 | * 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 : Select "DHCP". \\ Tick the "Force Backup Booter" box. \\ Click "Apply". | * 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" | * Go to "System"-"Shutdown" \\ Click "Shutdown" |
| * Unplug power. | * Unplug power. |
| * Create the following script using a text editor such as vi: vi ~/tftp/loader.sh | * 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-19.07-*-initramfs-* with the appropriate filename. | 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 | #!/bin/bash |
| --tftp-root=$(pwd) | --tftp-root=$(pwd) |
| |
| * Copy openwrt-19.07-*-initramfs-* file to the folder where the script is located. | * Copy openwrt-22.03-*-initramfs-* file to the folder where the script is located. |
| * Make the script executable | * Make the script executable |
| |
| * Congratulations, you installed OpenWrt on your MikroTik RouterBoard. | * Congratulations, you installed OpenWrt on your MikroTik RouterBoard. |
| |
| ==== using SSH instead on LuCI ==== | ==== 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. | - 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 | - Connect to web interface http://192.168.88.1 |
| - Go to "System"-"Routerboard". \\ Select "Boot ethernet-if fail-nand". \\ Select “DHCP” (if needed). \\ Turn on "Force Backup Booter". \\ Click "Apply". | - 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 | - 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. | - 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". | - 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. | - 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. |
| - 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. | - 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. | - 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. | |
| |
| 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)]]. | 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)]]. |
| - **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. | - **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. | - **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. You need SSH in that case. Username is root and there is no password. | - **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. | - **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. |
| |
| |
| 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 ==== | ==== Saving MikroTik RouterBoard License key using WinBox and Windows ==== |
| - 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. | - 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. | - 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 ===== |