Back to All
Project

QCA4020 Onboard without Cloud Mode


Skill LevelArea of FocusOperating SystemPlatform/Hardware
BeginnerBluetooth, IoT, Education, Embedded, Smart HomeRTOSQCA 402x WiFi/BLE/ZigBee

This project is intended to help you get familiar with the QCA4020 System-On-Chip (SoC) Product Development kit. The QCA4020 IoT solution offers Wi-Fi, Bluetooth low energy (BLE), and 802.15.4 capable radios in a single-chip package.

The project uses the “Onboard” sample demo included in the SDK with the Eclipse IDE to get started.

As part of this project, you will set up the development environment, import, build and flash a project on the QCA402x development board using the Eclipse IDE. You will then load a sample application on your Android smartphone to read the sensor values that are sent from the development board. The application will:

  1. Display the list of devices you’ve configured under the Zigbee network
  2. Allow you to select the Zigbee-connected QCA402x device, read the sensor values, and control the light intensity via BLE connection

Objective

The objective of this project is to get familiar with the QCA4020 development kit. The onboard demo application included in the SDK provides a mechanism to demonstrate end-to-end communication between the QCA402x development boards and the mobile app through cloud network or wireless technology. The desired outcome for this project is to use the onboard demo application in “Without Cloud” mode to directly read/write sensor data from the development kit using the BLE and Zigbee connections.

Onboard

Materials Required / Parts List / Tools

Additional Resources

Build / Assembly Instructions

In the Box

Qualcomm-image

 

The contents of the QCA4020 Development kit, as seen above, include:

  • QCA4020 development board
  • USB to Micro USB cables
  • Power supply
  • Jumpers
  • Setup guide

 

For the time being, you can set the kit aside while you install the software components and set up the development environment on your computer. During the setup process, you will only briefly use the kit while installing the FTDI drivers for JTAG.

Setup the development environment

  1. Install Python version 2.7.X
    Some of the support scripts are Python-based so be sure to install Python 2.7.X because the support scripts do not support Python 3. After installation, add the path to python.
    Example: If python.exe is in the folder
