Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
jtag3.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int jtag3_open_common (PROGRAMMER *pgm, char *port)
 
int jtag3_send (PROGRAMMER *pgm, unsigned char *data, size_t len)
 
int jtag3_recv (PROGRAMMER *pgm, unsigned char **msg)
 
void jtag3_close (PROGRAMMER *pgm)
 
int jtag3_getsync (PROGRAMMER *pgm, int mode)
 
int jtag3_getparm (PROGRAMMER *pgm, unsigned char scope, unsigned char section, unsigned char parm, unsigned char *value, unsigned char length)
 
int jtag3_setparm (PROGRAMMER *pgm, unsigned char scope, unsigned char section, unsigned char parm, unsigned char *value, unsigned char length)
 
int jtag3_command (PROGRAMMER *pgm, unsigned char *cmd, unsigned int cmdlen, unsigned char **resp, const char *descr)
 
void jtag3_initpgm (PROGRAMMER *pgm)
 
void jtag3_dw_initpgm (PROGRAMMER *pgm)
 
void jtag3_pdi_initpgm (PROGRAMMER *pgm)
 
void jtag3_setup (PROGRAMMER *pgm)
 
void jtag3_teardown (PROGRAMMER *pgm)
 

Variables

const char jtag3_desc []
 
const char jtag3_dw_desc []
 
const char jtag3_pdi_desc []
 

Function Documentation

◆ jtag3_close()

void jtag3_close ( PROGRAMMER pgm)
1448{
1449 unsigned char buf[4], *resp;
1450
1451 avrdude_message(MSG_NOTICE2, "%s: jtag3_close()\n", progname);
1452
1453 buf[0] = SCOPE_AVR;
1454 buf[1] = CMD3_SIGN_OFF;
1455 buf[2] = buf[3] = 0;
1456
1457 if (jtag3_command(pgm, buf, 3, &resp, "AVR sign-off") >= 0)
1458 free(resp);
1459
1460 buf[0] = SCOPE_GENERAL;
1461 buf[1] = CMD3_SIGN_OFF;
1462
1463 if (jtag3_command(pgm, buf, 4, &resp, "sign-off") >= 0)
1464 free(resp);
1465
1466 if (pgm->flag & PGM_FL_IS_EDBG)
1468
1469 serial_close(&pgm->fd);
1470 pgm->fd.ifd = -1;
1471}
char * progname
Definition main.c:61
int avrdude_message(const int msglvl, const char *format,...)
Definition main.c:93
#define MSG_NOTICE2
Definition avrdude.h:53
void free(void *)
static int jtag3_edbg_signoff(PROGRAMMER *pgm)
Definition jtag3.c:575
int jtag3_command(PROGRAMMER *pgm, unsigned char *cmd, unsigned int cmdlen, unsigned char **resp, const char *descr)
Definition jtag3.c:816
#define PGM_FL_IS_EDBG
Definition jtag3.c:86
#define SCOPE_GENERAL
Definition jtag3_private.h:96
#define CMD3_SIGN_OFF
Definition jtag3_private.h:111
#define SCOPE_AVR
Definition jtag3_private.h:98
#define serial_close
Definition libavrdude.h:576
int ifd
Definition libavrdude.h:522
static PROGRAMMER * pgm
Definition main.c:192
char flag
Definition libavrdude.h:690
union filedescriptor fd
Definition libavrdude.h:637

References avrdude_message(), CMD3_SIGN_OFF, programmer_t::fd, programmer_t::flag, free(), filedescriptor::ifd, jtag3_command(), jtag3_edbg_signoff(), MSG_NOTICE2, pgm, PGM_FL_IS_EDBG, progname, SCOPE_AVR, SCOPE_GENERAL, and serial_close.

Referenced by jtag3_dw_initpgm(), jtag3_initpgm(), and jtag3_pdi_initpgm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jtag3_command()

