How do I increase pyOCD flashing speed to rp2040 with custom probe?

Summary

The issue at hand is the slow flashing speed of pyOCD when used with a custom CMSIS-DAP probe to flash firmware to an rp2040 board. The current speed is approximately 20kB/s, which is significantly lower than the 80kB/s achieved with openOCD. The goal is to increase the flashing speed to a more acceptable level.

Root Cause

The root cause of the slow flashing speed is the overhead introduced by pyOCD. This overhead is due to the small block sizes used by the rp2 flashing algorithm, which results in a large number of requests from pyOCD to the probe. The python implementation of pyOCD also contributes to the overhead.

Why This Happens in Real Systems

This issue occurs in real systems due to the following reasons:

  • Inefficient flashing algorithms: The rp2 flashing algorithm used by pyOCD is not optimized for performance.
  • Small block sizes: The block sizes used by the rp2 flashing algorithm are too small, resulting in a large number of requests.
  • Overhead of python: The python implementation of pyOCD introduces additional overhead.

Real-World Impact

The slow flashing speed has the following real-world impacts:

  • Increased development time: The slow flashing speed increases the time it takes to develop and test firmware.
  • Decreased productivity: The slow flashing speed decreases the productivity of developers and engineers.
  • Limited scalability: The slow flashing speed limits the scalability of the system.

Example or Code

# Example of how to modify the target_rp2.py file to increase the page size
def __init__(self):
    self.page_size = 512  # Increase the page size to 512

How Senior Engineers Fix It

Senior engineers can fix this issue by:

  • Optimizing the flashing algorithm: Implementing a more efficient flashing algorithm that supports larger block sizes.
  • Increasing the block size: Increasing the block size used by the rp2 flashing algorithm to reduce the number of requests.
  • Reducing python overhead: Minimizing the python overhead by using optimized libraries or native code.

Why Juniors Miss It

Juniors may miss this issue due to:

  • Lack of experience: Limited experience with embedded systems and flashing algorithms.
  • Insufficient knowledge: Limited knowledge of pyOCD and CMSIS-DAP protocols.
  • Overlooking optimization: Failing to consider optimization and performance when implementing flashing algorithms.