mirror of
https://github.com/mariusgreuel/avrdude.git
synced 2025-12-17 19:04:42 +00:00
added verbose level in avrdude_message()
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1321 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
94
flip1.c
94
flip1.c
@@ -243,13 +243,13 @@ int flip1_initialize(PROGRAMMER* pgm, AVRPART *part)
|
||||
if (usbpid) {
|
||||
pid = *(int *)(ldata(usbpid));
|
||||
if (lnext(usbpid))
|
||||
avrdude_message("%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
} else {
|
||||
pid = part->usbpid;
|
||||
}
|
||||
if (!ovsigck && (part->flags & AVRPART_HAS_PDI)) {
|
||||
avrdude_message("%s: \"flip1\" (FLIP protocol version 1) is for AT90USB* and ATmega*U* devices.\n"
|
||||
avrdude_message(MSG_INFO, "%s: \"flip1\" (FLIP protocol version 1) is for AT90USB* and ATmega*U* devices.\n"
|
||||
"%s For Xmega devices, use \"flip2\".\n"
|
||||
"%s (Use -F to bypass this check.)\n",
|
||||
progname, progbuf, progbuf);
|
||||
@@ -264,31 +264,31 @@ int flip1_initialize(PROGRAMMER* pgm, AVRPART *part)
|
||||
/* Check if descriptor values are what we expect. */
|
||||
|
||||
if (dfu->dev_desc.idVendor != vid)
|
||||
avrdude_message("%s: Warning: USB idVendor = 0x%04X (expected 0x%04X)\n",
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB idVendor = 0x%04X (expected 0x%04X)\n",
|
||||
progname, dfu->dev_desc.idVendor, vid);
|
||||
|
||||
if (pid != 0 && dfu->dev_desc.idProduct != pid)
|
||||
avrdude_message("%s: Warning: USB idProduct = 0x%04X (expected 0x%04X)\n",
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB idProduct = 0x%04X (expected 0x%04X)\n",
|
||||
progname, dfu->dev_desc.idProduct, pid);
|
||||
|
||||
if (dfu->dev_desc.bNumConfigurations != 1)
|
||||
avrdude_message("%s: Warning: USB bNumConfigurations = %d (expected 1)\n",
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bNumConfigurations = %d (expected 1)\n",
|
||||
progname, (int) dfu->dev_desc.bNumConfigurations);
|
||||
|
||||
if (dfu->conf_desc.bNumInterfaces != 1)
|
||||
avrdude_message("%s: Warning: USB bNumInterfaces = %d (expected 1)\n",
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bNumInterfaces = %d (expected 1)\n",
|
||||
progname, (int) dfu->conf_desc.bNumInterfaces);
|
||||
|
||||
if (dfu->dev_desc.bDeviceClass != 254)
|
||||
avrdude_message("%s: Warning: USB bDeviceClass = %d (expected 254)\n",
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceClass = %d (expected 254)\n",
|
||||
progname, (int) dfu->dev_desc.bDeviceClass);
|
||||
|
||||
if (dfu->dev_desc.bDeviceSubClass != 1)
|
||||
avrdude_message("%s: Warning: USB bDeviceSubClass = %d (expected 1)\n",
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceSubClass = %d (expected 1)\n",
|
||||
progname, (int) dfu->dev_desc.bDeviceSubClass);
|
||||
|
||||
if (dfu->dev_desc.bDeviceProtocol != 0)
|
||||
avrdude_message("%s: Warning: USB bDeviceProtocol = %d (expected 0)\n",
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceProtocol = %d (expected 0)\n",
|
||||
progname, (int) dfu->dev_desc.bDeviceProtocol);
|
||||
|
||||
/*
|
||||
@@ -299,20 +299,20 @@ int flip1_initialize(PROGRAMMER* pgm, AVRPART *part)
|
||||
*/
|
||||
if (0) {
|
||||
if (dfu->intf_desc.bInterfaceClass != 254)
|
||||
avrdude_message("%s: Warning: USB bInterfaceClass = %d (expected 254)\n",
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceClass = %d (expected 254)\n",
|
||||
progname, (int) dfu->intf_desc.bInterfaceClass);
|
||||
|
||||
if (dfu->intf_desc.bInterfaceSubClass != 1)
|
||||
avrdude_message("%s: Warning: USB bInterfaceSubClass = %d (expected 1)\n",
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceSubClass = %d (expected 1)\n",
|
||||
progname, (int) dfu->intf_desc.bInterfaceSubClass);
|
||||
|
||||
if (dfu->intf_desc.bInterfaceProtocol != 0)
|
||||
avrdude_message("%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
|
||||
progname, (int) dfu->intf_desc.bInterfaceProtocol);
|
||||
}
|
||||
|
||||
if (dfu->dev_desc.bMaxPacketSize0 != 32)
|
||||
avrdude_message("%s: Warning: bMaxPacketSize0 (%d) != 32, things might go wrong\n",
|
||||
avrdude_message(MSG_INFO, "%s: Warning: bMaxPacketSize0 (%d) != 32, things might go wrong\n",
|
||||
progname, dfu->dev_desc.bMaxPacketSize0);
|
||||
|
||||
if (verbose)
|
||||
@@ -368,8 +368,7 @@ int flip1_chip_erase(PROGRAMMER* pgm, AVRPART *part)
|
||||
int aux_result;
|
||||
unsigned int default_timeout = FLIP1(pgm)->dfu->timeout;
|
||||
|
||||
if (verbose > 1)
|
||||
avrdude_message("%s: flip_chip_erase()\n", progname);
|
||||
avrdude_message(MSG_NOTICE2, "%s: flip_chip_erase()\n", progname);
|
||||
|
||||
struct flip1_cmd cmd = {
|
||||
FLIP1_CMD_WRITE_COMMAND, { 0, 0xff }
|
||||
@@ -384,7 +383,7 @@ int flip1_chip_erase(PROGRAMMER* pgm, AVRPART *part)
|
||||
return -1;
|
||||
|
||||
if (status.bStatus != DFU_STATUS_OK) {
|
||||
avrdude_message("%s: failed to send chip erase command: %s\n",
|
||||
avrdude_message(MSG_INFO, "%s: failed to send chip erase command: %s\n",
|
||||
progname, flip1_status_str(&status));
|
||||
if (status.bState == STATE_dfuERROR)
|
||||
dfu_clrstatus(FLIP1(pgm)->dfu);
|
||||
@@ -406,7 +405,7 @@ int flip1_read_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
|
||||
if (flip1_read_sig_bytes(pgm, part, mem) < 0)
|
||||
return -1;
|
||||
if (addr > mem->size) {
|
||||
avrdude_message("%s: flip1_read_byte(signature): address %lu out of range\n",
|
||||
avrdude_message(MSG_INFO, "%s: flip1_read_byte(signature): address %lu out of range\n",
|
||||
progname, addr);
|
||||
return -1;
|
||||
}
|
||||
@@ -417,10 +416,10 @@ int flip1_read_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
|
||||
mem_unit = flip1_mem_unit(mem->desc);
|
||||
|
||||
if (mem_unit == FLIP1_MEM_UNIT_UNKNOWN) {
|
||||
avrdude_message("%s: Error: "
|
||||
avrdude_message(MSG_INFO, "%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
avrdude_message("\n");
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -442,10 +441,10 @@ int flip1_write_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
|
||||
mem_unit = flip1_mem_unit(mem->desc);
|
||||
|
||||
if (mem_unit == FLIP1_MEM_UNIT_UNKNOWN) {
|
||||
avrdude_message("%s: Error: "
|
||||
avrdude_message(MSG_INFO, "%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
avrdude_message("\n");
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -463,10 +462,10 @@ int flip1_paged_load(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
|
||||
mem_unit = flip1_mem_unit(mem->desc);
|
||||
|
||||
if (mem_unit == FLIP1_MEM_UNIT_UNKNOWN) {
|
||||
avrdude_message("%s: Error: "
|
||||
avrdude_message(MSG_INFO, "%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
avrdude_message("\n");
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -489,16 +488,16 @@ int flip1_paged_write(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
|
||||
mem_unit = flip1_mem_unit(mem->desc);
|
||||
|
||||
if (mem_unit == FLIP1_MEM_UNIT_UNKNOWN) {
|
||||
avrdude_message("%s: Error: "
|
||||
avrdude_message(MSG_INFO, "%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
avrdude_message("\n");
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n_bytes > INT_MAX) {
|
||||
/* This should never happen, unless the int type is only 16 bits. */
|
||||
avrdude_message("%s: Error: Attempting to read more than %d bytes\n",
|
||||
avrdude_message(MSG_INFO, "%s: Error: Attempting to read more than %d bytes\n",
|
||||
progname, INT_MAX);
|
||||
exit(1);
|
||||
}
|
||||
@@ -511,14 +510,13 @@ int flip1_paged_write(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
|
||||
|
||||
int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
|
||||
{
|
||||
if (verbose > 1)
|
||||
avrdude_message("%s: flip1_read_sig_bytes(): ", progname);
|
||||
avrdude_message(MSG_NOTICE2, "%s: flip1_read_sig_bytes(): ", progname);
|
||||
|
||||
if (FLIP1(pgm)->dfu == NULL)
|
||||
return -1;
|
||||
|
||||
if (mem->size < sizeof(FLIP1(pgm)->part_sig)) {
|
||||
avrdude_message("%s: Error: Signature read must be at least %u bytes\n",
|
||||
avrdude_message(MSG_INFO, "%s: Error: Signature read must be at least %u bytes\n",
|
||||
progname, (unsigned int) sizeof(FLIP1(pgm)->part_sig));
|
||||
return -1;
|
||||
}
|
||||
@@ -536,8 +534,7 @@ int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
|
||||
FLIP1_CMD_READ_COMMAND, FLIP1_READ_FAMILY_CODE
|
||||
};
|
||||
|
||||
if (verbose > 1)
|
||||
avrdude_message("from device\n");
|
||||
avrdude_message(MSG_NOTICE2, "from device\n");
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
@@ -554,7 +551,7 @@ int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
|
||||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
avrdude_message("%s: failed to send cmd for signature byte %d: %s\n",
|
||||
avrdude_message(MSG_INFO, "%s: failed to send cmd for signature byte %d: %s\n",
|
||||
progname, i, flip1_status_str(&status));
|
||||
if (status.bState == STATE_dfuERROR)
|
||||
dfu_clrstatus(FLIP1(pgm)->dfu);
|
||||
@@ -569,7 +566,7 @@ int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
|
||||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
avrdude_message("%s: failed to read signature byte %d: %s\n",
|
||||
avrdude_message(MSG_INFO, "%s: failed to read signature byte %d: %s\n",
|
||||
progname, i, flip1_status_str(&status));
|
||||
if (status.bState == STATE_dfuERROR)
|
||||
dfu_clrstatus(FLIP1(pgm)->dfu);
|
||||
@@ -579,8 +576,7 @@ int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (verbose > 1)
|
||||
avrdude_message("cached\n");
|
||||
avrdude_message(MSG_NOTICE2, "cached\n");
|
||||
}
|
||||
|
||||
memcpy(mem->buf, FLIP1(pgm)->part_sig, sizeof(FLIP1(pgm)->part_sig));
|
||||
@@ -593,7 +589,7 @@ void flip1_setup(PROGRAMMER * pgm)
|
||||
pgm->cookie = calloc(1, sizeof(struct flip1));
|
||||
|
||||
if (pgm->cookie == NULL) {
|
||||
avrdude_message("%s: Out of memory allocating private data structure\n",
|
||||
avrdude_message(MSG_INFO, "%s: Out of memory allocating private data structure\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
@@ -611,7 +607,7 @@ void flip1_teardown(PROGRAMMER * pgm)
|
||||
void flip1_show_info(struct flip1 *flip1)
|
||||
{
|
||||
dfu_show_info(flip1->dfu);
|
||||
avrdude_message(" USB max packet size : %hu\n",
|
||||
avrdude_message(MSG_INFO, " USB max packet size : %hu\n",
|
||||
(unsigned short) flip1->dfu->dev_desc.bMaxPacketSize0);
|
||||
}
|
||||
|
||||
@@ -629,9 +625,8 @@ int flip1_read_memory(PROGRAMMER * pgm,
|
||||
unsigned int default_timeout = dfu->timeout;
|
||||
|
||||
|
||||
if (verbose > 1)
|
||||
avrdude_message("%s: flip_read_memory(%s, 0x%04x, %d)\n",
|
||||
progname, flip1_mem_unit_str(mem_unit), addr, size);
|
||||
avrdude_message(MSG_NOTICE2, "%s: flip_read_memory(%s, 0x%04x, %d)\n",
|
||||
progname, flip1_mem_unit_str(mem_unit), addr, size);
|
||||
|
||||
/*
|
||||
* As this function is called once per page, no need to handle 64
|
||||
@@ -661,7 +656,7 @@ int flip1_read_memory(PROGRAMMER * pgm,
|
||||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
avrdude_message("%s: failed to read %u bytes of %s memory @%u: %s\n",
|
||||
avrdude_message(MSG_INFO, "%s: failed to read %u bytes of %s memory @%u: %s\n",
|
||||
progname, size, flip1_mem_unit_str(mem_unit), addr,
|
||||
flip1_status_str(&status));
|
||||
if (status.bState == STATE_dfuERROR)
|
||||
@@ -675,7 +670,7 @@ int flip1_read_memory(PROGRAMMER * pgm,
|
||||
if (cmd_result < 0 && aux_result == 0 &&
|
||||
status.bStatus == DFU_STATUS_ERR_WRITE) {
|
||||
if (FLIP1(pgm)->security_mode_flag == 0)
|
||||
avrdude_message("\n%s:\n"
|
||||
avrdude_message(MSG_INFO, "\n%s:\n"
|
||||
"%s***********************************************************************\n"
|
||||
"%sMaybe the device is in ``security mode´´, and needs a chip erase first?\n"
|
||||
"%s***********************************************************************\n"
|
||||
@@ -689,7 +684,7 @@ int flip1_read_memory(PROGRAMMER * pgm,
|
||||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
avrdude_message("%s: failed to read %u bytes of %s memory @%u: %s\n",
|
||||
avrdude_message(MSG_INFO, "%s: failed to read %u bytes of %s memory @%u: %s\n",
|
||||
progname, size, flip1_mem_unit_str(mem_unit), addr,
|
||||
flip1_status_str(&status));
|
||||
if (status.bState == STATE_dfuERROR)
|
||||
@@ -723,14 +718,13 @@ int flip1_write_memory(struct dfu_dev *dfu,
|
||||
unsigned int default_timeout = dfu->timeout;
|
||||
unsigned char *buf;
|
||||
|
||||
if (verbose > 1)
|
||||
avrdude_message("%s: flip_write_memory(%s, 0x%04x, %d)\n",
|
||||
progname, flip1_mem_unit_str(mem_unit), addr, size);
|
||||
avrdude_message(MSG_NOTICE2, "%s: flip_write_memory(%s, 0x%04x, %d)\n",
|
||||
progname, flip1_mem_unit_str(mem_unit), addr, size);
|
||||
|
||||
if (size < 32) {
|
||||
/* presumably single-byte updates; must be padded to USB endpoint size */
|
||||
if ((addr + size - 1) / 32 != addr / 32) {
|
||||
avrdude_message("%s: flip_write_memory(): begin (0x%x) and end (0x%x) not within same 32-byte block\n",
|
||||
avrdude_message(MSG_INFO, "%s: flip_write_memory(): begin (0x%x) and end (0x%x) not within same 32-byte block\n",
|
||||
progname, addr, addr + size - 1);
|
||||
return -1;
|
||||
}
|
||||
@@ -742,7 +736,7 @@ int flip1_write_memory(struct dfu_dev *dfu,
|
||||
if ((buf = malloc(sizeof(struct flip1_cmd_header) +
|
||||
write_size +
|
||||
sizeof(struct flip1_prog_footer))) == 0) {
|
||||
avrdude_message("%s: Out of memory\n", progname);
|
||||
avrdude_message(MSG_INFO, "%s: Out of memory\n", progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -791,7 +785,7 @@ int flip1_write_memory(struct dfu_dev *dfu,
|
||||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
avrdude_message("%s: failed to write %u bytes of %s memory @%u: %s\n",
|
||||
avrdude_message(MSG_INFO, "%s: failed to write %u bytes of %s memory @%u: %s\n",
|
||||
progname, size, flip1_mem_unit_str(mem_unit), addr,
|
||||
flip1_status_str(&status));
|
||||
if (status.bState == STATE_dfuERROR)
|
||||
@@ -822,7 +816,7 @@ int flip1_set_mem_page(struct dfu_dev *dfu,
|
||||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
avrdude_message("%s: failed to set memory page: %s\n",
|
||||
avrdude_message(MSG_INFO, "%s: failed to set memory page: %s\n",
|
||||
progname, flip1_status_str(&status));
|
||||
if (status.bState == STATE_dfuERROR)
|
||||
dfu_clrstatus(dfu);
|
||||
|
||||
Reference in New Issue
Block a user