int jtag3_command ( PROGRAMMER pgm,
unsigned char *  cmd,
unsigned int  cmdlen,
unsigned char **  resp,
const char *  descr 
)
818{
819 int status;
820 unsigned char c;
821
822 avrdude_message(MSG_NOTICE2, "%s: Sending %s command: ",
823 progname, descr);
824 jtag3_send(pgm, cmd, cmdlen);
825
826 status = jtag3_recv(pgm, resp);
827 if (status <= 0) {
828 if (verbose >= 2)
829 putc('\n', stderr);
830 avrdude_message(MSG_NOTICE2, "%s: %s command: timeout/error communicating with programmer (status %d)\n",
831 progname, descr, status);
832 return -1;
833 } else if (verbose >= 3) {
834 putc('\n', stderr);
835 jtag3_prmsg(pgm, *resp, status);
836 } else {
837 avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", (*resp)[1], status);
838 }
839
840 c = (*resp)[1];
841 if ((c & RSP3_STATUS_MASK) != RSP3_OK) {
842 avrdude_message(MSG_INFO, "%s: bad response to %s command: 0x%02x\n",
843 progname, descr, c);
844 free(*resp);
845 resp = 0;
846 return -1;
847 }
848
849 return status;
850}
int verbose
Definition main.c:198
#define MSG_INFO
Definition avrdude.h:51
int jtag3_send(PROGRAMMER *pgm, unsigned char *data, size_t len)
Definition jtag3.c:401
int jtag3_recv(PROGRAMMER *pgm, unsigned char **msg)
Definition jtag3.c:774
static void jtag3_prmsg(PROGRAMMER *pgm, unsigned char *data, size_t len)
Definition jtag3.c:181
#define RSP3_OK
Definition jtag3_private.h:130
#define RSP3_STATUS_MASK
Definition jtag3_private.h:136
struct command cmd[]
Definition term.c:94

References avrdude_message(), cmd, free(), jtag3_prmsg(), jtag3_recv(), jtag3_send(), MSG_INFO, MSG_NOTICE2, pgm, progname, RSP3_OK, RSP3_STATUS_MASK, and verbose.

Referenced by jtag3_chip_erase(), jtag3_close(), jtag3_display(), jtag3_getparm(), jtag3_getsync(), jtag3_initialize(), jtag3_page_erase(), jtag3_paged_load(), jtag3_paged_write(), jtag3_program_disable(), jtag3_program_enable(), jtag3_read_byte(), jtag3_setparm(), and jtag3_write_byte().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jtag3_dw_initpgm()

