libftfdi: Allow to specify external resistor SWD connection.
More explanations in src/platforms/hosted/Readme.md
This commit is contained in:
parent
eabf45357d
commit
aff624b6e0
@ -13,19 +13,51 @@ connect to the BMP with the CDCACM GDB serial server. GDB functionality
|
|||||||
is the same, monitor option may vary.
|
is the same, monitor option may vary.
|
||||||
|
|
||||||
More arguments allow to
|
More arguments allow to
|
||||||
### print information on the connected target "blackmagiv -t"
|
### Print information on the connected target
|
||||||
### directly flash a binary file at 0x0800000 "blackmagic <file.bin>"
|
```
|
||||||
|
blackmagic -t
|
||||||
|
```
|
||||||
|
### Directly flash a binary file at lowest flash address
|
||||||
|
```
|
||||||
|
blackmagic <file.bin>
|
||||||
|
```
|
||||||
or with the -S argument at some other address
|
or with the -S argument at some other address
|
||||||
### read flash to binary file "blackmagic -r <file>.bin
|
```
|
||||||
### verify flash against binary file "blackmagic -V <file>.bin
|
blackmagic -S 0x08002000 <file.bin>
|
||||||
|
```
|
||||||
Use "blackmagic -h" to see all options.
|
|
||||||
|
|
||||||
|
### Read flash to binary file
|
||||||
|
```
|
||||||
|
blackmagic -r <file>.bin
|
||||||
|
```
|
||||||
|
### Verify flash against binary file
|
||||||
|
```
|
||||||
|
blackmagic -V <file>.bin
|
||||||
|
```
|
||||||
|
### Show more options
|
||||||
|
```
|
||||||
|
blackmagic -h"
|
||||||
|
```
|
||||||
## Used libraries:
|
## Used libraries:
|
||||||
### libusb
|
### libusb
|
||||||
### libftdi, for FTDI support
|
### libftdi, for FTDI support
|
||||||
### hidapi-libusb, for CMSIS-DAP support
|
### hidapi-libusb, for CMSIS-DAP support
|
||||||
|
|
||||||
|
## Compiling on windows
|
||||||
|
|
||||||
|
You can crosscompile blackmagic for windows with mingw or on windows
|
||||||
|
with cygwin. For compilation, headers for libftdi1 and libusb-1.0 are
|
||||||
|
needed. For running, libftdi1.dll and libusb-1.0.dll are needed and
|
||||||
|
the executable must be able to find them. Mingw on cygwin does not provide
|
||||||
|
a libftdi package yet.
|
||||||
|
|
||||||
|
To prepare libusb access to the ftdi device, run zadig https://zadig.akeo.ie/.
|
||||||
|
Choose WinUSB(libusb-1.0) for the BMP Ftdi device.
|
||||||
|
|
||||||
|
Running cygwin/blackmagic in a cygwin console, the program does not react
|
||||||
|
on ^C. In another console, run "ps ax" to find the WINPID of the process
|
||||||
|
and then "taskkill /F ?PID (WINPID)".
|
||||||
|
|
||||||
## Supported debuggers
|
## Supported debuggers
|
||||||
REMOTE_BMP is a "normal" BMP usb connected
|
REMOTE_BMP is a "normal" BMP usb connected
|
||||||
|
|
||||||
@ -39,6 +71,69 @@ REMOTE_BMP is a "normal" BMP usb connected
|
|||||||
| FTDI MPSSE | ++ | Requires a device descrition
|
| FTDI MPSSE | ++ | Requires a device descrition
|
||||||
| JLINK | - | Usefull to add BMP support for MCUs with built-in JLINK
|
| JLINK | - | Usefull to add BMP support for MCUs with built-in JLINK
|
||||||
|
|
||||||
|
## Device matching
|
||||||
|
As other USB dongles already connected to the host PC may use FTDI chips,
|
||||||
|
cable descriptions are provided to match with the dongle.
|
||||||
|
To match the dongle, at least USB VID/PID that must match.
|
||||||
|
If a description is given, the USB device must provide that string. If a
|
||||||
|
serial number string is given on the command line, that number must match
|
||||||
|
with serial number in the USB descriptor of the device.
|
||||||
|
|
||||||
|
## FTDI connection possibilities:
|
||||||
|
|
||||||
|
| Direct Connection |
|
||||||
|
| ----------------------|
|
||||||
|
| MPSSE_SK --> JTAG_TCK |
|
||||||
|
| MPSSE_DO --> JTAG_TDI |
|
||||||
|
| MPSSE_DI <-- JTAG_TDO |
|
||||||
|
| MPSSE_CS <-> JTAG_TMS |
|
||||||
|
|
||||||
|
\+ JTAG and bitbanging SWD is possible<br>
|
||||||
|
\- No level translation, no buffering, no isolation<br>
|
||||||
|
Example: [Flossjtag](https://randomprojects.org/wiki/Floss-JTAG).
|
||||||
|
|
||||||
|
| Resistor SWD |
|
||||||
|
|------------------------|
|
||||||
|
| MPSSE_SK ---> JTAG_TCK |
|
||||||
|
| MPSSE_DO -R-> JTAG_TMS |
|
||||||
|
| MPSSE_DI <--- JTAG_TMS |
|
||||||
|
|
||||||
|
BMP would allow direct MPSSE_DO ->JTAG_TMS connections as BMP tristates DO
|
||||||
|
when reading. Resistor defeats contentions anyways. R is typical choosen
|
||||||
|
in the range of 470R
|
||||||
|
|
||||||
|
\+ MPSSE SWD possible<br>
|
||||||
|
\- No Jtag, no level translation, no buffering, no isolation<br>
|
||||||
|
|
||||||
|
|Direct buffered Connection|
|
||||||
|
|--------------------------|
|
||||||
|
| MPSSE_SK -B-> JTAG_TCK |
|
||||||
|
| MPSSE_DO -B-> JTAG_TDI |
|
||||||
|
| MPSSE_DI <-B- JTAG_TDO |
|
||||||
|
| MPSSE_CS -B-> JTAG_TMS |
|
||||||
|
|
||||||
|
\+ Only Jtag, buffered, possible level translation and isolation<br>
|
||||||
|
\- No SWD<br>
|
||||||
|
Example: [Turtelizer]http://www.ethernut.de/en/hardware/turtelizer/index.html)
|
||||||
|
[schematics](http://www.ethernut.de/pdf/turtelizer20c-schematic.pdf)
|
||||||
|
|
||||||
|
The 'r' command line arguments allows to specify an external SWD
|
||||||
|
resistor connection added to some existing cable. Jtag is not possible
|
||||||
|
together with the 'r' argument.
|
||||||
|
|
||||||
|
### Many variants possible
|
||||||
|
As the FTDI has more pins, these pins may be used to control
|
||||||
|
enables of buffers and multiplexer selection in many variants.
|
||||||
|
|
||||||
|
### Reset, Target voltage readback etc
|
||||||
|
The additional pins may also control Reset functionality, provide
|
||||||
|
information if target voltage is applied. etc.
|
||||||
|
|
||||||
|
### Cable descriptions
|
||||||
|
Please help to verify the cable description and give feedback on the
|
||||||
|
cables already listed and propose other cable. A link to the schematics
|
||||||
|
is welcome.
|
||||||
|
|
||||||
## Feedback
|
## Feedback
|
||||||
### Issues and Pull request on https://github.com/blacksphere/blackmagic/
|
### Issues and Pull request on https://github.com/blacksphere/blackmagic/
|
||||||
### Discussions on Discord.
|
### Discussions on Discord.
|
||||||
|
@ -238,6 +238,22 @@ int ftdi_bmp_init(BMP_CL_OPTIONS_t *cl_opts, bmp_info_t *info)
|
|||||||
|
|
||||||
active_cable = &cable_desc[index];
|
active_cable = &cable_desc[index];
|
||||||
memcpy(&active_state, &active_cable->init, sizeof(data_desc_t));
|
memcpy(&active_state, &active_cable->init, sizeof(data_desc_t));
|
||||||
|
/* If swd_(read|write) is not given for the selected cable and
|
||||||
|
the 'r' command line argument is give, assume resistor SWD
|
||||||
|
connection.*/
|
||||||
|
if (cl_opts->external_resistor_swd &&
|
||||||
|
(active_cable->mpsse_swd_read.set_data_low == 0) &&
|
||||||
|
(active_cable->mpsse_swd_read.clr_data_low == 0) &&
|
||||||
|
(active_cable->mpsse_swd_read.set_data_high == 0) &&
|
||||||
|
(active_cable->mpsse_swd_read.clr_data_high == 0) &&
|
||||||
|
(active_cable->mpsse_swd_write.set_data_low == 0) &&
|
||||||
|
(active_cable->mpsse_swd_write.clr_data_low == 0) &&
|
||||||
|
(active_cable->mpsse_swd_write.set_data_high == 0) &&
|
||||||
|
(active_cable->mpsse_swd_write.clr_data_high == 0)) {
|
||||||
|
DEBUG_INFO("Using external resistor SWD\n");
|
||||||
|
active_cable->mpsse_swd_read.set_data_low = MPSSE_DO;
|
||||||
|
active_cable->mpsse_swd_write.set_data_low = MPSSE_DO;
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG_WARN("Black Magic Probe for FTDI/MPSSE\n");
|
DEBUG_WARN("Black Magic Probe for FTDI/MPSSE\n");
|
||||||
if(ftdic) {
|
if(ftdic) {
|
||||||
|
@ -135,6 +135,8 @@ static void cl_help(char **argv, BMP_CL_OPTIONS_t *opt)
|
|||||||
DEBUG_WARN("\t-C\t\t: Connect under reset\n");
|
DEBUG_WARN("\t-C\t\t: Connect under reset\n");
|
||||||
DEBUG_WARN("\t-t\t\t: Scan SWD or JTAG and display information about \n"
|
DEBUG_WARN("\t-t\t\t: Scan SWD or JTAG and display information about \n"
|
||||||
"\t\t\t connected devices\n");
|
"\t\t\t connected devices\n");
|
||||||
|
DEBUG_WARN("\t-e\t\t: Assume \"resistor SWD connection\" on FTDI: TDI\n"
|
||||||
|
"\t\t\t connected to TMS, TDO to TDI with eventual resistor\n");
|
||||||
DEBUG_WARN("\t-E\t\t: Erase flash until flash end or for given size\n");
|
DEBUG_WARN("\t-E\t\t: Erase flash until flash end or for given size\n");
|
||||||
DEBUG_WARN("\t-V\t\t: Verify flash against binary file\n");
|
DEBUG_WARN("\t-V\t\t: Verify flash against binary file\n");
|
||||||
DEBUG_WARN("\t-r\t\t: Read flash and write to binary file\n");
|
DEBUG_WARN("\t-r\t\t: Read flash and write to binary file\n");
|
||||||
@ -154,7 +156,7 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv)
|
|||||||
int c;
|
int c;
|
||||||
opt->opt_target_dev = 1;
|
opt->opt_target_dev = 1;
|
||||||
opt->opt_flash_size = 16 * 1024 *1024;
|
opt->opt_flash_size = 16 * 1024 *1024;
|
||||||
while((c = getopt(argc, argv, "Ehv:d:s:I:c:CnltVta:S:jpP:rR")) != -1) {
|
while((c = getopt(argc, argv, "eEhv:d:s:I:c:CnltVta:S:jpP:rR")) != -1) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
if (optarg)
|
if (optarg)
|
||||||
@ -177,6 +179,9 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv)
|
|||||||
case 'C':
|
case 'C':
|
||||||
opt->opt_connect_under_reset = true;
|
opt->opt_connect_under_reset = true;
|
||||||
break;
|
break;
|
||||||
|
case 'e':
|
||||||
|
opt->external_resistor_swd = true;
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
if (optarg)
|
if (optarg)
|
||||||
opt->opt_device = optarg;
|
opt->opt_device = optarg;
|
||||||
|
@ -42,6 +42,7 @@ typedef struct BMP_CL_OPTIONS_s {
|
|||||||
bool opt_tpwr;
|
bool opt_tpwr;
|
||||||
bool opt_list_only;
|
bool opt_list_only;
|
||||||
bool opt_connect_under_reset;
|
bool opt_connect_under_reset;
|
||||||
|
bool external_resistor_swd;
|
||||||
char *opt_flash_file;
|
char *opt_flash_file;
|
||||||
char *opt_device;
|
char *opt_device;
|
||||||
char *opt_serial;
|
char *opt_serial;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user