pyocd / pyOCD

Open source Python library for programming and debugging Arm Cortex-M microcontrollers
https://pyocd.io
Apache License 2.0
1.12k stars 480 forks source link

Need some clarifications on pyocd pack command #643

Closed rogernguessan closed 5 years ago

rogernguessan commented 5 years ago

Hi, what is the correct syntax to support new target after downloading manually its cmsis-pack. Is it pyocd --pack /my/pyOCD/Keil.pack/path/ like target_support docs mentioned? This does not work for me. Or, is this the real commandpyocd gdbserver --pack /my/pyOCD/Keil.pack/path/? Ok, let's take the second command: (venv) osboxes@osboxes:~/Desktop/pyOCD$ pyocd gdbserver --pack Keil.STM32L4xx_DFP.2.2.0.pack 0000469:INFO:session:Using config settings for board 066EFF535550755187241812 0000540:INFO:board:Target type is stm32l476rg 0000827:INFO:dap:DP IDR = 0x2ba01477 (v1 rev2) 0001020:INFO:ap:AP#0 IDR = 0x24770011 (AHB-AP var1 rev2) 0001356:INFO:rom_table:AP#0 ROM table #0 @ 0xe00ff000 (designer=020 part=415) 0001616:INFO:rom_table:[0]<e000e000:SCS-M4 class=14 designer=43b part=00c> 0001786:INFO:rom_table:[1]<e0001000:DWT class=14 designer=43b part=002> 0001953:INFO:rom_table:[2]<e0002000:FPB class=14 designer=43b part=003> 0002124:INFO:rom_table:[3]<e0000000:ITM class=14 designer=43b part=001> 0002295:INFO:rom_table:[4]<e0040000:TPIU-M4 class=9 designer=43b part=9a1 devtype=11 archid=0000 devid=0:0:ca1> 0002465:INFO:rom_table:[5]<e0041000:ETM-M4 class=9 designer=43b part=925 devtype=13 archid=0000 devid=0:0:0> 0002512:INFO:cortex_m:CPU core #0 is Cortex-M4 r0p1 0002574:INFO:cortex_m:FPU present: FPv4-SP 0002598:INFO:dwt:4 hardware watchpoints 0002655:INFO:fpb:6 hardware breakpoints, 4 literal comparators 0002784:INFO:server:Semihost server started on port 4444 0002786:INFO:gdbserver:GDB server started on port 3333

Gdbserver started but.... Is this target now considered supported by pyocd? Can i use this target to debug my application? Can i use Eclipse to debug?

Because: (venv) osboxes@osboxes:~/Desktop/pyOCD$ pyocd-flashtool -t stm32l476rg zephyr.elf usage: pyocd-flashtool [-h] [--version] [--config PATH] [--no-config] [--pack PATH] [-b BOARD_ID] [-l] [-d LEVEL] [-t TARGET] [-f FREQUENCY] [-ce | -se] [-u] [-a ADDRESS] [-n COUNT] [-s SKIP] [-hp] [-fp] [-da DAPARG [DAPARG ...]] [--mass-erase] [-O OPTION] [--no-deprecation-warning] [file] [{bin,hex,elf}] pyocd-flashtool: error: argument -t/--target: invalid choice: 'stm32l476rg' (choose from 'kl05z', 'kw36z4', 'max32600', 'kl82z7', 'stm32l031x6', 'cy8c6xxa', 'nrf52840', 'kw41z4', 'k22fa12', 'musca_b1', 'k20d50m', 'stm32f412xg', 'stm32f103rc', 'k22f', 'k66f18', 'mimxrt1050_hyperflash', 'max32630', 'lpc800', 'kw24d5', 'stm32f439xi', 'stm32f051', 'kl25z', 'lpc824', 'lpc55s69', 'kinetis', 'cc3220sf', 'lpc1768', 'nrf51', 'stm32l475xe', 'mimxrt1050_quadspi', 'kl28z', 'mimxrt1020', 'mimxrt1050', 'kl02z', 'stm32l475xg', 'ke15z7', 'k28f15', 'k32w042s', 'kl26z', 'ke18f16', 'max32625', 'kl43z4', 'kl27z4', 'max32620', 'rtl8195am', 'stm32l475xc', 'nrf52', 'kw40z4', 'k82f25615', 'lpc54114', 'kv10z7', 'lpc54608', 'lpc11u24', 'stm32f429xg', 'stm32f429xi', 'musca_a1', 'stm32f412xe', 'w7500', 'kw01z4', 'lpc4330', 'lpc4088dm', 'kv11z7', 'lpc4088qsb', 'lpc11xx_32', 'lpc4088', 'ncs36510', 'stm32f439xg', 'kl46z', 'k64f', 'cy8c6xx7')