void jtag3_dw_initpgm ( PROGRAMMER pgm)
2224{
2225 strcpy(pgm->type, "JTAGICE3_DW");
2226
2227 /*
2228 * mandatory functions
2229 */
2240
2241 /*
2242 * optional functions
2243 */
2249 pgm->page_size = 256;
2251}
static void jtag3_display(PROGRAMMER *pgm, const char *p)
Definition jtag3.c:2073
static void jtag3_enable(PROGRAMMER *pgm)
Definition jtag3.c:1268
static int jtag3_open_dw(PROGRAMMER *pgm, char *port)
Definition jtag3.c:1420
static int jtag3_program_enable_dummy(PROGRAMMER *pgm, AVRPART *p)
Definition jtag3.c:909
static void jtag3_print_parms(PROGRAMMER *pgm)
Definition jtag3.c:2149
void jtag3_close(PROGRAMMER *pgm)
Definition jtag3.c:1447
static int jtag3_chip_erase_dw(PROGRAMMER *pgm, AVRPART *p)
Definition jtag3.c:900
static int jtag3_paged_load(PROGRAMMER *pgm, AVRPART *p, AVRMEM *m, unsigned int page_size, unsigned int addr, unsigned int n_bytes)
Definition jtag3.c:1622
#define PGM_FL_IS_DW
Definition jtag3.c:83
static int jtag3_read_byte(PROGRAMMER *pgm, AVRPART *p, AVRMEM *mem, unsigned long addr, unsigned char *value)
Definition jtag3.c:1700
void jtag3_setup(PROGRAMMER *pgm)
Definition jtag3.c:109
static int jtag3_paged_write(PROGRAMMER *pgm, AVRPART *p, AVRMEM *m, unsigned int page_size, unsigned int addr, unsigned int n_bytes)
Definition jtag3.c:1518
void jtag3_teardown(PROGRAMMER *pgm)
Definition jtag3.c:119
static int jtag3_write_byte(PROGRAMMER *pgm, AVRPART *p, AVRMEM *mem, unsigned long addr, unsigned char data)
Definition jtag3.c:1855
static void jtag3_disable(PROGRAMMER *pgm)
Definition jtag3.c:1252
static int jtag3_initialize(PROGRAMMER *pgm, AVRPART *p)
Definition jtag3.c:975
void(* display)(struct programmer_t *pgm, const char *p)
Definition libavrdude.h:644
int(* paged_write)(struct programmer_t *pgm, AVRPART *p, AVRMEM *m, unsigned int page_size, unsigned int baseaddr, unsigned int n_bytes)
Definition libavrdude.h:659
int(* open)(struct programmer_t *pgm, char *port)
Definition libavrdude.h:657
int(* read_byte)(struct programmer_t *pgm, AVRPART *p, AVRMEM *m, unsigned long addr, unsigned char *value)
Definition libavrdude.h:670
int(* paged_load)(struct programmer_t *pgm, AVRPART *p, AVRMEM *m, unsigned int page_size, unsigned int baseaddr, unsigned int n_bytes)
Definition libavrdude.h:662
void(* teardown)(struct programmer_t *pgm)
Definition libavrdude.h:685
void(* enable)(struct programmer_t *pgm)
Definition libavrdude.h:645
int(* program_enable)(struct programmer_t *pgm, AVRPART *p)
Definition libavrdude.h:649
int(* write_byte)(struct programmer_t *pgm, AVRPART *p, AVRMEM *m, unsigned long addr, unsigned char value)
Definition libavrdude.h:668
void(* setup)(struct programmer_t *pgm)
Definition libavrdude.h:684
void(* print_parms)(struct programmer_t *pgm)
Definition libavrdude.h:673
char type[PGM_TYPELEN]
Definition libavrdude.h:619
int(* initialize)(struct programmer_t *pgm, AVRPART *p)
Definition libavrdude.h:643
void(* close)(struct programmer_t *pgm)
Definition libavrdude.h:658
int(* chip_erase)(struct programmer_t *pgm, AVRPART *p)
Definition libavrdude.h:650
void(* disable)(struct programmer_t *pgm)
Definition libavrdude.h:646
int page_size
Definition libavrdude.h:638

References programmer_t::chip_erase, programmer_t::close, programmer_t::disable, programmer_t::display, programmer_t::enable, programmer_t::flag, programmer_t::initialize, jtag3_chip_erase_dw(), jtag3_close(), jtag3_disable(), jtag3_display(), jtag3_enable(), jtag3_initialize(), jtag3_open_dw(), jtag3_paged_load(), jtag3_paged_write(), jtag3_print_parms(), jtag3_program_enable_dummy(), jtag3_read_byte(), jtag3_setup(), jtag3_teardown(), jtag3_write_byte(), programmer_t::open, programmer_t::page_size, programmer_t::paged_load, programmer_t::paged_write, pgm, PGM_FL_IS_DW, programmer_t::print_parms, programmer_t::program_enable, programmer_t::read_byte, programmer_t::setup, programmer_t::teardown, programmer_t::type, and programmer_t::write_byte.

+ Here is the call graph for this function:

◆ jtag3_getparm()

