QuecOpen® Quick Start Guide For FCM242D and FGM842D Series Modules

Introduction

Quectel FCM242D and FGM842D series modules support QuecOpen® solution. QuecOpen® is an embedded development platform based on RTOS system. It is intended to simplify the design and development of IoT applications.

This document is applicable to QuecOpen® solution based on SDK build environment. It is a quick start guide for FCM242D and FGM842D series modules. It outlines the SDK directory structure, compilation environment setup, application development and compilation, firmware flashing, and common compilation errors on Linux.

SDK Directory Structure

The directory structure of different QuecOpen SDK versions released by Quectel may vary slightly, whereas functions remain the same. An example of the QuecOpen SDK directory structure on Windows and Linux operating systems is shown in the following table.

Directory Name Description
ql_application Stores sample files and the user application project code.
ql_build Stores compilation-related script files.
ql_components Stores components, including third-party components and Quectel API components.
ql_kernel Stores chip-related code and code libraries, including support for RTOS (currently only FreeRTOS is supported).
ql_out Stores files output after project compilation, used for flashing, such as .bin and .map files.
ql_tools Stores the toolchain used for compilation.

Project Compilation Environment Setup

gcc-arm-none-eabi, the GCC toolchain of the ARM bare-metal system, is the project compilation toolchain of the module. Linux and Windows operating systems are supported for the compilation. The gcc-arm-none-eabi toolchain, CMake and MinGW (MinGW is only needed for Windows operating system) are integrated in the ql_tools directory of the SDK, and they can be automatically decompressed for use. The recommended Linux distribution is Ubuntu 16.04 or above version, Windows 10 or above version. Additionally, you need to install Python 3 or above version and add it to the system environment variables.

When compiling your project, only the gcc-arm-none-eabi toolchain integrated in the SDK is supported, and the gcc-arm-none-eabi toolchain installed on the Linux operating system is not supported.

If the automatic decompression and installation of the gcc-arm-none-eabi toolchain in the SDK fails, you can manually decompress and install it as follows:

  1. Open the Linux command terminal, execute the following command in ql_tools/toolchain directory to decompress the toolchain (If the toolchain has already been decompressed, skip this step):

    tar -vxf gcc-arm-none-eabi-5_4-2016q3.tar.bz2
    

    Decompress Toolchain

  2. Execute the following command to open the environment variable configuration file:

    sudo vim ~/.bashrc
    

    Open Environment Variable Configuration File

  3. Add the environment variable to the last line of the environment variable configuration file (add the actual file path on your system for the configuration file. The path in the figure below is for reference only):

    export PATH=$PATH:/home/xxx/ql_tools/toolchain/gcc_arm_none_eabi/gcc-arm-none-eabi-5_4-2016q3/bin
    

    Add Environment Variable

  4. Save and close the configuration file, then execute the following command in the Linux terminal window to apply the changes immediately. The environment variable is now set and the project compilation environment is ready:

    source ~/.bashrc
    

    Apply Configuration Changes Immediately

Application Development

Create Application Directory

  1. Create the required user folders (for storing source and header files) in the ql_application directory of QuecOpen SDK. For example, create user_code folder.

    Create user_code Folder

  2. Create user_inc and user_src folders in the user_code folder to store header and source files respectively.

    Create user_inc and user_src Folders

Application Demo Description

QuecOpen SDK provides reference application demos for application development in the ql_application/example directory in the SDK.

The application entry point, ql_app_main(), is in the ql_app_main.c file in the ql_application/ directory of the QuecOpen SDK. The demo programs can be called with ql_app_main() as needed, and you can refer to the following program logic to write your own code.

Example of Calling Demo Program

Add User Application

Create Application Thread

  1. Create and write the user_code.c and user_code.h files, and store them in the user_code/user_src and user_code/user_inc directories respectively. An example of writing the user_code.c file is as follows:

    Example of Writing user_code.c File

    The following definitions apply to the serial numbers in the figure above:

    1. Add the user-defined header files
    2. Initialization configuration
    3. Task processing code
    4. Task creation function
  2. Add ql_user_demo_thread_creat() to the ql_app_main() function to create a user task in the program.

    Create User Task

