laitimes

How to port MQTT protocol to the Buildroot of the Fling embedded T113-i development board?

author:Fling Embedded

The Fling embedded OK113i-S development board has received a lot of attention since it was launched for a period of time, and has also become a high-quality choice for many customers' project selection. In the actual project development, engineers may need to port some tools or protocols in the file system, so how to do the migration operation?

We can port new features to the Buildroot of the OK113i-S board by adding package configurations. In this article, we will take the MQTT protocol ported in Buildroot as an example.

How to port MQTT protocol to the Buildroot of the Fling embedded T113-i development board?

Part 1: Introduction to configuration files

First, let's take a look at the configuration files involved in porting functionality in Buildroot.

Check the existing configuration file in the source code of the Fling embedded OK113i-S development board, and you can see that 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 tells Buildroot which package is required to participate in the compilation by using BR2_PACKAGE_** as a switch, which is assigned in the OK113I_linux_defconfig configuration file under buildroot/buildroot-201902/configs/, similar to the Kconfig file in the kernel.

For example:

package/Config.in

source "package/mosquitto/Config.in";

package/mosquitto/Config.in中写了

BR2_PACKAGE_MOSQUITTO information.

How to port MQTT protocol to the Buildroot of the Fling embedded T113-i development board?

② demo.mk

This file declares some package information, such as: specifying the version of the package, the download link of the package source code, the storage path, the compilation rules, the toolchain, etc. During compilation, the source code package will be downloaded to the specified path according to the download address and version in the file, and the file will be compiled and copied, which is equivalent to the Makefile file.

For example: mosquitto.mk

At the beginning of the file, the package version and download address are written, and we can find the corresponding version of the package by accessing this address in the browser. At compile time, 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.

(3) 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 is for systemd, systemd will start the demo service according to this file after booting up, and the source path of this file will be specified in the demo.mk. The service is not currently used on the OK113i-S board, so you can leave it alone.

⑤ S50demo

This file class is demo.service, which is the boot service type currently used by the OK113i-S development board.

Config.in and demo.mk in the above five files are required, and other files can be configured as needed. For specific configurations, refer to existing documents or write them according to 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 the file you ported does not have a configuration file, you can refer to the existing configuration file to write one.

Part 2: Execution

We need to do it in buildroot/buildroot-201902

make OK113I_linux_defconfig

Then run the make menuconfig ARCH=arm command

Configure the configuration on the graphical configuration page (if an error is reported, install the sudo apt-get update and sudo apt-get install ncurses commands).

After entering the graphical configuration interface, enter "/" to search for the function to be configured, search for the information seen by Mosquitto as shown in the figure, press the prompt to select "1" to enter the target option, press "Space" to select and save and exit.

How to port MQTT protocol to the Buildroot of the Fling embedded T113-i development board?

After the configuration is complete, run ./build.sh in the current directory to compile the file system, and check whether the corresponding file already exists in the file system after the compilation is complete. (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 at the download address and put it in the source code package storage path.) )

Part 3

Test and verify MQTT

Modify the /etc/mosquitto/mosquitto.conf file of the OK113i-S development board and add a line of user root after #user mosquitto to restart the service or development board. You can also kill the process and re-execute:

/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Then test it –

Subscribe to a test topic:

mosquitto_sub -t test &

Publish the test topic:

mosquitto_pub -t test -m "hello world"

If you can see the word hello world returned, it means that the transplant has been successful.

The above is the method of porting the MQTT protocol in the Buildroot of the Fling embedded OK113i-S development board for the reference of engineers in front of the screen.

Read on