int jtag3_getparm ( PROGRAMMER pgm,
unsigned char  scope,
unsigned char  section,
unsigned char  parm,
unsigned char *  value,
unsigned char  length 
)
1996{
1997 int status;
1998 unsigned char buf[6], *resp, c;
1999 char descr[60];
2000
2001 avrdude_message(MSG_NOTICE2, "%s: jtag3_getparm()\n", progname);
2002
2003 buf[0] = scope;
2004 buf[1] = CMD3_GET_PARAMETER;
2005 buf[2] = 0;
2006 buf[3] = section;
2007 buf[4] = parm;
2008 buf[5] = length;
2009
2010 sprintf(descr, "get parameter (scope 0x%02x, section %d, parm %d)",
2011 scope, section, parm);
2012
2013 if ((status = jtag3_command(pgm, buf, 6, &resp, descr)) < 0)
2014 return -1;
2015
2016 c = resp[1];
2017 if (c != RSP3_DATA || status < 3) {
2018 avrdude_message(MSG_INFO, "%s: jtag3_getparm(): "
2019 "bad response to %s\n",
2020 progname, descr);
2021 free(resp);
2022 return -1;
2023 }
2024
2025 status -= 3;
2026 memcpy(value, resp + 3, (length < status? length: status));
2027 free(resp);
2028
2029 return 0;
2030}
#define RSP3_DATA
Definition jtag3_private.h:133
#define CMD3_GET_PARAMETER
Definition jtag3_private.h:109
double length(std::vector< SurfacePoint > &path)
Definition exact_geodesic.cpp:1682

References avrdude_message(), CMD3_GET_PARAMETER, free(), jtag3_command(), MSG_INFO, MSG_NOTICE2, pgm, progname, and RSP3_DATA.

Referenced by jtag3_display(), jtag3_initialize(), and jtag3_print_parms1().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jtag3_getsync()

int jtag3_getsync ( PROGRAMMER pgm,
int  mode 
)
853 {
854
855 unsigned char buf[3], *resp;
856
857 avrdude_message(MSG_DEBUG, "%s: jtag3_getsync()\n", progname);
858
859 if (pgm->flag & PGM_FL_IS_EDBG) {
860 if (jtag3_edbg_prepare(pgm) < 0)
861 return -1;
862 }
863
864 /* Get the sign-on information. */
865 buf[0] = SCOPE_GENERAL;
866 buf[1] = CMD3_SIGN_ON;
867 buf[2] = 0;
868
869 if (jtag3_command(pgm, buf, 3, &resp, "sign-on") < 0)
870 return -1;
871
872 free(resp);
873
874 return 0;
875}
#define MSG_DEBUG
Definition avrdude.h:54
static int jtag3_edbg_prepare(PROGRAMMER *pgm)
Definition jtag3.c:517
#define CMD3_SIGN_ON
Definition jtag3_private.h:110

References avrdude_message(), CMD3_SIGN_ON, programmer_t::flag, free(), jtag3_command(), jtag3_edbg_prepare(), MSG_DEBUG, pgm, PGM_FL_IS_EDBG, progname, and SCOPE_GENERAL.

Referenced by jtag3_open(), jtag3_open_dw(), and jtag3_open_pdi().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jtag3_initpgm()

void jtag3_initpgm ( PROGRAMMER pgm)
2189{
2190 strcpy(pgm->type, "JTAGICE3");
2191
2192 /*
2193 * mandatory functions
2194 */
2201 pgm->open = jtag3_open;
2205
2206 /*
2207 * optional functions
2208 */
2217 pgm->page_size = 256;
2219}
#define PGM_FL_IS_JTAG
Definition jtag3.c:85
static int jtag3_chip_erase(PROGRAMMER *pgm, AVRPART *p)
Definition jtag3.c:880
static int jtag3_parseextparms(PROGRAMMER *pgm, LISTID extparms)
Definition jtag3.c:1273
static int jtag3_set_sck_period(PROGRAMMER *pgm, double v)
Definition jtag3.c:1972
static int jtag3_open(PROGRAMMER *pgm, char *port)
Definition jtag3.c:1407
static int jtag3_page_erase(PROGRAMMER *pgm, AVRPART *p, AVRMEM *m, unsigned int addr)
Definition jtag3.c:1473
int(* parseextparams)(struct programmer_t *pgm, LISTID xparams)
Definition libavrdude.h:683
int(* page_erase)(struct programmer_t *pgm, AVRPART *p, AVRMEM *m, unsigned int baseaddr)
Definition libavrdude.h:665
int(* set_sck_period)(struct programmer_t *pgm, double v)
Definition libavrdude.h:677

