:orphan: .. _microchip-mplab-ipe-flashing: Flashing with Microchip MPLAB IPE ================================= Microchip devices can be programmed (flashed) using the **MPLAB Integrated Programming Environment (IPE)**. MPLAB IPE is a standalone programming tool that supports Microchip debug probes and on-board debuggers. It can be used from the command line via the ``ipecmd`` utility, which integrates with Zephyr's ``west flash`` command through the MPLAB IPE runner. This section describes how to install and configure MPLAB IPE for flashing Zephyr applications onto Microchip target boards. Overview -------- MPLAB IPE provides a production-ready programming interface for Microchip microcontrollers. When used with Zephyr, the ``ipecmd`` command-line tool is invoked by the ``west flash`` command to program the target device with the built firmware image. The flash process uses the Intel HEX file generated by the Zephyr build system: .. code-block:: console build/zephyr/zephyr.hex Supported Debug Tools --------------------- MPLAB IPE supports the following debug/programming tools: - MPLAB PICkitâ„¢ debuggers/programmers - MPLAB SNAP debuggers/programmers - MPLAB ICD debuggers - On-board debuggers (PKoB, PKoB4, EDBG) available on Microchip development boards The exact list of supported tools depends on the installed MPLAB IPE version and the target device family. Requirements ------------ Before flashing with MPLAB IPE, install and configure the following: - `MPLAB X IDE`_ (which includes MPLAB IPE) - Required Microchip device packs (installed automatically or via MPLAB IPE Pack Manager) - A supported Microchip debug probe or on-board debugger - A Zephyr firmware image built for the target board Installing MPLAB IPE -------------------- MPLAB IPE is included as part of the MPLAB X IDE installer. To install: #. Download the `MPLAB X IDE`_ installer from the Microchip Technology website. #. Extract the downloaded package and run the installer. On Linux: .. code-block:: console chmod +x MPLABX-vX.XX-linux-installer.sh sudo ./MPLABX-vX.XX-linux-installer.sh On Windows, run the ``.exe`` installer. #. During installation, ensure that **MPLAB IPE** is selected from the available components. #. After installation, verify that the ``ipecmd`` executable is accessible. On Linux, ``ipecmd`` is typically located at: .. code-block:: console /opt/microchip/mplabx/vX.XX/mplab_platform/bin/ipecmd.sh On Windows: .. code-block:: console C:\Program Files\Microchip\MPLABX\vX.XX\mplab_platform\bin\ipecmd.exe #. Add the directory containing ``ipecmd`` to your system ``PATH``. Verifying the Installation -------------------------- To verify that MPLAB IPE is correctly installed run the following. The help menu will be displayed. On Linux: .. code-block:: console ipecmd.sh -? On Windows: .. code-block:: console ipecmd.exe -? Building a Zephyr Application ------------------------------ Build the Zephyr application before flashing. For example, to build the Blinky sample: .. zephyr-app-commands:: :zephyr-app: samples/basic/blinky :board: :goals: build After a successful build, the HEX file is available at: .. code-block:: console build/zephyr/zephyr.hex Connecting the Board -------------------- Connect the debug/programming interface on the target board to your host machine: #. Connect the board's **debug USB port** to your host machine using a USB cable. #. This connection typically powers the board and provides access to the on-board debugger (e.g., PKoB or PKoB4). #. If using an external debug probe (e.g., PICkit, SNAP, ICD), connect the probe to the board's debug header and connect the probe to your host machine via USB. #. Ensure the board is powered. Some boards require a separate power connection in addition to the debug USB. .. note:: The specific debug USB port and connector name varies by board. Refer to your board's documentation page for the exact connection details. Flashing with ``west flash`` ----------------------------- Once the application is built and the board is connected, flash the device using: .. code-block:: console west flash The Zephyr build system invokes ``ipecmd`` with the appropriate parameters for the target device and connected tool. If you need to specify the runner explicitly: .. code-block:: console west flash -r mplab_ipe Troubleshooting --------------- ``ipecmd`` Is Not Found ~~~~~~~~~~~~~~~~~~~~~~~~ If ``west flash`` reports that ``ipecmd`` is not found: - Verify that MPLAB X IDE / MPLAB IPE is installed. - Ensure that the directory containing ``ipecmd`` is in your system ``PATH``. Tool Is Not Detected ~~~~~~~~~~~~~~~~~~~~ If the programming tool is not detected: - Check the USB connection between the probe/board and the host machine. - Ensure no other application (e.g., MPLAB X IDE, MPLAB IPE GUI) is currently using the debug tool. - Verify that the probe firmware is up to date. Use MPLAB IPE GUI to update the firmware if needed. - Disconnect and reconnect the probe. - On Linux, ensure that appropriate ``udev`` rules are installed for Microchip tools. Device Is Not Recognized ~~~~~~~~~~~~~~~~~~~~~~~~~ If the target device is not recognized: - Verify that the correct device pack is installed in MPLAB IPE. - Open MPLAB IPE GUI and use the Pack Manager to install or update packs. - Ensure the target board is powered and the debug connection is secure. - Confirm that the target device matches the device configured in the Zephyr board definition. Additional Resources -------------------- For more information, see: - `MPLAB X IDE`_ (includes MPLAB IPE) - `MPLAB IPE User Guide`_ .. _MPLAB X IDE: https://www.microchip.com/en-us/tools-resources/develop/mplab-x-ide .. _MPLAB IPE User Guide: https://ww1.microchip.com/downloads/aemDocuments/documents/DEV/ProductDocuments/UserGuides/MPLAB_IPE_Integrated_Programming_Environment_Users_Guide_50002227.pdf