Installing external packages on a Teltonika RUT9XX is quite cumbersome.
When talking about embedded systems in general, maintainers often reject package systems in preference of upgrading the entire system (firmware). The reason can be to save space or to be able to ensure compatibility.
Nonetheless, as a user or an advanced reseller of an embedded solution, developing and adding new software to a system is often required since the wanted functionality is usually missing. This lack of functionality is due to the simple fact that the manufacturer usually works with requirements which differ from other organisations. Therefore, unless you buy hundreds of thousands of devices, they see no benefit in introducing more work and complexity in their processes.
OpenWRT, the Linux distro the RUT9XX series uses as its OS, is somewhere between an embedded system and a server system. Developed as a "router OS", its intended target is of no question. Still, it maintains an extensive package system which allows for the installation of most server-related software. Components one seldom thinks of as part of a router. Then again, it is common for systems to have multiple roles these days. Whether or not this is a good thing is not to be debated today.
Compiling a piece of software and building an OpenWRT-compatible package is an adventure (rabbit hole) in itself. As such, we will not discuss it here, as our goal lies elsewhere.
OpenWRT uses the opkg package format, which derives from the now defunct ipkg package format. Yet still, the extension remains as
These files are compressed tar archives with a fixed structure similar to, but not compatible with, Debian packages.
Adding a new package source on OpenWRT
Opkg packages use one or several repositories (feeds) as the remote storage location. You can find the declaration of these repositories in the folder
/etc/opkg. Here you will find a couple of
.conf files. Each file (often) points to a particular origin. In the RUT9XXX firmware, the available files are;
The Teltonika-specific file points to a repository with Teltonika's packages for software such as MQTT, Modbus etc.
The Distfeeds file contains several repositories with OpenWRT packages. These files are not only for the RUT9XX but for all devices compatible with the same CPU architecture.
Last, there is the Customfeeds file. Here one can add references to other custom repositories. For example, to add the current NODA repository, add the following line to the file.
src/gz noda https://opkg.noda.se
Save it and run the following commands.
$ cd /tmp
$ wget https://opkg.noda.se/public.key
$ opkg-key add public.key $ opkg update
NOTE: If you get an error containing;
opkg_download: Failed to download https://downloads.openwrt.org/.../mips_24kc/vuci/Packages.gz
Then you can safely ignore this error. It is due to the removal of the vuci feed from OpenWRT mainline, something Teltonika still needs to patch in their firmware.
Installing NODA packages
The following packages are available in the NODA repository (feed).
- simple-modbus-server; a plain Modbus TCP server (slave) to act as an intermediary between two or more Modbus clients (masters). It supports multiple simultaneous connections, something lacking from the Modbus server available in the RUT9XX firmware since it can only handle one connection at a time.
To install a package; run the following command;
$ opkg install package-name
Simple Modbus Server
By default, this software runs on the same port as the Modbus server in the firmware and since two different software can't listen on the same TCP port. Therefore, you must disable the internal Modbus server before installing and deploying this software.
$ opkg install simple-modbus-server
The default configuration should suffice for most cases. If you need to change anything, you can find the configuration in;
$ cat /etc/config/modbus_server
config modbus 'modbus' option enabled '1' option port '502' option address '0.0.0.0' option coil '0:0' option discrete '0:0' option holding '0:9999' option input '0:0' option connections '32'
To enable the service to run at startup, execute the command;
$ /etc/init.d/modbus_server enable
To manually start the service, execute the command;
$ /etc/init.d/modbus_server start
There is one major caveat with all of this, and that is a firmware upgrade. In stark contrast to desktop systems, an embedded system doesn't perform an upgrade of newer packages. Instead, it replaces its entire OS environment with a new one on every upgrade.
Such an upgrade will completely wipe all modifications from the system and will, in essence, restore the device to factory default. To avoid losing configuration, OpenWRT uses a separate storage system, UCI, to store all configuration files. When performing a firmware upgrade, one can choose to retain or wipe this store.
Still, this only pertains to configuration files. Packages are not part of the UCI system. As a result, the system must download and install packages after each firmware upgrade—something it doesn't do independently.
Teltonika solves this in their firmware by keeping track of installed packages in a temporary file which survives the upgrade and is then automatically installed once the router is online. However, this only works for packages in Teltonika's feed, not those from mainline OpenWRT or our custom feed.
There exists an attempt at solving this dilemma in OpenWRT, which is called opkg-extras, but it's not a maintained solution and doesn't work as-is. Why this is not part of the mainline OpenWRT firmware is a good question.