References programmer_t::chip_erase, programmer_t::close, programmer_t::disable, programmer_t::display, programmer_t::enable, programmer_t::flag, programmer_t::initialize, jtag3_chip_erase(), jtag3_close(), jtag3_disable(), jtag3_display(), jtag3_enable(), jtag3_initialize(), jtag3_open(), jtag3_page_erase(), jtag3_paged_load(), jtag3_paged_write(), jtag3_parseextparms(), jtag3_print_parms(), jtag3_program_enable_dummy(), jtag3_read_byte(), jtag3_set_sck_period(), jtag3_setup(), jtag3_teardown(), jtag3_write_byte(), programmer_t::open, programmer_t::page_erase, programmer_t::page_size, programmer_t::paged_load, programmer_t::paged_write, programmer_t::parseextparams, pgm, PGM_FL_IS_JTAG, programmer_t::print_parms, programmer_t::program_enable, programmer_t::read_byte, programmer_t::set_sck_period, programmer_t::setup, programmer_t::teardown, programmer_t::type, and programmer_t::write_byte.

+ Here is the call graph for this function:

◆ jtag3_open_common()

int jtag3_open_common ( PROGRAMMER pgm,
char *  port 
)
1312{
1313 union pinfo pinfo;
1314 LNODEID usbpid;
1315 int rv = -1;
1316
1317#if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBHIDAPI)
1318 avrdude_message(MSG_INFO, "avrdude was compiled without USB or HIDAPI support.\n");
1319 return -1;
1320#endif
1321
1322 if (strncmp(port, "usb", 3) != 0) {
1323 avrdude_message(MSG_INFO, "%s: jtag3_open_common(): JTAGICE3/EDBG port names must start with \"usb\"\n",
1324 progname);
1325 return -1;
1326 }
1327
1328 if (pgm->usbvid)
1329 pinfo.usbinfo.vid = pgm->usbvid;
1330 else
1332
1333 /* If the config entry did not specify a USB PID, insert the default one. */
1334 if (lfirst(pgm->usbpid) == NULL)
1336
1337#if defined(HAVE_LIBHIDAPI)
1338 /*
1339 * Try HIDAPI first. LibUSB is more generic, but might then cause
1340 * troubles for HID-class devices in some OSes (like Windows).
1341 */
1343 for (usbpid = lfirst(pgm->usbpid); rv < 0 && usbpid != NULL; usbpid = lnext(usbpid)) {
1345 pinfo.usbinfo.pid = *(int *)(ldata(usbpid));
1346 pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3;
1349 pgm->fd.usb.eep = 0;
1350
1351 strcpy(pgm->port, port);
1352 rv = serial_open(port, pinfo, &pgm->fd);
1353 }
1354 if (rv < 0) {
1355#endif /* HAVE_LIBHIDAPI */
1356#if defined(HAVE_LIBUSB)
1358 for (usbpid = lfirst(pgm->usbpid); rv < 0 && usbpid != NULL; usbpid = lnext(usbpid)) {
1360 pinfo.usbinfo.pid = *(int *)(ldata(usbpid));
1361 pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3;
1365
1366 strcpy(pgm->port, port);
1367 rv = serial_open(port, pinfo, &pgm->fd);
1368 }
1369#endif /* HAVE_LIBUSB */
1370#if defined(HAVE_LIBHIDAPI)
1371 }
1372#endif
1373 if (rv < 0) {
1374 avrdude_message(MSG_INFO, "%s: jtag3_open_common(): Did not find any device matching VID 0x%04x and PID list: ",
1375 progname, (unsigned)pinfo.usbinfo.vid);
1376 int notfirst = 0;
1377 for (usbpid = lfirst(pgm->usbpid); usbpid != NULL; usbpid = lnext(usbpid)) {
1378 if (notfirst)
1380 avrdude_message(MSG_INFO, "0x%04x", (unsigned int)(*(int *)(ldata(usbpid))));
1381 notfirst = 1;
1382 }
1383 fputc('\n', stderr);
1384
1385 return -1;
1386 }
1387
1388 if (pgm->fd.usb.eep == 0)
1389 {
1390 /* The event EP has been deleted by usb_open(), so we are
1391 running on a CMSIS-DAP device, using EDBG protocol */
1393 avrdude_message(MSG_NOTICE, "%s: Found CMSIS-DAP compliant device, using EDBG protocol\n",
1394 progname);
1395 }
1396
1397 /*
1398 * drain any extraneous input
1399 */
1400 jtag3_drain(pgm, 0);
1401
1402 return 0;
1403}
#define MSG_NOTICE
Definition avrdude.h:52
static int jtag3_drain(PROGRAMMER *pgm, int display)
Definition jtag3.c:627
int ladd(LISTID lid, void *p)
Definition lists.c:547
struct serial_device * serdev
Definition ser_posix.c:562
#define serial_open
Definition libavrdude.h:574
struct filedescriptor::@12 usb
void * ldata(LNODEID)
Definition lists.c:720
struct serial_device usb_serdev_frame
struct pinfo::@13 usbinfo
void * LNODEID
Definition libavrdude.h:64
LNODEID lnext(LNODEID)
Definition lists.c:704
LNODEID lfirst(LISTID)
Definition lists.c:688
#define PINFO_FL_SILENT
Definition libavrdude.h:544
struct serial_device usbhid_serdev
Definition libavrdude.h:536
int usbvid
Definition libavrdude.h:631
char port[PGM_PORTLEN]
Definition libavrdude.h:620
LISTID usbpid
Definition libavrdude.h:632
#define USB_VENDOR_ATMEL
Definition usbdevs.h:28
#define USBDEV_MAX_XFER_3
Definition usbdevs.h:72
#define USBDEV_BULK_EP_READ_3
Definition usbdevs.h:70
#define USB_DEVICE_JTAGICE3
Definition usbdevs.h:33
#define USBDEV_BULK_EP_WRITE_3
Definition usbdevs.h:69
#define USBDEV_EVT_EP_READ_3
Definition usbdevs.h:71

