Skip to content

Commit fb65ae5

Browse files
committed
jtag_scan: split out jtag_discover()
This function will be used to re-discover JTAG devices without performing a JTAG reinit. Signed-off-by: Sean Cross <[email protected]>
1 parent cf0960e commit fb65ae5

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/include/target.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ bool bmda_rvswd_scan(void);
5555
bool adiv5_swd_scan(void);
5656
bool adiv5_swd_scan_targetid(uint32_t targetid);
5757
bool jtag_scan(void);
58+
bool jtag_discover(void);
5859
bool onboard_flash_scan(void);
5960

6061
size_t target_foreach(void (*callback)(size_t index, target_s *target, void *context), void *context);

src/target/jtag_scan.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ void jtag_add_device(const uint32_t dev_index, const jtag_dev_s *jtag_dev)
7676
*/
7777
bool jtag_scan(void)
7878
{
79-
/* Free the device list if any, and clean state ready */
80-
target_list_free();
81-
82-
jtag_dev_count = 0;
83-
memset(&jtag_devs, 0, sizeof(jtag_devs));
84-
8579
/*
8680
* Initialise the JTAG backend if it's not already
8781
* This will automatically do the SWD-to-JTAG sequence just in case we've got
@@ -99,6 +93,17 @@ bool jtag_scan(void)
9993

10094
/* Reset the chain ready */
10195
jtag_proc.jtagtap_reset();
96+
return jtag_discover();
97+
}
98+
99+
bool jtag_discover(void)
100+
{
101+
/* Free the device list if any, and clean state ready */
102+
target_list_free();
103+
104+
jtag_dev_count = 0;
105+
memset(&jtag_devs, 0, sizeof(jtag_devs));
106+
102107
/* Start by reading out the ID Codes for all the devices on the chain */
103108
if (!jtag_read_idcodes() ||
104109
/* Otherwise, try and learn the chain IR lengths */

0 commit comments

Comments
 (0)