How to Transplant MQTT Protocol in Buildroot of Embedded T113-i Development Board?
Forlinx Embedded OK113i-S development board has gained a lot of attention since it came into the market for some time, and it has also become a high-quality choice for many customers to select projects. In the actual project development, engineers may need to migrate some tools or protocols in the file system, so how to migrate them?
We can port new functions in the Buildroot of the OK113i-S development board by adding the package configuration. This article will show you how to port the MQTT protocol in the Buildroot of the T113-i development board.
Part 1 Configuration File Introduction
First, take a look at the configuration files involved in porting functionality in Buildroot.
View the existing configuration files in the source code of the embedded OK113i-S development board. The following files are included in the path:
buildroot/buildroot-201902/package/mosquitto:
Config.in
mosquitto.mk
mosquitto.hash
mosquitto.service
S50mosquitto
① Config.in
The Config.in file informs Buildroot which package needs to be included in the compilation using BR2_PACKAGE_** as a switch. The switch is assigned in the OK113I_linux_defconfig configuration file located in buildroot/buildroot-201902/configs/, similar to the Kconfig file in the kernel.
For example:
The calling relationship is written in the package/Config.in
source "package/mosquitto/Config.in";
The BR2_PACKAGE_MOSQUITTO information is written in
package/mosquitto/Config.in.
② demo.mk
This file declares some package information, such as the version of the specified package, the package source download link, the storage path, the compilation rules, the toolchain, and so on. When compiling, the source code package will be downloaded to the specified path according to the download address and version in this file, and then compiled and copied, which is equivalent to a Makefile file.
For example: mosquitto.mk
The software package version and download address are written at the beginning of the file, and we can find the corresponding version of the software package by visiting the address in the browser. When compiling, if the file is not in the source code, it will be downloaded automatically.
mosguitto-1.5.8.tar.gz
mosguitto-1.5.8.tar.gz.asc
In addition, other compilation rules are defined in the file, including the file copy path and so on.
③ demo.hash
This file will record the hash check code of the downloaded source code package to prevent errors in the downloaded source code package.
④ demo.service
This file serves systemd. After systemd is started, the demo service will be started according to this file. The source path and installed path of this file will be specified in the demo.mk. The OK113i-S development board does not currently use this service, so it can be left alone.
⑤ S50demo
It is a demo.service, which is the boot service type currently used by the OK113i-S development board.
Among the above 5 kinds of files Config.in and demo.mk is required, and other files can be configured as needed. The specific configuration contents can be written according to the existing documents or the actual situation. Mosquitto already has a written configuration file, which can be used directly. Generally, the configuration file is provided by the maintainer or developer of the project. If there is no configuration file in the file you migrate, you can refer to the existing configuration file to write one.
Part 2 Execution
We need to generate in buildroot/buildroot-201902
make OK113I_linux_defconfig
And then generate in make menuconfig ARCH=arm.
Configure in the graphical configuration interface (if an error is reported during execution, please install the command first: sudo apt-get update and sudo apt-get install ncurses).
After entering the graphic configuration interface, enter "/" to search for the function to be configured. As shown in the figure, search for the information seen by Mosquitto. Select "1" according to the prompt to enter the target option. Press "Space" to save and exit.
After the configuration is complete, execute. /build.sh in the current directory to compile the file system, and then check if there are already corresponding files in the files system.
(Note: If there is no network, the source code package cannot be automatically downloaded during compilation. You need to manually download the source code package from the download address and put it in the source code package storage path.)
Part 3 Test verification of MQTT
Modify the /etc/mosquitto/mosquitto.conf file of the OK113i-S development board, add a line user root after #user mosquitto, and reboot the service or development board. You can also kill the process and re-execute it:
/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
Then test——
Subscribe to the test topic:
mosquitto_sub -t test &
Release the test topic:
mosquitto_pub -t test -m "hello world"
If you can see the word hello world returned, it means that the migration is successful.
Above is the method to port MQTT protocol in Buildroot of Forlinx Embedded OK113i-S development board for engineers in front of the screen.