References avrdude_message(), programmer_t::fd, programmer_t::flag, jtag3_drain(), ladd(), ldata(), lfirst(), lnext(), MSG_INFO, MSG_NOTICE, pgm, PGM_FL_IS_EDBG, PINFO_FL_SILENT, programmer_t::port, progname, serdev, serial_open, filedescriptor::usb, USB_DEVICE_JTAGICE3, usb_serdev_frame, USB_VENDOR_ATMEL, USBDEV_BULK_EP_READ_3, USBDEV_BULK_EP_WRITE_3, USBDEV_EVT_EP_READ_3, USBDEV_MAX_XFER_3, usbhid_serdev, pinfo::usbinfo, programmer_t::usbpid, and programmer_t::usbvid.

Referenced by jtag3_open(), jtag3_open_dw(), and jtag3_open_pdi().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jtag3_pdi_initpgm()

void jtag3_pdi_initpgm ( PROGRAMMER pgm)
2256{
2257 strcpy(pgm->type, "JTAGICE3_PDI");
2258
2259 /*
2260 * mandatory functions
2261 */
2272
2273 /*
2274 * optional functions
2275 */
2283 pgm->page_size = 256;
2285}
#define PGM_FL_IS_PDI
Definition jtag3.c:84
static int jtag3_open_pdi(PROGRAMMER *pgm, char *port)
Definition jtag3.c:1433

