with the attached patch it has been possible to disable the hard requirement that a target exist, in order to successfully get the STLinkv2 to send JTAG commands out to a general (non-cortex_m) device.
that also involved adding in basic settings of ir_capture_mask, ir_length and ir_capture_value to support jtag newtap options in hla_tcl.c that were not being reported as *completely ignored*, thus leading to a huge amount of confusion for several weeks. a better patch would involve duplicating the error-checking used in src/jtag/tcl.c. an even better patch would use the same code rather than duplicate it. Christian: the above paragraph may explain why you were unable to get success, because the parameters you gave on the "jtag newtap" line were being completely and **silently** ignored. the clue was this line: ~~~ Debug: 53 8 core.c:1488 jtag_tap_init(): Created Tap: raspi.arm @ abs position 0, irlen 0, capture: 0x0 mask: 0x0 ~~~ you will need to properly investigate the patch to ensure that you can still specify a target (our application specifically does not need one). you can see the difference here. with the patch, we get this: ~~~ Debug: 38 1 core.c:1476 jtag_tap_init(): Created Tap: ls180.tap @ abs position 0, irlen 4, capture: 0x1 mask: 0xf ~~~ the stage we are at so far is that the device being communicated with may be unable to cope with a 140 khz clock rate, therefore we have yet to confirm success: however we got to the point where at least it looks like the STLinkv2 actually made an effort: ~~~ Debug: 83 5 stlink_usb.c:1019 stlink_usb_error_check(): unknown/unexpected STLINK status code 0x5 Error: 84 5 stlink_usb.c:3493 stlink_open(): init mode failed (unable to connect to the target) ~~~ also unfortunately there is no access to a logic analyzer at this location in order to debug further. in looking for more information as to whether HLA can actually do JTAG or not, i came across this: https://ftp.mak.com/out/classdocs/vrlink5.2.1/hla1516/vrl_hla_dis_and_protocol_independence.html The HLA 1.3 and IEEE 1516 specifications are copyrighted by their owners and MAK cannot distribute them to customers. You can get documentation for the RTI 1.3 and 1516 interface specifications at: http://shop.ieee.org/store/ (IEEE 1516 specifications) http://www.sisostds.org (SISO DLC HLA API 1516). however a quick google search shows this may be a red herring as HLA does not specify the actual wire format. it therefore remains to be confirmed as to whether it is in fact completely impossible to do plain JTAG over an STLinkv2. this is our best effort so far to investigate this matter: unfortunately the only remaining option to progress our project further, which is under time pressure, is to abandon the use of an STLinkV2 and to use bitbanging, USB Blaster, or FT2232. at least however the above insights may prove useful to someone else wishing to take this further. Attachments: - [x](https://sourceforge.net/p/openocd/tickets/_discuss/thread/479f38c9a4/d6ca/6395/attachment/x) (6.3 kB; application/octet-stream) --- ** [tickets:#280] stlink-v2 not working with bcm2835 raspberry pi** **Status:** new **Milestone:** 0.9.0 **Created:** Thu Oct 15, 2020 02:42 PM UTC by Christian Tenllado **Last Updated:** Thu Oct 15, 2020 04:25 PM UTC **Owner:** nobody Hi: I am trying to use a stlink-v2 to debug a raspberry pi (bcm2835) using jtag, but I am not succeding. I have tryied with two transports, hla and dapdirect, and each of them is giving me different problems. Using the openocd snapshot from debian unstable (from 2020-08-19). The commands I use to connect and the debug output from openocd are the following: - Using hla: $ openocd -d3 -f interface/stlink-v2.cfg -c "transport select hla_jtag" -c "adapter speed 100" -c "hla newtap raspi arm -irlen 5 -expected-id 0x07b7617F" -c "target create raspi.arm arm11 -chain-position raspi.arm" Open On-Chip Debugger 0.10.0+dev-snapshot (2020-10-14-11:42) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html User : 13 5 options.c:63 configuration_output_handler(): debug_level: 3 User : 14 5 options.c:63 configuration_output_handler(): Debug: 15 5 options.c:187 add_default_dirs(): bindir=/usr/bin Debug: 16 5 options.c:188 add_default_dirs(): pkgdatadir=/usr/share/openocd Debug: 17 5 options.c:189 add_default_dirs(): exepath=/usr/bin Debug: 18 5 options.c:190 add_default_dirs(): bin2data=../share/openocd Debug: 19 5 configuration.c:42 add_script_search_dir(): adding /home/christian/.openocd Debug: 20 5 configuration.c:42 add_script_search_dir(): adding /usr/bin/../share/openocd/site Debug: 21 5 configuration.c:42 add_script_search_dir(): adding /usr/bin/../share/openocd/scripts Debug: 22 6 configuration.c:97 find_file(): found /usr/bin/../share/openocd/scripts/interface/stlink-v2.cfg Debug: 23 6 command.c:146 script_debug(): command - echo WARNING: interface/stlink-v2.cfg is deprecated, please switch to interface/stlink.cfg User : 25 6 command.c:767 jim_echo(): WARNING: interface/stlink-v2.cfg is deprecated, please switch to interface/stlink.cfg Debug: 26 6 configuration.c:97 find_file(): found /usr/bin/../share/openocd/scripts/interface/stlink.cfg Debug: 27 6 command.c:146 script_debug(): command - adapter driver hla Debug: 29 6 command.c:352 register_command_handler(): registering 'hla_device_desc'... Debug: 30 6 command.c:352 register_command_handler(): registering 'hla_serial'... Debug: 31 6 command.c:352 register_command_handler(): registering 'hla_layout'... Debug: 32 6 command.c:352 register_command_handler(): registering 'hla_vid_pid'... Debug: 33 6 command.c:352 register_command_handler(): registering 'hla_command'... Debug: 34 6 command.c:146 script_debug(): command - hla_layout stlink Debug: 36 6 hla_interface.c:242 hl_interface_handle_layout_command(): hl_interface_handle_layout_command Debug: 37 6 command.c:146 script_debug(): command - hla_device_desc ST-LINK Debug: 39 6 hla_interface.c:216 hl_interface_handle_device_desc_command(): hl_interface_handle_device_desc_command Debug: 40 6 command.c:146 script_debug(): command - hla_vid_pid 0x0483 0x3744 0x0483 0x3748 0x0483 0x374b 0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753 Debug: 42 6 command.c:146 script_debug(): command - transport select hla_jtag Debug: 43 6 hla_transport.c:189 hl_transport_select(): hl_transport_select Debug: 44 6 command.c:352 register_command_handler(): registering 'hla'... Debug: 45 6 command.c:352 register_command_handler(): registering 'jtag'... Debug: 46 6 command.c:352 register_command_handler(): registering 'jtag'... Debug: 47 6 command.c:352 register_command_handler(): registering 'jtag'... Debug: 48 6 command.c:352 register_command_handler(): registering 'jtag'... Debug: 49 6 command.c:352 register_command_handler(): registering 'jtag'... Debug: 50 7 command.c:352 register_command_handler(): registering 'jtag'... Debug: 51 7 command.c:352 register_command_handler(): registering 'jtag'... Debug: 52 7 command.c:352 register_command_handler(): registering 'jtag'... Debug: 53 7 command.c:352 register_command_handler(): registering 'jtag'... Debug: 54 7 command.c:352 register_command_handler(): registering 'jtag_ntrst_delay'... User : 55 7 options.c:63 configuration_output_handler(): hla_jtagUser : 56 7 options.c:63 configuration_output_handler(): Debug: 57 7 command.c:146 script_debug(): command - adapter speed 100 Debug: 59 7 core.c:1822 jtag_config_khz(): handle jtag khz Debug: 60 7 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value Debug: 61 7 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value User : 62 7 options.c:63 configuration_output_handler(): adapter speed: 100 kHz User : 63 7 options.c:63 configuration_output_handler(): Debug: 64 7 command.c:146 script_debug(): command - hla newtap raspi arm -irlen 5 -expected-id 0x07b7617F Debug: 65 7 hla_tcl.c:111 jim_hl_newtap_cmd(): Creating New Tap, Chip: raspi, Tap: arm, Dotted: raspi.arm, 4 params Debug: 66 7 hla_tcl.c:121 jim_hl_newtap_cmd(): Processing option: -irlen Debug: 67 7 hla_tcl.c:121 jim_hl_newtap_cmd(): Processing option: -expected-id Debug: 68 7 core.c:1488 jtag_tap_init(): Created Tap: raspi.arm @ abs position 0, irlen 0, capture: 0x0 mask: 0x0 Debug: 69 7 command.c:146 script_debug(): command - target create raspi.arm arm11 -chain-position raspi.arm **Error: 70 7 target.c:5458 target_create(): The selected transport doesn't support this target** User : 71 8 command.c:692 command_run_line(): invalid command name "raspi.arm" - Using dapdirect: $ openocd -d3 -f interface/stlink-dap.cfg -c "transport select dapdirect_jtag" -c "adapter speed 100" -c "jtag newtap raspi arm -irlen 5 -expected-id 0x07b7617F" -c "target create raspi.arm arm11 -chain-position raspi.arm" Open On-Chip Debugger 0.10.0+dev-snapshot (2020-10-14-11:42) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html User : 13 6 options.c:63 configuration_output_handler(): debug_level: 3 User : 14 6 options.c:63 configuration_output_handler(): Debug: 15 6 options.c:187 add_default_dirs(): bindir=/usr/bin Debug: 16 6 options.c:188 add_default_dirs(): pkgdatadir=/usr/share/openocd Debug: 17 6 options.c:189 add_default_dirs(): exepath=/usr/bin Debug: 18 6 options.c:190 add_default_dirs(): bin2data=../share/openocd Debug: 19 6 configuration.c:42 add_script_search_dir(): adding /home/christian/.openocd Debug: 20 6 configuration.c:42 add_script_search_dir(): adding /usr/bin/../share/openocd/site Debug: 21 7 configuration.c:42 add_script_search_dir(): adding /usr/bin/../share/openocd/scripts Debug: 22 7 configuration.c:97 find_file(): found /usr/bin/../share/openocd/scripts/interface/stlink-dap.cfg Debug: 23 7 command.c:146 script_debug(): command - adapter driver st-link Debug: 25 7 command.c:352 register_command_handler(): registering 'st-link'... Debug: 26 7 command.c:352 register_command_handler(): registering 'st-link'... Debug: 27 7 command.c:146 script_debug(): command - st-link vid_pid 0x0483 0x3744 0x0483 0x3748 0x0483 0x374b 0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753 Debug: 29 7 command.c:146 script_debug(): command - transport select dapdirect_jtag Debug: 30 7 adi_v5_dapdirect.c:168 dapdirect_jtag_select(): dapdirect_jtag_select() Debug: 31 7 command.c:352 register_command_handler(): registering 'jtag'... Debug: 32 7 command.c:352 register_command_handler(): registering 'jtag'... Debug: 33 7 command.c:352 register_command_handler(): registering 'jtag'... Debug: 34 7 command.c:352 register_command_handler(): registering 'jtag'... Debug: 35 7 command.c:352 register_command_handler(): registering 'jtag'... Debug: 36 7 command.c:352 register_command_handler(): registering 'jtag'... Debug: 37 7 command.c:352 register_command_handler(): registering 'jtag'... Debug: 38 7 command.c:352 register_command_handler(): registering 'jtag'... Debug: 39 7 command.c:352 register_command_handler(): registering 'jtag'... Debug: 40 7 command.c:352 register_command_handler(): registering 'jtag'... Debug: 41 7 command.c:352 register_command_handler(): registering 'jtag_ntrst_delay'... User : 42 7 options.c:63 configuration_output_handler(): dapdirect_jtagUser : 43 7 options.c:63 configuration_output_handler(): Debug: 44 7 command.c:146 script_debug(): command - adapter speed 100 Debug: 46 7 core.c:1822 jtag_config_khz(): handle jtag khz Debug: 47 7 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value Debug: 48 7 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value User : 49 7 options.c:63 configuration_output_handler(): adapter speed: 100 kHz User : 50 8 options.c:63 configuration_output_handler(): **Debug: 51 8 command.c:146 script_debug(): command - jtag newtap raspi arm -irlen 5 -expected-id 0x07b7617F Debug: 52 8 tcl.c:567 jim_newtap_cmd(): Creating New Tap, Chip: raspi, Tap: arm, Dotted: raspi.arm, 4 params Debug: 53 8 core.c:1488 jtag_tap_init(): Created Tap: raspi.arm @ abs position 0, irlen 0, capture: 0x0 mask: 0x0 Debug: 54 8 command.c:146 script_debug(): command - target create raspi.arm arm11 -chain-position raspi.arm Debug: 55 8 target.c:1996 target_free_all_working_areas_restore(): freeing all working areas Error: 56 8 arm11.c:1104 arm11_target_create(): 'target arm11' expects IR LENGTH = 5** Debug: 57 8 target.c:5609 target_create(): target_create failed User : 58 8 command.c:692 command_run_line(): raspi.arm As you can see, the hla transport seems to not support arm11 as target. On the other hand, the dapdirect transport seems to ignore the -irlen flag passed to the jtag newtap command, and then the openocd complains when the tap is initialized. Can anyone help me to solve this problem or at least throw some light on it? Have anyone succed in using stlink-v2 to debug a raspberry pi using the jtag protocol? Thank you all. Christian. --- Sent from sourceforge.net because openocd-devel@lists.sourceforge.net is subscribed to https://sourceforge.net/p/openocd/tickets/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/openocd/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.