"CODE_READ_PROTECTION_ENABLED",
};
-int isp_ret_code(char* buf, char** endptr)
+int isp_ret_code(char* buf, char** endptr, int quiet)
{
unsigned int ret = 0;
ret = strtoul(buf, endptr, 10);
/* FIXME : Find how return code are sent (binary or ASCII) */
- if (ret > (sizeof(error_codes)/sizeof(char*))) {
- printf("Received unknown error code '%u' !\n", ret);
- } else if ((ret != 0) || trace_on) {
- printf("Received error code '%u': %s\n", ret, error_codes[ret]);
+ if (quiet != 1) {
+ if (ret > (sizeof(error_codes)/sizeof(char*))) {
+ printf("Received unknown error code '%u' !\n", ret);
+ } else if ((ret != 0) || trace_on) {
+ printf("Received error code '%u': %s\n", ret, error_codes[ret]);
+ }
}
return ret;
}
/* Connect or reconnect to the target.
* Return positive or NULL value when connection is OK, or negative value otherwise.
*/
-int isp_connect(unsigned int crystal_freq)
+int isp_connect(unsigned int crystal_freq, int quiet)
{
char buf[REP_BUFSIZE];
char freq[10];
if (strncmp(SYNCHRO, buf, strlen(SYNCHRO)) == 0) {
isp_serial_write(SYNCHRO, strlen(SYNCHRO));
} else {
- printf("Unable to synchronize, no synchro received.\n");
+ if (quiet != 1) {
+ printf("Unable to synchronize, no synchro received.\n");
+ }
return -3;
}
/* Empty read buffer (echo is on) */
/* Read eror code for command */
isp_serial_read(buf, REP_BUFSIZE, 3);
+ /* Leave it even in quiet mode, so the user knows something is going on */
printf("Device session openned.\n");
return 1;
}
-int isp_send_cmd_no_args(char* cmd_name, char* cmd)
+int isp_send_cmd_no_args(char* cmd_name, char* cmd, int quiet)
{
char buf[5];
int ret = 0, len = 0;
printf("Error reading %s acknowledge.\n", cmd_name);
return -4;
}
- ret = isp_ret_code(buf, NULL);
+ ret = isp_ret_code(buf, NULL, quiet);
return ret;
}
{
int ret = 0;
- ret = isp_send_cmd_no_args("unlock", UNLOCK);
+ ret = isp_send_cmd_no_args("unlock", UNLOCK, quiet);
if (ret != 0) {
printf("Unlock error.\n");
return -1;
int i = 0, ret = 0, len = 0;
unsigned long int uid[4];
- ret = isp_send_cmd_no_args("read-uid", READ_UID);
+ ret = isp_send_cmd_no_args("read-uid", READ_UID, 0);
if (ret != 0) {
printf("Read UID error.\n");
return ret;
int ret = 0, len = 0;
unsigned long int part_id = 0;
- ret = isp_send_cmd_no_args("read-part-id", READ_PART_ID);
+ ret = isp_send_cmd_no_args("read-part-id", READ_PART_ID, quiet);
if (ret != 0) {
- printf("Read part ID error.\n");
+ if (quiet != 1) {
+ printf("Read part ID error.\n");
+ }
return ret;
}
len = isp_serial_read(buf, REP_BUFSIZE, 15);
char* tmp = NULL;
unsigned int ver[2];
- ret = isp_send_cmd_no_args("read-boot-version", READ_BOOT_VERSION);
+ ret = isp_send_cmd_no_args("read-boot-version", READ_BOOT_VERSION, 0);
if (ret != 0) {
printf("Read boot version error.\n");
return ret;
printf("Error reading %s acknowledge.\n", cmd_name);
return -4;
}
- ret = isp_ret_code(buf, NULL);
+ ret = isp_ret_code(buf, NULL, 0);
return ret;
}
printf("Error reading %s result.\n", name);
return -4;
}
- ret = isp_ret_code(buf, &tmp);
+ ret = isp_ret_code(buf, &tmp, 0);
return ret;
}
printf("Error reading go result.\n");
return -3;
}
- ret = isp_ret_code(buf, NULL);
+ ret = isp_ret_code(buf, NULL, 0);
if (ret != 0) {
printf("Error when trying to execute programm at 0x%08lx in %s mode.\n", addr, mode);
return -1;
printf("Error reading %s result.\n", name);
return -4;
}
- ret = isp_ret_code(buf, NULL);
+ ret = isp_ret_code(buf, NULL, 0);
return ret;
}