RSMB: Really Small Message Broker is an MQTT broker/server, simpler than the alternatives like Mosquitto, RabiitMQ, and so on. While it has its origins in IBM labs (as the MQTT protocol), it is now a project/sub project on Eclipse Paho MQTT related software. While downloading the RSBM does provide some binaries for some common platforms, it doesn’t offer any binaries for, in my case, the DS212+ Marvell 88F628x ARM processor.
So let’s see how to cross compile the RSMB for Synology DS and in this process also learn how to cross compile in your desktop computer native software for the Diskstation.
Setting up the cross compiling environment:
First, a read of the following document The 3rd party developer guide from Synology located here https://www.synology.com/en-global/support/developer#tool is recommended. Based on this document (page 6 and 7)and on this page http://forum.synology.com/wiki/index.php/What_kind_of_CPU_does_my_NAS_have, we can know what version of the Synology tool chain we need to download from here: http://sourceforge.net/projects/dsgpl/files/DSM%205.0%20Beta%20Tool%20Chains/
Download the required tool chain for your Synology version. In my case I have the Synology DS212+ that has the Marvel 88F628x ARM processor, so download this file: http://sourceforge.net/projects/dsgpl/files/DSM%205.0%20Beta%20Tool%20Chains/Marvell%2088F628x%20Linux%202.6.32/
Uncompress the file into the /usr/local directory. DO USE this directory. The tool chain is configured to get all files, libraries and so on from the /usr/local/… directory:
sudo tar xvzf gcc464_glibc215_88f6281-GPL.tgz -C /usr/local/
(Note: It’s a CAPITAL C. Check Synology documentation).
We can now get the RSMB sources.
Cross compiling RSMB:
Open an shell terminal (preferably bash but other shells might work) and create and change to a working directory. Clone the RSMB repository located in http://git.eclipse.org/gitroot/mosquitto/org.eclipse.mosquitto.rsmb.git with git tools:
git clone http://git.eclipse.org/gitroot/mosquitto/org.eclipse.mosquitto.rsmb.git
While, for this case, not all the below settings are needed, for documentation purposes I document them here:
Just make sure that the INSTALLDIR variable and TARGETMACH and CROSS variables point to the correct settings.
Also, in this case, for compiling RSMB, we need also to add the following variable:
Otherwise we need to change the Makefile and change the line GCC=gcc to point to the correct compiler. We can compile now:
And we should have the broker executable among others.
Let’s make sure that it is ok:
pcortex@dune:~/01.Develop/org.eclipse.mosquitto.rsmb/rsmb/src$ file broker
broker: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, stripped
If the output is this:
broker: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=815abb3a1aad7f430c6e825670601c4991b45bd5, stripped
The wrong compiler was called.
Copy the following files to your synology station: broker and Messages.126.96.36.199. From your workstation:
scp broker root@diskstation:/usr/local/bin
scp Messages.188.8.131.52 root@diskstation:/usr/local/bin
Access through ssh the Synology terminal, and make sure that broker is executable and do a test run:
chmod +x broker
20150104 190523.162 CWNAN9999I Really Small Message Broker
20150104 190523.162 CWNAN9998I Part of Project Mosquitto in Eclipse
20150104 190523.163 CWNAN0053I Version 184.108.40.206, Jan 2 2015 20:13:39
20150104 190523.163 CWNAN0054I Features included: bridge
20150104 190523.163 CWNAN9993I Authors: Ian Craggs (firstname.lastname@example.org), Nicholas O'Leary
20150104 190523.163 CWNAN0014I MQTT protocol starting, listening on port 1883
And success! We can now test with MQTT-Spy (https://code.google.com/p/mqtt-spy/), Android Client, or Eclipse Paho tools.
Configuration and start and stopping:
For configuring the RSMB, we really should really read the documentation… 🙂 that is provided…
A simple configuration file should be located at /usr/local/etc and named rsmb.conf with the following basic contents:
# sample configuration on port 1883 with retained persistence in /tmp
And at the /usr/local/etc/rc.d create a file named S99rsmb.sh with the following content:
case $1 in
nohup /usr/local/bin/broker /usr/local/etc/rsmb.conf >> /var/log/rsmb.log&
/usr/bin/logger -p1 -t "rsmb: INFO " " Service started."
/usr/bin/logger -p1 -t "rsmb: INFO " " Service stopped."
Save and chmod +x S99rsmb.sh
Now the broker should start and stop automatically.
To use the broker from the Internet the port 1883/TCP should be open/forward at your router/firewall, and you should add authentication to the MQTT broker.