Added some verbose-level messages.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1259 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
joerg_wunsch 2014-01-15 16:32:11 +00:00
parent 6818690c26
commit c049e794dc
3 changed files with 54 additions and 19 deletions

View File

@ -1,3 +1,8 @@
2014-01-15 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* flip.c: Added some verbose-level messages (-vv)
* dfu.c: Added some verbose-level messages (-vvvv)
2014-01-15 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Submitted by Kirill Levchenko:

35
dfu.c
View File

@ -110,7 +110,7 @@ struct dfu_dev * dfu_open(char *port_spec)
*/
if (strncmp(port_spec, "usb", 3) != 0) {
fprintf(stderr, "%s: Error: " \
fprintf(stderr, "%s: Error: "
"Invalid port specification \"%s\" for USB device\n",
progname, port_spec);
return NULL;
@ -168,7 +168,7 @@ int dfu_init(struct dfu_dev *dfu, unsigned short vid, unsigned short pid)
*/
if (pid == 0 && dfu->dev_name == NULL) {
fprintf(stderr, "%s: Error: No DFU support for part; " \
fprintf(stderr, "%s: Error: No DFU support for part; "
"specify PID in config or USB address (via -P) to override.\n",
progname);
return -1;
@ -311,6 +311,10 @@ int dfu_getstatus(struct dfu_dev *dfu, struct dfu_status *status)
{
int result;
if (verbose > 3)
fprintf(stderr, "%s: dfu_getstatus(): issuing control IN message\n",
progname);
result = usb_control_msg(dfu->dev_handle,
0x80 | USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_GETSTATUS, 0, 0,
(char*) status, sizeof(struct dfu_status), DFU_TIMEOUT);
@ -328,11 +332,20 @@ int dfu_getstatus(struct dfu_dev *dfu, struct dfu_status *status)
}
if (result > sizeof(struct dfu_status)) {
fprintf(stderr, "%s: Error: Oversize read (should not happen); " \
fprintf(stderr, "%s: Error: Oversize read (should not happen); "
"exiting\n", progname);
exit(1);
}
if (verbose > 3)
fprintf(stderr,
"%s: dfu_getstatus(): bStatus 0x%02x, bwPollTimeout %d, bState 0x%02x, iString %d\n",
progname,
status->bStatus,
status->bwPollTimeout[0] | (status->bwPollTimeout[1] << 8) | (status->bwPollTimeout[2] << 16),
status->bState,
status->iString);
return 0;
}
@ -340,6 +353,10 @@ int dfu_clrstatus(struct dfu_dev *dfu)
{
int result;
if (verbose > 3)
fprintf(stderr, "%s: dfu_clrstatus(): issuing control OUT message\n",
progname);
result = usb_control_msg(dfu->dev_handle,
USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_CLRSTATUS, 0, 0,
NULL, 0, DFU_TIMEOUT);
@ -357,6 +374,11 @@ int dfu_dnload(struct dfu_dev *dfu, void *ptr, int size)
{
int result;
if (verbose > 3)
fprintf(stderr,
"%s: dfu_dnload(): issuing control OUT message, wIndex = %d, ptr = %p, size = %d\n",
progname, wIndex, ptr, size);
result = usb_control_msg(dfu->dev_handle,
USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_DNLOAD, wIndex++, 0,
ptr, size, DFU_TIMEOUT);
@ -386,6 +408,11 @@ int dfu_upload(struct dfu_dev *dfu, void *ptr, int size)
{
int result;
if (verbose > 3)
fprintf(stderr,
"%s: dfu_upload(): issuing control IN message, wIndex = %d, ptr = %p, size = %d\n",
progname, wIndex, ptr, size);
result = usb_control_msg(dfu->dev_handle,
0x80 | USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_UPLOAD, wIndex++, 0,
ptr, size, DFU_TIMEOUT);
@ -403,7 +430,7 @@ int dfu_upload(struct dfu_dev *dfu, void *ptr, int size)
}
if (result > size) {
fprintf(stderr, "%s: Error: Oversize read (should not happen); " \
fprintf(stderr, "%s: Error: Oversize read (should not happen); "
"exiting\n", progname);
exit(1);
}

33
flip.c
View File

@ -301,6 +301,9 @@ int flip2_chip_erase(PROGRAMMER* pgm, AVRPART *part)
int cmd_result = 0;
int aux_result;
if (verbose > 1)
fprintf(stderr, "%s: flip_chip_erase()\n", progname);
struct flip2_cmd cmd = {
FLIP2_CMD_GROUP_EXEC, FLIP2_CMD_CHIP_ERASE, { 0xFF, 0, 0, 0 }
};
@ -339,7 +342,7 @@ int flip2_read_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
mem_unit = flip2_mem_unit(mem->desc);
if (mem_unit == FLIP2_MEM_UNIT_UNKNOWN) {
fprintf(stderr, "%s: Error: " \
fprintf(stderr, "%s: Error: "
"\"%s\" memory not accessible using FLIP",
progname, mem->desc);
if (strcmp(mem->desc, "flash") == 0)
@ -362,7 +365,7 @@ int flip2_write_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
mem_unit = flip2_mem_unit(mem->desc);
if (mem_unit == FLIP2_MEM_UNIT_UNKNOWN) {
fprintf(stderr, "%s: Error: " \
fprintf(stderr, "%s: Error: "
"\"%s\" memory not accessible using FLIP",
progname, mem->desc);
if (strcmp(mem->desc, "flash") == 0)
@ -392,7 +395,7 @@ int flip2_paged_load(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
mem_unit = flip2_mem_unit(mem->desc);
if (mem_unit == FLIP2_MEM_UNIT_UNKNOWN) {
fprintf(stderr, "%s: Error: " \
fprintf(stderr, "%s: Error: "
"\"%s\" memory not accessible using FLIP",
progname, mem->desc);
if (strcmp(mem->desc, "flash") == 0)
@ -411,11 +414,6 @@ int flip2_paged_load(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
result = flip2_read_memory(FLIP2(pgm)->dfu, mem_unit, addr,
mem->buf + addr, n_bytes);
#if 0 /* DEBUG */
fprintf(stderr, "%s: Debug: flip2_read_memory(%s,0x%04X,0x%04X) = %d\n",
progname, mem->desc, addr, n_bytes, result);
#endif
return (result == 0) ? n_bytes : -1;
}
@ -431,7 +429,7 @@ int flip2_paged_write(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
mem_unit = flip2_mem_unit(mem->desc);
if (mem_unit == FLIP2_MEM_UNIT_UNKNOWN) {
fprintf(stderr, "%s: Error: " \
fprintf(stderr, "%s: Error: "
"\"%s\" memory not accessible using FLIP",
progname, mem->desc);
if (strcmp(mem->desc, "flash") == 0)
@ -450,12 +448,7 @@ int flip2_paged_write(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
result = flip2_write_memory(FLIP2(pgm)->dfu, mem_unit, addr,
mem->buf + addr, n_bytes);
#if 0 /* DEBUG */
fprintf(stderr, "%s: Debug: flip2_write_memory(%s,0x%04X,0x%04X) = %d\n",
progname, mem->desc, addr, n_bytes, result);
#endif
return 0;
return (result == 0) ? n_bytes : -1;
}
int flip2_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
@ -526,6 +519,11 @@ int flip2_read_memory(struct dfu_dev *dfu,
int read_size;
int result;
if (verbose > 1)
fprintf(stderr,
"%s: flip_read_memory(%s, 0x%04x, %d)\n",
progname, flip2_mem_unit_str(mem_unit), addr, size);
result = flip2_set_mem_unit(dfu, mem_unit);
if (result != 0) {
@ -586,6 +584,11 @@ int flip2_write_memory(struct dfu_dev *dfu,
int write_size;
int result;
if (verbose > 1)
fprintf(stderr,
"%s: flip_write_memory(%s, 0x%04x, %d)\n",
progname, flip2_mem_unit_str(mem_unit), addr, size);
result = flip2_set_mem_unit(dfu, mem_unit);
if (result != 0) {