【IoT Development Notes】Gizwits Cloud Device Transplantation RT-Thread
[Copy link]
This post was last edited by Maoqiu Dada on 2022-4-19 18:33
Development Environment:
Keil version: V5.30
RT-Thread version: 3.1.5
Development board MCU: STM32F103
The application code generated by the Gizwits Cloud platform is a bare metal version. In actual application, there are usually multiple functions. At this time, a real-time system is needed, such as FreeRTOS, AzureRTOS ThreadX, RT-Thread, etc. The author recommends RT-thread.
RT-Thread is a minimalist hard real-time kernel. It is developed in C language, adopts object-oriented programming thinking, has a good code style, and is a tailorable, preemptive real-time multi-tasking RTOS. It occupies very little memory resources, and its functions include task processing, software timer, semaphore, mailbox and real-time scheduling, etc. It is suitable for 32-bit ARM entry-level MCUs that are widely used in home appliances, consumer electronics, medical equipment, industrial control and other fields.
RT-Thread Nano is integrated into Keil MDK and CubeMX as a software package. You can download the Nano software package directly in the software to get the source code. For details about RT-Thread Nano porting, please refer to the author's article:
3.1 Nano Pack Installation
Open CubeMX, enter the Manage embeddedsoftware packages interface from the menu bar help, click the From Url button to enter the User DefinedPacks Manager interface, then click new, fill in the above URL, and then click check, as shown below:
After the check passes, click OK to return to the User Defined Packs Manager interface, click OK again, CubeMX automatically connects to the server and obtains the package description file.
Go back to the Manage embedded software packages interface, and you will find the RT-Thread Nano 3.1.5 software package. Select the software package and click InstallNow. After installation, the Licensing Agreement pops up. Agree to the agreement, then click Finish and wait for the installation to complete. After successful installation, the small blue box in front of the version turns into a filled yellow-green color, as shown in the following figure:
At this point, the RT-Thread Nano software package is installed and exit the Manage embeddedsoftware packages interface.
3.2 Add RT-Thread Nano to the project
Open the basic project, click SelectSoftwares, select the Select Components interface, select RealThread in Pack Vendor, and then select the RT-Thread component according to your needs (here only Nano is transplanted, so just select the kernel), and then click the OK button, as shown in the following figure:
After selecting the component, configure the component parameters. In the engineering interface Pinout&Configuration, enter the selected component parameter configuration area and configure according to the figure below.
Since the HardFault_Handler() and SysTick_Handler() interrupt service routines are re-implemented in RT-Thread's board.c and OS Tick is implemented, it is also necessary to delete the HardFault_Handler() and SysTick_Handler() that have been implemented in the project to avoid duplicate definitions during compilation. If the project is compiled at this time and no duplicate function definition errors occur, no modification is required.
Finally, save and generate the project.
After successful compilation, download it to the MCU.
For the creation and use of threads, please refer to the author's article:
The final effect will not be demonstrated here, as it is the same as in the previous chapter. At this point, the Gizwits Cloud device side is basically ready for use, and you can use the knowledge you have learned to develop some projects later.
|