In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to achieve HelloWorld in LiteOS". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. Create a HelloWorld project
Open IoT Studio and click create IoT Studio Project:
To fill in the project settings, you need to pay attention to the following points:
There can be no Chinese characters or spaces in the project name and directory
SDK version Select the latest IoT_LINK version, current 1.0.0
Hardware platform selection STM32L431RC_BearPi
Select hello_world_demo for the example project
After the creation is completed, enter the IoT Studio interface as shown below:
2. IoT_LINK SDK
When creating a project, the SDK version is selected, as shown in the figure:
Huawei IoT link SDK
Huawei IoT link SDK (hereinafter referred to as SDK) is a lightweight interconnection middleware deployed on terminal devices with wide area network capability and stringent restrictions on power consumption / storage / computing resources. You only need to call the API interface to achieve rapid access to the Internet of things platform, data reporting and command receiving and other functions.
SDK provides end-cloud collaboration capability, integrates a full set of IoT interconnection and interworking protocol stacks of MQTT, LwM2M, CoAP, mbedtls and LwIP, and provides open API on the basis of these protocol stacks. Users only need to pay attention to their own applications, without paying attention to the internal implementation details of the protocol, and directly use API encapsulated by SDK. The secure and reliable connection to Huawei OceanConnect cloud platform can be easily and quickly realized through four steps: connection, data reporting, command receiving and disconnection. With SDK, users can greatly reduce the development cycle, focus on their own business development, and quickly build their own products.
The relationship between SDK and LiteOS
The underlying layer of Huawei IoT link SDK has an OS adaptation layer, which can adapt to Linux, MacOS, LiteOS, and other third-party OS (you need to adapt it yourself). The OS adapted to the SDK underlying layer used in this tutorial is LiteOS.
The relationship between SDK and IoT Studio
For the convenience of user development, the code of SDK will not appear in IoT Studio. There is only the user's target project code (target) in IoT Studio, but the code of SDK will be compiled into the project at compile time.
So, where is the code for SDK? How do I view the code of SDK?
The code of SDK is in C:\ Users\ Administrator\ .icode\ sdk\ IoT_LINK_1.0.0 directory, where Administrator is my user name, in practice it will be your current user name, SDK code is more, so it is recommended to use VS Code to directly open the IoT_LINK_1.0.0 folder to check.
How to update SDK
SDK updates constantly. You can enter "File-> preferences" in the IoT Studio project, and select "SDK Management". If a new version is detected, the status will become "updatable". The update method is: select the SDK, and then click "install / Update":
Every time you open a project, check to see if the SDK is updated. The most recent update is 2019-11-28 (today). In addition, after updating the SDK, you need to recreate the project to refresh the configuration.
3. HelloWorld Demo
The sample code for HelloWorld is in the Demos/hello_world_demo/hello_world_demo.c file. In the sample code, a task named helloworld with priority 2 is created. The task prints data on the serial port every 4s, as follows:
# include static int app_hello_world_entry () {while (1) {printf ("Hello World! This is LiteOS!\ r\ n"); osal_task_sleep (4x1000);}} int standard_app_demo_main () {osal_task_create ("helloworld", app_hello_world_entry,NULL,0x400,NULL,2); return 0;} 4. Compile
IoT Studio compiles using the arm-none-eabi-gcc toolchain, builds compilations using make tools, and uses * .mk files to leave the user with some options in makefile.
Set compiler and make tool paths
Remember the development tool path you looked at when you installed IoT Studio in the previous article? Yes, next we need to configure these two paths:
Arm-none-eabi- compiler path
The path to the compiler is C:\ Users\ Administrator\ openSourceTools\ GNU Tools Arm Embedded\ 7 2018-q2-update\ bin, where Administrator is my user name, just change it to yours.
Enter "Project-> Project configuration" in IoT Studio, select "Compiler", and configure the compiler path:
Make Builder path
The path to the make builder is C:\ Users\ Administrator\ openSourceTools\ GNU MCU Eclipse\ Build Tools\ 2.11-20180428-1604\ bin, where Administrator is my user name, just change it to yours.
Enter "Project-> Project configuration" in IoT Studio, select "Compiler", and configure the make path:
Set the makefile of the project
The makefile of the entire project is in the GCC directory. Before compiling, be sure to specify the makefile in IoT Studio:
Compilation engineering
After you specify makefile, click the compile button to compile the entire project, and all the compilation output information will be printed on the console:
At present, ignore the warnings in SDK, just click compile again.
5. Burning recording
IoT Studio supports the use of Jlink or ST-Link downloader, and the ST-Link downloader on the development board of Cubs is STLink-v2.1 version, so use OpenOCD to download through ST-Link. The download settings are as follows:
St-link-v2.cfg and st-link-v2-1.cfg are different in the OpenOCD parameter!
After the settings are completed, connect the Cubs development board to PC, click the download button, and the console will print the download information:
After the burning is completed, the development board automatically resets and the program starts to run, and you can see that the LCD screen displays the following words:
Welcome to IoTCluB!BearPi IoT Develop BoardPowerd by Huawei LiteOS!Please wait for system init!6. View the serial port output result
IoT Studio integrates the serial port terminal, which can easily view the serial port output information.
Set the serial port before using it:
Connect the bear development board and make sure that the serial port selector switch in the upper right corner of the bear development board is dialed to the AT-MCU end.
Then click the View button to select the serial terminal:
The serial port terminal interface will be displayed in the console. Click the open serial port button, and you can see the output of the Demo program in the serial port as shown in the figure:
This is the end of the content of "how to achieve HelloWorld in LiteOS". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.