Building and programming a sample application

Building on the command line

Complete the following steps to build ZCAN IOT SDK projects on the command line after completing the command-line build setup.

  1. Open a terminal window.

    If you have installed the ZCAN IOT SDK using the gs_app_tcm, click the down arrow next to the version you installed and select Open bash.

  2. Go to the specific sample or application directory. For example, to build the Hello World sample, run the following command to navigate to the sample directory:

    cd ZCAN-sdk/samples/hello_world
    
  3. Build the sample or application using the west command. The build target is specified by the parameter build_target in the west command as follows:

    west build -b build_target

    Note

    To build from a directory other than the application directory, run the west build command with an additional parameter directory_name, specifying the application directory.

    See gs_programming_board_names for more information on the supported boards and build targets. To reuse an existing build directory for building another application for another board or build target, pass -p=auto to west build.

    If you want to configure your application, run the following west command:

    west build -t menuconfig
    

    See Configuring your application for additional information about configuring an application.

    After running the west build command, the build files can be found in build/zephyr. For more information on the contents of the build directory, see Build Directory Contents.

  4. Connect the development kit to your PC using a USB cable.

  5. Power on the development kit.

  6. Program the sample or application to the kit using the following command:

    west flash
    

    This command clears only the flash memory pages that are overwritten with the new application. If the application depends on other flash areas (for example, if it uses the Settings partition), erase the full kit before programming to ensure that these areas are updated with the new content. If you do not fully erase the kit, the old data in these areas will be retained.

    To fully erase the kit before programming the new application, use the following command:

    west flash --erase
    

    The west flash command automatically resets the kit and starts the application.

For more information on building and programming using the command line, see the Zephyr documentation on Building, Flashing and Debugging.