summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Martin <amartin@nvidia.com>2012-11-19 10:25:41 -0800
committerAllen Martin <amartin@nvidia.com>2012-11-29 11:00:38 -0800
commit53e2dc1e5e2252b16197135060a871a34c7b6da8 (patch)
treef8969e792bdfcd0dcbf4d57d88af8e5cf170d78b
parent665e2e7cacb9053eea5aa60f98201399b4b6a6f6 (diff)
downloadtegrarcm-53e2dc1e5e2252b16197135060a871a34c7b6da8.tar.gz
Add more verbose debug/error messages
Add more diagnostic information to some of the erorr/debug messages Signed-off-by: Allen Martin <amartin@nvidia.com> Change-Id: I6d2c996e02711fbf913e5f9332f7c2781c40a3a1 Reviewed-on: http://git-master/r/164847 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Stephen Warren <swarren@nvidia.com>
-rw-r--r--src/main.c14
-rw-r--r--src/nv3p.c35
2 files changed, 37 insertions, 12 deletions
diff --git a/src/main.c b/src/main.c
index f075c87..9d41e40 100644
--- a/src/main.c
+++ b/src/main.c
@@ -188,16 +188,16 @@ int main(int argc, char **argv)
// write query version message to device
ret = usb_write(usb, msg_buff, rcm_get_msg_len(msg_buff));
if (ret)
- error(1, errno, "USB transfer failure");
+ error(1, errno, "write query version - USB transfer failure");
free(msg_buff);
msg_buff = NULL;
// read response
ret = usb_read(usb, (uint8_t *)&status, sizeof(status), &actual_len);
if (ret)
- error(1, ret, "USB transfer failure");
+ error(1, ret, "read query version - USB transfer failure");
if (actual_len < sizeof(status))
- error(1, EIO, "USB read truncated");
+ error(1, EIO, "read query version - USB read truncated");
printf("RCM version: %d.%d\n", RCM_VERSION_MAJOR(status),
RCM_VERSION_MINOR(status));
@@ -269,13 +269,19 @@ static int wait_status(nv3p_handle_t h3p)
nv3p_cmd_status_t *status_arg = 0;
ret = nv3p_cmd_recv(h3p, &cmd, (void **)&status_arg);
- if (ret)
+ if (ret) {
+ dprintf("nv3p_cmd_recv failed\n");
goto fail;
+ }
if (cmd != NV3P_CMD_STATUS) {
+ dprintf("expecting NV3P_CMD_STATUS(0x%x) got 0x%x\n",
+ NV3P_CMD_STATUS, cmd);
ret = EIO;
goto fail;
}
if (status_arg->code != nv3p_status_ok) {
+ dprintf("expecting nv3p_status_ok(0x%x) got 0x%x\n",
+ nv3p_status_ok, status_arg->code);
ret = EIO;
goto fail;
}
diff --git a/src/nv3p.c b/src/nv3p.c
index 2db1905..19c5976 100644
--- a/src/nv3p.c
+++ b/src/nv3p.c
@@ -376,14 +376,18 @@ static int nv3p_recv_hdr(nv3p_handle_t h3p, nv3p_header_t *hdr,
tmp = &s_buffer[0];
length = NV3P_PACKET_SIZE_BASIC;
ret = nv3p_read(h3p->usb, tmp, length);
- if (ret)
+ if (ret) {
+ dprintf("error reading packet: %d\n", ret);
return ret;
+ }
READ32(tmp, hdr->version);
READ32(tmp, hdr->packet_type);
READ32(tmp, hdr->sequence);
if (hdr->version != NV3P_VERSION) {
+ dprintf("version mismatch, expecting NV3P_VERSION(0x%x), got 0x%x\n",
+ NV3P_VERSION, hdr->version);
return EINVAL;
}
@@ -600,18 +604,25 @@ int nv3p_cmd_recv(nv3p_handle_t h3p, uint32_t *command, void **args)
// get the basic header, verify it's a command
ret = nv3p_recv_hdr(h3p, &hdr, &recv_checksum);
- if (ret)
+ if (ret) {
+ dprintf("nv3p_recv_hdr returned %d\n", ret);
return ret;
+ }
- if(hdr.packet_type != NV3P_PACKET_TYPE_CMD)
+ if(hdr.packet_type != NV3P_PACKET_TYPE_CMD) {
+ dprintf("expecting NV3P_PACKET_TYPE_CMD(0x%x), got 0x%x\n",
+ NV3P_PACKET_TYPE_CMD, hdr.packet_type);
return nv3p_drain_packet(h3p, &hdr);
+ }
tmp = &s_buffer[0];
// get length and command number
ret = nv3p_read(h3p->usb, tmp, (2 * 4));
- if (ret)
+ if (ret) {
+ dprintf("nv3p_read() returned %d\n", ret);
return ret;
+ }
READ32(tmp, length);
READ32(tmp, *(uint32_t *)command);
@@ -619,12 +630,16 @@ int nv3p_cmd_recv(nv3p_handle_t h3p, uint32_t *command, void **args)
// read the args
if (length) {
ret = nv3p_read(h3p->usb, tmp, length);
- if (ret)
+ if (ret) {
+ dprintf("nv3p_read returned %d\n", ret);
return ret;
+ }
ret = nv3p_get_args(h3p, *command, args, tmp);
- if (ret)
+ if (ret) {
+ dprintf("nv3p_get_args returned %d\n", ret);
return ret;
+ }
} else {
// command may be output only
ret = nv3p_get_args(h3p, *command, args, 0);
@@ -637,11 +652,15 @@ int nv3p_cmd_recv(nv3p_handle_t h3p, uint32_t *command, void **args)
// get/verify the checksum
ret = nv3p_read(h3p->usb, (uint8_t *)&checksum, 4);
- if (ret)
+ if (ret) {
+ dprintf("nv3p_read returned %d reading checksum\n", ret);
return ret;
+ }
- if(recv_checksum + checksum != 0)
+ if(recv_checksum + checksum != 0) {
+ dprintf("checksum mismatch\n");
return EIO;
+ }
return 0;
}