Skip to content
reed-dan edited this page Feb 25, 2024 · 3 revisions

PYOCD

The below instruction are written with the MM32SPIN05PF mcu as an exmaple, but should apply to other boards as well.

Adding MM32spin05pf board

By default the MM32SPIN05PF mcu is not included as a built in target with PYOCD. Don’t be worried though adding the board is easy, as someone else has already built the necessary files.

  • Check to make sure your mcu is available by searching on https://www.keil.arm.com/devices/
  • pyocd pack -u OR pyocd pack --update
  • Update the CMSIS Device Family Packs that provide additional target device support.
  • pyocd pack -i mm32spin05pf OR pyocd pack install mm32spin05pf
  • Install the CMSIS Device pack for the MM32SPIN05PF
  • pyocd list -t OR pyocd list --targets
  • This will list all the installed CMSIS Device packs

Erasing MM32spin05pf board

  1. Connect chip mcu NREST pin to ground (not all mcu require shorting NREST to ground try first without it)
    • If using a St Link V2 don't connect the nrst to stlink because the rst on stlink v2 is for stm8 only
  2. pyocd erase -t mm32spin05pf --chip
  3. Quickly disconnect NREST from ground
    • If you see "Timed out waiting for core to halt after reset (state is RESET) [cortex_m]" you didn't pull the NREST to ground connection quick enough.

Flashing MM32spin05pf board

  1. Connect chip mcu NREST pin to ground (not all mcu require shorting NREST to ground try first without it)
    • If using a St Link V2 don't connect the nrst to stlink because the rst on stlink v2 is for stm8 only
  2. pyocd flash -t mm32spin05pf c:\blink.hex
    • pyocd flash -t mm32spin05pf file location
    • A .bin file is also acceptable
  3. Once you see "I Erasing chip... [eraser]" disconnect NREST from ground
    • C Memory transfer fault (Unspecified error.) [main]
      • You did not successfully bring NREST to ground
    • W Timed out waiting for core to halt after reset (state is RESET) [cortex_m] C cannot write registers pc, r0, r1, r2, r9, sp, lr because core #0 is not halted [main]
      • You did not disconnect NREST from ground in time
C:\Users\X>pyocd erase -t mm32spin05pf --chip
0002614 W STLink, CMSIS-DAPv2 and PicoProbe probes are not supported because no libusb library was found. [common]
0005179 C Memory transfer fault (Unspecified error.) [__main__]

C:\Users\X>pyocd erase -t mm32spin05pf --chip
0002267 W STLink, CMSIS-DAPv2 and PicoProbe probes are not supported because no libusb library was found. [common]
0004488 I Erasing chip... [eraser]
0008618 W Timed out waiting for core to halt after reset (state is RESET) [cortex_m]
0008710 C cannot write registers pc, r0, r1, r2, r9, sp, lr because core #0 is not halted [__main__]

C:\Users\x>pyocd erase -t mm32spin05pf --chip
0002621 W STLink, CMSIS-DAPv2 and PicoProbe probes are not supported because no libusb library was found. [common]
0005375 I Erasing chip... [eraser]
0006575 I Chip erase complete [eraser]