Python minimal thread (threading.Thread) example

This is a really simple example of how to add an extra thread to your Python script, to run some task in the background:

from threading import Thread
import time

def extra_thread_function():
    while True:
        print("extra_thread is running")
        time.sleep(1)

extra_thread = threading.Thread(target=extra_thread_function)
extra_thread.start()

# TODO Your code for the main thread goes here!

# OPTIONAL: Wait for extra_thread to finish
extra_thread.join()

 

Posted by Uli Köhler in Python

Python minimal enum (enum.Enum) example

from enum import Enum

class Shape(Enum):
    Circle = 0
    Square = 1
    Hexagon = 2

# Usage example
print(Shape.Square) # prints Shape.Square

Based on the official enum package docs.

Posted by Uli Köhler in Python

How to fix STM32 error: expected constructor, destructor, or type conversion before __declspec(dllexport)

Problem:

When trying to compile a firmware for an STM32 microcontroller, you see a compiler error message like

myheader.h:23:12: error: expected constructor, destructor, or type conversion before ‘(’ token
   23 |  __declspec(dllexport) int myfunc(

Solution:

We previously explored the same problem for Linux platforms.

__declspec(dllexport) is a Windows-specific feature and not available on non-Windows platform such as the ARM embedded API platform (e.g. STM32). In order to fix it in a compatible way with both Windows and the STM32, add the following code either in a header that is included in every file containing __declspec(dllexport) or add it in each file where the error occurs:

#ifdef __ARM_EABI__
#define __declspec(v)
#endif

This will basically ignore any __declspec() call on the preprocessor level.

By using __ARM_EABI__ specfically, the definition will not trigger for ARM platforms for Windows.

Posted by Uli Köhler in C/C++, GCC errors, STM32

How to install ESP32 espota.py on Linux

Currently there is no pip install ... way of installing espota.py. The easiest way of installing it is to download it from GitHub:

wget https://raw.githubusercontent.com/espressif/arduino-esp32/master/tools/espota.py

 

Posted by Uli Köhler in Embedded, ESP8266/ESP32, Networking

How to fix ESP32 esptool.py Running stub… StopIteration

Problem:

When flashing an ESP32, especially when flashing remotely, you see the following log message

Serial port rfc2217://10.1.2.3.105:4418
Connecting...
Device PID identification is only supported on COM and /dev/ serial ports.
..
Chip is ESP32-S2
Features: WiFi, No Embedded Flash, No Embedded PSRAM, ADC and temperature sensor calibration in BLK2 of efuse V2
Crystal is 40MHz
MAC: 60:55:f9:f0:3a:16
Uploading stub...
Running stub...
Traceback (most recent call last):
  File "/usr/local/bin/esptool.py", line 34, in <module>
    esptool._main()
  File "/usr/local/lib/python3.8/dist-packages/esptool/__init__.py", line 1004, in _main
    main()
  File "/usr/local/lib/python3.8/dist-packages/esptool/__init__.py", line 684, in main
    esp = esp.run_stub()
  File "/usr/local/lib/python3.8/dist-packages/esptool/loader.py", line 912, in run_stub
    p = self.read()
  File "/usr/local/lib/python3.8/dist-packages/esptool/loader.py", line 307, in read
    return next(self._slip_reader)
StopIteration

Solution:

This issue occurs not because of a hardware defect but because the latency of the connection is quite high and therefore the timeout occurs before the communication between the script and the bootloader can happen.

In order to fix it, you need to edit the hard-coded default timeout in the esptool.py installation!

First, you need to identify the location of loader.py in your installation. You can simply do that from the following part of the stack trace:

File "/usr/local/lib/python3.8/dist-packages/esptool/loader.py", line 912, in run_stub p = self.read()

In this case, loader.py is located at

/usr/local/lib/python3.8/dist-packages/esptool/loader.py

You need to edit the following line:

MEM_END_ROM_TIMEOUT = 0.05  # short timeout for ESP_MEM_END, as it may never respond

and increase the timeout – my recommendation is to increase it to 2.5 seconds.

… or you can simply change the timeout using the following command:

sed -i -e 's/MEM_END_ROM_TIMEOUT = 0.05/MEM_END_ROM_TIMEOUT = 2.5/g' /usr/local/lib/python3.8/dist-packages/esptool/loader.py

After that, your upload should work just fine.

Posted by Uli Köhler in Electronics, Embedded, ESP8266/ESP32, Networking

Python curses keycode to key mapping

The following mapping is helpful in order to determine the mapping of a keycode to the corresponding curses.KEY_... constant.

I extracted this mapping by using

import curses
print(curses.__dict__)

Curses key mapping

'A_ATTRIBUTES': 4294967040,
'A_NORMAL': 0,
'A_STANDOUT': 65536,
'A_UNDERLINE': 131072,
'A_REVERSE': 262144,
'A_BLINK': 524288,
'A_DIM': 1048576,
'A_BOLD': 2097152,
'A_ALTCHARSET': 4194304,
'A_INVIS': 8388608,
'A_PROTECT': 16777216,
'A_CHARTEXT': 255,
'A_COLOR': 65280,
'A_HORIZONTAL': 33554432,
'A_LEFT': 67108864,
'A_LOW': 134217728,
'A_RIGHT': 268435456,
'A_TOP': 536870912,
'A_VERTICAL': 1073741824,
'A_ITALIC': 2147483648,
'COLOR_BLACK': 0,
'COLOR_RED': 1,
'COLOR_GREEN': 2,
'COLOR_YELLOW': 3,
'COLOR_BLUE': 4,
'COLOR_MAGENTA': 5,
'COLOR_CYAN': 6,
'COLOR_WHITE': 7,
'BUTTON1_PRESSED': 2,
'BUTTON1_RELEASED': 1,
'BUTTON1_CLICKED': 4,
'BUTTON1_DOUBLE_CLICKED': 8,
'BUTTON1_TRIPLE_CLICKED': 16,
'BUTTON2_PRESSED': 64,
'BUTTON2_RELEASED': 32,
'BUTTON2_CLICKED': 128,
'BUTTON2_DOUBLE_CLICKED': 256,
'BUTTON2_TRIPLE_CLICKED': 512,
'BUTTON3_PRESSED': 2048,
'BUTTON3_RELEASED': 1024,
'BUTTON3_CLICKED': 4096,
'BUTTON3_DOUBLE_CLICKED': 8192,
'BUTTON3_TRIPLE_CLICKED': 16384,
'BUTTON4_PRESSED': 65536,
'BUTTON4_RELEASED': 32768,
'BUTTON4_CLICKED': 131072,
'BUTTON4_DOUBLE_CLICKED': 262144,
'BUTTON4_TRIPLE_CLICKED': 524288,
'BUTTON5_PRESSED': 2097152,
'BUTTON5_RELEASED': 1048576,
'BUTTON5_CLICKED': 4194304,
'BUTTON5_DOUBLE_CLICKED': 8388608,
'BUTTON5_TRIPLE_CLICKED': 16777216,
'BUTTON_SHIFT': 67108864,
'BUTTON_CTRL': 33554432,
'BUTTON_ALT': 134217728,
'ALL_MOUSE_EVENTS': 268435455,
'REPORT_MOUSE_POSITION': 268435456,
'KEY_BREAK': 257,
'KEY_DOWN': 258,
'KEY_UP': 259,
'KEY_LEFT': 260,
'KEY_RIGHT': 261,
'KEY_HOME': 262,
'KEY_BACKSPACE': 263,
'KEY_F0': 264,
'KEY_F1': 265,
'KEY_F2': 266,
'KEY_F3': 267,
'KEY_F4': 268,
'KEY_F5': 269,
'KEY_F6': 270,
'KEY_F7': 271,
'KEY_F8': 272,
'KEY_F9': 273,
'KEY_F10': 274,
'KEY_F11': 275,
'KEY_F12': 276,
'KEY_F13': 277,
'KEY_F14': 278,
'KEY_F15': 279,
'KEY_F16': 280,
'KEY_F17': 281,
'KEY_F18': 282,
'KEY_F19': 283,
'KEY_F20': 284,
'KEY_F21': 285,
'KEY_F22': 286,
'KEY_F23': 287,
'KEY_F24': 288,
'KEY_F25': 289,
'KEY_F26': 290,
'KEY_F27': 291,
'KEY_F28': 292,
'KEY_F29': 293,
'KEY_F30': 294,
'KEY_F31': 295,
'KEY_F32': 296,
'KEY_F33': 297,
'KEY_F34': 298,
'KEY_F35': 299,
'KEY_F36': 300,
'KEY_F37': 301,
'KEY_F38': 302,
'KEY_F39': 303,
'KEY_F40': 304,
'KEY_F41': 305,
'KEY_F42': 306,
'KEY_F43': 307,
'KEY_F44': 308,
'KEY_F45': 309,
'KEY_F46': 310,
'KEY_F47': 311,
'KEY_F48': 312,
'KEY_F49': 313,
'KEY_F50': 314,
'KEY_F51': 315,
'KEY_F52': 316,
'KEY_F53': 317,
'KEY_F54': 318,
'KEY_F55': 319,
'KEY_F56': 320,
'KEY_F57': 321,
'KEY_F58': 322,
'KEY_F59': 323,
'KEY_F60': 324,
'KEY_F61': 325,
'KEY_F62': 326,
'KEY_F63': 327,
'KEY_DL': 328,
'KEY_IL': 329,
'KEY_DC': 330,
'KEY_IC': 331,
'KEY_EIC': 332,
'KEY_CLEAR': 333,
'KEY_EOS': 334,
'KEY_EOL': 335,
'KEY_SF': 336,
'KEY_SR': 337,
'KEY_NPAGE': 338,
'KEY_PPAGE': 339,
'KEY_STAB': 340,
'KEY_CTAB': 341,
'KEY_CATAB': 342,
'KEY_ENTER': 343,
'KEY_SRESET': 344,
'KEY_RESET': 345,
'KEY_PRINT': 346,
'KEY_LL': 347,
'KEY_A1': 348,
'KEY_A3': 349,
'KEY_B2': 350,
'KEY_C1': 351,
'KEY_C3': 352,
'KEY_BTAB': 353,
'KEY_BEG': 354,
'KEY_CANCEL': 355,
'KEY_CLOSE': 356,
'KEY_COMMAND': 357,
'KEY_COPY': 358,
'KEY_CREATE': 359,
'KEY_END': 360,
'KEY_EXIT': 361,
'KEY_FIND': 362,
'KEY_HELP': 363,
'KEY_MARK': 364,
'KEY_MESSAGE': 365,
'KEY_MOVE': 366,
'KEY_NEXT': 367,
'KEY_OPEN': 368,
'KEY_OPTIONS': 369,
'KEY_PREVIOUS': 370,
'KEY_REDO': 371,
'KEY_REFERENCE': 372,
'KEY_REFRESH': 373,
'KEY_REPLACE': 374,
'KEY_RESTART': 375,
'KEY_RESUME': 376,
'KEY_SAVE': 377,
'KEY_SBEG': 378,
'KEY_SCANCEL': 379,
'KEY_SCOMMAND': 380,
'KEY_SCOPY': 381,
'KEY_SCREATE': 382,
'KEY_SDC': 383,
'KEY_SDL': 384,
'KEY_SELECT': 385,
'KEY_SEND': 386,
'KEY_SEOL': 387,
'KEY_SEXIT': 388,
'KEY_SFIND': 389,
'KEY_SHELP': 390,
'KEY_SHOME': 391,
'KEY_SIC': 392,
'KEY_SLEFT': 393,
'KEY_SMESSAGE': 394,
'KEY_SMOVE': 395,
'KEY_SNEXT': 396,
'KEY_SOPTIONS': 397,
'KEY_SPREVIOUS': 398,
'KEY_SPRINT': 399,
'KEY_SREDO': 400,
'KEY_SREPLACE': 401,
'KEY_SRIGHT': 402,
'KEY_SRSUME': 403,
'KEY_SSAVE': 404,
'KEY_SSUSPEND': 405,
'KEY_SUNDO': 406,
'KEY_SUSPEND': 407,
'KEY_UNDO': 408,
'KEY_MOUSE': 409,
'KEY_RESIZE': 410,
'KEY_MIN': 257,
'KEY_MAX': 511}

 

Posted by Uli Köhler in Allgemein

How to fix apt error: NO_PUBKEY A2F683C52980AECF

Problem:

When running apt update, you see the following error message:

Err:13 https://download.virtualbox.org/virtualbox/debian jammy InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A2F683C52980AECF

Solution:

This error occurs due to the VirtualBox repo using the outdated (as of April 2022) apt-key method of importing keys.

You can import the key by just installing the tailscale repo again (these commands are based on the commands from the VirtualBox Linux downloads page):

wget -qO- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --dearmor --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list

and then running

apt update

again.

 

Posted by Uli Köhler in Linux

How to fix apt error: NO_PUBKEY 458CA832957F5868

Problem:

When running apt update, you see the following error message:

Err:27 https://pkgs.tailscale.com/stable/ubuntu jammy InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 458CA832957F5868

 

Solution:

This error occurs due to the Tailscale repo using the outdated (as of April 2022) apt-key method of importing keys.

You can import the key by just installing the tailscale repo again (these commands are listed on the official tailscale installation page):

curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/jammy.noarmor.gpg | sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/jammy.tailscale-keyring.list | sudo tee /etc/apt/sources.list.d/tailscale.list

and then running

apt update

again.

 

Posted by Uli Köhler in Linux

How to get current time in MikroTik RouterOS script

In order to get the current time in RouterOS, use

/system clock get time

The time returned will be in hh:mm:dd format and local time

For example, the following command will print the current time:

:put [/system clock get time]

 

Posted by Uli Köhler in MikroTik, Networking

How to print in MikroTik RouterOS script

In order to print from within a RouterOS script on a MikroTik router, use

:put

For example,

:put [/system clock get time]

will print, for example

[admin@MyRouter] > :put [/system clock get time]
22:55:11

 

Posted by Uli Köhler in MikroTik, Networking

How to make MikroTik router boot using PXE (netboot) / BOOTP

My experience is that PXE on MikroTik devices only works properly when you trigger it using the hardware reset button. You can also trigger it using System -> RouterBOARD -> Settings but this reproducibly didn’t work for me.

This method was tested on the hEX PoE Lite (i.e. RB750UPr2)

Method of triggering Netboot using the RESET button

  1. Unplug all (!) power supplies from your router. This includes PoE if used. Check if all LEDs are off.
  2. Press the reset button, you should hear a small click sound. Sometimes these are a little bit hard to press, sometimes you think you’ve pressed it but you didn’t since the button is sometimes smaller than the hole. I use tweezers to press it. Keep the reset button pressed until you’ve finished the procedure.
  3. Keep pressing the reset button while plugging in the power supply
  4. While still keeping the reset button pressed, wait for the following phases of reset:
    1. After ~5 seconds one of the LEDs will start to blink
    2. After a further 5 seconds, the LED will stop blinking and turn on permanently
    3. After a further 5 seconds, the LED will turn off permanently.
  5. Only after you see the LED go dark after these three phases (approximately 15 seconds), release the reset button
  6. The router should now boot using PXE
Posted by Uli Köhler in MikroTik

How to flash OpenWRT on hEX PoE Lite (RB750UPr2)

Important note: Flashing OpenWRT permanently breaks PoE out functionality even after reinstalling RouterOS! PoE does not work on OpenWRT either!

I had significant problem with the official instructions of flashing OpenWRT on the MikroTik hEX PoE Lite as described on the OpenWRT wiki. I used RouterOS 7.4.1 and a Linux host for the flash process.

Specificially, starting the flash process from within RouterOS via System -> RouterBoard -> Settings did not work, neither with the backup bootloader nor without it, neither with DHCP nor with BOOTP. This caused a boot-and-DHCP-request loop with the log shown blow

Steps to flash OpenWRT on the RB750UPr2

… and probably most other RouterOS boards. There is no specific requirement  for the firmware version. RouterOS 6.47 works. RouterOS 7.4.1 works. I didn’t check any one beside that, but most likely it won’t make a difference. Specifically, there is no need to downgrade if using this method! The RouterOS downgrade is only neccessary for some old-ish Windows based flash method.

1 – Connect a ethernet cable from your flashing computer to the first Ethernet connector of the router.

PXE will only work on this specific port and will not work on other ports!

2 – Setup your flashing computer’s IP interface config.

We’ll use eth0 in this example. Be sure to use the correct interface

sudo ifconfig eth0 192.168.1.10 netmask 255.255.255.0

I read somewhere that MikroTiks expect the PXE host to be at IP 192.168.1.10 – this definitively works. Other IP addresses might or might not also work, I didn’t check. Just use that one.

3 – Setup dnsmasq

sudo apt -y install dnsmasq

and then do not forget to stop dnsmasq and remove the default config

sudo systemctl disable --now dnsmasq
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.default.conf

4 – Download the correct image from OpenWRT

Google for OpenWRT + your RouterBoard type, e.g. OpenWRT RB750UPr2. This will lead you to a site like this one. Scroll down and download both the Firmware OpenWrt Install URL and the Firmware OpenWrt Upgrade URLIn the end you will need both anyway, but for now we need the one ending with ...-initramfs-kernel.img!

Save that file with the original name. The name does not matter – what matters is only that you use the correct image, not the ...-sysupgrade.bin for PXE boot! There is absolutely no need to name the file vmlinux etc.

5 – Startup dnsmasq server

In the following command, be sure to set the correct image name in the --dhcp-boot line

sudo /usr/sbin/dnsmasq \
--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.10-ar71xx-mikrotik-rb-nor-flash-16M-initramfs-kernel.bin \
--log-dhcp \
--enable-tftp \
--tftp-root=$(pwd)

6 – Reset the router into PXE boot mode

As noted above, resetting via RouterOS did not work for me at all. I can only recommend this method, which I also described in my blogpost How to make MikroTik router boot using PXE (netboot) / BOOTP

  1. Unplug all (!) power supplies from your router. This includes PoE if used. Check if all LEDs are off.
  2. Press the reset button, you should hear a small click sound. Sometimes these are a little bit hard to press, sometimes you think you’ve pressed it but you didn’t since the button is sometimes smaller than the hole. I use tweezers to press it. Keep the reset button pressed until you’ve finished the procedure.
  3. Keep pressing the reset button while plugging in the power supply
  4. While still keeping the reset button pressed, wait for the following phases of reset:
    1. After ~5 seconds one of the LEDs will start to blink
    2. After a further 5 seconds, the LED will stop blinking and turn on permanently
    3. After a further 5 seconds, the LED will turn off permanently.
  5. Only after you see the LED go dark after these three phases (approximately 15 seconds), release the reset button
  6. The router should now boot using PXE

7 – Proceed with OpenWRT

If the reset & PXE boot worked, OpenWRT is running on 192.168.1.1On most MikroTik devices, you need to plugin the Ethernet to one of the LAN ports (typically every port except the first port) in order to access OpenWRT. Note that DHCP is not active by default.

The next step is basically to check if OpenWRT works properly and then install it to the flash using the ...-sysupgrade.bin image which we have downloaded before. This is rather easy and performed using the Web UI, it’s best to check the OpenWRT wiki page for more details.

Error log when starting the PXE flash via RouterOS

See above for the procedure that works. This error occured when I didn’t start the PXE process via the Reset button

dnsmasq-dhcp: 1534706347 vendor class: Mips_boot
dnsmasq-dhcp: 1534706347 DHCPDISCOVER(eth1) dc:2c:6e:d7:60:9d 
dnsmasq-dhcp: 1534706347 tags: eth1
dnsmasq-dhcp: 1534706347 DHCPOFFER(eth1) 192.168.1.100 dc:2c:6e:d7:60:9d 
dnsmasq-dhcp: 1534706347 requested options: 1:netmask, 3:router
dnsmasq-dhcp: 1534706347 bootfile name: rb-nor-flash-16M-initramfs-kernel.bin
dnsmasq-dhcp: 1534706347 next server: 192.168.1.10
dnsmasq-dhcp: 1534706347 sent size:  1 option: 53 message-type  2
dnsmasq-dhcp: 1534706347 sent size:  4 option: 54 server-identifier  192.168.1.10
dnsmasq-dhcp: 1534706347 sent size:  4 option: 51 lease-time  1h
dnsmasq-dhcp: 1534706347 sent size:  4 option: 58 T1  30m
dnsmasq-dhcp: 1534706347 sent size:  4 option: 59 T2  52m30s
dnsmasq-dhcp: 1534706347 sent size:  4 option:  1 netmask  255.255.255.0
dnsmasq-dhcp: 1534706347 sent size:  4 option: 28 broadcast  192.168.1.255
dnsmasq-dhcp: 1534706347 sent size:  4 option:  3 router  192.168.1.10
dnsmasq-dhcp: 4257818828 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 4257818828 vendor class: Mips_boot
dnsmasq-dhcp: 4257818828 DHCPDISCOVER(eth1) dc:2c:6e:d7:60:9d 
dnsmasq-dhcp: 4257818828 tags: eth1
dnsmasq-dhcp: 4257818828 DHCPOFFER(eth1) 192.168.1.100 dc:2c:6e:d7:60:9d 
dnsmasq-dhcp: 4257818828 requested options: 1:netmask, 3:router
dnsmasq-dhcp: 4257818828 bootfile name: rb-nor-flash-16M-initramfs-kernel.bin
dnsmasq-dhcp: 4257818828 next server: 192.168.1.10
dnsmasq-dhcp: 4257818828 sent size:  1 option: 53 message-type  2
dnsmasq-dhcp: 4257818828 sent size:  4 option: 54 server-identifier  192.168.1.10
dnsmasq-dhcp: 4257818828 sent size:  4 option: 51 lease-time  1h
dnsmasq-dhcp: 4257818828 sent size:  4 option: 58 T1  30m
dnsmasq-dhcp: 4257818828 sent size:  4 option: 59 T2  52m30s
dnsmasq-dhcp: 4257818828 sent size:  4 option:  1 netmask  255.255.255.0
dnsmasq-dhcp: 4257818828 sent size:  4 option: 28 broadcast  192.168.1.255
dnsmasq-dhcp: 4257818828 sent size:  4 option:  3 router  192.168.1.10
dnsmasq-dhcp: 1683968382 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 1683968382 vendor class: Mips_boot
dnsmasq-dhcp: 1683968382 DHCPDISCOVER(eth1) dc:2c:6e:d7:60:9d 
dnsmasq-dhcp: 1683968382 tags: eth1
dnsmasq-dhcp: 1683968382 DHCPOFFER(eth1) 192.168.1.100 dc:2c:6e:d7:60:9d 
dnsmasq-dhcp: 1683968382 requested options: 1:netmask, 3:router
dnsmasq-dhcp: 1683968382 bootfile name: rb-nor-flash-16M-initramfs-kernel.bin
dnsmasq-dhcp: 1683968382 next server: 192.168.1.10
dnsmasq-dhcp: 1683968382 sent size:  1 option: 53 message-type  2
dnsmasq-dhcp: 1683968382 sent size:  4 option: 54 server-identifier  192.168.1.10
dnsmasq-dhcp: 1683968382 sent size:  4 option: 51 lease-time  1h
dnsmasq-dhcp: 1683968382 sent size:  4 option: 58 T1  30m
dnsmasq-dhcp: 1683968382 sent size:  4 option: 59 T2  52m30s
dnsmasq-dhcp: 1683968382 sent size:  4 option:  1 netmask  255.255.255.0
dnsmasq-dhcp: 1683968382 sent size:  4 option: 28 broadcast  192.168.1.255
dnsmasq-dhcp: 1683968382 sent size:  4 option:  3 router  192.168.1.10
dnsmasq-dhcp: 424531201 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 424531201 vendor class: Mips_boot
dnsmasq-dhcp: 424531201 DHCPDISCOVER(eth1) dc:2c:6e:d7:60:9d 
dnsmasq-dhcp: 424531201 tags: eth1
dnsmasq-dhcp: 424531201 DHCPOFFER(eth1) 192.168.1.100 dc:2c:6e:d7:60:9d 
dnsmasq-dhcp: 424531201 requested options: 1:netmask, 3:router
dnsmasq-dhcp: 424531201 bootfile name: rb-nor-flash-16M-initramfs-kernel.bin
dnsmasq-dhcp: 424531201 next server: 192.168.1.10
dnsmasq-dhcp: 424531201 sent size:  1 option: 53 message-type  2
dnsmasq-dhcp: 424531201 sent size:  4 option: 54 server-identifier  192.168.1.10
dnsmasq-dhcp: 424531201 sent size:  4 option: 51 lease-time  1h
dnsmasq-dhcp: 424531201 sent size:  4 option: 58 T1  30m
dnsmasq-dhcp: 424531201 sent size:  4 option: 59 T2  52m30s
dnsmasq-dhcp: 424531201 sent size:  4 option:  1 netmask  255.255.255.0
dnsmasq-dhcp: 424531201 sent size:  4 option: 28 broadcast  192.168.1.255
dnsmasq-dhcp: 424531201 sent size:  4 option:  3 router  192.168.1.10
dnsmasq-dhcp: 3459997603 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3459997603 vendor class: Mips_boot
dnsmasq-dhcp: 3459997603 DHCPDISCOVER(eth1) dc:2c:6e:d7:60:9d 
dnsmasq-dhcp: 3459997603 tags: eth1
dnsmasq-dhcp: 3459997603 DHCPOFFER(eth1) 192.168.1.100 dc:2c:6e:d7:60:9d 
dnsmasq-dhcp: 3459997603 requested options: 1:netmask, 3:router
dnsmasq-dhcp: 3459997603 bootfile name: rb-nor-flash-16M-initramfs-kernel.bin
dnsmasq-dhcp: 3459997603 next server: 192.168.1.10
dnsmasq-dhcp: 3459997603 sent size:  1 option: 53 message-type  2
dnsmasq-dhcp: 3459997603 sent size:  4 option: 54 server-identifier  192.168.1.10
dnsmasq-dhcp: 3459997603 sent size:  4 option: 51 lease-time  1h
dnsmasq-dhcp: 3459997603 sent size:  4 option: 58 T1  30m
dnsmasq-dhcp: 3459997603 sent size:  4 option: 59 T2  52m30s
dnsmasq-dhcp: 3459997603 sent size:  4 option:  1 netmask  255.255.255.0
dnsmasq-dhcp: 3459997603 sent size:  4 option: 28 broadcast  192.168.1.255
dnsmasq-dhcp: 3459997603 sent size:  4 option:  3 router  192.168.1.10
dnsmasq-dhcp: 657189184 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 657189184 vendor class: Mips_boot
dnsmasq-dhcp: 657189184 DHCPDISCOVER(eth1) dc:2c:6e:d7:60:9d 
dnsmasq-dhcp: 657189184 tags: eth1
dnsmasq-dhcp: 657189184 DHCPOFFER(eth1) 192.168.1.100 dc:2c:6e:d7:60:9d 
dnsmasq-dhcp: 657189184 requested options: 1:netmask, 3:router
dnsmasq-dhcp: 657189184 bootfile name: rb-nor-flash-16M-initramfs-kernel.bin
dnsmasq-dhcp: 657189184 next server: 192.168.1.10
dnsmasq-dhcp: 657189184 sent size:  1 option: 53 message-type  2
dnsmasq-dhcp: 657189184 sent size:  4 option: 54 server-identifier  192.168.1.10
dnsmasq-dhcp: 657189184 sent size:  4 option: 51 lease-time  1h
dnsmasq-dhcp: 657189184 sent size:  4 option: 58 T1  30m
dnsmasq-dhcp: 657189184 sent size:  4 option: 59 T2  52m30s
dnsmasq-dhcp: 657189184 sent size:  4 option:  1 netmask  255.255.255.0
dnsmasq-dhcp: 657189184 sent size:  4 option: 28 broadcast  192.168.1.255
dnsmasq-dhcp: 657189184 sent size:  4 option:  3 router  192.168.1.10
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot
dnsmasq-dhcp: 3031796432 available DHCP range: 192.168.1.100 -- 192.168.1.200
dnsmasq-dhcp: 3031796432 vendor class: Mips_boot

 

Posted by Uli Köhler in MikroTik, Networking, OpenWRT

How to check how much flash space is available on MikroTik RouterOS

Using WebFig (Web UI)

Click on System on the left, then click on Resources. You can see the free space on the flash as Free HDD Space:

Using the command line

Enter the following command:

/system resource print

and look for the free-hdd-space line – for example:

[admin@CoreSwitch01] > /system resource print
                   uptime: 4d19h26m41s
                  version: 7.4.1 (stable)
               build-time: Aug/04/2022 11:48:11
         factory-software: 6.44.6
              free-memory: 408.7MiB
             total-memory: 512.0MiB
                      cpu: ARM
                cpu-count: 2
                 cpu-load: 26%
           free-hdd-space: 44.0KiB
          total-hdd-space: 15.9MiB
  write-sect-since-reboot: 35547
         write-sect-total: 520339
               bad-blocks: 0%
        architecture-name: arm
               board-name: CRS309-1G-8S+
                 platform: MikroTik

 

Posted by Uli Köhler in MikroTik, Networking

Is tailscale available for OpenWRT 19.07?

No, tailscale can’t be installed using opkg on OpenWRT 19.xx. I have experimentally verified this using a MIPSBE router with OpenWRT 19.07.10.

However, tailscale is available on OpenWRT starting from version 21.02 – source: tailscale package page on OpenWRT.

Posted by Uli Köhler in Headscale, Networking, OpenWRT

How to pair cheap Amazon “P4” gamepads with Android (Bluetooth pairing)

There are a number of nice third-party gamepads available on Amazon like this one. While the instructions tell you that in order to connect it to a PlayStation, you need to first connect it via USB, there are no instructions on how to connect it to an Android device or Laptop using Bluetooth.

First, you need to put the device into pairing mode. For my device, this worked by pressing both the Home and the Share button for approximately 5 seconds, until the LED bar started to blink.

When the LED bar blinks, you can immediately connect to the device using Bluetooth.

Note that just long-pressing the Home button made the LED bar blink but didn’t work – you need to press both the buttons circled in red.

Posted by Uli Köhler in Android

Is ZeroTier available for OpenWRT 19.07?

Yes, ZeroTier is available via

opkg update
opkg install zerotier

on OpenWRT 19.07. On my router, which is running OpenWRT 19.07.10 I could install ZeroTier without any modifications or extra package repositories.

Posted by Uli Köhler in OpenWRT, ZeroTier

How to fix OpenWRT SSH Unable to negotiate with … no matching host key type found. Their offer: ssh-rsa

Problem:

When using a modern Linux client to connect with an OpenWRT device using SSH, you an error message like the following:

Unable to negotiate with 192.168.1.1 port 22: no matching host key type found. Their offer: ssh-rsa

Solution:

You can explicitly tell SSH to allow ssh-rsa by using -oHostKeyAlgorithms=+ssh-rsa, for example:

ssh -oHostKeyAlgorithms=+ssh-rsa [email protected]

Using this command should allow you to connect to your OpenWRT device.

Posted by Uli Köhler in Networking, OpenWRT

How to backup MikroTik RouterOS license to a file

On the terminal (or via SSH / Telnet), run the following command:

/system license print file="License.txt"

Now you can find the file under Files in WebFig:

Posted by Uli Köhler in MikroTik, Networking

How to generate JSON with random password with pwgen and bash

This script will generate a random password stored in a JSON file:

echo "{\"secret\": \"$(pwgen 30 1)\"}" > secret.json

Example output

{"secret": "thie2uv6Ro3cah2oodohx2vai5Ahka"}

 

Posted by Uli Köhler in Linux

Which MikroTik devices support ZeroTier?

MikroTik published an official ZeroTier package for MikroTik routers. But not all Routers support

Devices which only support SwOS (SwitchOS) do not support ZeroTier. You need a device running RouterOS.

But even among the RouterOS devices, not all devices support ZeroTier. The first requirement is that you are running a recent version of RouterOS such as RouterOS 7.4.1

At the time of writing this post (2022-08-22), only devices with the ARM and ARM64 architecture support ZeroTier. For other devices, you can’t even download the package. This include CHR (cloud hosted router) running on x86 or x86_64 for which ZeroTier is currently not available.

More specifically, for RouterOS version 7.4.1 and 7.5beta11, neither x86/x86_64 nor the  SMIPS/MMIPS/MIPSBE or Tile architecture support ZeroTier.

Before buying a device or commiting to ZeroTier, download the Extra packages for your architecture from the MikroTik download page and check if there’s a zerotier-....npk in the ZIP archive. If it isn’t available there, you currently can’t use ZeroTier on that device – but possibly it will be supported in the future.

Posted by Uli Köhler in MikroTik, Networking, ZeroTier
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPTPrivacy &amp; Cookies Policy