Add Compilation File

For successful compilation, the source files and header files must be added to the compilation script, otherwise these files will not be found during compilation. Follow these steps:

  1. Enter the ql_application directory, and open the configure.cmake file.

    Open configure.cmake File

  2. Add the following code to configure.cmake file to create a user_srcs list of source files.

    Create user_srcs List of Source Files

  3. Open the CMakeLists.txt file in the root directory of the SDK.

    Open CMakeLists.txt File

  4. Find the line that reads list (APPEND include_files and add the path to the user’s header file. Find the line that reads list (APPEND source_files and add the path to the user’s source file. Refer to the lines marked in red in the image below for guidance.

    Add Paths for Header and Source Files

Application Compilation

This chapter explains application compilation using FCM242D module as an example.

Compilation Instructions

Linux Operating System

Open the Linux command terminal, enter SDK root directory and execute the following command to compile the application:

./build.sh

Compile Application (Linux System)

Upon successful compilation, the following interface will be displayed.

Successful Compilation (Linux System)

Windows Operating System

Open the Windows command terminal, enter SDK root directory and execute the following command to view compilation options:

build

After that, execute the corresponding compilation option to compile the application. For example, execute the following command to compile the program:

build new FCM242D your_firmware_version release

Compile Application (Windows System)

Upon successful compilation, the following interface will be displayed.

Successful Compilation (Windows System)

Compilation Result

The files generated after compilation are stored in the ql_out directory. The contents of the ql_out folder are as follows:

Compilation Result

Files in the ql_out folder include:

  • all_2M.1220.bin: Complete generated program firmware, which is flashed through the module's serial port.
  • bootloader.bin: Bootloader file.
  • fcm242d.elf: Executable object file generated in Linux.
  • fcm242d.map: Program map file.
  • fcm242d_uart_2M.1220.bin: Actual generated firmware (complete firmware except boot).

Clear Files Generated in Previous Compilations

The files generated in previous compilations are automatically cleared before a new compilation begins.

Firmware Flashing

The module supports firmware flashing through the serial port using the BKFIL tool (contact Quectel Technical Support to obtain BKFIL tool and related usage information) as follows:

  1. Open BKFIL tool, then click SelectPort on the main interface and choose the main port to flash the firmware.
  2. Click the Bin Path Icon icon after Bin Path and choose the all_2M.1220.bin file.
  3. Click Download, then press reset button on the module to flash the firmware. After flashing, if "done" is displayed in the Status box, flashing is successful.

BKFIL Interface

Common Compilation Errors on Linux

  1. Error message: "arm-none-eabi-gcc: Command not found"

    This error message indicates that the gcc-arm-none-eabi toolchain is either not added to the environment variable or the toolchain is missing the required dependencies.

    To resolve this issue:

    • Ensure that the gcc-arm-none-eabi toolchain is installed and properly added to the environment variable, see Chapter 3 for detailed steps.

    • If the error message persists even after the toolchain is installed, it indicates that the required dependencies are missing. In this case, execute the following commands to install the missing required dependencies:

      apt install libc6-i386 lsb-core
      apt-get install lib32z1
      apt-get install lib32stdc++6
      apt-get install libstdc++6
      
  2. Error message: "arm-none-eabi-gcc: fatal error: -fuse-linker-plugin, but liblto_plugin.so not found"

    This error message indicates that the liblto_plugin.so file is not found.

    To resolve this issue:

    • Rename the liblto_plugin.so.0.0.0 file to liblto_plugin.so in the toolchain/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/ directory.

Appendix References

Abbreviation Description
API Application Programming Interface
ARM Advanced RISC Machine
GCC GNU Compiler Collection
IoT Internet of Things
RTOS Real-Time Operating System
SDK Software Development Kit