References programmer_t::chip_erase, programmer_t::close, programmer_t::disable, programmer_t::display, programmer_t::enable, programmer_t::flag, programmer_t::initialize, jtag3_chip_erase(), jtag3_close(), jtag3_disable(), jtag3_display(), jtag3_enable(), jtag3_initialize(), jtag3_open_pdi(), jtag3_page_erase(), jtag3_paged_load(), jtag3_paged_write(), jtag3_print_parms(), jtag3_program_enable_dummy(), jtag3_read_byte(), jtag3_set_sck_period(), jtag3_setup(), jtag3_teardown(), jtag3_write_byte(), programmer_t::open, programmer_t::page_erase, programmer_t::page_size, programmer_t::paged_load, programmer_t::paged_write, pgm, PGM_FL_IS_PDI, programmer_t::print_parms, programmer_t::program_enable, programmer_t::read_byte, programmer_t::set_sck_period, programmer_t::setup, programmer_t::teardown, programmer_t::type, and programmer_t::write_byte.

+ Here is the call graph for this function:

◆ jtag3_recv()

int jtag3_recv ( PROGRAMMER pgm,
unsigned char **  msg 
)
774 {
775 unsigned short r_seqno;
776 int rv;
777
778 for (;;) {
779 if ((rv = jtag3_recv_frame(pgm, msg)) <= 0)
780 return rv;
781
782 if ((rv & USB_RECV_FLAG_EVENT) != 0) {
783 if (verbose >= 3)
785
786 free(*msg);
787 continue;
788 }
789
791 r_seqno = ((*msg)[2] << 8) | (*msg)[1];
792 avrdude_message(MSG_DEBUG, "%s: jtag3_recv(): "
793 "Got message seqno %d (command_sequence == %d)\n",
794 progname, r_seqno, PDATA(pgm)->command_sequence);
795 if (r_seqno == PDATA(pgm)->command_sequence) {
796 if (++(PDATA(pgm)->command_sequence) == 0xffff)
797 PDATA(pgm)->command_sequence = 0;
798 /*
799 * We move the payload to the beginning of the buffer, to make
800 * the job easier for the caller. We have to return the
801 * original pointer though, as the caller must free() it.
802 */
803 rv -= 3;
804 memmove(*msg, *msg + 3, rv);
805
806 return rv;
807 }
808 avrdude_message(MSG_NOTICE2, "%s: jtag3_recv(): "
809 "got wrong sequence number, %u != %u\n",
810 progname, r_seqno, PDATA(pgm)->command_sequence);
811
812 free(*msg);
813 }
814}
#define PDATA(pgm)
Definition jtag3.c:77
static int jtag3_recv_frame(PROGRAMMER *pgm, unsigned char **msg)
Definition jtag3.c:641
static void jtag3_prevent(PROGRAMMER *pgm, unsigned char *data, size_t len)
Definition jtag3.c:309
#define USB_RECV_FLAG_EVENT
Definition usbdevs.h:81
#define USB_RECV_LENGTH_MASK
Definition usbdevs.h:80

References avrdude_message(), free(), jtag3_prevent(), jtag3_recv_frame(), MSG_DEBUG, MSG_NOTICE2, PDATA, pgm, progname, USB_RECV_FLAG_EVENT, USB_RECV_LENGTH_MASK, and verbose.

Referenced by jtag3_command().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jtag3_send()

