English
English
简体中文
Contact Us
Register
Log In
layoutIndex

OpenCPU SDK of LZ201 Module

Last Updated on : 2022-05-09 01:34:42download

OpenCPU is the open CPU of a module. You can develop and compile programs in the development environment of the OpenCPU SDK, and flash the program as the firmware to the CPU of the module by using the flashing tool.

OpenCPU SDK of LZ201 Module

This topic also applies to the OpenCPU SDK of the LZ211 module.

Build a development environment

This section describes how to install the operating system on which the OpenCPU SDK depends.

Get the Ubuntu image

  1. Download the Ubuntu operating system image file in the Ubuntu Downloads area.

  2. Find and download the ubuntu-16.04.7-desktop-amd64.iso image file.

    Note: Ubuntu16 must be selected for download, other versions may be missing some system library files.

Install Ubuntu

You can install the Ubuntu image file by using the following methods:

  • Method 1: Use the UltraISO.exe tool to make the .iso file into a bootable USB flash drive, and install it on the computer.
  • Method 2 (frequently used): In the Windows operating system, use a virtual machine such as VMware to install the image file.

To install the image by using Method 2, perform the following steps:.

  1. Download and install VMware Workstation Player.

    OpenCPU SDK of LZ201 Module

  2. Open the software VMware Workstation Player and choose to create a new virtual machine.

    OpenCPU SDK of LZ201 Module
  3. Select the downloaded .iso file.

    OpenCPU SDK of LZ201 Module
  4. Enter the required user information in the dialog box and click Next to continue with following steps. Keep the default settings until the Specify Disk Capacity step.

    OpenCPU SDK of LZ201 Module
  5. In the Specify Disk Capacity step, if the disk space of the computer is sufficient, we recommend that you specify a disk capacity as large as possible. Then, define the hardware resources such as the memory, processor, and network adapter.

    OpenCPU SDK of LZ201 Module
  6. Click Finish. Now, the virtual machine is created and started.

    OpenCPU SDK of LZ201 Module
  7. Wait for the computer to automatically install Ubuntu.

    OpenCPU SDK of LZ201 Module
  8. After Ubuntu is installed, enter the system and open the Linux terminal.

    OpenCPU SDK of LZ201 Module

System configuration and update

  1. Configure the virtual machine network to support the bridged or NAT mode. This way, the virtual machine can be connected to the Internet. For more information, see specific configuration tutorials

  2. After the virtual machine is networked, configure the Samba sharing environment. For more information, see related tutorials on the specific configuration methods.

  3. Execute the following command to install the development environment dependent software:

    sudo apt install build-essential python3 python3-tk qtbase5-dev sudo apt install libc6:i386 libstdc++6:i386 zlib1g:i386

Get the OpenCPU firmware and SDK

Before you use the LZ201 module to develop embedded applications, create a product that uses the LZ201 module on the Tuya IoT Platform and complete the hardware development. During the development, the following tools are required:

  • OpenCPU basic firmware
  • OpenCPU SDK
  • Flashing and debugging tools

Build an OpenCPU environment

To build an OpenCPU environment, perform the following steps:

  1. In the Ubuntu environment, extract the downloaded OpenCPU SDK.

    OpenCPU SDK of LZ201 Module

    The OpenCPU development environment is ready. The following directories are included:

    Directory Description
    apps Application code
    cmake Compilation script
    components Header files and libraries of OpenCPU SDK
    ldscripts Link script
    prebuilts Cross-compilation toolchain
    scripts Project script
    tools Firmware creation tool
    build.sh One-click compilation script of the project
  2. Execute build.sh, follow the instruction to select the app to be compiled and start automatic compilation.

    OpenCPU SDK of LZ201 Module

  3. After the compilation, the firmware is generated in the apps/hello/output/0.0.1 directory.

    OpenCPU SDK of LZ201 Module

    The following firmware is used in flashing.

    • hello_0.0.1.pac: your application firmware. Flash this firmware to the module and build your application.
    • hello_0.0.1.img: the firmware to update your application. Upload the firmware to the Tuya IoT Platform, and update the program via OTA.
    • appimg_flash_delete.pac: the firmware to erase your application. This firmware can be used to erase your application in the flash memory of the module.
  4. Extract the LZ201-tools.rar toolkit downloaded from the Tuya IoT Platform to get the flashing and debugging tools.

    OpenCPU SDK of LZ201 Module

    Directory Description
    cooltools Debugging and log viewing tool
    FACTORYDOWNLOAD Manufacturing flashing tool of the production line
    fota_creator FOTA update package creation tool
    gdb GDB debugging tool
    RESEARCHDOWNLOAD R&D flashing tool

Develop your app

This section describes how to build an application development project in the SDK, and complete code development, compilation, flashing, and debugging. TuyaOS APIs are integrated in the SDK. They can be used to develop IoT applications. For more information, see OpenCPU SDK Demo of LZ201 Module.

Build a project

Follow the demo project directory structure in the SDK and build your project directories.

OpenCPU SDK of LZ201 Module

user_app is the project name that can be customized. CMakeLists.txt is the project compilation script. You can copy the compilation script of the demo project and modify the script based on your needs. The src directory stores the source file and the include directory stores the header file.

Develop the project

  1. Add the application source file and header file to the project to complete code development.

    OpenCPU SDK of LZ201 Module

  2. Modify CMakeList.txt and add the source file to the compilation script.

    OpenCPU SDK of LZ201 Module

Compile the project

  1. Execute ./build.sh, select the created project, and then start compiling.

    OpenCPU SDK of LZ201 Module

    Note: During development, the flash space occupied by the application cannot exceed 192 KB, and the RAM space cannot exceed 64 KB.

  2. After the project is compiled, the firmware is generated in the apps/user_app/output/xxx directory.

    OpenCPU SDK of LZ201 Module

    xxx is the version number, which can be customized during compilation. For more information, see the instructions in build.sh.

Flash the firmware

  1. After compilation, flash the firmware to the module by using the RESEARCHDOWNLOAD tool.

    OpenCPU SDK of LZ201 Module

  2. Click Button 1 in the following figure to select the flashing file, and click Button 2 to start flashing.

Debug the module

  1. After the flashing is completed, start the application firmware, connect the module USB to the computer, open the coolwatcher_usb.exe tool, view the log, and then implement online debugging.

    OpenCPU SDK of LZ201 Module

  2. Enter the port number of Unisoc Usb Serial Port 4 in the lastcommport.

    OpenCPU SDK of LZ201 Module
  3. After CoolWatcher is opened, choose Plugins > Activate Tracer to open the log tracer interface, and choose Tracer > Start Tracer to show the log information.

    OpenCPU SDK of LZ201 Module

    Note: The log function might not be enabled by default. You can use the serial debugging assistant to connect to the serial port of Unisoc Usb Serial Port 0. This port supports the following settings: Baud 9600, data bit 8, stop bit 1, no parity, and no flow control. Enter at^tracectrl=0,1,2 to enable the log function.

Flash the authorization information

Flash the authorization information on the Cloud Module Burning Authorization Platform. For more information, see General Wi-Fi SDK Burning and Authorization Instruction.

Firmware OTA update

For more information, see OTA Update Guide of Wi-Fi Common Solution.

This section contains the following topics to help you quickly understand related concepts and how-to guides: