首页 > 其他分享 >PyOCD Notes

PyOCD Notes

时间:2022-11-29 00:45:01浏览次数:62  
标签:AT32F40x PyOCD Notes local Series ArteryTek pyocd pack

Installation

Ubuntu20.04

For Ubuntu20.04 the version in apt repository is 0.13.1+dfsg-1, which is too low to recognize J-Link probe

$ apt-cache show python3-pyocd
Package: python3-pyocd
Architecture: all
Version: 0.13.1+dfsg-1
Priority: optional

When you run pyocd-tool list it won't detect the jlink probe

Remove

sudo apt remove python3-pyocd

Then install from pip

pip install pyocd

This will work (it's a J-Link clone)

~$ pyocd list
  #   Probe/Board               Unique ID   Target  
----------------------------------------------------
  0   Segger J-Link (unknown)   123456      n/a     

Ubuntu 22.04

This is instantly available but not recommended

sudo pip install pyocd
# or with a mirror
sudo pip install pyocd -i https://mirrors.ustc.edu.cn/pypi/web/simple/
# This will install pyocd (currently pyocd-0.34.2) into:
	/usr/local/bin/pyocd
	/usr/local/bin/pyocd-gdbserver
	/usr/local/lib/python3.10/dist-packages/pyocd-0.34.2.dist-info/*
	/usr/local/lib/python3.10/dist-packages/pyocd/*

This is recommended but not instantly available (you need logout & login)

pip uninstall pyocd
# This will install pyocd into:
	/home/milton/.local/bin/pyocd
	/home/milton/.local/bin/pyocd-gdbserver
	/home/milton/.local/lib/python3.10/site-packages/pyocd-0.34.2.dist-info/*
	/home/milton/.local/lib/python3.10/site-packages/pyocd/*

You don't need to add .local/bin to the PATH because .profile already takes care of it, but it won't take effect until your next login

Basic Commands

# Show helps
pyocd --help
pyocd list --help
pyocd pack --help

# List information about probes
pyocd list
# List available targets
pyocd list -t

# Manage CMSIS-Packs for target support, clean packs
pyocd pack -c 
# List install packs
pyocd pack -s
# Update pack index
pyocd pack -u
# Show pack info according to IC type
pyocd pack -f stm32f103
# Install pack for specified IC type
pyocd pack -i stm32f103

# Reset a target device.
pyocd reset
# Run debug probe server.
pyocd server

Add New Targets

According to Target Support, pyocd list -t will list built-in targets, if you want to add new targets, you should run the following commands

# Clean packs
pyocd pack -c 
# List install packs
pyocd pack -s
# Update pack index
pyocd pack -u
# Show pack info according to IC type
pyocd pack -f stm32f103
# Install pack for specified IC type
pyocd pack -i stm32f103

The above command pyocd pack -u will download all .pdsc files into $HOME/.local/share/cmsis-pack-manager/, and generate aliases.json and index.json. But this command may not succeeded -- it's very slow and full of connection errors and format errors.

If you just want specified target types, and you happen to have the pack files, you can manually add the target support by creating a configuration file.

create a file named pyocd.yaml with the following content

pack:
  - ./Misc/ArteryTek.AT32F403A_407_DFP.2.1.3.pack
  - [relative or absolute paths to other pack files]

Then run pyocd from the same folder, it will take this file as configuration and treat these pack files as installed,

$ pyocd list -t
  Name                      Vendor                  Part Number                  Families                     Source   
-----------------------------------------------------------------------------------------------------------------------
  _at32f403acct7            ArteryTek               -AT32F403ACCT7               AT32F40x Series, AT32F403A   pack     
  _at32f403accu7            ArteryTek               -AT32F403ACCU7               AT32F40x Series, AT32F403A   pack     
  _at32f403acet7            ArteryTek               -AT32F403ACET7               AT32F40x Series, AT32F403A   pack     
...
  _at32f407vet7             ArteryTek               -AT32F407VET7                AT32F40x Series, AT32F407    pack     
  _at32f407vgt7             ArteryTek               -AT32F407VGT7                AT32F40x Series, AT32F407    pack     
  cc3220sf                  Texas Instruments       CC3220SF                                                  builtin  
  cortex_m                  Generic                 CoreSightTarget                                           builtin  

You can rename this configuration file and place it to other path, and specify this configuration with --config

$ pyocd list -t --config ./Misc/pyocd_renamed.yaml 
  Name                      Vendor                  Part Number                  Families                     Source   
-----------------------------------------------------------------------------------------------------------------------
  _at32f403acct7            ArteryTek               -AT32F403ACCT7               AT32F40x Series, AT32F403A   pack     
  _at32f403accu7            ArteryTek               -AT32F403ACCU7               AT32F40x Series, AT32F403A   pack     
  _at32f403acet7            ArteryTek               -AT32F403ACET7               AT32F40x Series, AT32F403A   pack     
  _at32f403aceu7            ArteryTek               -AT32F403ACEU7               AT32F40x Series, AT32F403A   pack     
...
  _at32f407vet7             ArteryTek               -AT32F407VET7                AT32F40x Series, AT32F407    pack     
  _at32f407vgt7             ArteryTek               -AT32F407VGT7                AT32F40x Series, AT32F407    pack     
  cc3220sf                  Texas Instruments       CC3220SF                                                  builtin  
  cortex_m                  Generic                 CoreSightTarget                                           builtin  
  cy8c64_sysap              Cypress                 cy8c64_sysap                                              builtin  

Operations

Task AT32F403ACGT7 for example.

Reset

Reset

pyocd reset -t _at32f403acgt7 --config somewhere/pyocd.yaml

Reset and halt

pyocd reset -l -t _at32f403acgt7 --config somewhere/pyocd.yaml

Erase

Erase entire chip, target is _at32f403acgt7

$ pyocd erase -t _at32f403acgt7 -c --config somewhere/pyocd.yaml
0000972 I Erasing chip... [eraser]
0003906 I Chip erase complete [eraser]

Flash(Load)

$ pyocd load -t _at32f403acgt7 ./led_toggle.hex --config somewhere/pyocd.yaml
0000957 I Loading /home/milton/somewhere/led_toggle.hex [load_cmd]
[==================================================] 100%
0001481 I Erased 4096 bytes (2 sectors), programmed 3072 bytes (3 pages), skipped 0 bytes (0 pages) at 5.77 kB/s [loader]

Ref

标签:AT32F40x,PyOCD,Notes,local,Series,ArteryTek,pyocd,pack
From: https://www.cnblogs.com/milton/p/16934226.html

相关文章