I'm submitting this patch with the consent of the original author Zbigniew Bodek <zbigniew.bodek@...>
The flashing process occurred to contain an undefined behavior, resulting in flashing garbage data to the connected board. It rarely occured with small images (e.g. zephyr-hello-world or zephyr-philosophers samples) but became visible with custom applications.
The exact mechanism is described in the commit log of the patch.
Zbigniew Bodek (1): zephyr-flash-pyocd.bbclass: Fix problems with flashing particular boards