Appendix E: Setting Up OpenOCD for PKOB-Equipped Boards
Some newer Microchip development boards use a PKOB (PICkit On Board) programmer/debugger instead of the EDBG interface. The PKOB is not yet supported by the upstream OpenOCD release. Two setup steps are required to use these boards with Zephyr:
- Clone the Microchip custom OpenOCD repository
- Flash the PKOB with CMSIS-DAP firmware so that OpenOCD can communicate with it
Once the PKOB is running CMSIS-DAP firmware, MPLAB X will not be able to detect the board. To use MPLAB X again, restore the original firmware. See Switching Back to MPLAB Firmware below.
Step 1: Cloning the Custom OpenOCD Repository
Adding new board support to the upstream OpenOCD release takes time. Microchip provides a customized OpenOCD binary that supports the latest boards ahead of upstream. Clone the repository into your Zephyr workspace:
- Ubuntu
- macOS
- Windows
$ git clone https://github.com/MicrochipTech/openOCD-wireless
$ git clone https://github.com/MicrochipTech/openOCD-wireless
PS C:\Users\...\zephyrproject> git clone https://github.com/MicrochipTech/openOCD-wireless
The cloned repository contains both the OpenOCD binaries and the PKOB firmware files used in the next step.
Step 2: Flashing CMSIS-DAP Firmware onto the PKOB
Installing pycmsisdapswitcher
Activate your Zephyr virtual environment and install the pycmsisdapswitcher tool:
- Ubuntu
- macOS
- Windows
$ source ~/zephyrproject/.venv/bin/activate
(.venv) $ pip install pycmsisdapswitcher
$ source ~/zephyrproject/.venv/bin/activate
(.venv) $ pip install pycmsisdapswitcher
PS C:\Users\...\zephyrproject> .\.venv\Scripts\Activate.ps1
(.venv) PS C:\Users\...\zephyrproject> pip install pycmsisdapswitcher
Switching to CMSIS-DAP Firmware
With your board connected via USB, run the following from your Zephyr workspace directory to flash the CMSIS-DAP firmware:
- Ubuntu
- macOS
- Windows
(.venv) $ cd ~/zephyrproject
(.venv) $ pycmsisdapswitcher --action switch --target=evalboard --source=openOCD-wireless/pkob4-cmsis_dap-switcher/pkob4_app_cmsis-dap.hex --fwtype=cmsis
(.venv) $ cd ~/zephyrproject
(.venv) $ pycmsisdapswitcher --action switch --target=evalboard --source=openOCD-wireless/pkob4-cmsis_dap-switcher/pkob4_app_cmsis-dap.hex --fwtype=cmsis
(.venv) PS C:\Users\...\zephyrproject> pycmsisdapswitcher --action switch --target=evalboard --source=openOCD-wireless\pkob4-cmsis_dap-switcher\pkob4_app_cmsis-dap.hex --fwtype=cmsis
The firmware switching process can be inconsistent. If the command fails, disconnect and reconnect the board and try running it again.
Once the switch is successful, reconnect the board. OpenOCD and west flash will now be able to communicate with the board through the PKOB.
Switching Back to MPLAB Firmware
To use MPLAB X with the board again, restore the original PKOB firmware:
- Ubuntu
- macOS
- Windows
(.venv) $ cd ~/zephyrproject
(.venv) $ pycmsisdapswitcher --action switch --target=evalboard --source=openOCD-wireless/pkob4-cmsis_dap-switcher/pkob4_app.hex --fwtype=mplab
(.venv) $ cd ~/zephyrproject
(.venv) $ pycmsisdapswitcher --action switch --target=evalboard --source=openOCD-wireless/pkob4-cmsis_dap-switcher/pkob4_app.hex --fwtype=mplab
(.venv) PS C:\Users\...\zephyrproject> pycmsisdapswitcher --action switch --target=evalboard --source=openOCD-wireless\pkob4-cmsis_dap-switcher\pkob4_app.hex --fwtype=mplab
As with the CMSIS-DAP switch, if the command fails, disconnect and reconnect the board and try again.
After a successful switch, reconnect the board — MPLAB X will detect it as normal.