C:\CRMApps\Apps\Python276-64
set path as follows:
%PATH%=%PATH%:C:\CRMApps\Apps\Python276-64
  • Install Eclipse IDE for C/C++: GUI based integrated development environment
    Supported Version: Oxygen version - Release 4.7.2
  • Install Java: Eclipse IDE has dependency on Java, JDK 8 or higher.
    After installation, add path to Java.
    Example: If Java.exe is in
  • C:\ProgramData\Oracle\Java\javapath
    set path as follows:
    %PATH%=%PATH%: C:\Program Files\Java\jdk1.8.0_161\bin
  • Install OpenOCD version 0.10.0 [2017-06-09] which is available here.
    OpenOCD plugin is required to establish the connection between Eclipse IDE and onboard FTDI JTAG debugger. After installation, add the path to OpenOCD.
    Example: If openocd.exe is in
  • C:\Program Files\OpenOCD-20170609\bin
    set path as follows:
    set %PATH%=%PATH%:C:\Program Files\OpenOCD-20170609\bin
  • Download GNU Arm Embedded toolchain version 6.x (gcc-arm-none-eabi-6-2017-q2-update).
    Install by running the ".exe" file and make sure you select the option to "Add path to environment variables" during the final step.
  • Setup OpenOCD plugin usage with Eclipse
    1. Install GNU MCU plugin for Eclipse
  • Go to Help > Install new software
    in Eclipse IDE
    Adding
  • In the Available Software window, click "Add" and enter the Name and Location of the repository.
    Location: "http://gnu-mcu-eclipse.netlify.com/v4-neonupdates" Enter details and click "OK" as seen below.
  • Adding
  • Select "GNU ARM & RISC-V C/C++ Cross Development Tools" and click "Next" as seen below.
  • Adding
  • You will see the list of Items to be installed as seen below.
    click "Next".
  • Adding
  • Follow the on-screen instructions and select "Finish" to complete the installation.
  • Restart the Eclipse IDE
  • Set path to openOCD
    Restart the Eclipse IDE and under
  • Window > preferences
    set path to openOCD as seen below.
    Setting
  • Set the Debug Config
    1. Go to
  • Run >Debug Configurations > GDB OpenOCD Debugging
    Set the Application and OpenOCD options as show in the images below.
  • Select Quartz.elf as the C/C++ application.
    If you have already built the image, select Disable auto build. If image is not built, select Use workspace settings.
  • Debug
  • In the Debugger window, provide the openocd executable path with config option,
  • -f ${project_loc}\build\gcc\qca402x_openocd.cfg
  • Provide the arm-none-eabi-dgb executable path for the GDB client as seen below.
  • Debug
  • Download "QCA4020 OEM SDK+CDB" which is available under the Qualcomm Developer Network software section here.
    The SDK contains sample demo applications with source code to demonstrate different features and technologies that QCA402x supports. Demos are in the following folder:
  • target\quart\demo\<name_of_demo>
  • Install the QCA plugin jar file available at
  • <SDK_source>/target/quartz/demo/EclipseSupportFiles
    1. Copy the jar file (QCA402x_plugin.jar) to the "dropin" folder under the Eclipse IDE installed folder.
    2. Restart the Eclipse IDE if running. To restart Eclipse, click on the File menu of Eclipse IDE and select the Restart menu item after the plug-in is installed.
  • Install FTDI driver for JTAG
    1. Download the zadig application from http://zadig.akeo.ie/.
    2. Connect the J85 connector on the development board to the host PC using the included Micro-USB cable.
    3. Once the QCA4020 Development board is connected to the host PC, the Device Manager shows two COM ports. The lower port number is for JTAG and the upper port number is for serial connection.
    4. Run zadig.exe file and go to
  • Options > List All
    devices and select the device in the drop down. Dual RS232-HS (interface 0) represents lower port number and dual RS232-HS (interface 1) represents higher port number. The following example shows Select Dual RS232-HS (interface 0) to install FTDI on the WinUSB driver for JTAG interface.
    Installing
    After installing the FTDI driver, the Device Manager will look as seen below.
    Device
  • Download the JSNM library.
    You will need this library to parse the sensor data received from the router/coordinator.
    1. Download jsmn library from https://github.com/zserge/jsmn and extract it.
    2. Create
  • thirdparty/jsmn/src
    folder under the target folder.
  • Create
  • thirdparty/jsmn/include
    folder under target folder
  • Copy the "jsmn.c" file from extracted "jsmn-master" to the
  • thirdparty/jsmn/src
    folder.
  • Copy the "jsmn.h" file from extracted "jsmn-master" to the
  • thirdparty/jsmn/include
    folder

    Make sure that the paths are set correctly under the environment variables.
    They should be set as seen below.

    System

    Congratulations, you have now successfully set up the development environment for the QCA4020 development kit. The next section shows you how to import the sample "Onboard_demo" application.

    Import sample "Onboard_demo" application

    1. Install Eclipse project files for sample demo applications.
      To install there is
    eclipseSupport.bat
    for Windows and
    eclipseSupport.sh
    for Linux in
    <SDK_source>/target
  • Open a terminal window and navigate to
  • <SDK_source>/target
  • Run the
  • sh eclipseSupport.sh
    or
    eclipseSupport.bat
    command.
    After executing the script, the Eclipse project files .cproject, .project and .settings folder are updated in the respective folders of the demo applications.
  • Open the Eclipse application.
  • Go to
  • File > Open Projects
    from File System and set import source for the demo application.
    Example: <path>/target/quartz/demo/Onboard_demo

    You should be able to see the import source as an Eclipse project.
  • Click Finish.

  • Next, build the application.

    Build the Application

    1. Go to:
    Project properties > Configure build setting
  • Right click on the project name in project explorer and go to "Properties".
  • Verify the build command and the build directory in the Builder settings tab.
  • Go to C/C++ build and set the build command to "build.bat", and the build directory to "path to source".

  • Hello

    1. Click "Apply and Close".
    2. Build the application and you will see the following messages in Console Window
    Eclipse

    Flash the Application on the QCA4020 development board using JTAG and Eclipse.

    Alright, time to start playing with the Developer Kit. Since this project/demo involves two QCA402x development boards, flash both the boards by following the below steps.

    1. Setup the QCA4020 development board as described in Appendix A, "CDB2x board setup" in QCA402x-CDB2x development kit user’s guide.
    2. Put the jumper on J31 1&2 on the QCA4020 development board.
      Tip: There is a "Dot" next to each header that indicates the position of Pin Number 1.
      After the flashing through JTAG is done, remove the jumper.
      Jumpers on the developer board should be as seen below.
      1. Jumper on J31 (Pins 1 and 2),
        Jumper on J37 (Pins 2 and 3),
        Cross connect pins 2 and 3 of J38 and J39
    Jumpers
  • Jumpers on J30 and J32
  • Jumpers
  • Jumpers on J57 and J36
  • Jumpers
  • Open Eclipse IDE and navigate to:
  • Run > External Tools > External Tools Configuration
  • Click on the program, create a new launch configuration and update the paths as shown below in the Main tab.
  • Provide the path for "flash_openocd.bat" or "flash_openocd.sh" in the location box.
  • Run
  • To flash the program, click
  • Run > External Tools > OpenOCD JTAG Flashing
    The flashing logs can be seen on the Eclipse console.
    You will see the following lines at the end of the log:
    [2018-07-17 16:51:24,434] INFO: Script finished processing generated_fwd_table.xml File:flash_through_gdb.py:699 Function:main
     Flash Operation Completed Successfully...
     SUCCESS: The process "openocd.exe" with PID 17776 has been terminated.

    The application was flashed successfully on the development board.

    Installing the mobile application

    There are two mobile applications available at the following location within the downloaded SDK:

    /target/mobileapp/android

    - QCAOnboard and Sensor application.

    Copy the application apk files from this folder to your smartphone with Android device version 5.0 or higher and install them.

    The goal of these mobile applications is to onboard the QCA402x development boards to the user network as follows:

    1. Application scans for available devices; you should provide the credentials required to onboard the kit.
    2. Application establishes connection to the board via Wi-Fi or BLE, based on the onboarding mode for which the device is configured.

     

    Usage Instructions

    Run the application on the development board

    You can use the autoboot mode to run the application on the development board. The Autoboot mode refers to the mode where the system boots up on a power cycle and no JTAG connectivity is required. Follow the below steps to run the application in Autoboot mode on both the development boards.

    1. Remove the jumper on J31.
      This was connected to flash the image on the board.
    2. Power cycle the system.
    3. The device starts in BLE peripheral mode and starts advertising.

     

    Launch the Smartphone App

    1. This first step is not required if you are onboarding for the first time.
      The application has the provision to save list of previously onboarded ZigBee coordinators, so if you have used the application before, it is required to delete the previously onboarded device.
      1. Click on the "Settings" icon on top right corner of qca_onboarding mobile application. By selecting the Coordinator List, you will find the list of saved Zigbee Coordinator devices.
      2. Click on the "Delete" icon and choose "YES" to remove the device from saved list of Zigbee Coordinators.
    Delete
  • On your smartphone, launch the "QCA OnBoarding" application that was installed during the setup.
  • The flow of events and data exchange between the Mobile application and the QCA402x development board is as seen below.
  • Flow
  • The mobile app uses BLE scan to connect to the development board with default password "123456".
  • Once the development board receives the BLE passkey and proceeds onboarding from the mobile app, it validates the configuration and saves it to the filesystem.
  • Next step is to onboard the Zigbee coordinator on QCA4020 development board. On successful BLE connection of mobile app and QCA4020 device, the mobile app reads the Zigbee service for onboard status through BLE connection. If the status is success and Zigbee mode is coordinator, the mobile app generates link key and sends the credentials packet to the QCA4020 device running as Zigbee coordinator.
  • Once the QCA4020 device gets the operating mode and link key, the onboarding demo extracts the onboard details, validates the configuration, stores to the filesystem and sends the ACK to the mobile app. The QCA4020 device starts Zigbee service as a coordinator/router/end device based on the user-configured Zigbee operating mode.
  • Onboarding
  • Once the mobile app receives the Zigbee onboard status notification it displays the onboard status screen and status.
  • Onboard Zigbee end device on the second QCA402x development board via BLE connection. This QCA402x device runs as the Zigbee end device connecting to the Zigbee coordinator QCA4020 device.
  • On the mobile app main screen, select and onboard the device using the default password "123456" via BLE connection.
  • The mobile app checks for the QCA4020 onboard status over a BLE connection and displays the Zigbee connection status. You will need to select the relevant Coordinator device name which lets the end device join the zigbee network.
  • If the QCA4020 end device is onboarded successfully, the mobile app displays successful onboarding device status; else it notifies with failure status and disconnects from the device.
  • Once both devices are onboarded, the next step is to get the sensor data through Zigbee and BLE. You should be able to read sensor data and control sensors on the Zigbee end device through Zigbee coordinator.
    On the mobile app screen, connect to the coordinator device QCA4020_XXXXXX, and choose "Get Sensor List [Zigbee+BLE]" button via BLE using default password "123456".
  • Request
  • The mobile app screen displays the list of devices under the Zigbee network. You can select the Zigbee-connected QCA402x device, read the sensor values, and control the light intensity via BLE connection.
  • Request

    Congratulations! You set up the development environment, imported, built and flashed a project on the QCA402x development board using the Eclipse IDE. On your smartphone, you can now read the sensor values that are sent from the development board.

    Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries ("Qualcomm"). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.

    Project Authors
    Staff Engineer, Qualcomm Technologies, Inc.

    Sign up for the Developer Newsletter.

    Get software and hardware tool resources to help optimize your development delivered to your inbox weekly.

    Qualcomm relentlessly innovates to deliver intelligent computing everywhere, helping the world tackle some of its most important challenges. Our leading-edge AI, high performance, low-power computing, and unrivaled connectivity deliver proven solutions that transform major industries. At Qualcomm, we are engineering human progress.

    Stay connected

    Get the latest Qualcomm and industry information delivered to your inbox.

    Subscribe
    Manage your subscription

    © Qualcomm Technologies, Inc. and/or its affiliated companies.

    Snapdragon and Qualcomm branded products are products of Qualcomm Technologies, Inc. and/or its subsidiaries. Qualcomm patented technologies are licensed by Qualcomm Incorporated.

    Note: Certain services and materials may require you to accept additional terms and conditions before accessing or using those items.

    References to "Qualcomm" may mean Qualcomm Incorporated, or subsidiaries or business units within the Qualcomm corporate structure, as applicable.

    Qualcomm Incorporated includes our licensing business, QTL, and the vast majority of our patent portfolio. Qualcomm Technologies, Inc., a subsidiary of Qualcomm Incorporated, operates, along with its subsidiaries, substantially all of our engineering, research and development functions, and substantially all of our products and services businesses, including our QCT semiconductor business.

    Materials that are as of a specific date, including but not limited to press releases, presentations, blog posts and webcasts, may have been superseded by subsequent events or disclosures.

    Nothing in these materials is an offer to sell or license any of the services or materials referenced herein.