the target is still not recognized.

Maybe I missed something or maybe I overvalue the command. If i missed something, specific steps will be welcome.

flit commented 5 years ago

You need to add the --pack /my/pyOCD/Keil.pack/path/ argument to all pyOCD tool invocations, not just one time.

It may be easier for you to create a pyocd.yaml config file that sets the pack option. This way you don't have to pass --pack for every command, assuming the config file is in your working directory (or you pass --config=path/to/config/file). (Configuration docs have more info.)

Here's an example pyocd.yaml config file (copied from my own config file) that adds a bunch of packs:

pack:
  - /Users/creed/Downloads/_packs/NXP.MK66F18_DFP.11.0.0.pack
  - /Users/creed/Downloads/_packs/NXP.MK64F12_DFP.11.0.0.pack
  - /Users/creed/Downloads/_packs/NordicSemiconductor.nRF_DeviceFamilyPack.8.17.0.pack
  - /Users/creed/Downloads/_packs/Keil.STM32L0xx_DFP.2.0.0.pack
  - /Users/creed/Downloads/_packs/Keil.STM32L4xx_DFP.2.0.0.pack
  - /Users/creed/Downloads/_packs/Keil.STM32F4xx_DFP.2.13.0.pack
  - /Users/creed/Downloads/_packs/NXP.MIMXRT1052_DFP.11.0.0.pack
  - /Users/creed/Downloads/_packs/Keil.STM32F4xx_DFP.2.13.0.pack
  - /Users/creed/Downloads/_packs/ARM.Musca_A1_BSP.2.0.0.pack
rogernguessan commented 5 years ago

Thanks @flit, this works.

My pyocd.yaml:

probes:
  066EFF535550755187241812: # Probe's unique ID.
    target_override:  stm32l476rg
    test_binary:      nucleo_l476rg.bin
  0667FF575550897767151751:
    target_override:  stm32f103rb
    test_binary:      nucleo_f103rb.bin

pack:
  - /home/osboxes/Desktop/pyOCD/Keil.STM32L4xx_DFP.2.2.0.pack
  - /home/osboxes/Desktop/pyOCD/Keil.STM32F1xx_DFP.2.3.0.pack

Auto-detection too:

(venv) osboxes@osboxes:~/Desktop/pyOCD$ pyocd flash zephyr.bin 
0000270:INFO:session:Using config settings for board 066EFF535550755187241812
0000888:INFO:rom_table:AP#0 ROM table #0 @ 0xe00ff000 (designer=020 part=415)
0000913:INFO:rom_table:[0]<e000e000:SCS-M4 class=14 designer=43b part=00c>
0000927:INFO:rom_table:[1]<e0001000:DWT class=14 designer=43b part=002>
0000941:INFO:rom_table:[2]<e0002000:FPB class=14 designer=43b part=003>
0000958:INFO:rom_table:[3]<e0000000:ITM class=14 designer=43b part=001>
0000971:INFO:rom_table:[4]<e0040000:TPIU-M4 class=9 designer=43b part=9a1 devtype=11 archid=0000 devid=0:0:ca1>
0000985:INFO:rom_table:[5]<e0041000:ETM-M4 class=9 designer=43b part=925 devtype=13 archid=0000 devid=0:0:0>
[====================] 100%
0009075:INFO:loader:Erased 16384 bytes (8 sectors), programmed 16384 bytes (16 pages), skipped 0 bytes (0 pages) at 2.05 kB/s