Commit Graph

1556 Commits

Author SHA1 Message Date
Uwe Bonnes d4ae308f9f cmsis: implement srst_set_val() 2021-10-31 12:55:41 +01:00
Uwe Bonnes 166eb3ee3e cmsis_dap: Always transfer 65 bytes with hid_read|write()
CMSIS-DAP Dragonprobe works on some devices. E.g. it does not work
on NUCLEO-F103
2021-10-31 12:55:41 +01:00
Uwe Bonnes b343ebe06f cmsis-dap/linux: Link against libhidapi-hidraw
libhidapi-libusb detaches a kernel module but does not reattach again.
This may wrack interaction with other programs using hidapi.
2021-10-31 12:55:41 +01:00
Uwe Bonnes d144f9d54b adiv5: CMSIS DAP transactions are slow but work in principle
Slowness results in strange STM32F767 DHCSR implementation to nearly never
halt in the given 2 second period when F767 is sleeping most of the time.
2021-10-31 12:55:41 +01:00
Uwe Bonnes 761e0230d4 cmsis-dap: Print messages when transfers fail.
Expect signal integrity errors when using jumper cables. Often probes switch
the SWJ GPIO with highest speed, resulting in possible reflections. Additional
ground wires may help. If there is isolation between probe and targets,
additional ground wires are a must or ground shift will wrack the transfer!
2021-10-31 12:55:41 +01:00
Uwe Bonnes 39fbffd3d2 stlinkv2: Fix low access to AP registers. 2021-10-31 12:55:41 +01:00
Uwe Bonnes c13778139f adiv5/hosted: Export the BMP_TYPE in DP. 2021-10-31 12:55:41 +01:00
Uwe Bonnes b7e7aa3f9a adiv5: Either use only LL functions in cortexm_initial_halt or no LL at all.
Platform implementation may disturb ADIV5_AP_DRW and so low_read DHCSR may
give values other from registers
2021-10-31 12:55:41 +01:00
Uwe Bonnes 485105221e dap: Always work on a copy of the buffer when calling dbg_dap_cmd() in a loop
A better solution would use seperate buffers for dbg_dap_cmd. But as WAIT is
already handled in DAP, cahnces are low that loop re-entry is needed.
2021-10-31 12:55:41 +01:00
Uwe Bonnes 397fbd5749 cmsis: Only cmsis internal use must differentiate between HID and Bulk access
Missing DAP_SWD_SEQUENCE may eventually need a distinction visible from
outside later.
2021-10-31 12:55:41 +01:00
Uwe Bonnes 7b1eb6e6e3 bmp_libusb: reset type on every device. 2021-10-31 12:53:47 +01:00
Uwe Bonnes 80064c18a9 bmp_libusb: Fix CMSIS-DAP related memory leak. 2021-10-31 11:13:34 +01:00
Uwe Bonnes 8845a22226 stm32l4: Use targetid when available.
Fixes STM32U5 from crashing.
2021-10-31 11:13:34 +01:00
Uwe Bonnes c4b6b42dcf stlinkv2: Read targetid on DPv2 devices. 2021-10-31 11:13:34 +01:00
Uwe Bonnes 5dafc0828c SWD: Remove excessive line resets. 2021-10-31 11:12:46 +01:00
Uwe Bonnes e7e1bfdb53 mpsse: Fix using 60 MHz clock on fast devices. 2021-10-30 13:55:57 +02:00
Uwe Bonnes 99a5fdb6f8 bmp_remote: Better error propagation.
Negative values from platform_buffer_read are errors too!
2021-10-30 13:55:57 +02:00
Uwe Bonnes f4117aa1b4 cdcacm: Use the USB strings. 2021-10-30 13:55:57 +02:00
Uwe Bonnes f28f05952f stlink: Add another STLINK-V3 ID. 2021-10-30 13:55:57 +02:00
SG 7307f086c6
Support for STM32WB55 (#942)
* add STM32WB55 support
2021-10-30 13:01:06 +02:00
Uwe Bonnes e1a928beb1 Fixes to compile with gcc11 #925
Target code changes are pure for formal correctness and not tested!
2021-10-10 15:59:57 +02:00
fabalthazar e2d3161442 Removed -S message as debugger selection option since it is used for reading bytes 2021-10-09 21:38:48 +02:00
fabalthazar 59282b6f66 Fixed typography 2021-10-09 21:18:52 +02:00
fabalthazar 7274f55ff4 Fixed return value of hosted blackmagic in erase mode 2021-10-09 21:17:58 +02:00
fabalthazar 3f54fba986 HOSTED_BMP_ONLY=0 by default on Linux.
The user is warned about missing dependencies.
2021-10-09 21:14:52 +02:00
Vegard Storheil Eriksen 7ccbdd98c0 hosted/dap: Copy command buffer in wait/retry loop.
The same buffer is used for both command and response, causing part of
the command to be overwritten before it’s retried. Solve this by saving
and restoring a copy of the command before retrying.
2021-10-05 23:21:07 +02:00
Jeff Lutgen f69f29a660 f4discovery/blackpill: fix usbusart 2021-10-01 00:10:03 +02:00
Uwe Bonnes b076d5cea1 stm32f1: Check if unlock failed and propagate error. 2021-09-22 21:41:43 +02:00
Uwe Bonnes 554e34517e Better reporting when monitor command fails. 2021-09-22 21:41:43 +02:00
Uwe Bonnes 9e98cfa220 adiv5: Remove leftover debug output. 2021-09-22 21:41:43 +02:00
Thiadmer Riemersma 64f756d627 Test voltage on VREF before enabling target power (mon tpwr), to avoid potential power conflict. 2021-09-22 20:45:18 +02:00
Uwe Bonnes 356325f563 ftdi_bmp: Fix bit select. 2021-09-22 15:16:20 +02:00
Uwe Bonnes 79066c950f bmp_libusb: Remove duplicated libusb_init.
Thanks to Red Liu for noticing
2021-09-22 15:16:20 +02:00
Uwe Bonnes 9ebc44bcea Make more functions static. 2021-09-22 15:16:20 +02:00
Uwe Bonnes db1f13db25 remote: Packets may be larger than 256 bytes. 2021-09-22 15:16:20 +02:00
Uwe Bonnes 88cce08ce4 hosted: Fix "monitor version" 2021-09-22 15:16:20 +02:00
Uwe Bonnes da15cc3cb7 remote_jtagtap: Fix memory corruption in jtagtap_tdi_tdo_seq 2021-09-22 15:16:20 +02:00
Uwe Bonnes a93e57e112 ftdi: Fixed wrong direction report in DEBUG. 2021-09-22 15:16:20 +02:00
Uwe Bonnes 9de69bb3ab Adiv5/Initial halt: More fixes for dd28fa5743. #925
Stlink does not like low level access and aborts with STLINK_SWD_DP_ERROR.
Either our implementation still has faults or stlink can not handle

MINDP devices with BMP/Firmware also seemm not to like low level access,
either du to some hidden error in BMP or by design
2021-09-22 15:16:20 +02:00
Uwe Bonnes a9854e9b37 adiv5: Fix the MINDP case introduced with dd28fa5743 #925 2021-09-16 12:39:26 +02:00
Andy Makovec 01583560cd hosted: Update Readme.md to use HOSTED_BMP_ONLY 2021-09-16 11:02:31 +02:00
dpc f66caa0d29 add some more nxp s32k14x variants
the sdid bits correspond to s32k14x as well as s32k11x but i only have
access to the k14x variants so didn't bother w/ the k11x variants.
the memory/flash sizes also can come from the sdid bits, but the
splits still need to come from a lookup.
2021-09-13 23:01:05 +02:00
dpc 95288bcf75 fix a size format warning 2021-09-13 23:01:05 +02:00
Uwe Bonnes e58b7d623b crc32: Abort generic_crc32 with error from target_mem_read
Use larger chunks for hosted to speed up. Send pure NULL as line keep-alive.
2021-09-07 10:57:17 +02:00
Uwe Bonnes ff79108f66 cl_utils: Increase worksize for increased speed.
H743 reads 2 MB in ~23 vs 27 seconds
2021-09-07 10:57:17 +02:00
Uwe Bonnes a76a559656 pc/platform_delay: Wait ms and not us! 2021-09-07 10:57:17 +02:00
Uwe Bonnes dd28fa5743 adiv5: Tighten up loop to initial halt cortexm
Use TRNCNT when available.

Now the F767 with the NutOS 300 ms sleep example  with the one ms tick is
halted even in hosted after few ms.
2021-09-04 21:15:07 +02:00
Uwe Bonnes a297c8c8ad hosted/Makefile.inc: Use gcc to build hosted, if not advised otherwise 2021-09-04 21:15:07 +02:00
Uwe Bonnes 698cfeb1f4 bmp_serial: Nag MACOS programmer to implement find_debuggers! 2021-09-04 21:15:07 +02:00
Thiadmer Riemersma 35687018eb Escape '*' in responses of the Remote Serial Protocol, to avoid that it is interpreted as the start of an RLE sequence 2021-08-31 15:44:17 +02:00
Uwe Bonnes 863a41daac adiv5_swdp: Initialize initial_dp with the definition 2021-08-15 16:43:29 +02:00
Uwe Bonnes 49122b50b6 hosted: Make HOSTED_BMP_ONLY the default.
Hopefully more people will use it when reporting errors!
2021-08-15 16:43:29 +02:00
Uwe Bonnes 2fcd4a878a ftdi_bmp.h: Fix error when compiling with HOSTED_BMP_ONLY=1 2021-08-15 16:43:29 +02:00
Uwe Bonnes 6308506276 jtag: Make jtag_devs argument to jtag_handler. 2021-08-15 16:43:29 +02:00
Uwe Bonnes 6dff2a9f31 target: target_error_check now defaults to not indicate error.
Remove unneeded nop_function from efm32
2021-08-15 16:43:29 +02:00
Uwe Bonnes f7670fcd44 ftdi_bmp: Add verbosity for libftdi_jtagtap_tdi_tdo_seq() 2021-08-15 16:43:29 +02:00
Uwe Bonnes 3df692ecb2 adiv5_swdp_scan: If SWD scan fails, try a JTAG scan. 2021-08-15 16:43:29 +02:00
Uwe Bonnes 5c8e277663 hosted/dap: Fix tdi_tdo_seq. 2021-08-15 16:43:29 +02:00
Uwe Bonnes 2d4a503135 jtag_scan: Rework chain detection
Fixme: stlinkv2/hosted probably does only handle STM devices. Check if
jtag_devs.c really needed.
2021-08-15 16:43:29 +02:00
Uwe Bonnes e1a1865de9 remote/jtagtap_tdi_tdo_seq: Split up large transactions.
FIXME: One remote transaction still can only do up to 64 ticks, leaving
room for speed enhancement with larger transactions.
Firmware assumes  (1LL << 65) == 0LL !
2021-08-15 16:43:29 +02:00
Uwe Bonnes 8084a75634 cl_utils: Allow Hardware reset from the command line 2021-08-15 16:43:29 +02:00
Uwe Bonnes 36836d0746 ftdi_bmp: Fix setting bits and FTDIJTAG srst. 2021-08-15 16:43:29 +02:00
Uwe Bonnes cfdf55855e ftdi_bmp: Export and use reset functions. 2021-08-15 16:43:29 +02:00
Uwe Bonnes 1845d71f00 jtag_scan: Deliver full idcode to the handler. 2021-08-15 16:43:29 +02:00
Uwe Bonnes 0d78331149 remote/jtag_tdi_tdo_seq: Fix wrong bitmask calculation. 2021-08-15 16:43:29 +02:00
Thiadmer Riemersma c7bc4b6a5d Bug fix in Flash erase function for LPC MCUs. 2021-08-13 16:18:53 +02:00
aam335 5eb43a1ddb platforms: stm32f4x1 blackpillv2 as variant of f4discovery
Compile as make PROBE_HOST=f4discovery BLACKPILL=1
2021-08-13 16:18:05 +02:00
Thiadmer Riemersma be534a9c5e Turn error LED off after successful attach to target (error LED blinks on 'target lost'). 2021-08-13 16:10:37 +02:00
Thiadmer Riemersma 72bd825a60 Add support for NXP LPC11xx XL series, add 'readuid' command for some MCUs of the LPC11xx series where it was missing; add comments mapping Device IDs to part descriptions. 2021-07-31 16:08:34 +02:00
Uwe Bonnes 6d6a67b44b timeout: Make sure we wait at least the period requested (#900, #902)
Fixes bug introduced with last commit( Recover from bad AP access)

Let STM32 timers run at 100 Hz against 10 Hz before.

Programming STM32F103 failed random (#900) with 20 ms timeout requested
against the 100 ms timeout granularity provided up to now.

STM32 Firmware only ticked at 10 hertz, so the sequence "low_access",
"set timeout", "send out 8 bit command", "read 3 bit result" when
reading "wait" and timer increment tick happening during that sequence
will already hits the timeout even so only mininal time has elapsed
and not the requested timeout.
2021-07-27 10:59:03 +02:00
Uwe Bonnes 0c63903071 adiv5: Recover from bad AP access.
E.g. AP1 on a STM32WLE5 points to a ROM table, but access to the ROM table
via AP1 hangs forever.
- Substantial reduce timeout when wait for a response. Valid access should
  succeed fast.
- Abort AP access to free DP for other accesses
- Don't throw exception, only set dp->fault
- React on higher level
2021-07-15 15:06:54 +02:00
Uwe Bonnes b887a8d355 stm32: Portability changes
Allow to compile on STM32F0 platform too.
2021-07-15 15:06:54 +02:00
Uwe Bonnes 3cfd8226ba bmp_libusb: Check only for cmsis_dap if no cable has been found yet. 2021-06-18 11:44:50 +02:00
UweBonnes a0dbb2a787
Merge pull request #896 from RadinnAB/for-upstream
Add nRF51 erase UICR command and fix some warnings
2021-06-07 17:43:56 +02:00
fabalthazar ea4b232996 Fix de83dbb: duplicate BMP_MODE_FLASH_VERIFY -> BMP_MODE_FLASH_WRITE_VERIFY 2021-06-07 17:29:41 +02:00
Björn Mellström 5ea01030e2 Add nRF51 command for (only) erasing the UICR registers
Original implementation by: Benjamin Vedder <benjamin@vedder.se>
2021-06-07 13:50:36 +02:00
Björn Mellström d987a8dd8c Add define to allow platform override of debug printf function 2021-06-04 06:58:29 +02:00
Björn Mellström 4b8c4990dc Fix warning about unused variable in adiv5.c
This happens if the platform has debugging support but debugging
is not enabled.
2021-06-03 12:56:41 +02:00
Björn Mellström 711a87f7ba Fix some warnings when compiling with -Wshadow
There are still a few more places that would need to be corrected
before -Wshadow could be added by default.
2021-06-03 12:55:28 +02:00
Björn Mellström 53f022d29b Require semicolon after debug log statements
This also fixes a warning about an empty body in cortexm.c
if PLATFORM_HAS_DEBUG is defined but debugging is not enabled:

    if (platform_timeout_is_expired(&to))
        DEBUG_WARN("Reset seem to be stuck low!\n");
2021-06-03 12:52:07 +02:00
Björn Mellström 04eab8e1f8 Add guard around _GNU_SOURCE define
This avoids warnings if the define has already been set by the
build system.
2021-06-03 12:51:27 +02:00
Uwe Bonnes 2a0d608b07 hosted: Fix last commit
-Wno-format-truncation may not be understood by all systems
2021-06-01 18:42:37 +02:00
Uwe Bonnes 1b49823f64 Fix hosted compile on MacOS. hidapi-libusb has a different name 2021-06-01 16:58:25 +02:00
Uwe Bonnes de83dbb7e2 cl-utils: Fix bug introduced with 5288eef617
Always use the file size for write and verify.
2021-06-01 16:23:19 +02:00
Uwe Bonnes c0437e7b25 bmp_serial: Autodetect more BMP string variants. 2021-06-01 16:23:19 +02:00
Uwe Bonnes 891633322a lpc: Care for protected pages on LPC80x devices. 2021-06-01 16:23:19 +02:00
Uwe Bonnes f7b4697280 lpc11xx/lpc8c04: Do not expose two top system flash sectors. 2021-06-01 16:23:19 +02:00
Uwe Bonnes 42ebcac329 efm32_devices: Rearrange struct efm32_device_t to save flash space. 2021-06-01 16:23:19 +02:00
Uwe Bonnes 21a702dc1e lpc: More verbosity and more definitions 2021-06-01 16:23:19 +02:00
Uwe Bonnes 6454d0bc96 bmp_libusb: Invalidate manufacturer and product in case libusb_get_string_descriptor_ascii fails.
Prevent more false detections
2021-05-20 12:06:56 +02:00
Uwe Bonnes 7f1a560288 stm32/usbuart: Clear USART_ICR if provided.
Otherwise endless interrupts happened.
2021-05-20 12:06:56 +02:00
Uwe Bonnes 90534b3cf6 stm32: portability enhancements
Needed for e.g. stlinkv3
2021-05-20 12:06:56 +02:00
Uwe Bonnes 87acd99fe4 cortexm: For Cortex-M0+ devices, probe also for lpc11 to detect LPC80 #884 2021-05-18 12:24:00 +02:00
Uwe Bonnes cb4cff2c71 hosted/ftdi: Compare only for length of the string given in the header
Devices may have added version like "Tigard V1.1" vs "Tigard"
2021-05-18 12:24:00 +02:00
Uwe Bonnes c3fd198f0d bmp_libusb: Reject non-BMP devices with VID 1d50. 2021-05-18 12:24:00 +02:00
Uwe Bonnes 36ad6efc6f cmsis_dap.h: Fix wrong leftover argument. 2021-05-16 17:17:33 +02:00
Uwe Bonnes f0dd8c9517 cl_utils: List -l option in the help. 2021-05-16 17:17:33 +02:00
Uwe Bonnes 517d5b5b31 rp: Show spinner only when called from monitor command. 2021-05-16 11:26:14 +02:00
James Turton 0ab10fee0b rp: Increase timeout for flash_range_program
If the RP2040 is using the ring oscilator (ROSC) rather than the crystal
oscilator (XOSC) then flashing program will take much longer. As the XOSC is not
enabled at boot we should not assume it will be enabled before the debugger is
connected (or indeed at all), thus should use the longer timeout during load
commands.
2021-05-16 11:26:14 +02:00
James Turton ff30259354 rp: Add more debug logging during flash 2021-05-16 11:26:14 +02:00
James Turton e453740aca rp: Increase spinner timeout to 500ms
Increasing spinner timeout to 500 means `tc_printf` is not called during
the `_flash_range_erase`. This is important as `_flash_range_erase` is
used when loading. This fixes the issue:
https://github.com/blacksphere/blackmagic/issues/875
Also adding spinner timeout counter to reduce bus traffic.
2021-05-16 11:26:14 +02:00
James Turton 67c9003522 rp: Flush cache after erase and write
The RP2040 datasheet suggests that _flash_flush_cache and _flash_enter_cmd_xip
should be called after erasing and writing to flash.
2021-05-16 11:26:14 +02:00
James Turton f880734050 Fix compiling for native probe 2021-05-16 11:26:14 +02:00
Uwe Bonnes e4421799ba More header cleanup 2021-05-15 12:54:51 +02:00
Uwe Bonnes 8e438b9e5f Add missing headers and remove double typedef. 2021-05-14 19:58:16 +02:00
Uwe Bonnes cfbe9f1c94 pc/gdb_if.c: More verbosity for Error messages #873
Thanks to "pshri" for dissecting and adding messages, as  problems with
Hpyer-V and port permissions happened on Win10
2021-05-09 11:49:32 +02:00
Vegard Storheil Eriksen f121350fc9 hosted/cmsis_dap: Verify that a v2 interface has endpoints. 2021-04-27 11:39:43 +02:00
Vegard Storheil Eriksen 494524dd85 hosted/cmsis_dap: Add v2 support. 2021-04-27 10:26:06 +02:00
Vegard Storheil Eriksen 4f52a7b235 hosted/cmsis_dap: Add discovery by interface string and prepare for v2 support. 2021-04-26 21:56:24 +02:00
Vegard Storheil Eriksen c4874fdf44 hosted/dap: Add parentheses around bitwise operator. 2021-04-26 21:54:38 +02:00
Uwe Bonnes f9414d5826 cmsis-dap: Handle ADI DP22 devices on probes not multidrop capable. 2021-04-26 18:18:18 +02:00
Uwe Bonnes 923edc7f7e cmsis-dap: Fix wrong handling when reading data not word-aligned 2021-04-26 15:08:09 +02:00
Uwe Bonnes 877a6e694c Revert "cmsis_dap: Always write full reportsize + 1 buffers"
This reverts commit 61e237ec87.
This makes a CMSIS-DAP probe with version < 1.2 work again on DP V1 devices.
Status of other combination unknown:
    DP  V1 V2 V2/Multidrop
Probe
<  1.2  ok ok --
>= 1.2   ? ?  ?
2021-04-25 22:53:40 +02:00
Uwe Bonnes 1f67bab475 nxpke04: Move unsafe_enables to target bool union. 2021-04-25 16:03:23 +02:00
Uwe Bonnes f87dff8d83 kinetis: Remove static variables, add word union to target_s.
Add a word union to target structure to hold a single word variable.
2021-04-25 16:03:23 +02:00
Uwe Bonnes ac7c1057cc efm32/samd/samx5x: Remove static allocates strings. Allocate in priv_storage.
Static allocated variables in the different targets eat up common RAM and
will collide in chains with multiple similar targets.
2021-04-25 16:03:23 +02:00
Uwe Bonnes cddf02f174 samx5: Verbose error reports on protected devices. 2021-04-25 16:03:23 +02:00
Uwe Bonnes 8c8aa980cf adiv5: Detect unprotected SAMD5x only once 2021-04-25 16:02:20 +02:00
Uwe Bonnes f98b7274b4 hosted/stlinkv3: Detect STlinkV3 in bootloader mode. 2021-04-25 16:02:20 +02:00
Uwe Bonnes a83700d1cf stm32/usbuart: DMA stream handling is not STM32F4 specific 2021-04-25 16:02:20 +02:00
Uwe Bonnes 1330288271 firmware: Unify serial number handling
Use one file in dfu and server
For STM32, provide 3 ways to handle
- BMP way (8 bytes)
- DFU way (12 Bytes)
- Full unique id (24 Bytes), as with STLINK(V3) Bootloader
2021-04-25 16:02:20 +02:00
Uwe Bonnes 1b26ff560d rp.c: Add reset_usb_boot as monitor command 2021-04-24 14:48:58 +02:00
Uwe Bonnes 52bffa70cf rp: Handle flash.
- Beware, after reset, only a valid flash payload get mapped to XIP!
  Only 0 is read from flash when flash image is not valid
2021-04-21 21:55:03 +02:00
Uwe Bonnes 2b0e255c40 cortexm: timeout and debug for run_stub() 2021-04-21 21:50:38 +02:00
Uwe Bonnes 61efe26348 swdp_scan: Break infinite loop after Dormant->SWD transition. 2021-04-21 21:50:38 +02:00
Uwe Bonnes fa5e69e3be RP 2040: Special handling for rescue DP
As the rescue DP provided no AP, trigger the reset with attach().
However attach will indicate failure also reset/halt has succeeded.
2021-04-21 21:50:38 +02:00
Uwe Bonnes ea92c8b8c8 cmsis-dap: Allow to use adiv5_swdp_scan. 2021-04-21 21:50:38 +02:00
Uwe Bonnes 23f942ac8c Raspberry RP2040: Recognize. No flash handling yet. 2021-04-21 21:50:35 +02:00
Uwe Bonnes 04d1c9805b swd: Remove swd_proc and swdptap.h. 2021-04-21 21:50:04 +02:00
Uwe Bonnes b6fbf86743 Extend ADIv5_DP_t for low level routines needed for multi-drop.
Will replace swd_proc
2021-04-21 21:50:04 +02:00
Uwe Bonnes 61e237ec87 cmsis_dap: Always write full reportsize + 1 buffers
Expect short reads and other errors else
2021-04-21 21:50:04 +02:00
Uwe Bonnes d6ade4d94e cmsis-dap: Use SWD_SEQUENCE if available. 2021-04-21 21:50:04 +02:00
Uwe Bonnes 5abb288c7a hosted: Provide the DP functions in swd_proc. 2021-04-21 21:50:04 +02:00
Uwe Bonnes fa561c8d66 adiv5_swdp: Starting point to handle multi-drop
- RP2040 show both DPs
- Multidrop test with STM32L552 and STM32H745 allows selection
  with "-m 0x4500041" (H7), "-m 1" (L552) or "-m 0x01002927" (RP2040)
2021-04-21 21:50:04 +02:00
Uwe Bonnes be3bfc48a8 cortexm: M33 has up to 8 hardware breakpoints 2021-04-21 21:22:59 +02:00
Uwe Bonnes b1ac4187b9 Fix some formatting strings for 32-bit compile 2021-04-21 21:22:59 +02:00
Uwe Bonnes 637d76b585 cl_utils.c: Try jtag scan if swd scan did not give results. 2021-04-21 21:22:59 +02:00
Uwe Bonnes 5288eef617 cl_utils: With no size given, read the size of the lowest block. 2021-04-20 18:48:27 +02:00
Fabio Baltieri beaccf2714 target: stm32l4: add support for STM32WLxx
This adds support for the STM32WL series in stm32l4.c. These parts have
the same flash registers layout as the L4 series, but a different base.
Since there are already two sets of registers in this target file, this
adds support for register maps that can be customized for each device
ID.
2021-04-20 18:42:36 +02:00
Uwe Bonnes 21b80949ff Compile with -Os as default. Change like "make OPT_FLAGS=..."
SWD/JTAG Bitbang is compiled with -O3 for good bitbang speed.
2021-04-20 18:20:41 +02:00
Fabio Baltieri f55ad67b1b adiv5: catch timeout on adiv5_ap_read_id and abort
This adds a TRY_CATCH around the adiv5_ap_read_id() in
adiv5_component_probe() and resets the DP when that happens.
It seems like the STM32WLE5 comes with the AP of the inactive core
enabled in a way that does not make it detectable, and the current code
times out and leaves the whole device hanging.

Catching the timeout and calling adiv5_dp_abort() seems to restore the
device to a useable state.

Tested on Seed LoRa-E5 (STM32E5JC).
2021-04-19 16:57:13 +02:00
Vestrel 806787529f Use DMA for USBUSART TX/RX 2021-04-17 17:57:08 +02:00
Uwe Bonnes cf5b4afb38 bmp_serial/linux: Honor opt_list_only (-l). 2021-04-17 16:19:57 +02:00
fabalthazar d6b24c00c8 Fixed STM32G43x/G44x option bytes support
Previously took L4 values so FLASH_SEC1R was not applied
2021-04-17 14:44:30 +02:00
fabalthazar 99f9557cc0 Support for STM32G49x/G4Ax (category 4) 2021-04-17 14:44:30 +02:00
fabalthazar c85c946ce3 PRIx32 fix 2021-04-17 14:44:30 +02:00
Stoyan Shopov 9ec7d05d8d Put null terminating characters when scanning for BMP probes on linux
This patch puts null terminating characters for the 'type',
'version', and 'serial' strings extracted from blackmagic probe
id strings on linux systems.
2021-04-17 14:41:28 +02:00
Uwe Bonnes 299da8627c libftdi: Remove unneeded explicit path. 2021-04-17 13:35:21 +02:00
Uwe Bonnes a6a8606edb STM32L55: Detect, memory map, read and flash write. Options handling missing.
Only non-secure states considered!
2021-04-04 17:26:31 +02:00
fabalthazar 739941dc5f Verify right after programming 2021-03-31 13:06:52 +02:00
fabalthazar 2982888b66 BMP_MODE_FLASH_WRITE_VERIFY combined operation 2021-03-31 12:07:53 +02:00
fabalthazar f85c54be97 Prepared -w option 2021-03-31 12:07:53 +02:00
fabalthazar 6d6cfd6c98 Comprehensive STM32G03/4/5/6/7/8/B/C driver 2021-03-29 21:42:40 +02:00
Uwe Bonnes 58f153e12b cortexm: Always halt and release reset before romtable scan
Only release from halt once after romtable scan
Should fix #836.
2021-03-26 17:43:11 +01:00
Uwe Bonnes a025c9a7bd Revert "stm32f1: On ST parts there is no need to read IDCODE again."
Romtable partno is not unique for devices, e.g. in STM32F0
This reverts commit f89b07d892.
2021-03-26 17:35:00 +01:00
Uwe Bonnes f89b07d892 stm32f1: On ST parts there is no need to read IDCODE again.
IDCODE is already known from the Romtable
Probably this has the same effect as #836
2021-03-12 20:45:34 +01:00
Uwe Bonnes e6a9a1a366 cmsis-dap: Get the firmware version. 2021-03-06 13:30:09 +01:00
Uwe Bonnes 7859a2aabd adiv5_swd: Factor out creation of packet request. 2021-03-06 13:30:09 +01:00
Uwe Bonnes cfb784d428 adiv5: Fix comments and debug output 2021-03-05 16:49:19 +01:00
Uwe Bonnes 3aa6f16964 serial_unix: Split timeout in seconds and microseconds
Macos exposed errors when tv_usec was > 1000000.
2021-03-05 16:49:19 +01:00
Uwe Bonnes 43770736f1 cl_utils: Rework Flash/Ram printout 2021-03-05 16:49:19 +01:00
Thiadmer Riemersma 560a046a22 Add support for NXP LPC802, LPC804, LPC832 and LPC834 2021-02-22 19:37:46 +01:00
Uwe Bonnes 0df44e205b ADIv5: Abort Romtable scan also if CIDR0 is invalid after halting #832
STM32WLE5 has the same dual core chip as STM32WL5. For the second
core, the additional AP can be see, but access to e.g. CIDR0 for that
Romtable fails.
Aborting the scan too if again the second read of CIDR0 fails makes
sense anyways!
2021-02-19 18:48:02 +01:00
Uwe Bonnes d70fa8c7f6 hosted: Remove restrictions when gathering information on the debugger
That way, we find RPI Pico pico-debug.
2021-02-15 17:47:29 +01:00
Uwe Bonnes c776e7a9a6 swd_scan: Add '-m' as targetid argument to swd_scan to prepare multi-drop.
In a real multi-drop setup, the device to use must be specified.
2021-02-15 17:47:29 +01:00
Uwe Bonnes 8e2f6937d5 hosted: Run target specific monitor commands with -M "command" .
Lists available commands: "blackmagic -M help"
Quote multi argument monitor commands, e.g. STM32F1: blackmagic -M "option help"
2021-02-15 17:47:29 +01:00
Uwe Bonnes 165560edd8 cl_utils: target selection '-n' argument needs optarg.
foreach now returns the number of targets.
2021-02-15 17:47:29 +01:00
Uwe Bonnes 4eb336277c native: Remove high current draw (#814)
Special iRST_SENSE handling does not apply at least for BMP 2.1c.
On V2.1c, iRST_SENSE was set as output high and xRST high shorted
iRST_SENSE to ground via Q2
FIXME: Check for older versions!
2021-02-15 15:00:19 +01:00
Martin 3b8502c2e5 add space in USB product string (be consistent with ../stm32/dfucore.c)
This changes the USB identification from
"Black Magic Probe(STLINK/V2) v..." to
"Black Magic Probe (STLINK/V2) v..."

Signed-off-by: Martin <Ho-Ro@users.noreply.github.com>
2021-01-29 14:47:28 +01:00
Martin d4dc3b2717 The USB CDC is no modem and does not use the AT protocol
Signed-off-by: Martin <Ho-Ro@users.noreply.github.com>
2021-01-29 14:47:28 +01:00
Alex Norman 42f590ce0b fixing some memory map errors for stm32h7, PR #821 2020-12-23 20:10:39 +01:00
Uwe Bonnes 09c000eca8 hosted: Really handle setting tpwr on remote on the command line #817
Expect the command to fail, due to old firmware or remote not implementing
the power switch.
2020-12-19 16:36:09 +01:00
Sean Cross 2b06f045c4 target: kinetis: add S32K148
This adds support for the NXP S32K148. This is an automotive-grade part
that is derived from the Kinetis line, so it has a very similar
interface to other parts in the family.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-16 12:49:23 +01:00
Sean Cross 5f76169b95 hosted: remove ftdi include when built with BMP_ONLY #811
Signed-off-by: Sean Cross <sean@xobs.io>
2020-12-16 11:30:42 +01:00
Uwe Bonnes 98c92a6d18 hosted: Really fix the case of no serial number (#807) 2020-12-13 14:12:05 +01:00
UweBonnes aa0d8f4b5d
Merge pull request #783 from UweBonnes/frequency
Frequency
2020-12-12 19:50:53 +01:00
Noah Pendleton 020600aa56 target/lpc546xx: fix lpc546xx flash support (#801)
**Summary**
Modifications to fix flash support on the lpc546xx:

- fix IAP entrypoint to be `0x03000204`, not the value at that address
- add a reset and attach sequence before erasing flash sectors. there's
little documentation around this, but experimentally, erasing sector 0
fails when the ROM bootloader is mapped to it (on reset). stepping the
chip once and attaching is enough to snap the chip out of it, permitting
flash erase on sector 0.
- add a few test commands to the lpc546xx table (read_uid, erase/write
sector, etc).
- write the magic CRC value when writing to sector 0
(`lpc_flash_write_magic_vect`).
- move the lpc546xx probe to before the lpc43xx probe, to prevent
getting the lpc546xx into Lockup when reading an illegal memory location
during lpc43xx probing

Fixes #786.

I don't 100% understand the reset/load sequence of this part, but these
changes are sufficient to program and debug the part now.

I didn't do a detailed analysis of what pyocd (via st-link hardware
adapter) and segger jlink do to handle the same, but both of those
worked without modification, so there's some difference in the
sequence they're using.

**Testing**
Verified I can now successfully erase and write an executable in sector
0 (and other sectors).
Verified the new commands work correctly.
2020-12-12 19:48:05 +01:00
Uwe Bonnes 6dbb5ff7ee Frequency: Implementing for jlink.
SWD frequency is fixed for jlink according to the docs from 2010.
2020-12-12 18:33:09 +01:00
Uwe Bonnes fdc654cfb3 stlink: Implementation of frequency setting. 2020-12-12 18:33:09 +01:00
Uwe Bonnes de26ba6f73 hosted: Add is_jtag to the info structure
Needed for different frequency setting procedures on some platforms.
2020-12-12 18:33:09 +01:00
Uwe Bonnes 28a966a3e6 frequency: Implement for ftdi.
For all 2232H types, use undivided 60 Mhz.
FIXME: Check FT2322C/D for unsymetric clock at 6 MHz!
2020-12-12 18:33:09 +01:00
Uwe Bonnes 13e8a262e4 SWJ Frequency: Implement for cmsis-dap 2020-12-12 18:33:09 +01:00
Uwe Bonnes 1ca9f234f7 Infrastructure for setting maximum SWJ frequency.
Implement for BMP/firmware on STM32.
2020-12-12 18:33:09 +01:00
Uwe Bonnes 7365a44989 hosted: Implement SWJ test mode (-T).
Continious read/write-back some core register as NOP operation to allow scope
measurement of SWJ timing.
2020-12-12 18:33:09 +01:00
Uwe Bonnes f796b774bd hosted: Fix info.serial if USB device has no serial number #807 2020-12-12 18:32:15 +01:00
Aaron Lindsay 518529a772 Support GD32E23x 2020-12-12 18:29:30 +01:00
Uwe Bonnes 14498decd9 HOSTED_BMP_ONLY/linux: Fix case when no serial device is connected #806 2020-12-12 15:06:26 +01:00
Noah Pendleton 93d4c65948 Fix building with newer GNU make(#804)
More recent versions of GNU make remove the `-` prefix from
`$(MAKEFLAGS)`, which breaks the build:

```bash
 # output truncated to interesting parts
> make -C src --trace all_platforms
set -e ;\
mkdir -p artifacts/v1.7.1-91-g98b4ec5 ;\
echo "<html><body><ul>" > artifacts/index.html ;\
for i in platforms/*/Makefile.inc ; do \
        ...\
        make w --trace --no-print-directory clean ;\
        make w --trace --no-print-directory;\
        ...\
done ;\
echo "</ul></body></html>" >> artifacts/index.html ;\
cp artifacts/*.bin artifacts/v1.7.1-91-g98b4ec5
Building for hardware platform: f4discovery
make[1]: *** No rule to make target 'w'.  Stop.
```

Per the
[documentation](https://www.gnu.org/software/make/manual/html_node/Options_002fRecursion.html),
there's no need to manually apply insert `$(MAKEFLAGS)`, it should be
automatically included when using `$(MAKE)` when recursing.

I tested on my machine (make 4.2.1) and a docker image based on
ubuntu:trusty (make 3.81), both behaved the same (directories were not
printed when recursing by default);
2020-12-12 14:39:52 +01:00
Stoyan Shopov b5172cf6df Implement the 'find_debuggers()' function for hosted BMP on windows. 2020-12-11 18:36:48 +01:00
Stoyan Shopov 01f8628aed Bugfix in detecting BMP probes by usb serial number. 2020-12-11 18:36:48 +01:00
Stoyan Shopov 170fe0c368 Remove spurious comment. 2020-12-11 18:36:16 +01:00
Uwe Bonnes 4c5ce0b16a Hosted: Handle devices w/o serial number, e.g. GigaDevices GD-Link ARM/CMSIS-DAP 2020-12-11 18:36:16 +01:00
Uwe Bonnes 0f1fe9e438 hosted/linux: Find BMP devices without libusb. 2020-12-11 18:36:09 +01:00
Uwe Bonnes bd5f4c6ed5 hosted: Consolidate ident output. 2020-12-11 17:55:31 +01:00
Uwe Bonnes 0870b778c0 hosted: Allow to build without libusb, libftdi and hidapi with HOSTED_BMP_ONLY=1 2020-12-11 17:50:16 +01:00
Uwe Bonnes 32db38ecf2 hosted/libusb: Move platform.c libusb related functions to own file. 2020-12-11 17:35:43 +01:00
Uwe Bonnes 41788f923b ftdi/stlink/jlink: Provide dummy functions in the HOSTED_BMP_ONLY case
Do not allow multiple inclusion by not declaring the functions as static to
help keep code clean.
2020-12-11 17:31:25 +01:00
Uwe Bonnes 98b4ec58bc Update to recent libopencm3 to undo unwanted change. 2020-12-07 21:51:22 +01:00
Emilio Lopes 633c6a2e81 Recognize "J-Trace Cortex-M PRO V2" in hosted mode 2020-12-07 11:52:33 +01:00
Uwe Bonnes 17dfec3572 dfu/cdcacm: Consolidate usage of ST vs BMP serial number. 2020-12-06 15:18:08 +01:00
Uwe Bonnes 5c7e0eedb0 command.c: Consolidate "mon version" output 2020-12-06 15:18:08 +01:00
Uwe Bonnes 07c3699225 version.h: Remove from platform.h files
- Consolidate ident string generation
- Recompile only needed files
2020-12-06 15:18:08 +01:00
Uwe Bonnes dd6aadc54d jtag: Add verbosity about devices found. 2020-12-06 15:18:08 +01:00
Uwe Bonnes 0a7bfd5923 dfu_f4: Fix sector_erase. 2020-12-06 15:18:08 +01:00
Stoyan Shopov e318f884bf Change the type of 'cortexm_wait_timeout' to unsigned.
It makes sense that the timeout value is unsigned, it also
resolves build errors on some platforms.
2020-12-04 11:44:50 +01:00
Stoyan Shopov c9a419e44b Correct loss of sync protocol error #787 2020-12-04 11:33:23 +01:00
mean e3fd12ebc6 gd32f1/f3 detection and ram/flash autoset 2020-12-03 11:16:47 +01:00
Jonathan Giles 575c25e570 Add support for STM32F1 clone with new AP_DESIGNER id 2020-12-01 10:23:16 +01:00
Uwe Bonnes 48a79ff9da adiv5: More checks for a sensible DPIDR. 2020-11-29 21:11:11 +01:00
Uwe Bonnes 752bc26536 adiv5: Fix memleak with duplicated base. 2020-11-29 21:11:11 +01:00
Uwe Bonnes acec489647 adiv5_jtagdp: Always set idcode. 2020-11-29 21:11:11 +01:00
Uwe Bonnes 9e1b7fdac0 jlink/swd_low_access: Fix data direction during response read phase. 2020-11-29 15:48:50 +01:00
Uwe Bonnes 8903026c14 jlink/swd: swd frequency is fixed, not need to set. 2020-11-29 15:48:50 +01:00
Uwe Bonnes f45c56af83 adiv5/swdp: Check early for valid DP idcode. 2020-11-29 15:48:50 +01:00
Uwe Bonnes 3b6432912d jlink: Catch another error with no target connected. 2020-11-29 15:48:50 +01:00
Uwe Bonnes 7df314e265 Firmware/Jlink: Fix double free when debug power-up fails (#780) 2020-11-29 15:48:50 +01:00
Uwe Bonnes e1329499de platform_adiv5_swdp_scan: Do not double free with early errors.
adiv5_dp_init() clean up itself if errors happen
2020-11-29 15:48:50 +01:00
Uwe Bonnes bf548e92c0 swd: After write low_access, always append 8 clk to move data through SW-DP.
Especially needed when leaving the debugger or during debug unit power-up.

ARM Debug Interface Architecture Specification ADIv5.0 to ADIv5.2
tells to clock the data through SW-DP to either :
- immediate start a new transaction
- continue to drive idle cycles
- or clock at least 8 idle cycles

Implement last option to favour correctness over slight speed decrease

Implement only for adapters where we assemble the seq_out_parity in our code,
as on firmware, ftdi and jlink. Hopefully the high level adapters do it right.

Reverts 2c33cde63f and
cde7726b87
2020-11-27 22:26:48 +01:00
Uwe Bonnes 139e5d7e22 f4discovery: Compile time option to compile with ST bootloader
Just to keep things active. Prepare for F72 bootloader.
2020-11-27 22:26:48 +01:00
Uwe Bonnes 636bcee355 stlink/swlink: Remove the DFU upgrade utility.
Hopefully no old bootloaders are around. If otherwise, revert to last
commit before this and update the DFU bootloader.
2020-11-27 22:26:48 +01:00
Uwe Bonnes 27ef4569ca stm32/dfucore.c: Use libopencm3 provided defines and functions. 2020-11-27 22:26:48 +01:00
Uwe Bonnes 9d55128ab8 cl_utils: Get voltage only once. 2020-11-27 22:26:48 +01:00
Uwe Bonnes e6823f39de Hosted: Print version with "-h" and "-t" option. 2020-11-27 22:26:48 +01:00
Uwe Bonnes 3ee31473c6 cortexm.c: LPC15xx has designer 43b and Partno 4c3
Thanks to JojoS!
2020-11-27 22:26:48 +01:00
Uwe Bonnes 62d9f60f03 hosted/firmware: Waits for read response as long as cortexm_wait_timeout. 2020-11-27 22:26:48 +01:00
Uwe Bonnes 26a23dd1cb stlinkv2: Try harder to open an AP.
Problem seen on STM32L0 with probably long sleep periods.
2020-11-27 22:26:48 +01:00
Uwe Bonnes 19e1fddba2 adiv5: Remove unnescessary read. 2020-11-27 22:26:48 +01:00
Uwe Bonnes cda83d3084 Fix memleaks.
Happened e.g. when Stlink could not enter debug or when cortexm_prepare timed out.
2020-11-27 22:26:48 +01:00
Uwe Bonnes 9ac5adfcef adiv5: Additional decoding. 2020-11-27 22:26:48 +01:00
Uwe Bonnes d78d7838d3 stm32f1: Always read DBGMCU_IDCODE for t->idcode (#770)
At least STM32F042 has 0x440 as romtable partno vs 0x445 as DBGMCU_IDCODE.
Thanks to Andrey Melnikov(aam335) for pointing out!
2020-11-27 22:26:48 +01:00
Uwe Bonnes 653d486ee2 cortexm: Store CPUID in target structure. 2020-11-27 22:26:48 +01:00
Uwe Bonnes 824a1d8abc hosted/find_debuggers: Do not check hubs. Print class of devices unable to open. 2020-11-27 22:26:48 +01:00
Uwe Bonnes e68dd25813 cl_utils: Clarify -d option is BMP/firmware only and deprecate -d. 2020-11-27 22:26:48 +01:00
Uwe Bonnes f71e18948a GPIO for SWD: Slow down edges on more platforms. 2020-11-27 22:26:48 +01:00
Uwe Bonnes 80154c5c7a adiv5_swdp: Fix more memory leak. 2020-11-27 22:26:48 +01:00
Noah Pendleton 35bcb4f7c6 Switch on the lpc546xx target
Enable the lpc546xx target. Tested on the LPCXpresso54628 dev board,
able to flash and debug.
2020-11-24 21:32:39 +01:00
Sean Cross e9c02296f2 target: kinetis: add S32K118
This adds support for the NXP S32K118. This is an automotive-grade part
that is derived from the Kinetis line, so it has a very similar
interface to other parts in the family.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-11-14 13:06:23 +01:00
jbuonagurio f18be6ef7a Add support for Kinetis K12 and placeholders for other K-series MCUs 2020-11-07 12:44:05 +01:00
Uwe Bonnes 2c33cde63f cortexm.c/cortexm_halt_resume: Add some clock cycles to always get CPU going (#768) 2020-11-01 21:53:23 +01:00
Uwe Bonnes d75f3124b9 ftdi_bmp.c: Reapply fix from #715: Check for libftdi 1.5 2020-11-01 12:09:27 +01:00
Stoyan Shopov 99142d1c0e Add documentation details for building PC-hosted BMP in msys2. 2020-11-01 11:33:54 +01:00
Uwe Bonnes 1f7a716710 adiv5.c: Run cortexm_prepare on all suspected CortexM instances.
Gets all debug units of the second CPU of a STM32H745 visible.
2020-10-23 09:40:15 +02:00
Uwe Bonnes 18673d9a56 adiv5: Rework DP/AP refcounting.
ASAN non longer reports leaks with the STM32H745.
2020-10-23 09:40:15 +02:00
Uwe Bonnes f76a7c4e92 adiv5: Release devices after scan.
Before, scanning only kept device stopped until POR or attach/detach cycle.
2020-10-23 09:40:15 +02:00
Uwe Bonnes 73e6b540b2 command: When debug channel is available, print morse messages readable. 2020-10-23 09:40:15 +02:00
Uwe Bonnes 776861c6a0 Makefile: Fix version.h generation for make all_platforms
Same fix as 0ae65cc10f.
2020-10-23 09:40:15 +02:00
Uwe Bonnes 80ddafc2f8 Jtag/High Level : Transfer dp->dp_jd_index with every HL command.
- Add REMOTE_HL_VERSION, now at 1. Fall back to hosted/low-level
  when wrong version is found and give hint to user.
2020-10-23 09:40:15 +02:00
Uwe Bonnes 59dc1b7eb4 cortex-m7: Give hint about buggy core revision. 2020-10-23 09:40:15 +02:00
Uwe Bonnes 976c763747 jtag remote: Start fixing handling M0 (second jtag) for LPC4322 in high-level
- LPC11: Only print none-null unknown idcodes.
2020-10-23 09:40:15 +02:00
Uwe Bonnes 0995fe1288 cmsis-dap: Various fixes
- decrease report size to 64, otherwise MIMRXT10x0-EVK crashed when
  reading larger memory block
- dp_read_reg acts direct, fixing CortexM core register read.
- length of data to write with read_block.
2020-10-23 09:40:15 +02:00