.. _gs_programming: Building and programming a sample application ############################################# .. contents:: :local: :depth: 2 .. _gs_programming_cmd: Building on the command line **************************** Complete the following steps to build |ZSDK| projects on the command line after completing the :ref:`command-line build setup `. 1. Open a terminal window. If you have installed the |ZSDK| using the :ref:`gs_app_tcm`, click the down arrow next to the version you installed and select :guilabel:`Open bash`. #. Go to the specific sample or application directory. For example, to build the :ref:`hello_world` sample, run the following command to navigate to the sample directory: .. code-block:: console cd ZCAN-sdk/samples/hello_world #. 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: .. parsed-literal:: :class: highlight 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 :ref:`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: .. code-block:: console west build -t menuconfig See :ref:`configure_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 :ref:`zephyr:build-directory-contents`. #. Connect the development kit to your PC using a USB cable. #. Power on the development kit. #. Program the sample or application to the kit using the following command: .. code-block:: console 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 :ref:`zephyr:settings_api` 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: .. code-block:: console 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 :ref:`zephyr:west-build-flash-debug`.