int jtag3_send ( PROGRAMMER pgm,
unsigned char *  data,
size_t  len 
)
402{
403 unsigned char *buf;
404
405 if (pgm->flag & PGM_FL_IS_EDBG)
406 return jtag3_edbg_send(pgm, data, len);
407
408 avrdude_message(MSG_DEBUG, "\n%s: jtag3_send(): sending %lu bytes\n",
409 progname, (unsigned long)len);
410
411 if ((buf = malloc(len + 4)) == NULL)
412 {
413 avrdude_message(MSG_INFO, "%s: jtag3_send(): out of memory",
414 progname);
415 return -1;
416 }
417
418 buf[0] = TOKEN;
419 buf[1] = 0; /* dummy */
420 u16_to_b2(buf + 2, PDATA(pgm)->command_sequence);
421 memcpy(buf + 4, data, len);
422
423 if (serial_send(&pgm->fd, buf, len + 4) != 0) {
424 avrdude_message(MSG_INFO, "%s: jtag3_send(): failed to send command to serial port\n",
425 progname);
426 return -1;
427 }
428
429 free(buf);
430
431 return 0;
432}
void * malloc(YYSIZE_T)
static int jtag3_edbg_send(PROGRAMMER *pgm, unsigned char *data, size_t len)
Definition jtag3.c:434
static void u16_to_b2(unsigned char *b, unsigned short l)
Definition jtag3.c:157
#define TOKEN
Definition jtag3_private.h:91
#define serial_send
Definition libavrdude.h:577

References avrdude_message(), programmer_t::fd, programmer_t::flag, free(), jtag3_edbg_send(), malloc(), MSG_DEBUG, MSG_INFO, PDATA, pgm, PGM_FL_IS_EDBG, progname, serial_send, TOKEN, and u16_to_b2().

Referenced by jtag3_command().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jtag3_setparm()

int jtag3_setparm ( PROGRAMMER pgm,
unsigned char  scope,
unsigned char  section,
unsigned char  parm,
unsigned char *  value,
unsigned char  length 
)
2038{
2039 int status;
2040 unsigned char *buf, *resp;
2041 char descr[60];
2042
2043 avrdude_message(MSG_NOTICE2, "%s: jtag3_setparm()\n", progname);
2044
2045 sprintf(descr, "set parameter (scope 0x%02x, section %d, parm %d)",
2046 scope, section, parm);
2047
2048 if ((buf = malloc(6 + length)) == NULL)
2049 {
2050 avrdude_message(MSG_INFO, "%s: jtag3_setparm(): Out of memory\n",
2051 progname);
2052 return -1;
2053 }
2054
2055 buf[0] = scope;
2056 buf[1] = CMD3_SET_PARAMETER;
2057 buf[2] = 0;
2058 buf[3] = section;
2059 buf[4] = parm;
2060 buf[5] = length;
2061 memcpy(buf + 6, value, length);
2062
2063 status = jtag3_command(pgm, buf, length + 6, &resp, descr);
2064
2065 free(buf);
2066 if (status > 0)
2067 free(resp);
2068
2069 return status;
2070}
#define CMD3_SET_PARAMETER
Definition jtag3_private.h:108

References avrdude_message(), CMD3_SET_PARAMETER, free(), jtag3_command(), malloc(), MSG_INFO, MSG_NOTICE2, pgm, and progname.

Referenced by jtag3_initialize(), jtag3_set_sck_mega_jtag(), jtag3_set_sck_xmega_jtag(), and jtag3_set_sck_xmega_pdi().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jtag3_setup()

void jtag3_setup ( PROGRAMMER pgm)
110{
111 if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
112 avrdude_message(MSG_INFO, "%s: jtag3_setup(): Out of memory allocating private data\n",
113 progname);
114 exit(1);
115 }
116 memset(pgm->cookie, 0, sizeof(struct pdata));
117}
Definition avr910.c:50
void * cookie
Definition libavrdude.h:689

References avrdude_message(), programmer_t::cookie, malloc(), MSG_INFO, pgm, and progname.

Referenced by jtag3_dw_initpgm(), jtag3_initpgm(), and jtag3_pdi_initpgm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jtag3_teardown()

void jtag3_teardown ( PROGRAMMER pgm)
120{
121 free(pgm->cookie);
122}

References programmer_t::cookie, free(), and pgm.

Referenced by jtag3_dw_initpgm(), jtag3_initpgm(), and jtag3_pdi_initpgm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ jtag3_desc

const char jtag3_desc[]
extern

◆ jtag3_dw_desc

const char jtag3_dw_desc[]
extern

◆ jtag3_pdi_desc

const char jtag3_pdi_desc[]
extern