From owner-freebsd-firewire@FreeBSD.ORG Sun Aug 17 03:46:00 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 178F51065672; Sun, 17 Aug 2008 03:46:00 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id D9A838FC0C; Sun, 17 Aug 2008 03:45:59 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 312E31A90C8; Sat, 16 Aug 2008 20:38:55 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Fl-LCtUbzu9Y; Sat, 16 Aug 2008 20:38:54 -0700 (PDT) Received: from [10.47.1.6] (vpn.office.miralink.com [10.0.0.5]) by plato.miralink.com (Postfix) with ESMTP id 970F31A90BE; Sat, 16 Aug 2008 20:38:53 -0700 (PDT) Message-ID: <48A79EF5.5010805@miralink.com> Date: Sat, 16 Aug 2008 20:45:57 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: freebsd-firewire@freebsd.org Content-Type: multipart/mixed; boundary="------------030404060106020503020701" Cc: Hidetoshi Shimokawa , Scott Long Subject: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Aug 2008 03:46:00 -0000 This is a multi-part message in MIME format. --------------030404060106020503020701 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I think that this is much closer to the finished product now. I've incorporated a lot of error checking and error reporting in this version(thanks Dieter!). I cleaned up the usage() summary along with the man page just a bit at Dieter's suggestion as well. The main changes are around the use of booleans for many of the new variables instead of integers. Also, I believe declaring the majority of the new integers as "int32_t" instead of "int" will ensure that the x86_64 compile doesn't spew any warnings, but I'd like a quick review please. Finally, this patch should work across 6/7/HEAD AFAIK. I've tested 6 and 7 under i368/i686 architectures. -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Cell 503-358-6832 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com --------------030404060106020503020701 Content-Type: text/x-patch; name="fwcontrol.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fwcontrol.diff" Index: fwcontrol.8 =================================================================== --- fwcontrol.8 (revision 181478) +++ fwcontrol.8 (working copy) @@ -59,7 +59,7 @@ The following options are available: .Bl -tag -width indent .It Fl u Ar bus_num -Specify the FireWire bus number to be operated on. +Specify the FireWire bus number to be operated on. Default is bus 0. .It Fl r Initiate bus reset. .It Fl t Index: fwcontrol.c =================================================================== --- fwcontrol.c (revision 181478) +++ fwcontrol.c (working copy) @@ -56,6 +56,8 @@ #include #include #include +#include +#include #include "fwmethods.h" static void sysctl_set_int(const char *, int); @@ -64,21 +66,22 @@ usage(void) { fprintf(stderr, - "fwcontrol [-u bus_num] [-rt] [-f node] [-g gap_count] " - "[-o node] " - "[-b pri_req] [-c node] [-d node] [-l file] " - "[-R file] [-S file] [-m target]\n" + "fwcontrol [-u bus_num] [-prt] [-c node] [-d node] [-o node] [-s node]\n" + "\t [-l file] [-g gap_count] [-f force_root ] [-b pri_req]\n" + "\t [-M mode] [-R filename] [-S filename] [-m EUI64 | hostname]\n" "\t-u: specify bus number\n" - "\t-f: broadcast force_root by phy_config packet\n" - "\t-g: broadcast gap_count by phy_config packet\n" - "\t-o: send link-on packet to the node\n" - "\t-s: write RESET_START register on the node\n" - "\t-b: set PRIORITY_BUDGET register on all supported nodes\n" - "\t-c: read configuration ROM\n" + "\t-p: Display current PHY register settings\n" "\t-r: bus reset\n" "\t-t: read topology map\n" + "\t-c: read configuration ROM\n" "\t-d: hex dump of configuration ROM\n" + "\t-o: send link-on packet to the node\n" + "\t-s: write RESET_START register on the node\n" "\t-l: load and parse hex dump file of configuration ROM\n" + "\t-g: broadcast gap_count by phy_config packet\n" + "\t-f: broadcast force_root by phy_config packet\n" + "\t-b: set PRIORITY_BUDGET register on all supported nodes\n" + "\t-M: specify dv or mpeg\n" "\t-R: Receive DV or MPEG TS stream\n" "\t-S: Send DV stream\n" "\t-m: set fwmem target\n"); @@ -92,18 +95,14 @@ *(u_int32_t*)&(eui->octet[4]) = htonl(fweui->lo); } -static struct fw_devlstreq * -get_dev(int fd) +static void +get_dev(int fd, struct fw_devlstreq *data) { - struct fw_devlstreq *data; - - data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); if (data == NULL) - err(1, "malloc"); + err(EX_SOFTWARE, "%s: data malloc", __func__); if( ioctl(fd, FW_GDEVLST, data) < 0) { - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); } - return data; } static int @@ -130,17 +129,25 @@ if (eui64_hostton(nodestr, &eui) != 0 && eui64_aton(nodestr, &eui) != 0) return (-1); - data = get_dev(fd); + data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); + if (data == NULL) + err(EX_SOFTWARE, "%s: data malloc", __func__); + get_dev(fd,data); for (i = 0; i < data->info_len; i++) { fweui2eui64(&data->dev[i].eui, &tmpeui); if (memcmp(&eui, &tmpeui, sizeof(struct eui64)) == 0) { node = data->dev[i].dst; + if (data != NULL) + free(data); goto gotnode; } } - if (i >= data->info_len) + if (i >= data->info_len) { + if (data != NULL) + free(data); return (-1); + } gotnode: if (node < 0 || node > 63) @@ -158,7 +165,10 @@ char addr[EUI64_SIZ], hostname[40]; int i; - data = get_dev(fd); + data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); + if (data == NULL) + err(EX_SOFTWARE, "%s:data malloc", __func__); + get_dev(fd, data); printf("%d devices (info_len=%d)\n", data->n, data->info_len); printf("node EUI64 status hostname\n"); for (i = 0; i < data->info_len; i++) { @@ -184,6 +194,8 @@ u_int32_t *qld, res; asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 16); + if (asyreq == NULL) + err(EX_SOFTWARE, "%s:asyreq malloc", __func__); asyreq->req.len = 16; #if 0 asyreq->req.type = FWASREQNODE; @@ -206,7 +218,7 @@ asyreq->pkt.mode.wreqq.data = htonl(data); if (ioctl(fd, FW_ASYREQ, asyreq) < 0) { - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); } res = qld[3]; free(asyreq); @@ -222,6 +234,8 @@ struct fw_asyreq *asyreq; asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 12); + if (asyreq == NULL) + err(EX_SOFTWARE, "%s:asyreq malloc", __func__); asyreq->req.len = 12; asyreq->req.type = FWASREQNODE; asyreq->pkt.mode.ld[0] = 0; @@ -237,16 +251,18 @@ root_node, gap_count); if (ioctl(fd, FW_ASYREQ, asyreq) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); free(asyreq); } static void -send_link_on(int fd, int node) +link_on(int fd, int node) { struct fw_asyreq *asyreq; asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 12); + if (asyreq == NULL) + err(EX_SOFTWARE, "%s:asyreq malloc", __func__); asyreq->req.len = 12; asyreq->req.type = FWASREQNODE; asyreq->pkt.mode.common.tcode = FWTCODE_PHY; @@ -254,7 +270,7 @@ asyreq->pkt.mode.ld[2] = ~asyreq->pkt.mode.ld[1]; if (ioctl(fd, FW_ASYREQ, asyreq) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); free(asyreq); } @@ -264,6 +280,8 @@ struct fw_asyreq *asyreq; asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 16); + if (asyreq == NULL) + err(EX_SOFTWARE, "%s:asyreq malloc", __func__); asyreq->req.len = 16; asyreq->req.type = FWASREQNODE; asyreq->pkt.mode.wreqq.dst = FWLOCALBUS | (node & 0x3f); @@ -276,7 +294,7 @@ asyreq->pkt.mode.wreqq.data = htonl(0x1); if (ioctl(fd, FW_ASYREQ, asyreq) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); free(asyreq); } @@ -290,7 +308,10 @@ u_int32_t max, reg, old; int i; - data = get_dev(fd); + data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); + if (data == NULL) + err(EX_SOFTWARE, "%s:data malloc", __func__); + get_dev(fd, data); #define BUGET_REG 0xf0000218 for (i = 0; i < data->info_len; i++) { devinfo = &data->dev[i]; @@ -344,7 +365,10 @@ int i, error; struct fw_devlstreq *data; - data = get_dev(fd); + data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); + if (data == NULL) + err(EX_SOFTWARE, "%s:data malloc", __func__); + get_dev(fd, data); for (i = 0; i < data->info_len; i++) { if (data->dev[i].dst == node && data->dev[i].eui.lo != 0) @@ -360,7 +384,7 @@ buf.ptr = crom_buf; bzero(crom_buf, len); if ((error = ioctl(fd, FW_GCROM, &buf)) < 0) { - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); } return error; @@ -469,9 +493,9 @@ static const char *speed[] = {"S100", "S200", "S400", "S800"}; tmap = malloc(sizeof(struct fw_topology_map)); if (tmap == NULL) - return; + err(EX_SOFTWARE, "%s:tmap malloc", __func__); if (ioctl(fd, FW_GTPMAP, tmap) < 0) { - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); } printf("crc_len: %d generation:%d node_count:%d sid_count:%d\n", tmap->crc_len, tmap->generation, @@ -512,7 +536,7 @@ for (i = 0; i < len; i++) { reg.addr = offset + i; if (ioctl(fd, FWOHCI_RDPHYREG, ®) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); buf[i] = (u_int8_t) reg.data; printf("0x%02x ", reg.data); } @@ -527,7 +551,7 @@ reg.addr = 0x7; reg.data = ((page & 7) << 5) | (port & 0xf); if (ioctl(fd, FWOHCI_WRPHYREG, ®) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); read_phy_registers(fd, buf, 8, 8); } @@ -590,22 +614,16 @@ ); } -static void -open_dev(int *fd, char *devbase) +static int +open_dev(int *fd, char *devname) { - char name[256]; - int i; - if (*fd < 0) { - for (i = 0; i < 4; i++) { - snprintf(name, sizeof(name), "%s.%d", devbase, i); - if ((*fd = open(name, O_RDWR)) >= 0) - break; - } + *fd = open(devname, O_RDWR); if (*fd < 0) - err(1, "open"); + return(-1); } + return(0); } static void @@ -634,15 +652,17 @@ bufreq.tx.psize = 0; if (ioctl(fd, FW_SSTBUF, &bufreq) < 0) - err(1, "ioctl FW_SSTBUF"); + err(EX_IOERR, "%s: ioctl FW_SSTBUF", __func__); isoreq.ch = ich & 0x3f; isoreq.tag = (ich >> 6) & 3; if (ioctl(fd, FW_SRSTREAM, &isoreq) < 0) - err(1, "ioctl FW_SRSTREAM"); + err(EX_IOERR, "%s: ioctl FW_SRSTREAM", __func__); buf = (char *)malloc(1024*16); + if (buf == NULL) + err(EX_SOFTWARE, "%s:buf malloc", __func__); len = read(fd, buf, 1024*16); ptr = (u_int32_t *) buf; ciph = (struct ciphdr *)(ptr + 1); @@ -666,99 +686,166 @@ int main(int argc, char **argv) { +#define MAX_BOARDS 10 u_int32_t crom_buf[1024/4]; - char devbase[1024] = "/dev/fw0"; - int fd, ch, len=1024; + u_int32_t crom_buf_hex[1024/4]; + char devbase[64]; + const char *device_string = "/dev/fw"; + int fd = -1, ch, len=1024; + int32_t current_board = 0; + /* + * If !command_set, then -u will display the nodes for the board. + * This emulates the previous behavior when -u is passed by itself + */ + bool command_set = false; + bool open_needed = false; long tmp; struct fw_eui64 eui; struct eui64 target; fwmethod *recvfn = NULL; +/* + * Holders for which functions + * to iterate through + */ + bool display_board_only = false; + bool display_crom = false; + bool send_bus_reset = false; + bool display_crom_hex = false; + bool load_crom_from_file = false; + bool set_fwmem_target = false; + bool dump_topology = false; + bool dump_phy_reg = false; - fd = -1; + int32_t priority_budget = -1; + int32_t adjust_gap_count = -1; + int32_t reset_gap_count = -1; + int32_t send_link_on = -1; + int32_t send_reset_start = -1; + char *crom_string = NULL; + char *crom_string_hex = NULL; + char *recv_data = NULL; + char *send_data = NULL; + if (argc < 2) { - open_dev(&fd, devbase); - list_dev(fd); + for (current_board = 0; current_board < MAX_BOARDS; current_board++) { + snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); + if (open_dev(&fd, devbase) < 0) { + if (current_board == 0) { + usage(); + } + return(EIO); + } + list_dev(fd); + close(fd); + fd = -1; + } } - - while ((ch = getopt(argc, argv, "M:f:g:m:o:s:b:prtc:d:l:u:R:S:")) != -1) + /* + * Parse all command line options, then execute requested operations. + */ + while ((ch = getopt(argc, argv, "M:f:g:m:o:s:b:prtc:d:l:u:R:S:")) != -1) { switch(ch) { case 'b': - tmp = strtol(optarg, NULL, 0); - if (tmp < 0 || tmp > (long)0xffffffff) - errx(EX_USAGE, "invalid number: %s", optarg); - open_dev(&fd, devbase); - set_pri_req(fd, tmp); + priority_budget = strtol(optarg, NULL, 0); + if (priority_budget < 0 || priority_budget > INT32_MAX) + errx(EX_USAGE, "%s: invalid number: %s", __func__, optarg); + command_set = true; + open_needed = true; + display_board_only = false; break; case 'c': - open_dev(&fd, devbase); - tmp = str2node(fd, optarg); - get_crom(fd, tmp, crom_buf, len); - show_crom(crom_buf); + crom_string = malloc(strlen(optarg)+1); + if (crom_string == NULL) + err(EX_SOFTWARE, "%s:crom_string malloc", __func__); + if ( (strtol(crom_string, NULL, 0) < 0) || strtol(crom_string, NULL, 0) > MAX_BOARDS) + err(EX_USAGE, "%s:Invalid value for node", __func__); + strcpy(crom_string, optarg); + display_crom = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 'd': - open_dev(&fd, devbase); - tmp = str2node(fd, optarg); - get_crom(fd, tmp, crom_buf, len); - dump_crom(crom_buf); + crom_string_hex = malloc(strlen(optarg)+1); + if (crom_string_hex == NULL) + err(EX_SOFTWARE, "%s:crom_string_hex malloc", __func__); + strcpy(crom_string_hex, optarg); + display_crom_hex = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 'f': - tmp = strtol(optarg, NULL, 0); - open_dev(&fd, devbase); - send_phy_config(fd, tmp, -1); + adjust_gap_count = strtol(optarg, NULL, 0); + if ( (adjust_gap_count < 0) || (adjust_gap_count > INT32_MAX) ) + err(EX_USAGE, "%s:adjust_gap_count out of range", __func__); + open_needed = true; + command_set = true; + display_board_only = false; break; case 'g': - tmp = strtol(optarg, NULL, 0); - open_dev(&fd, devbase); - send_phy_config(fd, -1, tmp); + reset_gap_count = strtol(optarg, NULL, 0); + if ( (reset_gap_count < 0) || (reset_gap_count > INT32_MAX) ) + err(EX_USAGE, "%s:reset_gap_count out of range", __func__); + open_needed = true; + command_set = true; + display_board_only = false; break; case 'l': + load_crom_from_file = 1; load_crom(optarg, crom_buf); - show_crom(crom_buf); + command_set = true; + display_board_only = false; break; case 'm': - if (eui64_hostton(optarg, &target) != 0 && - eui64_aton(optarg, &target) != 0) - errx(EX_USAGE, "invalid target: %s", optarg); - eui.hi = ntohl(*(u_int32_t*)&(target.octet[0])); - eui.lo = ntohl(*(u_int32_t*)&(target.octet[4])); - sysctl_set_int("hw.firewire.fwmem.eui64_hi", eui.hi); - sysctl_set_int("hw.firewire.fwmem.eui64_lo", eui.lo); + set_fwmem_target = 1; + open_needed = 0; + command_set = true; + display_board_only = false; + if (eui64_hostton(optarg, &target) != 0 && + eui64_aton(optarg, &target) != 0) + err(EX_USAGE, "%s: invalid target: %s", __func__, optarg); break; case 'o': - open_dev(&fd, devbase); - tmp = str2node(fd, optarg); - send_link_on(fd, tmp); + send_link_on = str2node(fd, optarg); + if ( (send_link_on < 0) || (send_link_on > INT32_MAX) ) + err(EX_USAGE, "%s: node out of range: %s\n",__func__, optarg); + open_needed = true; + command_set = true; + display_board_only = false; break; case 'p': - open_dev(&fd, devbase); - dump_phy_registers(fd); + dump_phy_reg = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 'r': - open_dev(&fd, devbase); - if(ioctl(fd, FW_IBUSRST, &tmp) < 0) - err(1, "ioctl"); + send_bus_reset = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 's': - open_dev(&fd, devbase); - tmp = str2node(fd, optarg); - reset_start(fd, tmp); + send_reset_start = str2node(fd, optarg); + if ( (send_reset_start < 0) || (send_reset_start > INT32_MAX) ) + err(EX_USAGE, "%s: node out of range: %s\n", __func__, optarg); + open_needed = true; + command_set = true; + display_board_only = false; break; case 't': - open_dev(&fd, devbase); - show_topology_map(fd); + dump_topology = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 'u': - tmp = strtol(optarg, NULL, 0); - snprintf(devbase, sizeof(devbase), "/dev/fw%ld", tmp); - if (fd > 0) { - close(fd); - fd = -1; - } - if (argc == optind) { - open_dev(&fd, devbase); - list_dev(fd); - } + if(!command_set) + display_board_only = true; + current_board = strtol(optarg, NULL, 0); + open_needed = true; break; #define TAG (1<<6) #define CHANNEL 63 @@ -774,22 +861,156 @@ errx(EX_USAGE, "unrecognized method: %s", optarg); } + command_set = true; + display_board_only = false; break; case 'R': - open_dev(&fd, devbase); - if (recvfn == NULL) /* guess... */ - recvfn = detect_recv_fn(fd, TAG | CHANNEL); - close(fd); - fd = -1; - open_dev(&fd, devbase); - (*recvfn)(fd, optarg, TAG | CHANNEL, -1); + recv_data = malloc(strlen(optarg)+1); + if (recv_data == NULL) + err(EX_SOFTWARE, "%s:recv_data malloc", __func__); + strcpy(recv_data, optarg); + open_needed = true; + command_set = true; + display_board_only = false; break; case 'S': - open_dev(&fd, devbase); - dvsend(fd, optarg, TAG | CHANNEL, -1); + send_data = malloc(strlen(optarg)+1); + if (send_data == NULL) + err(EX_SOFTWARE, "%s:send_data malloc", __func__); + strcpy(send_data, optarg); + open_needed = true; + display_board_only = false; break; default: usage(); + return 0; } + } /* end while */ + + /* + * If -u is passed, execute + * command for that card only. + * + * If -u is not passed, execute + * command for card 0 only. + * + */ + if(open_needed){ + snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); + if (open_dev(&fd, devbase) < 0) { + errx(EX_IOERR, "%s: Error opening board #%d\n", __func__, current_board); + } + } + /* + * display the nodes on this board "-u" + * only + */ + if (display_board_only) + list_dev(fd); + + /* + * dump_phy_reg "-p" + */ + if (dump_phy_reg) + dump_phy_registers(fd); + + /* + * send a BUS_RESET Event "-r" + */ + if (send_bus_reset) { + if(ioctl(fd, FW_IBUSRST, &tmp) < 0) + err(EX_IOERR, "%s: ioctl", __func__); + } + /* + * Print out the CROM for this node "-c" + */ + if (display_crom) { + tmp = str2node(fd, crom_string); + get_crom(fd, tmp, crom_buf, len); + show_crom(crom_buf); + free(crom_string); + } + /* + * Hex Dump the CROM for this node "-d" + */ + if (display_crom_hex) { + tmp = str2node(fd, crom_string_hex); + get_crom(fd, tmp, crom_buf_hex, len); + dump_crom(crom_buf_hex); + free(crom_string_hex); + } + /* + * Set Priority Budget to value for this node "-b" + */ + if (priority_budget >= 0) + set_pri_req(fd, priority_budget); + + /* + * Adjust the gap count for this card/bus to value "-f" + */ + if (adjust_gap_count >= 0) + send_phy_config(fd, adjust_gap_count, -1); + + /* + * Reset the gap count for this card/bus "-g" + */ + if (reset_gap_count >= 0) + send_phy_config(fd, -1, reset_gap_count); + + /* + * Load a CROM from a file "-l" + */ + if (load_crom_from_file) + show_crom(crom_buf); + /* + * Set the fwmem target for a node to argument "-m" + */ + if (set_fwmem_target) { + eui.hi = ntohl(*(u_int32_t*)&(target.octet[0])); + eui.lo = ntohl(*(u_int32_t*)&(target.octet[4])); + sysctl_set_int("hw.firewire.fwmem.eui64_hi", eui.hi); + sysctl_set_int("hw.firewire.fwmem.eui64_lo", eui.lo); + } + + /* + * Send a link on to this board/bus "-o" + */ + if (send_link_on >= 0) + link_on(fd, send_link_on); + + /* + * Send a reset start to this board/bus "-s" + */ + if (send_reset_start >= 0) + reset_start(fd, send_reset_start); + + /* + * Dump the node topology for this board/bus "-t" + */ + if (dump_topology) + show_topology_map(fd); + + /* + * Recieve data file from node "-R" + */ + if (recv_data != NULL){ + if (recvfn == NULL) /* guess... */ + recvfn = detect_recv_fn(fd, TAG | CHANNEL); + (*recvfn)(fd, recv_data, TAG | CHANNEL, -1); + free(recv_data); + } + + /* + * Send data file to node "-S" + */ + if (send_data != NULL){ + dvsend(fd, send_data, TAG | CHANNEL, -1); + free(send_data); + } + + if (fd > 0) { + close(fd); + fd = -1; + } return 0; } --------------030404060106020503020701-- From owner-freebsd-firewire@FreeBSD.ORG Sun Aug 17 17:06:27 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27DF91065675; Sun, 17 Aug 2008 17:06:27 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 380B78FC31; Sun, 17 Aug 2008 17:06:25 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7HH6GV49039; Sun, 17 Aug 2008 10:06:16 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id RAA12502; Sun, 17 Aug 2008 17:05:08 GMT Message-Id: <200808171705.RAA12502@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Sat, 16 Aug 2008 20:45:57 PDT." <48A79EF5.5010805@miralink.com> Date: Sun, 17 Aug 2008 10:05:08 +0100 From: Dieter Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Aug 2008 17:06:27 -0000 > len = read(fd, buf, 1024*16); It would be good practice to check for read failing. From owner-freebsd-firewire@FreeBSD.ORG Sun Aug 17 17:34:53 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CDA8C1065675; Sun, 17 Aug 2008 17:34:53 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id 972FB8FC1A; Sun, 17 Aug 2008 17:34:53 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id D1ADE1A90DA; Sun, 17 Aug 2008 10:27:41 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HUBthofHMQV7; Sun, 17 Aug 2008 10:27:40 -0700 (PDT) Received: from [10.47.1.6] (vpn.office.miralink.com [10.0.0.5]) by plato.miralink.com (Postfix) with ESMTP id 2616D1A90CA; Sun, 17 Aug 2008 10:27:40 -0700 (PDT) Message-ID: <48A8613A.4000506@miralink.com> Date: Sun, 17 Aug 2008 10:34:50 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808171705.RAA12502@sopwith.solgatos.com> In-Reply-To: <200808171705.RAA12502@sopwith.solgatos.com> Content-Type: multipart/mixed; boundary="------------070705040800010708040509" Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Aug 2008 17:34:53 -0000 This is a multi-part message in MIME format. --------------070705040800010708040509 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Dieter wrote: >> len = read(fd, buf, 1024*16); >> > > It would be good practice to check for read failing. > Indeed it would. I looked into fwdev.c::fw_read() a little bit and documented what I think it's doing as well. -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Cell 503-358-6832 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com --------------070705040800010708040509 Content-Type: text/x-patch; name="fwcontrol.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fwcontrol.diff" Index: fwcontrol.8 =================================================================== --- fwcontrol.8 (revision 181478) +++ fwcontrol.8 (working copy) @@ -59,7 +59,7 @@ The following options are available: .Bl -tag -width indent .It Fl u Ar bus_num -Specify the FireWire bus number to be operated on. +Specify the FireWire bus number to be operated on. Default is bus 0. .It Fl r Initiate bus reset. .It Fl t Index: fwcontrol.c =================================================================== --- fwcontrol.c (revision 181478) +++ fwcontrol.c (working copy) @@ -56,6 +56,8 @@ #include #include #include +#include +#include #include "fwmethods.h" static void sysctl_set_int(const char *, int); @@ -64,21 +66,22 @@ usage(void) { fprintf(stderr, - "fwcontrol [-u bus_num] [-rt] [-f node] [-g gap_count] " - "[-o node] " - "[-b pri_req] [-c node] [-d node] [-l file] " - "[-R file] [-S file] [-m target]\n" + "fwcontrol [-u bus_num] [-prt] [-c node] [-d node] [-o node] [-s node]\n" + "\t [-l file] [-g gap_count] [-f force_root ] [-b pri_req]\n" + "\t [-M mode] [-R filename] [-S filename] [-m EUI64 | hostname]\n" "\t-u: specify bus number\n" - "\t-f: broadcast force_root by phy_config packet\n" - "\t-g: broadcast gap_count by phy_config packet\n" - "\t-o: send link-on packet to the node\n" - "\t-s: write RESET_START register on the node\n" - "\t-b: set PRIORITY_BUDGET register on all supported nodes\n" - "\t-c: read configuration ROM\n" + "\t-p: Display current PHY register settings\n" "\t-r: bus reset\n" "\t-t: read topology map\n" + "\t-c: read configuration ROM\n" "\t-d: hex dump of configuration ROM\n" + "\t-o: send link-on packet to the node\n" + "\t-s: write RESET_START register on the node\n" "\t-l: load and parse hex dump file of configuration ROM\n" + "\t-g: broadcast gap_count by phy_config packet\n" + "\t-f: broadcast force_root by phy_config packet\n" + "\t-b: set PRIORITY_BUDGET register on all supported nodes\n" + "\t-M: specify dv or mpeg\n" "\t-R: Receive DV or MPEG TS stream\n" "\t-S: Send DV stream\n" "\t-m: set fwmem target\n"); @@ -92,18 +95,14 @@ *(u_int32_t*)&(eui->octet[4]) = htonl(fweui->lo); } -static struct fw_devlstreq * -get_dev(int fd) +static void +get_dev(int fd, struct fw_devlstreq *data) { - struct fw_devlstreq *data; - - data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); if (data == NULL) - err(1, "malloc"); + err(EX_SOFTWARE, "%s: data malloc", __func__); if( ioctl(fd, FW_GDEVLST, data) < 0) { - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); } - return data; } static int @@ -130,17 +129,25 @@ if (eui64_hostton(nodestr, &eui) != 0 && eui64_aton(nodestr, &eui) != 0) return (-1); - data = get_dev(fd); + data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); + if (data == NULL) + err(EX_SOFTWARE, "%s: data malloc", __func__); + get_dev(fd,data); for (i = 0; i < data->info_len; i++) { fweui2eui64(&data->dev[i].eui, &tmpeui); if (memcmp(&eui, &tmpeui, sizeof(struct eui64)) == 0) { node = data->dev[i].dst; + if (data != NULL) + free(data); goto gotnode; } } - if (i >= data->info_len) + if (i >= data->info_len) { + if (data != NULL) + free(data); return (-1); + } gotnode: if (node < 0 || node > 63) @@ -158,7 +165,10 @@ char addr[EUI64_SIZ], hostname[40]; int i; - data = get_dev(fd); + data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); + if (data == NULL) + err(EX_SOFTWARE, "%s:data malloc", __func__); + get_dev(fd, data); printf("%d devices (info_len=%d)\n", data->n, data->info_len); printf("node EUI64 status hostname\n"); for (i = 0; i < data->info_len; i++) { @@ -184,6 +194,8 @@ u_int32_t *qld, res; asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 16); + if (asyreq == NULL) + err(EX_SOFTWARE, "%s:asyreq malloc", __func__); asyreq->req.len = 16; #if 0 asyreq->req.type = FWASREQNODE; @@ -206,7 +218,7 @@ asyreq->pkt.mode.wreqq.data = htonl(data); if (ioctl(fd, FW_ASYREQ, asyreq) < 0) { - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); } res = qld[3]; free(asyreq); @@ -222,6 +234,8 @@ struct fw_asyreq *asyreq; asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 12); + if (asyreq == NULL) + err(EX_SOFTWARE, "%s:asyreq malloc", __func__); asyreq->req.len = 12; asyreq->req.type = FWASREQNODE; asyreq->pkt.mode.ld[0] = 0; @@ -237,16 +251,18 @@ root_node, gap_count); if (ioctl(fd, FW_ASYREQ, asyreq) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); free(asyreq); } static void -send_link_on(int fd, int node) +link_on(int fd, int node) { struct fw_asyreq *asyreq; asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 12); + if (asyreq == NULL) + err(EX_SOFTWARE, "%s:asyreq malloc", __func__); asyreq->req.len = 12; asyreq->req.type = FWASREQNODE; asyreq->pkt.mode.common.tcode = FWTCODE_PHY; @@ -254,7 +270,7 @@ asyreq->pkt.mode.ld[2] = ~asyreq->pkt.mode.ld[1]; if (ioctl(fd, FW_ASYREQ, asyreq) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); free(asyreq); } @@ -264,6 +280,8 @@ struct fw_asyreq *asyreq; asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 16); + if (asyreq == NULL) + err(EX_SOFTWARE, "%s:asyreq malloc", __func__); asyreq->req.len = 16; asyreq->req.type = FWASREQNODE; asyreq->pkt.mode.wreqq.dst = FWLOCALBUS | (node & 0x3f); @@ -276,7 +294,7 @@ asyreq->pkt.mode.wreqq.data = htonl(0x1); if (ioctl(fd, FW_ASYREQ, asyreq) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); free(asyreq); } @@ -290,7 +308,10 @@ u_int32_t max, reg, old; int i; - data = get_dev(fd); + data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); + if (data == NULL) + err(EX_SOFTWARE, "%s:data malloc", __func__); + get_dev(fd, data); #define BUGET_REG 0xf0000218 for (i = 0; i < data->info_len; i++) { devinfo = &data->dev[i]; @@ -344,7 +365,10 @@ int i, error; struct fw_devlstreq *data; - data = get_dev(fd); + data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); + if (data == NULL) + err(EX_SOFTWARE, "%s:data malloc", __func__); + get_dev(fd, data); for (i = 0; i < data->info_len; i++) { if (data->dev[i].dst == node && data->dev[i].eui.lo != 0) @@ -360,7 +384,7 @@ buf.ptr = crom_buf; bzero(crom_buf, len); if ((error = ioctl(fd, FW_GCROM, &buf)) < 0) { - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); } return error; @@ -469,9 +493,9 @@ static const char *speed[] = {"S100", "S200", "S400", "S800"}; tmap = malloc(sizeof(struct fw_topology_map)); if (tmap == NULL) - return; + err(EX_SOFTWARE, "%s:tmap malloc", __func__); if (ioctl(fd, FW_GTPMAP, tmap) < 0) { - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); } printf("crc_len: %d generation:%d node_count:%d sid_count:%d\n", tmap->crc_len, tmap->generation, @@ -512,7 +536,7 @@ for (i = 0; i < len; i++) { reg.addr = offset + i; if (ioctl(fd, FWOHCI_RDPHYREG, ®) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); buf[i] = (u_int8_t) reg.data; printf("0x%02x ", reg.data); } @@ -527,7 +551,7 @@ reg.addr = 0x7; reg.data = ((page & 7) << 5) | (port & 0xf); if (ioctl(fd, FWOHCI_WRPHYREG, ®) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); read_phy_registers(fd, buf, 8, 8); } @@ -590,22 +614,16 @@ ); } -static void -open_dev(int *fd, char *devbase) +static int +open_dev(int *fd, char *devname) { - char name[256]; - int i; - if (*fd < 0) { - for (i = 0; i < 4; i++) { - snprintf(name, sizeof(name), "%s.%d", devbase, i); - if ((*fd = open(name, O_RDWR)) >= 0) - break; - } + *fd = open(devname, O_RDWR); if (*fd < 0) - err(1, "open"); + return(-1); } + return(0); } static void @@ -625,25 +643,40 @@ u_int32_t *ptr; struct ciphdr *ciph; fwmethod *retfn; +#define RECV_NUM_PACKET 16 +#define RECV_PACKET_SZ 1024 bufreq.rx.nchunk = 8; - bufreq.rx.npacket = 16; - bufreq.rx.psize = 1024; + bufreq.rx.npacket = RECV_NUM_PACKET; + bufreq.rx.psize = RECV_PACKET_SZ; bufreq.tx.nchunk = 0; bufreq.tx.npacket = 0; bufreq.tx.psize = 0; if (ioctl(fd, FW_SSTBUF, &bufreq) < 0) - err(1, "ioctl FW_SSTBUF"); + err(EX_IOERR, "%s: ioctl FW_SSTBUF", __func__); isoreq.ch = ich & 0x3f; isoreq.tag = (ich >> 6) & 3; if (ioctl(fd, FW_SRSTREAM, &isoreq) < 0) - err(1, "ioctl FW_SRSTREAM"); + err(EX_IOERR, "%s: ioctl FW_SRSTREAM", __func__); - buf = (char *)malloc(1024*16); - len = read(fd, buf, 1024*16); + buf = (char *)malloc(RECV_NUM_PACKET * RECV_PACKET_SZ); + if (buf == NULL) + err(EX_SOFTWARE, "%s:buf malloc", __func__); + /* + * fwdev.c seems to return EIO on error and + * the return value of the last uiomove + * on success. For now, checking that the + * return is not less than zero should be + * sufficient. fwdev.c::fw_read() should + * return the total length read, not the value + * of the last uiomove(). + */ + len = read(fd, buf, RECV_NUM_PACKET * RECV_PACKET_SZ); + if (len < 0) + err(EX_IOERR, "%s: error reading from device\n", __func__); ptr = (u_int32_t *) buf; ciph = (struct ciphdr *)(ptr + 1); @@ -666,99 +699,166 @@ int main(int argc, char **argv) { +#define MAX_BOARDS 10 u_int32_t crom_buf[1024/4]; - char devbase[1024] = "/dev/fw0"; - int fd, ch, len=1024; + u_int32_t crom_buf_hex[1024/4]; + char devbase[64]; + const char *device_string = "/dev/fw"; + int fd = -1, ch, len=1024; + int32_t current_board = 0; + /* + * If !command_set, then -u will display the nodes for the board. + * This emulates the previous behavior when -u is passed by itself + */ + bool command_set = false; + bool open_needed = false; long tmp; struct fw_eui64 eui; struct eui64 target; fwmethod *recvfn = NULL; +/* + * Holders for which functions + * to iterate through + */ + bool display_board_only = false; + bool display_crom = false; + bool send_bus_reset = false; + bool display_crom_hex = false; + bool load_crom_from_file = false; + bool set_fwmem_target = false; + bool dump_topology = false; + bool dump_phy_reg = false; - fd = -1; + int32_t priority_budget = -1; + int32_t adjust_gap_count = -1; + int32_t reset_gap_count = -1; + int32_t send_link_on = -1; + int32_t send_reset_start = -1; + char *crom_string = NULL; + char *crom_string_hex = NULL; + char *recv_data = NULL; + char *send_data = NULL; + if (argc < 2) { - open_dev(&fd, devbase); - list_dev(fd); + for (current_board = 0; current_board < MAX_BOARDS; current_board++) { + snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); + if (open_dev(&fd, devbase) < 0) { + if (current_board == 0) { + usage(); + } + return(EIO); + } + list_dev(fd); + close(fd); + fd = -1; + } } - - while ((ch = getopt(argc, argv, "M:f:g:m:o:s:b:prtc:d:l:u:R:S:")) != -1) + /* + * Parse all command line options, then execute requested operations. + */ + while ((ch = getopt(argc, argv, "M:f:g:m:o:s:b:prtc:d:l:u:R:S:")) != -1) { switch(ch) { case 'b': - tmp = strtol(optarg, NULL, 0); - if (tmp < 0 || tmp > (long)0xffffffff) - errx(EX_USAGE, "invalid number: %s", optarg); - open_dev(&fd, devbase); - set_pri_req(fd, tmp); + priority_budget = strtol(optarg, NULL, 0); + if (priority_budget < 0 || priority_budget > INT32_MAX) + errx(EX_USAGE, "%s: invalid number: %s", __func__, optarg); + command_set = true; + open_needed = true; + display_board_only = false; break; case 'c': - open_dev(&fd, devbase); - tmp = str2node(fd, optarg); - get_crom(fd, tmp, crom_buf, len); - show_crom(crom_buf); + crom_string = malloc(strlen(optarg)+1); + if (crom_string == NULL) + err(EX_SOFTWARE, "%s:crom_string malloc", __func__); + if ( (strtol(crom_string, NULL, 0) < 0) || strtol(crom_string, NULL, 0) > MAX_BOARDS) + err(EX_USAGE, "%s:Invalid value for node", __func__); + strcpy(crom_string, optarg); + display_crom = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 'd': - open_dev(&fd, devbase); - tmp = str2node(fd, optarg); - get_crom(fd, tmp, crom_buf, len); - dump_crom(crom_buf); + crom_string_hex = malloc(strlen(optarg)+1); + if (crom_string_hex == NULL) + err(EX_SOFTWARE, "%s:crom_string_hex malloc", __func__); + strcpy(crom_string_hex, optarg); + display_crom_hex = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 'f': - tmp = strtol(optarg, NULL, 0); - open_dev(&fd, devbase); - send_phy_config(fd, tmp, -1); + adjust_gap_count = strtol(optarg, NULL, 0); + if ( (adjust_gap_count < 0) || (adjust_gap_count > INT32_MAX) ) + err(EX_USAGE, "%s:adjust_gap_count out of range", __func__); + open_needed = true; + command_set = true; + display_board_only = false; break; case 'g': - tmp = strtol(optarg, NULL, 0); - open_dev(&fd, devbase); - send_phy_config(fd, -1, tmp); + reset_gap_count = strtol(optarg, NULL, 0); + if ( (reset_gap_count < 0) || (reset_gap_count > INT32_MAX) ) + err(EX_USAGE, "%s:reset_gap_count out of range", __func__); + open_needed = true; + command_set = true; + display_board_only = false; break; case 'l': + load_crom_from_file = 1; load_crom(optarg, crom_buf); - show_crom(crom_buf); + command_set = true; + display_board_only = false; break; case 'm': - if (eui64_hostton(optarg, &target) != 0 && - eui64_aton(optarg, &target) != 0) - errx(EX_USAGE, "invalid target: %s", optarg); - eui.hi = ntohl(*(u_int32_t*)&(target.octet[0])); - eui.lo = ntohl(*(u_int32_t*)&(target.octet[4])); - sysctl_set_int("hw.firewire.fwmem.eui64_hi", eui.hi); - sysctl_set_int("hw.firewire.fwmem.eui64_lo", eui.lo); + set_fwmem_target = 1; + open_needed = 0; + command_set = true; + display_board_only = false; + if (eui64_hostton(optarg, &target) != 0 && + eui64_aton(optarg, &target) != 0) + err(EX_USAGE, "%s: invalid target: %s", __func__, optarg); break; case 'o': - open_dev(&fd, devbase); - tmp = str2node(fd, optarg); - send_link_on(fd, tmp); + send_link_on = str2node(fd, optarg); + if ( (send_link_on < 0) || (send_link_on > INT32_MAX) ) + err(EX_USAGE, "%s: node out of range: %s\n",__func__, optarg); + open_needed = true; + command_set = true; + display_board_only = false; break; case 'p': - open_dev(&fd, devbase); - dump_phy_registers(fd); + dump_phy_reg = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 'r': - open_dev(&fd, devbase); - if(ioctl(fd, FW_IBUSRST, &tmp) < 0) - err(1, "ioctl"); + send_bus_reset = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 's': - open_dev(&fd, devbase); - tmp = str2node(fd, optarg); - reset_start(fd, tmp); + send_reset_start = str2node(fd, optarg); + if ( (send_reset_start < 0) || (send_reset_start > INT32_MAX) ) + err(EX_USAGE, "%s: node out of range: %s\n", __func__, optarg); + open_needed = true; + command_set = true; + display_board_only = false; break; case 't': - open_dev(&fd, devbase); - show_topology_map(fd); + dump_topology = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 'u': - tmp = strtol(optarg, NULL, 0); - snprintf(devbase, sizeof(devbase), "/dev/fw%ld", tmp); - if (fd > 0) { - close(fd); - fd = -1; - } - if (argc == optind) { - open_dev(&fd, devbase); - list_dev(fd); - } + if(!command_set) + display_board_only = true; + current_board = strtol(optarg, NULL, 0); + open_needed = true; break; #define TAG (1<<6) #define CHANNEL 63 @@ -774,22 +874,156 @@ errx(EX_USAGE, "unrecognized method: %s", optarg); } + command_set = true; + display_board_only = false; break; case 'R': - open_dev(&fd, devbase); - if (recvfn == NULL) /* guess... */ - recvfn = detect_recv_fn(fd, TAG | CHANNEL); - close(fd); - fd = -1; - open_dev(&fd, devbase); - (*recvfn)(fd, optarg, TAG | CHANNEL, -1); + recv_data = malloc(strlen(optarg)+1); + if (recv_data == NULL) + err(EX_SOFTWARE, "%s:recv_data malloc", __func__); + strcpy(recv_data, optarg); + open_needed = true; + command_set = true; + display_board_only = false; break; case 'S': - open_dev(&fd, devbase); - dvsend(fd, optarg, TAG | CHANNEL, -1); + send_data = malloc(strlen(optarg)+1); + if (send_data == NULL) + err(EX_SOFTWARE, "%s:send_data malloc", __func__); + strcpy(send_data, optarg); + open_needed = true; + display_board_only = false; break; default: usage(); + return 0; } + } /* end while */ + + /* + * If -u is passed, execute + * command for that card only. + * + * If -u is not passed, execute + * command for card 0 only. + * + */ + if(open_needed){ + snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); + if (open_dev(&fd, devbase) < 0) { + errx(EX_IOERR, "%s: Error opening board #%d\n", __func__, current_board); + } + } + /* + * display the nodes on this board "-u" + * only + */ + if (display_board_only) + list_dev(fd); + + /* + * dump_phy_reg "-p" + */ + if (dump_phy_reg) + dump_phy_registers(fd); + + /* + * send a BUS_RESET Event "-r" + */ + if (send_bus_reset) { + if(ioctl(fd, FW_IBUSRST, &tmp) < 0) + err(EX_IOERR, "%s: ioctl", __func__); + } + /* + * Print out the CROM for this node "-c" + */ + if (display_crom) { + tmp = str2node(fd, crom_string); + get_crom(fd, tmp, crom_buf, len); + show_crom(crom_buf); + free(crom_string); + } + /* + * Hex Dump the CROM for this node "-d" + */ + if (display_crom_hex) { + tmp = str2node(fd, crom_string_hex); + get_crom(fd, tmp, crom_buf_hex, len); + dump_crom(crom_buf_hex); + free(crom_string_hex); + } + /* + * Set Priority Budget to value for this node "-b" + */ + if (priority_budget >= 0) + set_pri_req(fd, priority_budget); + + /* + * Adjust the gap count for this card/bus to value "-f" + */ + if (adjust_gap_count >= 0) + send_phy_config(fd, adjust_gap_count, -1); + + /* + * Reset the gap count for this card/bus "-g" + */ + if (reset_gap_count >= 0) + send_phy_config(fd, -1, reset_gap_count); + + /* + * Load a CROM from a file "-l" + */ + if (load_crom_from_file) + show_crom(crom_buf); + /* + * Set the fwmem target for a node to argument "-m" + */ + if (set_fwmem_target) { + eui.hi = ntohl(*(u_int32_t*)&(target.octet[0])); + eui.lo = ntohl(*(u_int32_t*)&(target.octet[4])); + sysctl_set_int("hw.firewire.fwmem.eui64_hi", eui.hi); + sysctl_set_int("hw.firewire.fwmem.eui64_lo", eui.lo); + } + + /* + * Send a link on to this board/bus "-o" + */ + if (send_link_on >= 0) + link_on(fd, send_link_on); + + /* + * Send a reset start to this board/bus "-s" + */ + if (send_reset_start >= 0) + reset_start(fd, send_reset_start); + + /* + * Dump the node topology for this board/bus "-t" + */ + if (dump_topology) + show_topology_map(fd); + + /* + * Recieve data file from node "-R" + */ + if (recv_data != NULL){ + if (recvfn == NULL) /* guess... */ + recvfn = detect_recv_fn(fd, TAG | CHANNEL); + (*recvfn)(fd, recv_data, TAG | CHANNEL, -1); + free(recv_data); + } + + /* + * Send data file to node "-S" + */ + if (send_data != NULL){ + dvsend(fd, send_data, TAG | CHANNEL, -1); + free(send_data); + } + + if (fd > 0) { + close(fd); + fd = -1; + } return 0; } --------------070705040800010708040509-- From owner-freebsd-firewire@FreeBSD.ORG Sun Aug 17 17:43:19 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A0E31065671; Sun, 17 Aug 2008 17:43:19 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id 338218FC08; Sun, 17 Aug 2008 17:43:19 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 7A0B51A90DA; Sun, 17 Aug 2008 10:36:07 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3EfCQKtzjxHJ; Sun, 17 Aug 2008 10:36:07 -0700 (PDT) Received: from [10.47.1.6] (vpn.office.miralink.com [10.0.0.5]) by plato.miralink.com (Postfix) with ESMTP id E9C5A1A90CA; Sun, 17 Aug 2008 10:36:06 -0700 (PDT) Message-ID: <48A86335.8060508@miralink.com> Date: Sun, 17 Aug 2008 10:43:17 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808171705.RAA12502@sopwith.solgatos.com> In-Reply-To: <200808171705.RAA12502@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Aug 2008 17:43:19 -0000 Dieter wrote: >> len = read(fd, buf, 1024*16); >> > > It would be good practice to check for read failing. > BTW, did the compile warnings on AMD64 go away? -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Cell 503-358-6832 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com From owner-freebsd-firewire@FreeBSD.ORG Sun Aug 17 23:10:22 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 454AA1065671; Sun, 17 Aug 2008 23:10:22 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 90DEA8FC18; Sun, 17 Aug 2008 23:10:21 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7HNA7G49547; Sun, 17 Aug 2008 16:10:07 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id XAA21188; Sun, 17 Aug 2008 23:09:07 GMT Message-Id: <200808172309.XAA21188@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Sun, 17 Aug 2008 10:34:50 PDT." <48A8613A.4000506@miralink.com> Date: Sun, 17 Aug 2008 16:09:07 +0100 From: Dieter Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Aug 2008 23:10:22 -0000 > >> len = read(fd, buf, 1024*16); > > > > It would be good practice to check for read failing. > > Indeed it would. I looked into fwdev.c::fw_read() a little bit and > documented what I think it's doing as well. > BTW, did the compile warnings on AMD64 go away? I still need to give it a closer inspection, and run some tests, but it looks good so far. And gcc isn't complaining (7.0 on AMD64). From owner-freebsd-firewire@FreeBSD.ORG Mon Aug 18 11:06:49 2008 Return-Path: Delivered-To: freebsd-firewire@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D1671065686 for ; Mon, 18 Aug 2008 11:06:49 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 0529A8FC0A for ; Mon, 18 Aug 2008 11:06:49 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m7IB6mAd079783 for ; Mon, 18 Aug 2008 11:06:48 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m7IB6msh079779 for freebsd-firewire@FreeBSD.org; Mon, 18 Aug 2008 11:06:48 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 18 Aug 2008 11:06:48 GMT Message-Id: <200808181106.m7IB6msh079779@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-firewire@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-firewire@FreeBSD.org X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Aug 2008 11:06:49 -0000 Current FreeBSD problem reports Critical problems Serious problems S Tracker Resp. Description -------------------------------------------------------------------------------- o kern/74238 firewire [firewire] fw_rcv: unknown response; firewire ad-hoc w 1 problem total. Non-critical problems S Tracker Resp. Description -------------------------------------------------------------------------------- o kern/113785 firewire [firewire] dropouts when playing DV on firewire 1 problem total. From owner-freebsd-firewire@FreeBSD.ORG Mon Aug 18 19:14:34 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 57B3A106566B; Mon, 18 Aug 2008 19:14:34 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 992A78FC1A; Mon, 18 Aug 2008 19:14:33 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7IJEPO51816; Mon, 18 Aug 2008 12:14:25 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id TAA21449; Mon, 18 Aug 2008 19:13:29 GMT Message-Id: <200808181913.TAA21449@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Sun, 17 Aug 2008 10:43:17 PDT." <48A86335.8060508@miralink.com> Date: Mon, 18 Aug 2008 12:13:29 +0100 From: Dieter Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Aug 2008 19:14:34 -0000 case 'b': if (priority_budget < 0 || priority_budget > INT32_MAX) errx(EX_USAGE, "%s: invalid number: %s", __func__, optarg); case 'f': if ( (adjust_gap_count < 0) || (adjust_gap_count > INT32_MAX) ) err(EX_USAGE, "%s:adjust_gap_count out of range", __func__); I think "out of range" is better than "invalid number". -5 is a valid number. Just a minor nit, feel free to ignore this one. :-) ================================================================================ > case 'c': > crom_string = malloc(strlen(optarg)+1); > if (crom_string == NULL) > err(EX_SOFTWARE, "%s:crom_string malloc", __func__); > if ( (strtol(crom_string, NULL, 0) < 0) || strtol(crom_string, NULL, 0) > MAX_BOARDS) > err(EX_USAGE, "%s:Invalid value for node", __func__); > strcpy(crom_string, optarg); Strtol() reads freshly malloc-ed memory before anything has been put there. Perhaps: case 'c': { long node_num; node_num = strtol(optarg, NULL, 0); if ( (node_num < 0) || (node_num > MAX_BOARDS) ) err(EX_USAGE, "%s:node out of range", __func__); crom_string = malloc(strlen(optarg)+1); if (crom_string == NULL) err(EX_SOFTWARE, "%s:crom_string malloc", __func__); strcpy(crom_string, optarg); ... } case 'd': ================================================================================ case 'u': current_board = strtol(optarg, NULL, 0); Does this need a range check? ================================================================================ From owner-freebsd-firewire@FreeBSD.ORG Mon Aug 18 19:21:28 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 19945106567D; Mon, 18 Aug 2008 19:21:28 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id D767C8FC28; Mon, 18 Aug 2008 19:21:27 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 524D51A9138; Mon, 18 Aug 2008 12:14:01 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id v1XLgwKPVxKY; Mon, 18 Aug 2008 12:14:00 -0700 (PDT) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id D32BE1A90EA; Mon, 18 Aug 2008 12:14:00 -0700 (PDT) Message-ID: <48A9CBB5.6030402@miralink.com> Date: Mon, 18 Aug 2008 12:21:25 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808181913.TAA21449@sopwith.solgatos.com> In-Reply-To: <200808181913.TAA21449@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Aug 2008 19:21:28 -0000 Dieter wrote: > case 'b': > > if (priority_budget < 0 || priority_budget > INT32_MAX) > errx(EX_USAGE, "%s: invalid number: %s", __func__, optarg); > > case 'f': > > if ( (adjust_gap_count < 0) || (adjust_gap_count > INT32_MAX) ) > err(EX_USAGE, "%s:adjust_gap_count out of range", __func__); > > > I think "out of range" is better than "invalid number". > -5 is a valid number. > current_board = strtol(optarg, NULL, 0); > Just a minor nit, feel free to ignore this one. :-) > > ================================================================================ > > Agreed. It's a nit, but I'll change it. >> case 'c': >> crom_string = malloc(strlen(optarg)+1); >> if (crom_string == NULL) >> err(EX_SOFTWARE, "%s:crom_string malloc", __func__); >> if ( (strtol(crom_string, NULL, 0) < 0) || strtol(crom_string, NULL, 0) > MAX_BOARDS) >> err(EX_USAGE, "%s:Invalid value for node", __func__); >> strcpy(crom_string, optarg); >> > > Strtol() reads freshly malloc-ed memory before anything has been put there. > > Perhaps: > > case 'c': > { > long node_num; > node_num = strtol(optarg, NULL, 0); > if ( (node_num < 0) || (node_num > MAX_BOARDS) ) > err(EX_USAGE, "%s:node out of range", __func__); > crom_string = malloc(strlen(optarg)+1); > if (crom_string == NULL) > err(EX_SOFTWARE, "%s:crom_string malloc", __func__); > strcpy(crom_string, optarg); > > ... > > } > case 'd': > > > ================================================================================ > > This is a big ol' whoops on my part. The whole "malloc" and copy thing just seems pointless and needs to be consolidated into just a "strtol()" instead. > case 'u': > > current_board = strtol(optarg, NULL, 0); > > Does this need a range check? > > ================================================================================ > Probably should be a range check( current_board < 0 and current_board > MAX_BOARDS). -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com From owner-freebsd-firewire@FreeBSD.ORG Mon Aug 18 21:50:38 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 04269106567B; Mon, 18 Aug 2008 21:50:38 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 647AA8FC1F; Mon, 18 Aug 2008 21:50:37 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7ILoUQ52043; Mon, 18 Aug 2008 14:50:30 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id VAA27124; Mon, 18 Aug 2008 21:48:56 GMT Message-Id: <200808182148.VAA27124@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Mon, 18 Aug 2008 12:21:25 PDT." <48A9CBB5.6030402@miralink.com> Date: Mon, 18 Aug 2008 14:48:56 +0100 From: Dieter Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Aug 2008 21:50:38 -0000 Am I correct in assuming that none of this stuff that fwcontrol sets should carry across a reboot? And that the firewire controller should get completely reset by a reboot? I'm getting some bad results. Attempt to recover: Changed symlink from current fwcontrol to known working fwcontrol_prev. Powered off camcorder. Rebooted FreeBSD. Powered on camcorder. Ran fix_dv script to get FreeBSD into "non CYCLEMASTER mode". fwcontrol -u 1 -f 0 fwcontrol -u 1 -r Start playing a tape (so I can run fwcontrol -R) FreeBSD console starts spewing: fwohci1: Initiate bus reset fwohci1: BUS reset fwohci1: node_id=0x8000ffc0, gen=4, non CYCLEMASTER mode <-- from fix_dv script firewire1: 2 nodes, maxhop <= 1, cable IRM = 1 fwohci1: BUS reset fwohci1: node_id=0xc000ffc1, gen=7, CYCLEMASTER mode firewire1: 2 nodes, maxhop <= 1, cable IRM = 1 (me) firewire1: bus manager 1 (me) got BUSRST packet!? fwohci1: BUS reset fwohci1: node_id=0xc000ffc1, gen=8, CYCLEMASTER mode firewire1: 2 nodes, maxhop <= 1, cable IRM = 1 (me) firewire1: bus manager 1 (me) fwohci1: BUS reset fwohci1: node_id=0xc000ffc0, gen=12, CYCLEMASTER mode firewire1: 1 nodes, maxhop <= 0, cable IRM = 0 (me) firewire1: bus manager 0 (me) got BUSRST packet!? got BUSRST packet!? got BUSRST packet!? fwohci1: BUS reset fwohci1: node_id=0xc000ffc1, gen=33, CYCLEMASTER mode firewire1: 2 nodes, maxhop <= 1, cable IRM = 1 (me) firewire1: bus manager 0 fwohci1: BUS reset fwohci1: node_id=0xc000ffc0, gen=38, CYCLEMASTER mode firewire1: 1 nodes, maxhop <= 0, cable IRM = 0 (me) firewire1: bus manager 0 (me) got BUSRST packet!? got BUSRST packet!? fwohci1: BUS reset fwohci1: node_id=0xc000ffc1, gen=57, CYCLEMASTER mode firewire1: 2 nodes, maxhop <= 1, cable IRM = 1 (me) firewire1: bus manager 0 fwohci1: BUS reset fwohci1: node_id=0xc000ffc0, gen=62, CYCLEMASTER mode firewire1: 1 nodes, maxhop <= 0, cable IRM = 0 (me) firewire1: bus manager 0 (me) got BUSRST packet!? got BUSRST packet!? got BUSRST packet!? fwohci1: BUS reset ... fwohci1: node_id=0xc000ffc0, gen=122, CYCLEMASTER mode firewire1: 1 nodes, maxhop <= 0, cable IRM = 0 (me) firewire1: bus manager 0 (me) got BUSRST packet!? got BUSRST packet!? fwohci1: BUS reset fwohci1: node_id=0xc000ffc1, gen=144, CYCLEMASTER mode firewire1: 2 nodes, maxhop <= 1, cable IRM = 1 (me) firewire1: bus manager 0 Stopping the camcorder stops the spewing. Needless to say, fwcontrol -R no longer works. I ran the fixit script again, and fwcontrol -S does work. I notice that it doesn't print every generation. I notice that the node_id changes. FreeBSD 7.0 AMD64 fw controller: NEC uPD72871/2 Ideas? From owner-freebsd-firewire@FreeBSD.ORG Mon Aug 18 22:27:02 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 290651065689; Mon, 18 Aug 2008 22:27:02 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id E50BE8FC0A; Mon, 18 Aug 2008 22:27:01 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id BFEC71A90DC; Mon, 18 Aug 2008 15:19:34 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nrHuhGQ5ZUyd; Mon, 18 Aug 2008 15:19:34 -0700 (PDT) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id 68C3F1A90D4; Mon, 18 Aug 2008 15:19:34 -0700 (PDT) Message-ID: <48A9F735.5090507@miralink.com> Date: Mon, 18 Aug 2008 15:27:01 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808182148.VAA27124@sopwith.solgatos.com> In-Reply-To: <200808182148.VAA27124@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Aug 2008 22:27:02 -0000 Dieter wrote: > Am I correct in assuming that none of this stuff that > fwcontrol sets should carry across a reboot? And that > the firewire controller should get completely reset > by a reboot? > > My assumption is that no settings should survive a reboot. > I'm getting some bad results. Attempt to recover: > > Changed symlink from current fwcontrol to known working fwcontrol_prev. > Powered off camcorder. > Rebooted FreeBSD. > Powered on camcorder. > Ran fix_dv script to get FreeBSD into "non CYCLEMASTER mode". > fwcontrol -u 1 -f 0 > fwcontrol -u 1 -r > Start playing a tape (so I can run fwcontrol -R) > > Hrm ... the old code closed "fd" and then re-opened it. I have duplicated that behavior in the attached patch. > Needless to say, fwcontrol -R no longer works. > > I ran the fixit script again, and fwcontrol -S does work. > > I notice that it doesn't print every generation. > I notice that the node_id changes. > > This alarms me quite a bit. I didn't think there was anyway for the generation to change without the log message being spit out. Interesting. I have been suspicious of a race condition for some time in the firewire stack, I see it across multiple devices(sbp, sbp_targ) and now fwcontrol is acting weird. Very interesting. > FreeBSD 7.0 > AMD64 > fw controller: NEC uPD72871/2 > > Ideas? > Yes. Try the attached patch. Let me know. -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com From owner-freebsd-firewire@FreeBSD.ORG Mon Aug 18 23:11:03 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 074971065673; Mon, 18 Aug 2008 23:11:03 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 3EC738FC12; Mon, 18 Aug 2008 23:11:02 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7INAlZ52159; Mon, 18 Aug 2008 16:10:47 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id XAA20058; Mon, 18 Aug 2008 23:01:45 GMT Message-Id: <200808182301.XAA20058@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Mon, 18 Aug 2008 12:21:25 PDT." <48A9CBB5.6030402@miralink.com> Date: Mon, 18 Aug 2008 16:01:45 +0100 From: Dieter Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Aug 2008 23:11:03 -0000 Here are some testing results from before I noticed the console spew problem: # fwcontrol -f -6 fwcontrol: main:adjust_gap_count out of range: No such file or directory The "out of range" is expected. The "No such file or directory" part seems wrong. ====================================================== # fwcontrol -c -7 fwcontrol: no such node -1. Interesting that -7 becomes -1. -d does the same thing. BTW, running fwcontrol with no arguments does print out a line with node -1. Whatever that means. ====================================================== Now test things that should work: fwcontrol -u 1 -f 0 works fwcontrol -u 1 -r works fwcontrol -u 1 -S /dev/stdin works fwcontrol -u 1 -R camera.dv fwcontrol: detect_recv_fn: error reading from device : Resource temporarily unavailable fwcontrol_prev -u 1 -R camera.dv Detected DV format on input. (EAGAIN) (EAGAIN) (EAGAIN) And then I noticed the console spewing away as reported in my previous message, and tried rebooting... From owner-freebsd-firewire@FreeBSD.ORG Mon Aug 18 23:59:17 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B0C1B1065675; Mon, 18 Aug 2008 23:59:17 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 1C7AA8FC13; Mon, 18 Aug 2008 23:59:16 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7INxBh52228; Mon, 18 Aug 2008 16:59:11 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id XAA09163; Mon, 18 Aug 2008 23:55:29 GMT Message-Id: <200808182355.XAA09163@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Mon, 18 Aug 2008 15:27:01 PDT." <48A9F735.5090507@miralink.com> Date: Mon, 18 Aug 2008 16:55:29 +0100 From: Dieter Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Aug 2008 23:59:17 -0000 > > I notice that it doesn't print every generation. > > I notice that the node_id changes. > > > This alarms me quite a bit. I didn't think there was anyway for the > generation to change > without the log message being spit out. Interesting. It also skips on dmesg, so it isn't a console problem: fwohci1: node_id=0xc000ffc0, gen=86, CYCLEMASTER mode firewire1: 1 nodes, maxhop <= 0, cable IRM = 0 (me) firewire1: bus manager 0 (me) got BUSRST packet!? got BUSRST packet!? got BUSRST packet!? fwohci1: BUS reset fwohci1: node_id=0xc000ffc1, gen=108, CYCLEMASTER mode firewire1: 2 nodes, maxhop <= 1, cable IRM = 1 (me) firewire1: bus manager 0 fwohci1: BUS reset fwohci1: node_id=0xc000ffc0, gen=112, CYCLEMASTER mode fwohci1: invalid SID len = 0 <-----------------------<<< didn't notice this line before fwohci1: BUS reset only occurs twice in dmesg fwohci1: node_id=0xc000ffc1, gen=130, CYCLEMASTER mode firewire1: 2 nodes, maxhop <= 1, cable IRM = 1 (me) firewire1: bus manager 1 (me) fwohci1: BUS reset fwohci1: node_id=0xc000ffc0, gen=135, CYCLEMASTER mode firewire1: 1 nodes, maxhop <= 0, cable IRM = 0 (me) firewire1: bus manager 0 (me) got BUSRST packet!? got BUSRST packet!? fwohci1: BUS reset fwohci1: node_id=0xc000ffc1, gen=154, CYCLEMASTER mode Does "got BUSRST packet!?" mean that the camera is sending out bus reset commands? That doesn't seem right. BTW, shouldn't that line have a prefix telling where it comes from (e.g. fwohci1: or firewire1:) ? BTW there is just the FreeBSD box and the camera, no other nodes on the firewire bus. > I have been suspicious of a race condition for some time in the firewire > stack, I see it across multiple > devices(sbp, sbp_targ) and now fwcontrol is acting weird. Very interesting. > Yes. Try the attached patch. Let me know. I don't see a patch. Note that fwcontrol is not running when the spew happens. I press play on the camcorder, and the spewing starts. I press stop and the spewing stops. My only theories are that fwcontrol set something that survives a reboot, or that the fw controller chip isn't getting completely reset and properly initialized. I'm leaning towards the chip being the more likely explaination. From owner-freebsd-firewire@FreeBSD.ORG Tue Aug 19 00:03:04 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5E437106566B; Tue, 19 Aug 2008 00:03:04 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id ED6328FC13; Tue, 19 Aug 2008 00:03:03 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id CA9A01A90FC; Mon, 18 Aug 2008 16:55:35 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MboIe5mqL6tA; Mon, 18 Aug 2008 16:55:29 -0700 (PDT) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id 202CE1A90DC; Mon, 18 Aug 2008 16:55:29 -0700 (PDT) Message-ID: <48AA0DB0.2020306@miralink.com> Date: Mon, 18 Aug 2008 17:02:56 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808182355.XAA09163@sopwith.solgatos.com> In-Reply-To: <200808182355.XAA09163@sopwith.solgatos.com> Content-Type: multipart/mixed; boundary="------------000207030906020703070903" Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Aug 2008 00:03:04 -0000 This is a multi-part message in MIME format. --------------000207030906020703070903 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Dieter wrote: >>> I notice that it doesn't print every generation. >>> I notice that the node_id changes. >>> >> This alarms me quite a bit. I didn't think there was anyway for the >> generation to change >> without the log message being spit out. Interesting. >> > > It also skips on dmesg, so it isn't a console problem: > > fwohci1: node_id=0xc000ffc0, gen=86, CYCLEMASTER mode > firewire1: 1 nodes, maxhop <= 0, cable IRM = 0 (me) > firewire1: bus manager 0 (me) > got BUSRST packet!? > got BUSRST packet!? > got BUSRST packet!? > fwohci1: BUS reset > fwohci1: node_id=0xc000ffc1, gen=108, CYCLEMASTER mode > firewire1: 2 nodes, maxhop <= 1, cable IRM = 1 (me) > firewire1: bus manager 0 > fwohci1: BUS reset > fwohci1: node_id=0xc000ffc0, gen=112, CYCLEMASTER mode > fwohci1: invalid SID len = 0 <-----------------------<<< didn't notice this line before > fwohci1: BUS reset only occurs twice in dmesg > fwohci1: node_id=0xc000ffc1, gen=130, CYCLEMASTER mode > firewire1: 2 nodes, maxhop <= 1, cable IRM = 1 (me) > firewire1: bus manager 1 (me) > fwohci1: BUS reset > fwohci1: node_id=0xc000ffc0, gen=135, CYCLEMASTER mode > firewire1: 1 nodes, maxhop <= 0, cable IRM = 0 (me) > firewire1: bus manager 0 (me) > got BUSRST packet!? > got BUSRST packet!? > fwohci1: BUS reset > fwohci1: node_id=0xc000ffc1, gen=154, CYCLEMASTER mode > > Does "got BUSRST packet!?" mean that the camera is sending out > bus reset commands? That doesn't seem right. BTW, shouldn't that > line have a prefix telling where it comes from (e.g. fwohci1: > or firewire1:) ? > > BTW there is just the FreeBSD box and the camera, no other nodes > on the firewire bus. > > thanks, that's good to know. >> I have been suspicious of a race condition for some time in the firewire >> stack, I see it across multiple >> devices(sbp, sbp_targ) and now fwcontrol is acting weird. Very interesting. >> > > >> Yes. Try the attached patch. Let me know. >> > > I don't see a patch. > > Doh! Let me attach it this time! :) > Note that fwcontrol is not running when the spew happens. > I press play on the camcorder, and the spewing starts. > I press stop and the spewing stops. > > My only theories are that fwcontrol set something that > survives a reboot, or that the fw controller chip isn't > getting completely reset and properly initialized. I'm > leaning towards the chip being the more likely explaination. > fwcontrol is ridiculously dangerous IMO. It is a userland app that does raw direct access to registers on firewire devices. I would think that some kind of safety wrapper/API is in order here. -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com --------------000207030906020703070903 Content-Type: text/plain; name="fwcontrol.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fwcontrol.diff" Index: fwcontrol.8 =================================================================== --- fwcontrol.8 (revision 5721) +++ fwcontrol.8 (working copy) @@ -59,7 +59,7 @@ The following options are available: .Bl -tag -width indent .It Fl u Ar bus_num -Specify the FireWire bus number to be operated on. +Specify the FireWire bus number to be operated on. Default is bus 0. .It Fl r Initiate bus reset. .It Fl t Index: fwcontrol.c =================================================================== --- fwcontrol.c (revision 5721) +++ fwcontrol.c (working copy) @@ -56,6 +56,8 @@ #include #include #include +#include +#include #include "fwmethods.h" static void sysctl_set_int(const char *, int); @@ -64,21 +66,22 @@ usage(void) { fprintf(stderr, - "fwcontrol [-u bus_num] [-rt] [-f node] [-g gap_count] " - "[-o node] " - "[-b pri_req] [-c node] [-d node] [-l file] " - "[-R file] [-S file] [-m target]\n" + "fwcontrol [-u bus_num] [-prt] [-c node] [-d node] [-o node] [-s node]\n" + "\t [-l file] [-g gap_count] [-f force_root ] [-b pri_req]\n" + "\t [-M mode] [-R filename] [-S filename] [-m EUI64 | hostname]\n" "\t-u: specify bus number\n" - "\t-f: broadcast force_root by phy_config packet\n" - "\t-g: broadcast gap_count by phy_config packet\n" - "\t-o: send link-on packet to the node\n" - "\t-s: write RESET_START register on the node\n" - "\t-b: set PRIORITY_BUDGET register on all supported nodes\n" - "\t-c: read configuration ROM\n" + "\t-p: Display current PHY register settings\n" "\t-r: bus reset\n" "\t-t: read topology map\n" + "\t-c: read configuration ROM\n" "\t-d: hex dump of configuration ROM\n" + "\t-o: send link-on packet to the node\n" + "\t-s: write RESET_START register on the node\n" "\t-l: load and parse hex dump file of configuration ROM\n" + "\t-g: broadcast gap_count by phy_config packet\n" + "\t-f: broadcast force_root by phy_config packet\n" + "\t-b: set PRIORITY_BUDGET register on all supported nodes\n" + "\t-M: specify dv or mpeg\n" "\t-R: Receive DV or MPEG TS stream\n" "\t-S: Send DV stream\n" "\t-m: set fwmem target\n"); @@ -92,18 +95,14 @@ *(u_int32_t*)&(eui->octet[4]) = htonl(fweui->lo); } -static struct fw_devlstreq * -get_dev(int fd) +static void +get_dev(int fd, struct fw_devlstreq *data) { - struct fw_devlstreq *data; - - data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); if (data == NULL) - err(1, "malloc"); + err(EX_SOFTWARE, "%s: data malloc", __func__); if( ioctl(fd, FW_GDEVLST, data) < 0) { - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); } - return data; } static int @@ -130,17 +129,25 @@ if (eui64_hostton(nodestr, &eui) != 0 && eui64_aton(nodestr, &eui) != 0) return (-1); - data = get_dev(fd); + data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); + if (data == NULL) + err(EX_SOFTWARE, "%s: data malloc", __func__); + get_dev(fd,data); for (i = 0; i < data->info_len; i++) { fweui2eui64(&data->dev[i].eui, &tmpeui); if (memcmp(&eui, &tmpeui, sizeof(struct eui64)) == 0) { node = data->dev[i].dst; + if (data != NULL) + free(data); goto gotnode; } } - if (i >= data->info_len) + if (i >= data->info_len) { + if (data != NULL) + free(data); return (-1); + } gotnode: if (node < 0 || node > 63) @@ -158,7 +165,10 @@ char addr[EUI64_SIZ], hostname[40]; int i; - data = get_dev(fd); + data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); + if (data == NULL) + err(EX_SOFTWARE, "%s:data malloc", __func__); + get_dev(fd, data); printf("%d devices (info_len=%d)\n", data->n, data->info_len); printf("node EUI64 status hostname\n"); for (i = 0; i < data->info_len; i++) { @@ -184,6 +194,8 @@ u_int32_t *qld, res; asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 16); + if (asyreq == NULL) + err(EX_SOFTWARE, "%s:asyreq malloc", __func__); asyreq->req.len = 16; #if 0 asyreq->req.type = FWASREQNODE; @@ -206,7 +218,7 @@ asyreq->pkt.mode.wreqq.data = htonl(data); if (ioctl(fd, FW_ASYREQ, asyreq) < 0) { - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); } res = qld[3]; free(asyreq); @@ -222,6 +234,8 @@ struct fw_asyreq *asyreq; asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 12); + if (asyreq == NULL) + err(EX_SOFTWARE, "%s:asyreq malloc", __func__); asyreq->req.len = 12; asyreq->req.type = FWASREQNODE; asyreq->pkt.mode.ld[0] = 0; @@ -237,16 +251,18 @@ root_node, gap_count); if (ioctl(fd, FW_ASYREQ, asyreq) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); free(asyreq); } static void -send_link_on(int fd, int node) +link_on(int fd, int node) { struct fw_asyreq *asyreq; asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 12); + if (asyreq == NULL) + err(EX_SOFTWARE, "%s:asyreq malloc", __func__); asyreq->req.len = 12; asyreq->req.type = FWASREQNODE; asyreq->pkt.mode.common.tcode = FWTCODE_PHY; @@ -254,7 +270,7 @@ asyreq->pkt.mode.ld[2] = ~asyreq->pkt.mode.ld[1]; if (ioctl(fd, FW_ASYREQ, asyreq) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); free(asyreq); } @@ -264,6 +280,8 @@ struct fw_asyreq *asyreq; asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 16); + if (asyreq == NULL) + err(EX_SOFTWARE, "%s:asyreq malloc", __func__); asyreq->req.len = 16; asyreq->req.type = FWASREQNODE; asyreq->pkt.mode.wreqq.dst = FWLOCALBUS | (node & 0x3f); @@ -276,7 +294,7 @@ asyreq->pkt.mode.wreqq.data = htonl(0x1); if (ioctl(fd, FW_ASYREQ, asyreq) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); free(asyreq); } @@ -290,7 +308,10 @@ u_int32_t max, reg, old; int i; - data = get_dev(fd); + data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); + if (data == NULL) + err(EX_SOFTWARE, "%s:data malloc", __func__); + get_dev(fd, data); #define BUGET_REG 0xf0000218 for (i = 0; i < data->info_len; i++) { devinfo = &data->dev[i]; @@ -344,7 +365,10 @@ int i, error; struct fw_devlstreq *data; - data = get_dev(fd); + data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); + if (data == NULL) + err(EX_SOFTWARE, "%s:data malloc", __func__); + get_dev(fd, data); for (i = 0; i < data->info_len; i++) { if (data->dev[i].dst == node && data->dev[i].eui.lo != 0) @@ -360,7 +384,7 @@ buf.ptr = crom_buf; bzero(crom_buf, len); if ((error = ioctl(fd, FW_GCROM, &buf)) < 0) { - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); } return error; @@ -469,9 +493,9 @@ static const char *speed[] = {"S100", "S200", "S400", "S800"}; tmap = malloc(sizeof(struct fw_topology_map)); if (tmap == NULL) - return; + err(EX_SOFTWARE, "%s:tmap malloc", __func__); if (ioctl(fd, FW_GTPMAP, tmap) < 0) { - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); } printf("crc_len: %d generation:%d node_count:%d sid_count:%d\n", tmap->crc_len, tmap->generation, @@ -512,7 +536,7 @@ for (i = 0; i < len; i++) { reg.addr = offset + i; if (ioctl(fd, FWOHCI_RDPHYREG, ®) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); buf[i] = (u_int8_t) reg.data; printf("0x%02x ", reg.data); } @@ -527,7 +551,7 @@ reg.addr = 0x7; reg.data = ((page & 7) << 5) | (port & 0xf); if (ioctl(fd, FWOHCI_WRPHYREG, ®) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); read_phy_registers(fd, buf, 8, 8); } @@ -590,22 +614,16 @@ ); } -static void -open_dev(int *fd, char *devbase) +static int +open_dev(int *fd, char *devname) { - char name[256]; - int i; - if (*fd < 0) { - for (i = 0; i < 4; i++) { - snprintf(name, sizeof(name), "%s.%d", devbase, i); - if ((*fd = open(name, O_RDWR)) >= 0) - break; - } + *fd = open(devname, O_RDWR); if (*fd < 0) - err(1, "open"); + return(-1); } + return(0); } static void @@ -625,25 +643,40 @@ u_int32_t *ptr; struct ciphdr *ciph; fwmethod *retfn; +#define RECV_NUM_PACKET 16 +#define RECV_PACKET_SZ 1024 bufreq.rx.nchunk = 8; - bufreq.rx.npacket = 16; - bufreq.rx.psize = 1024; + bufreq.rx.npacket = RECV_NUM_PACKET; + bufreq.rx.psize = RECV_PACKET_SZ; bufreq.tx.nchunk = 0; bufreq.tx.npacket = 0; bufreq.tx.psize = 0; if (ioctl(fd, FW_SSTBUF, &bufreq) < 0) - err(1, "ioctl FW_SSTBUF"); + err(EX_IOERR, "%s: ioctl FW_SSTBUF", __func__); isoreq.ch = ich & 0x3f; isoreq.tag = (ich >> 6) & 3; if (ioctl(fd, FW_SRSTREAM, &isoreq) < 0) - err(1, "ioctl FW_SRSTREAM"); + err(EX_IOERR, "%s: ioctl FW_SRSTREAM", __func__); - buf = (char *)malloc(1024*16); - len = read(fd, buf, 1024*16); + buf = (char *)malloc(RECV_NUM_PACKET * RECV_PACKET_SZ); + if (buf == NULL) + err(EX_SOFTWARE, "%s:buf malloc", __func__); + /* + * fwdev.c seems to return EIO on error and + * the return value of the last uiomove + * on success. For now, checking that the + * return is not less than zero should be + * sufficient. fwdev.c::fw_read() should + * return the total length read, not the value + * of the last uiomove(). + */ + len = read(fd, buf, RECV_NUM_PACKET * RECV_PACKET_SZ); + if (len < 0) + err(EX_IOERR, "%s: error reading from device\n", __func__); ptr = (u_int32_t *) buf; ciph = (struct ciphdr *)(ptr + 1); @@ -666,102 +699,167 @@ int main(int argc, char **argv) { +#define MAX_BOARDS 10 u_int32_t crom_buf[1024/4]; - char devbase[1024] = "/dev/fw0"; - int fd, ch, len=1024; + u_int32_t crom_buf_hex[1024/4]; + char devbase[64]; + const char *device_string = "/dev/fw"; + int fd = -1, ch, len=1024; + int32_t current_board = 0; + /* + * If !command_set, then -u will display the nodes for the board. + * This emulates the previous behavior when -u is passed by itself + */ + bool command_set = false; + bool open_needed = false; long tmp; struct fw_eui64 eui; struct eui64 target; fwmethod *recvfn = NULL; +/* + * Holders for which functions + * to iterate through + */ + bool display_board_only = false; + bool display_crom = false; + bool send_bus_reset = false; + bool display_crom_hex = false; + bool load_crom_from_file = false; + bool set_fwmem_target = false; + bool dump_topology = false; + bool dump_phy_reg = false; - fd = -1; + int32_t priority_budget = -1; + int32_t adjust_gap_count = -1; + int32_t reset_gap_count = -1; + int32_t send_link_on = -1; + int32_t send_reset_start = -1; + char *crom_string = NULL; + char *crom_string_hex = NULL; + char *recv_data = NULL; + char *send_data = NULL; + if (argc < 2) { - open_dev(&fd, devbase); - list_dev(fd); + for (current_board = 0; current_board < MAX_BOARDS; current_board++) { + snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); + if (open_dev(&fd, devbase) < 0) { + if (current_board == 0) { + usage(); + } + return(EIO); + } + list_dev(fd); + close(fd); + fd = -1; + } } - - while ((ch = getopt(argc, argv, "M:f:g:m:o:s:b:prtc:d:l:u:R:S:")) != -1) + /* + * Parse all command line options, then execute requested operations. + */ + while ((ch = getopt(argc, argv, "M:f:g:m:o:s:b:prtc:d:l:u:R:S:")) != -1) { switch(ch) { case 'b': - tmp = strtol(optarg, NULL, 0); - if (tmp < 0 || tmp > (long)0xffffffff) - errx(EX_USAGE, "invalid number: %s", optarg); - open_dev(&fd, devbase); - set_pri_req(fd, tmp); + priority_budget = strtol(optarg, NULL, 0); + if (priority_budget < 0 || priority_budget > INT32_MAX) + errx(EX_USAGE, "%s: invalid number: %s", __func__, optarg); + command_set = true; + open_needed = true; + display_board_only = false; break; case 'c': - open_dev(&fd, devbase); - tmp = str2node(fd, optarg); - get_crom(fd, tmp, crom_buf, len); - show_crom(crom_buf); + crom_string = malloc(strlen(optarg)+1); + if (crom_string == NULL) + err(EX_SOFTWARE, "%s:crom_string malloc", __func__); + if ( (strtol(crom_string, NULL, 0) < 0) || strtol(crom_string, NULL, 0) > MAX_BOARDS) + err(EX_USAGE, "%s:Invalid value for node", __func__); + strcpy(crom_string, optarg); + display_crom = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 'd': - open_dev(&fd, devbase); - tmp = str2node(fd, optarg); - get_crom(fd, tmp, crom_buf, len); - dump_crom(crom_buf); + crom_string_hex = malloc(strlen(optarg)+1); + if (crom_string_hex == NULL) + err(EX_SOFTWARE, "%s:crom_string_hex malloc", __func__); + strcpy(crom_string_hex, optarg); + display_crom_hex = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 'f': - tmp = strtol(optarg, NULL, 0); - open_dev(&fd, devbase); - send_phy_config(fd, tmp, -1); + adjust_gap_count = strtol(optarg, NULL, 0); + if ( (adjust_gap_count < 0) || (adjust_gap_count > INT32_MAX) ) + err(EX_USAGE, "%s:adjust_gap_count out of range", __func__); + open_needed = true; + command_set = true; + display_board_only = false; break; case 'g': - tmp = strtol(optarg, NULL, 0); - open_dev(&fd, devbase); - send_phy_config(fd, -1, tmp); + reset_gap_count = strtol(optarg, NULL, 0); + if ( (reset_gap_count < 0) || (reset_gap_count > INT32_MAX) ) + err(EX_USAGE, "%s:reset_gap_count out of range", __func__); + open_needed = true; + command_set = true; + display_board_only = false; break; case 'l': + load_crom_from_file = 1; load_crom(optarg, crom_buf); - show_crom(crom_buf); + command_set = true; + display_board_only = false; break; case 'm': - if (eui64_hostton(optarg, &target) != 0 && - eui64_aton(optarg, &target) != 0) - errx(EX_USAGE, "invalid target: %s", optarg); - eui.hi = ntohl(*(u_int32_t*)&(target.octet[0])); - eui.lo = ntohl(*(u_int32_t*)&(target.octet[4])); - sysctl_set_int("hw.firewire.fwmem.eui64_hi", eui.hi); - sysctl_set_int("hw.firewire.fwmem.eui64_lo", eui.lo); + set_fwmem_target = 1; + open_needed = 0; + command_set = true; + display_board_only = false; + if (eui64_hostton(optarg, &target) != 0 && + eui64_aton(optarg, &target) != 0) + err(EX_USAGE, "%s: invalid target: %s", __func__, optarg); break; case 'o': - open_dev(&fd, devbase); - tmp = str2node(fd, optarg); - send_link_on(fd, tmp); + send_link_on = str2node(fd, optarg); + if ( (send_link_on < 0) || (send_link_on > INT32_MAX) ) + err(EX_USAGE, "%s: node out of range: %s\n",__func__, optarg); + open_needed = true; + command_set = true; + display_board_only = false; break; case 'p': - open_dev(&fd, devbase); - dump_phy_registers(fd); + dump_phy_reg = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 'r': - open_dev(&fd, devbase); - if(ioctl(fd, FW_IBUSRST, &tmp) < 0) - err(1, "ioctl"); + send_bus_reset = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 's': - open_dev(&fd, devbase); - tmp = str2node(fd, optarg); - reset_start(fd, tmp); + send_reset_start = str2node(fd, optarg); + if ( (send_reset_start < 0) || (send_reset_start > INT32_MAX) ) + err(EX_USAGE, "%s: node out of range: %s\n", __func__, optarg); + open_needed = true; + command_set = true; + display_board_only = false; break; case 't': - open_dev(&fd, devbase); - show_topology_map(fd); + dump_topology = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 'u': - tmp = strtol(optarg, NULL, 0); - snprintf(devbase, sizeof(devbase), "/dev/fw%ld", tmp); - if (fd > 0) { - close(fd); - fd = -1; - } - if (argc == optind) { - open_dev(&fd, devbase); - list_dev(fd); - } + if(!command_set) + display_board_only = true; + current_board = strtol(optarg, NULL, 0); + open_needed = true; break; -#define TAG (1<<6) -#define CHANNEL 63 case 'M': switch (optarg[0]) { case 'm': @@ -774,22 +872,164 @@ errx(EX_USAGE, "unrecognized method: %s", optarg); } + command_set = true; + display_board_only = false; break; case 'R': - open_dev(&fd, devbase); - if (recvfn == NULL) /* guess... */ - recvfn = detect_recv_fn(fd, TAG | CHANNEL); - close(fd); - fd = -1; - open_dev(&fd, devbase); - (*recvfn)(fd, optarg, TAG | CHANNEL, -1); + recv_data = malloc(strlen(optarg)+1); + if (recv_data == NULL) + err(EX_SOFTWARE, "%s:recv_data malloc", __func__); + strcpy(recv_data, optarg); + open_needed = false; + command_set = true; + display_board_only = false; break; case 'S': - open_dev(&fd, devbase); - dvsend(fd, optarg, TAG | CHANNEL, -1); + send_data = malloc(strlen(optarg)+1); + if (send_data == NULL) + err(EX_SOFTWARE, "%s:send_data malloc", __func__); + strcpy(send_data, optarg); + open_needed = true; + command_set = true; + display_board_only = false; break; default: usage(); + return 0; } + } /* end while */ + + /* + * If -u is passed, execute + * command for that card only. + * + * If -u is not passed, execute + * command for card 0 only. + * + */ + if(open_needed){ + snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); + if (open_dev(&fd, devbase) < 0) { + errx(EX_IOERR, "%s: Error opening board #%d\n", __func__, current_board); + } + } + /* + * display the nodes on this board "-u" + * only + */ + if (display_board_only) + list_dev(fd); + + /* + * dump_phy_reg "-p" + */ + if (dump_phy_reg) + dump_phy_registers(fd); + + /* + * send a BUS_RESET Event "-r" + */ + if (send_bus_reset) { + if(ioctl(fd, FW_IBUSRST, &tmp) < 0) + err(EX_IOERR, "%s: ioctl", __func__); + } + /* + * Print out the CROM for this node "-c" + */ + if (display_crom) { + tmp = str2node(fd, crom_string); + get_crom(fd, tmp, crom_buf, len); + show_crom(crom_buf); + free(crom_string); + } + /* + * Hex Dump the CROM for this node "-d" + */ + if (display_crom_hex) { + tmp = str2node(fd, crom_string_hex); + get_crom(fd, tmp, crom_buf_hex, len); + dump_crom(crom_buf_hex); + free(crom_string_hex); + } + /* + * Set Priority Budget to value for this node "-b" + */ + if (priority_budget >= 0) + set_pri_req(fd, priority_budget); + + /* + * Adjust the gap count for this card/bus to value "-f" + */ + if (adjust_gap_count >= 0) + send_phy_config(fd, adjust_gap_count, -1); + + /* + * Reset the gap count for this card/bus "-g" + */ + if (reset_gap_count >= 0) + send_phy_config(fd, -1, reset_gap_count); + + /* + * Load a CROM from a file "-l" + */ + if (load_crom_from_file) + show_crom(crom_buf); + /* + * Set the fwmem target for a node to argument "-m" + */ + if (set_fwmem_target) { + eui.hi = ntohl(*(u_int32_t*)&(target.octet[0])); + eui.lo = ntohl(*(u_int32_t*)&(target.octet[4])); + sysctl_set_int("hw.firewire.fwmem.eui64_hi", eui.hi); + sysctl_set_int("hw.firewire.fwmem.eui64_lo", eui.lo); + } + + /* + * Send a link on to this board/bus "-o" + */ + if (send_link_on >= 0) + link_on(fd, send_link_on); + + /* + * Send a reset start to this board/bus "-s" + */ + if (send_reset_start >= 0) + reset_start(fd, send_reset_start); + + /* + * Dump the node topology for this board/bus "-t" + */ + if (dump_topology) + show_topology_map(fd); + + /* + * Recieve data file from node "-R" + */ +#define TAG (1<<6) +#define CHANNEL 63 + if (recv_data != NULL){ + if (recvfn == NULL) { /* guess... */ + recvfn = detect_recv_fn(fd, TAG | CHANNEL); + close(fd); + } + snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); + if (open_dev(&fd, devbase) < 0) + errx(EX_IOERR, "%s: Error opening board #%d in recv_data\n", __func__, current_board); + (*recvfn)(fd, recv_data, TAG | CHANNEL, -1); + free(recv_data); + } + + /* + * Send data file to node "-S" + */ + if (send_data != NULL){ + dvsend(fd, send_data, TAG | CHANNEL, -1); + free(send_data); + } + + if (fd > 0) { + close(fd); + fd = -1; + } return 0; } --------------000207030906020703070903-- From owner-freebsd-firewire@FreeBSD.ORG Tue Aug 19 02:14:58 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C099A1065678; Tue, 19 Aug 2008 02:14:58 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 1A9118FC08; Tue, 19 Aug 2008 02:14:57 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7J2EmN52430; Mon, 18 Aug 2008 19:14:48 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id CAA20684; Tue, 19 Aug 2008 02:13:44 GMT Message-Id: <200808190213.CAA20684@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Mon, 18 Aug 2008 17:02:56 PDT." <48AA0DB0.2020306@miralink.com> Date: Mon, 18 Aug 2008 19:13:44 +0100 From: Dieter Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Aug 2008 02:14:58 -0000 I tried rebooting again, and then powered up the camera and pressed play. Without running fwcontrol at all. The console spewed away. Just to be explicit, it didn't do this until today. So I think the kernel device driver needs to reset and/or initialize something, probably on the fw controller chip. Thoughts? From owner-freebsd-firewire@FreeBSD.ORG Tue Aug 19 02:25:32 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9BA201065679; Tue, 19 Aug 2008 02:25:32 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id 789F18FC0A; Tue, 19 Aug 2008 02:25:32 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 1AE1D1A9149; Mon, 18 Aug 2008 19:18:03 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YCqGY5Zy7xjT; Mon, 18 Aug 2008 19:18:02 -0700 (PDT) Received: from [10.47.1.6] (vpn.office.miralink.com [10.0.0.5]) by plato.miralink.com (Postfix) with ESMTP id 5AF8E1A90DC; Mon, 18 Aug 2008 19:18:02 -0700 (PDT) Message-ID: <48AA2F1A.9040306@miralink.com> Date: Mon, 18 Aug 2008 19:25:30 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808190213.CAA20684@sopwith.solgatos.com> In-Reply-To: <200808190213.CAA20684@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Aug 2008 02:25:32 -0000 Dieter wrote: > I tried rebooting again, and then powered up the camera > and pressed play. Without running fwcontrol at all. > The console spewed away. > > Just to be explicit, it didn't do this until today. > > So I think the kernel device driver needs to reset and/or > initialize something, probably on the fw controller chip. > Thoughts? > Ok, good times. Can you post the output of "fwcontrol -p" for me? -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Cell 503-358-6832 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com From owner-freebsd-firewire@FreeBSD.ORG Tue Aug 19 04:00:29 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0D956106568A for ; Tue, 19 Aug 2008 04:00:29 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id E92F98FC20 for ; Tue, 19 Aug 2008 04:00:28 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id E5E021A9149; Mon, 18 Aug 2008 20:52:58 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ow2EZNPBfkNG; Mon, 18 Aug 2008 20:52:58 -0700 (PDT) Received: from [10.47.1.6] (vpn.office.miralink.com [10.0.0.5]) by plato.miralink.com (Postfix) with ESMTP id 47DE41A90DC; Mon, 18 Aug 2008 20:52:58 -0700 (PDT) Message-ID: <48AA4543.1040404@miralink.com> Date: Mon, 18 Aug 2008 21:00:03 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808190213.CAA20684@sopwith.solgatos.com> <48AA2F1A.9040306@miralink.com> In-Reply-To: <48AA2F1A.9040306@miralink.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Aug 2008 04:00:29 -0000 Sean Bruno wrote: > Dieter wrote: >> I tried rebooting again, and then powered up the camera >> and pressed play. Without running fwcontrol at all. >> The console spewed away. >> >> Just to be explicit, it didn't do this until today. >> >> So I think the kernel device driver needs to reset and/or >> initialize something, probably on the fw controller chip. >> Thoughts? >> > Ok, good times. > Can you post the output of "fwcontrol -p" for me? > Looking over the driver code, I can't see any clear path from what malfunctioned to the errors you are seeing now. I would think that a simple bus reset from fwcontrol would clear this. The BUSRST message means that the driver is getting a BUS_RESET when it's internal state machine is not BUS_RESET. Kind of confusing, but that means you should be able to clear it out with a "fwcontrol -r -u 1" ??? You will _HAVE_ to use the new code to send a bus reset to the second bus. -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Cell 503-358-6832 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com From owner-freebsd-firewire@FreeBSD.ORG Tue Aug 19 05:57:13 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AF377106567B; Tue, 19 Aug 2008 05:57:13 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id F0A2D8FC16; Tue, 19 Aug 2008 05:57:07 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7J5uwg52745; Mon, 18 Aug 2008 22:56:58 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id FAA25963; Tue, 19 Aug 2008 05:55:59 GMT Message-Id: <200808190555.FAA25963@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Mon, 18 Aug 2008 19:25:30 PDT." <48AA2F1A.9040306@miralink.com> Date: Mon, 18 Aug 2008 22:55:59 +0100 From: Dieter Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Aug 2008 05:57:13 -0000 > > I tried rebooting again, and then powered up the camera > > and pressed play. Without running fwcontrol at all. > > The console spewed away. > > > > Just to be explicit, it didn't do this until today. > > > > So I think the kernel device driver needs to reset and/or > > initialize something, probably on the fw controller chip. > > Thoughts? > > Ok, good times. > > Can you post the output of "fwcontrol -p" for me? fwcontrol -u 0 -p ( for comparison ) === base register === 0x03 0x05 0xe2 0x40 0xc1 0x03 0x00 0x20 Physical_ID:0 R:1 CPS:1 RHB:0 IBR:0 Gap_Count:5 Extended:7 Num_Ports:2 PHY_Speed:2 Delay:0 LCtrl:1 C:1 Jitter:0 Pwr_Class:1 WDIE:0 ISBR:0 CTOI:0 CPSI:0 STOI:0 PEI:0 EAA:1 EMC:1 Max_Legacy_SPD:0 BLINK:0 Bridge:0 Page_Select:1 Port_Select0 === page 0 port 0 === 0x08 0x00 0x00 0x00 0x00 0x00 0x00 0x00 Astat:0 BStat:0 Ch:1 Con:0 RXOK:0 Dis:0 Negotiated_speed:0 PIE:0 Fault:0 Stanby_fault:0 Disscrm:0 B_Only:0 DC_connected:0 Max_port_speed:0 LPP:0 Cable_speed:0 Connection_unreliable:0 Beta_mode:0 Port_error:0x0 Loop_disable:0 In_standby:0 Hard_disable:0 === page 0 port 1 === 0x08 0x00 0x00 0x00 0x00 0x00 0x00 0x00 Astat:0 BStat:0 Ch:1 Con:0 RXOK:0 Dis:0 Negotiated_speed:0 PIE:0 Fault:0 Stanby_fault:0 Disscrm:0 B_Only:0 DC_connected:0 Max_port_speed:0 LPP:0 Cable_speed:0 Connection_unreliable:0 Beta_mode:0 Port_error:0x0 Loop_disable:0 In_standby:0 Hard_disable:0 === page 1 === 0x01 0x00 0x00 0x11 0x63 0x30 0x60 0x01 Compliance:1 Vendor_ID:0x001163 Product_ID:0x306001 fwcontrol -u 1 -p (the bus actually in use) === base register === 0x06 0x85 0xe2 0x42 0xd7 0x03 0x00 0x20 Physical_ID:1 R:1 CPS:0 RHB:1 IBR:0 Gap_Count:5 Extended:7 Num_Ports:2 PHY_Speed:2 Delay:2 LCtrl:1 C:1 Jitter:2 Pwr_Class:7 WDIE:0 ISBR:0 CTOI:0 CPSI:0 STOI:0 PEI:0 EAA:1 EMC:1 Max_Legacy_SPD:0 BLINK:0 Bridge:0 Page_Select:1 Port_Select0 === page 0 port 0 === 0x08 0x00 0x00 0x00 0x00 0x00 0x00 0x00 Astat:0 BStat:0 Ch:1 Con:0 RXOK:0 Dis:0 Negotiated_speed:0 PIE:0 Fault:0 Stanby_fault:0 Disscrm:0 B_Only:0 DC_connected:0 Max_port_speed:0 LPP:0 Cable_speed:0 Connection_unreliable:0 Beta_mode:0 Port_error:0x0 Loop_disable:0 In_standby:0 Hard_disable:0 === page 0 port 1 === 0xfe 0x00 0x00 0x00 0x00 0x00 0x00 0x00 Astat:3 BStat:3 Ch:1 Con:1 RXOK:1 Dis:0 Negotiated_speed:0 PIE:0 Fault:0 Stanby_fault:0 Disscrm:0 B_Only:0 DC_connected:0 Max_port_speed:0 LPP:0 Cable_speed:0 Connection_unreliable:0 Beta_mode:0 Port_error:0x0 Loop_disable:0 In_standby:0 Hard_disable:0 === page 1 === 0x01 0x00 0x00 0x00 0x4c 0x02 0x00 0x00 Compliance:1 Vendor_ID:0x00004c Product_ID:0x020000 And while we're at it: fwcontrol -u 0 -t crc_len: 3 generation:1 node_count:1 sid_count:1 id link gap_cnt speed delay cIRM power port0 port1 port2 ini more 00 1 5 S400 0 1 15W - - 1 0 fwcontrol -u 1 -t crc_len: 4 generation:8 node_count:2 sid_count:2 id link gap_cnt speed delay cIRM power port0 port1 port2 ini more 00 1 63 S100 0 1 0W - P 1 0 01 1 5 S400 0 1 -9W - C 0 0 > I would think that a simple bus reset from fwcontrol would clear this. So I clear a bus reset with a bus reset. Like fighting fire(wire) with fire(wire). :-) It may clear something, but when I press play it starts again. > The BUSRST message means that the driver > is getting a BUS_RESET when it's internal state machine is not > BUS_RESET. Ok, but why is it getting all these BUS_RESETs? DV data arrives from the camera and all these BUS_RESETs happen. Hundreds of them, the gen number wraps around. > Kind of confusing, but that means > you should be able to clear it out with a "fwcontrol -r -u 1" ??? You > will _HAVE_ to use the new code to send a bus reset > to the second bus. The prev version is able to reset the bus. Prev version is dated Mar 5, file(1) doesn't say "for FreeBSD 7.0" like it does on the recent ones, so it would be from 6.2, adding the -f option to force "non CYCLEMASTER mode" (see PR kern/113785). fwcontrol -u 1 -f 0 fwcontrol -u 1 -r IIRC, the prev version is picky about the order of the arguments, (-u 1 needs to be first) but it does reset the bus. From owner-freebsd-firewire@FreeBSD.ORG Tue Aug 19 06:23:45 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 163C71065675; Tue, 19 Aug 2008 06:23:45 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 5E8128FC24; Tue, 19 Aug 2008 06:23:44 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7J6NZh52792; Mon, 18 Aug 2008 23:23:35 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id GAA18270; Tue, 19 Aug 2008 06:22:29 GMT Message-Id: <200808190622.GAA18270@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Mon, 18 Aug 2008 15:27:01 PDT." <48A9F735.5090507@miralink.com> Date: Mon, 18 Aug 2008 23:22:29 +0100 From: Dieter Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Aug 2008 06:23:45 -0000 > > I notice that it doesn't print every generation. > > I notice that the node_id changes. > > > This alarms me quite a bit. I didn't think there was anyway for the > generation to change > without the log message being spit out. Interesting. Perhaps there is some register on the controller chip that affects receiving data but not sending it, and isn't getting initialized. Perhaps the controller chip thinks it is receiving bad data, and flags an error or requests a bus reset? If the resets are happening faster than the printf can run, maybe the data (generation number) changes underneath the printf, much like ps/top don't get a pure snapshot? From owner-freebsd-firewire@FreeBSD.ORG Wed Aug 20 00:11:02 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 73AF81065699; Wed, 20 Aug 2008 00:11:02 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id 520608FC16; Wed, 20 Aug 2008 00:11:02 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 6A71B1A90C5; Tue, 19 Aug 2008 17:03:21 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XjuFF+dAYRJi; Tue, 19 Aug 2008 17:03:21 -0700 (PDT) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id 1C8181A90B3; Tue, 19 Aug 2008 17:03:21 -0700 (PDT) Message-ID: <48AB6115.6090308@miralink.com> Date: Tue, 19 Aug 2008 17:11:01 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808190622.GAA18270@sopwith.solgatos.com> In-Reply-To: <200808190622.GAA18270@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Aug 2008 00:11:02 -0000 Dieter wrote: >>> I notice that it doesn't print every generation. >>> I notice that the node_id changes. >>> >> This alarms me quite a bit. I didn't think there was anyway for the >> generation to change >> without the log message being spit out. Interesting. >> > > Perhaps there is some register on the controller chip that > affects receiving data but not sending it, and isn't getting > initialized. Perhaps the controller chip thinks it is receiving > bad data, and flags an error or requests a bus reset? > > If the resets are happening faster than the printf can run, > maybe the data (generation number) changes underneath the printf, > much like ps/top don't get a pure snapshot? > Hrm...First, let's try and get your camera working again. I would like you to try and connect your camera to a Mac, Linux or Windows box and try to get it working again. Sean -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com From owner-freebsd-firewire@FreeBSD.ORG Wed Aug 20 06:08:24 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0A8BE1065676; Wed, 20 Aug 2008 06:08:24 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 41A438FC17; Wed, 20 Aug 2008 06:08:23 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7K68Di55393; Tue, 19 Aug 2008 23:08:13 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id GAA01246; Wed, 20 Aug 2008 06:07:13 GMT Message-Id: <200808200607.GAA01246@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Tue, 19 Aug 2008 17:11:01 PDT." <48AB6115.6090308@miralink.com> Date: Tue, 19 Aug 2008 23:07:13 +0100 From: Dieter Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Aug 2008 06:08:24 -0000 > >>> I notice that it doesn't print every generation. > >>> I notice that the node_id changes. > >>> > >> This alarms me quite a bit. I didn't think there was anyway for the > >> generation to change > >> without the log message being spit out. Interesting. > >> > > > > Perhaps there is some register on the controller chip that > > affects receiving data but not sending it, and isn't getting > > initialized. Perhaps the controller chip thinks it is receiving > > bad data, and flags an error or requests a bus reset? > > > > If the resets are happening faster than the printf can run, > > maybe the data (generation number) changes underneath the printf, > > much like ps/top don't get a pure snapshot? > > > Hrm...First, let's try and get your camera working again. > > I would like you to try and connect your camera to a Mac, Linux or > Windows box and try to get it working again. As far as I can tell the camera is working fine. For example I can send DV data *to* the camera over firewire and it happily converts it to analog and ships it out s-video to the TV. And the data *from* the camera is recognized as DV: fwcontrol_prev -u 1 -R camera.dv Detected DV format on input. (EAGAIN) (EAGAIN) (EAGAIN) The camera was of course powered off while I tested the argument range checks. And I only ran tests that seemed safe. I'm not *completely* insane. From owner-freebsd-firewire@FreeBSD.ORG Wed Aug 20 16:56:06 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D501106564A; Wed, 20 Aug 2008 16:56:06 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id 706628FC15; Wed, 20 Aug 2008 16:56:06 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id B78D51A90B5; Wed, 20 Aug 2008 09:48:13 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cItwwSma8urZ; Wed, 20 Aug 2008 09:48:13 -0700 (PDT) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id 5AA351A8EF1; Wed, 20 Aug 2008 09:48:13 -0700 (PDT) Message-ID: <48AC4CA2.2080801@miralink.com> Date: Wed, 20 Aug 2008 09:56:02 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808200607.GAA01246@sopwith.solgatos.com> In-Reply-To: <200808200607.GAA01246@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Aug 2008 16:56:06 -0000 Dieter wrote: >>>>> I notice that it doesn't print every generation. >>>>> I notice that the node_id changes. >>>>> >>>>> >>>> This alarms me quite a bit. I didn't think there was anyway for the >>>> generation to change >>>> without the log message being spit out. Interesting. >>>> >>>> >>> Perhaps there is some register on the controller chip that >>> affects receiving data but not sending it, and isn't getting >>> initialized. Perhaps the controller chip thinks it is receiving >>> bad data, and flags an error or requests a bus reset? >>> >>> If the resets are happening faster than the printf can run, >>> maybe the data (generation number) changes underneath the printf, >>> much like ps/top don't get a pure snapshot? >>> >>> >> Hrm...First, let's try and get your camera working again. >> >> I would like you to try and connect your camera to a Mac, Linux or >> Windows box and try to get it working again. >> > > As far as I can tell the camera is working fine. > > For example I can send DV data *to* the camera over firewire and it > happily converts it to analog and ships it out s-video to the TV. > > And the data *from* the camera is recognized as DV: > > fwcontrol_prev -u 1 -R camera.dv > Detected DV format on input. > (EAGAIN) > (EAGAIN) > (EAGAIN) > > The camera was of course powered off while I tested the argument > range checks. And I only ran tests that seemed safe. I'm not > *completely* insane. > So, is you camera working perfectly at this time? I.e. with old fwcontrol, everything is fine? My concern was that somehow we had triggered a bit in the firewire hardware(most likely the camera) that caused you camera to be non-functional. -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com From owner-freebsd-firewire@FreeBSD.ORG Wed Aug 20 17:37:59 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8FE26106564A; Wed, 20 Aug 2008 17:37:59 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 039458FC1E; Wed, 20 Aug 2008 17:37:58 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7KHbmA56941; Wed, 20 Aug 2008 10:37:48 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id RAA06706; Wed, 20 Aug 2008 17:36:36 GMT Message-Id: <200808201736.RAA06706@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Wed, 20 Aug 2008 09:56:02 PDT." <48AC4CA2.2080801@miralink.com> Date: Wed, 20 Aug 2008 10:36:36 +0100 From: Dieter Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Aug 2008 17:37:59 -0000 > >>>>> I notice that it doesn't print every generation. > >>>>> I notice that the node_id changes. > >>>>> > >>>>> > >>>> This alarms me quite a bit. I didn't think there was anyway for the > >>>> generation to change > >>>> without the log message being spit out. Interesting. > >>>> > >>>> > >>> Perhaps there is some register on the controller chip that > >>> affects receiving data but not sending it, and isn't getting > >>> initialized. Perhaps the controller chip thinks it is receiving > >>> bad data, and flags an error or requests a bus reset? > >>> > >>> If the resets are happening faster than the printf can run, > >>> maybe the data (generation number) changes underneath the printf, > >>> much like ps/top don't get a pure snapshot? > >>> > >>> > >> Hrm...First, let's try and get your camera working again. > >> > >> I would like you to try and connect your camera to a Mac, Linux or > >> Windows box and try to get it working again. > >> > > > > As far as I can tell the camera is working fine. > > > > For example I can send DV data *to* the camera over firewire and it > > happily converts it to analog and ships it out s-video to the TV. > > > > And the data *from* the camera is recognized as DV: > > > > fwcontrol_prev -u 1 -R camera.dv > > Detected DV format on input. > > (EAGAIN) > > (EAGAIN) > > (EAGAIN) > > > > The camera was of course powered off while I tested the argument > > range checks. And I only ran tests that seemed safe. I'm not > > *completely* insane. > > > So, is you camera working perfectly at this time? I.e. with old > fwcontrol, everything is fine? My concern was that somehow we had > triggered a bit in the firewire hardware(most likely the camera) that > caused you camera to be non-functional. I think the camera itself is working. I think the NEC fw controller in the FreeBSD box is slightly messed up, resulting in lots of bus resets when the camera sends DV data. I'll try the VIA fw controller and see if -R works. If it works, then we know the camera is fine. Unfortunately I don't know if -R ever worked with the VIA. -S definitely doesn't work properly with VIA. I haven't been able to get the VIA to go into "non CYCLEMASTER mode", even using the -f option that works with the NEC. From owner-freebsd-firewire@FreeBSD.ORG Wed Aug 20 23:56:13 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7AA3D106566B; Wed, 20 Aug 2008 23:56:13 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id DAE6F8FC13; Wed, 20 Aug 2008 23:56:12 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7KNu2457478; Wed, 20 Aug 2008 16:56:02 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id XAA00211; Wed, 20 Aug 2008 23:54:23 GMT Message-Id: <200808202354.XAA00211@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Wed, 20 Aug 2008 09:56:02 PDT." <48AC4CA2.2080801@miralink.com> Date: Wed, 20 Aug 2008 16:54:23 +0100 From: Dieter Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Aug 2008 23:56:13 -0000 >> So, is you camera working perfectly at this time? I.e. with old >> fwcontrol, everything is fine? My concern was that somehow we had >> triggered a bit in the firewire hardware(most likely the camera) that >> caused you camera to be non-functional. > > I think the camera itself is working. > > I think the NEC fw controller in the FreeBSD box is slightly messed up, > resulting in lots of bus resets when the camera sends DV data. > > I'll try the VIA fw controller and see if -R works. If it works, > then we know the camera is fine. Unfortunately I don't know if > -R ever worked with the VIA. -S definitely doesn't work properly > with VIA. I haven't been able to get the VIA to go into > "non CYCLEMASTER mode", even using the -f option that works with > the NEC. I moved the cable from the NEC port (bus 1) to the VIA port (bus 0) # fwcontrol -u 0 -f 0 send phy_config root_node=0 gap_count=-1 console says: nothing # fwcontrol -u 0 -r console says: fwohci0: Initiate bus reset fwohci0: BUS reset fwohci0: node_id=0xc800ffc1, gen=5, CYCLEMASTER mode <-- should be non-CYCLEMASTER mode? :-( firewire0: 2 nodes, maxhop <= 1, cable IRM = 1 (me) firewire0: bus manager 1 (me) # fwcontrol -u 0 -t crc_len: 4 generation:5 node_count:2 sid_count:2 id link gap_cnt speed delay cIRM power port0 port1 port2 ini more 00 1 5 S100 0 1 0W - P 0 0 01 1 5 S400 0 1 15W - C 1 0 # fwcontrol -u 0 -R camera.dv Detected DV format on input. NTSC 012345678901234567890123456789 012345678901234567890123456789 012345678901234567890123456789 console says: nothing I then powered down the camera, moved the cable back to the NEC port, powered up, put the NEC into non-CYCLEMASTER mode, ran fwcontrol -S and the DV file played fine. So: the camera itself works fine, and the VIA controller can do -R even in CYCLEMASTER mode. So I'm back to my theory that the NEC controller is slightly unhappy. But what I'd really like, is a way to get the onboard VIA VT6307 controller to do fwcontrol -S correctly. The NEC controller card is using up a slot I need for other things. From owner-freebsd-firewire@FreeBSD.ORG Thu Aug 21 00:01:15 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38DEB1065677; Thu, 21 Aug 2008 00:01:15 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id 0E0EB8FC15; Thu, 21 Aug 2008 00:01:15 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 9F7961A90CF; Wed, 20 Aug 2008 16:53:21 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bg4VIw4qrvgQ; Wed, 20 Aug 2008 16:53:21 -0700 (PDT) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id 329291A90B3; Wed, 20 Aug 2008 16:53:21 -0700 (PDT) Message-ID: <48ACB04A.4000009@miralink.com> Date: Wed, 20 Aug 2008 17:01:14 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808202354.XAA00211@sopwith.solgatos.com> In-Reply-To: <200808202354.XAA00211@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Aug 2008 00:01:15 -0000 > I moved the cable from the NEC port (bus 1) to the VIA port (bus 0) > > # fwcontrol -u 0 -f 0 > send phy_config root_node=0 gap_count=-1 > > console says: nothing > > # fwcontrol -u 0 -r > > console says: > > fwohci0: Initiate bus reset > fwohci0: BUS reset > fwohci0: node_id=0xc800ffc1, gen=5, CYCLEMASTER mode <-- should be non-CYCLEMASTER mode? :-( > firewire0: 2 nodes, maxhop <= 1, cable IRM = 1 (me) > firewire0: bus manager 1 (me) > > # fwcontrol -u 0 -t > crc_len: 4 generation:5 node_count:2 sid_count:2 > id link gap_cnt speed delay cIRM power port0 port1 port2 ini more > 00 1 5 S100 0 1 0W - P 0 0 > 01 1 5 S400 0 1 15W - C 1 0 > > # fwcontrol -u 0 -R camera.dv > Detected DV format on input. > NTSC > 012345678901234567890123456789 > 012345678901234567890123456789 > 012345678901234567890123456789 > > console says: nothing > > I then powered down the camera, moved the cable back to the > NEC port, powered up, put the NEC into non-CYCLEMASTER mode, > ran fwcontrol -S and the DV file played fine. So: the camera > itself works fine, and the VIA controller can do -R even in > CYCLEMASTER mode. > > So I'm back to my theory that the NEC controller is slightly unhappy. > But what I'd really like, is a way to get the onboard VIA VT6307 controller > to do fwcontrol -S correctly. The NEC controller card is using up a slot > I need for other things. > So your current status is: Camera works with VIA controller. Camera still doesn't work with NEC controller. 1. Does the camera work with the unpatched version of fwcontrol and the NEC controller? 2. The NEC controller is a PCI card. Does anything else work with the NEC controller(external HD?). 3. Is there a bug reported on your VIA VT6307? -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com From owner-freebsd-firewire@FreeBSD.ORG Thu Aug 21 02:10:11 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1C420106568A; Thu, 21 Aug 2008 02:10:11 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 820758FC16; Thu, 21 Aug 2008 02:10:07 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7L29sa57678; Wed, 20 Aug 2008 19:09:54 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id CAA00979; Thu, 21 Aug 2008 02:08:52 GMT Message-Id: <200808210208.CAA00979@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Wed, 20 Aug 2008 17:01:14 PDT." <48ACB04A.4000009@miralink.com> Date: Wed, 20 Aug 2008 19:08:52 +0100 From: Dieter Cc: Scott Long , freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Aug 2008 02:10:11 -0000 > > I moved the cable from the NEC port (bus 1) to the VIA port (bus 0) > > > > # fwcontrol -u 0 -f 0 > > send phy_config root_node=0 gap_count=-1 > > > > console says: nothing > > > > # fwcontrol -u 0 -r > > > > console says: > > > > fwohci0: Initiate bus reset > > fwohci0: BUS reset > > fwohci0: node_id=0xc800ffc1, gen=5, CYCLEMASTER mode <-- should be non-CYCLEMASTER mode? :-( > > firewire0: 2 nodes, maxhop <= 1, cable IRM = 1 (me) > > firewire0: bus manager 1 (me) > > > > # fwcontrol -u 0 -t > > crc_len: 4 generation:5 node_count:2 sid_count:2 > > id link gap_cnt speed delay cIRM power port0 port1 port2 ini more > > 00 1 5 S100 0 1 0W - P 0 0 > > 01 1 5 S400 0 1 15W - C 1 0 > > > > # fwcontrol -u 0 -R camera.dv > > Detected DV format on input. > > NTSC > > 012345678901234567890123456789 > > 012345678901234567890123456789 > > 012345678901234567890123456789 > > > > console says: nothing > > > > I then powered down the camera, moved the cable back to the > > NEC port, powered up, put the NEC into non-CYCLEMASTER mode, > > ran fwcontrol -S and the DV file played fine. So: the camera > > itself works fine, and the VIA controller can do -R even in > > CYCLEMASTER mode. > > > > So I'm back to my theory that the NEC controller is slightly unhappy. > > But what I'd really like, is a way to get the onboard VIA VT6307 controller > > to do fwcontrol -S correctly. The NEC controller card is using up a slot > > I need for other things. > > > So your current status is: Camera works with VIA controller. Camera > still doesn't work with NEC controller. More accurately: the camera itself works VIA controller can do fwcontrol -R VIA controller attempting to do fwcontrol -S gives dropouts on a regular basis, every couple seconds. NEC does the same thing if in CYCLEMASTER mode. I have not been able to get the VIA into non-CYCLEMASTER mode. See today's attempt to do so using fwcontrol -f above. NEC controller can do fwcontrol -S (after switching to non-CYCLEMASTER mode) NEC controller used to do fwcontrol -R Now, if camera is connected to NEC controller and I press play (sending DV data to computer), lots of bus resets happen. The resets have nothing to do with running fwcontrol. The resets happen even if fwcontrol has not been run at all since FreeBSD was rebooted. > 1. Does the camera work with the unpatched version of fwcontrol and the > NEC controller? NEC controller can do fwcontrol -S (after switching to non-CYCLEMASTER mode) > 2. The NEC controller is a PCI card. yes > Does anything else work with the > NEC controller(external HD?). unknown > 3. Is there a bug reported on your VIA VT6307? yes http://www.FreeBSD.org/cgi/query-pr.cgi?pr=113785&cat=kern If we assume that I need to get the VIA into non-CYCLEMASTER mode, (since that worked with the NEC), any ideas why fwcontrol -u 0 -f 0 fwcontrol -u 0 -r doesn't force the VIA into non-CYCLEMASTER mode the way it (with -u 1) works for NEC? From owner-freebsd-firewire@FreeBSD.ORG Thu Aug 21 03:18:52 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4CF4E1065681 for ; Thu, 21 Aug 2008 03:18:52 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id 242E18FC18 for ; Thu, 21 Aug 2008 03:18:52 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 016981A90E8; Wed, 20 Aug 2008 20:10:57 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NJn1QUXHwVaQ; Wed, 20 Aug 2008 20:10:56 -0700 (PDT) Received: from [10.47.1.18] (vpn.office.miralink.com [10.0.0.5]) by plato.miralink.com (Postfix) with ESMTP id EBB0C1A90CB; Wed, 20 Aug 2008 20:10:50 -0700 (PDT) Message-ID: <48ACDE83.1040408@miralink.com> Date: Wed, 20 Aug 2008 20:18:27 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808210208.CAA00979@sopwith.solgatos.com> In-Reply-To: <200808210208.CAA00979@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Aug 2008 03:18:52 -0000 > More accurately: > > the camera itself works > > VIA controller can do fwcontrol -R > > VIA controller attempting to do fwcontrol -S gives dropouts > on a regular basis, every couple seconds. NEC does the same > thing if in CYCLEMASTER mode. I have not been able to get > the VIA into non-CYCLEMASTER mode. See today's attempt to > do so using fwcontrol -f above. > > NEC controller can do fwcontrol -S (after switching to > non-CYCLEMASTER mode) > > NEC controller used to do fwcontrol -R > > Now, if camera is connected to NEC controller and I press play > (sending DV data to computer), lots of bus resets happen. The > resets have nothing to do with running fwcontrol. The resets > happen even if fwcontrol has not been run at all since FreeBSD > was rebooted. > > Thank you for being patient with me as I begin my journey into the firewire stack! So, at this point I have done "something" to the NEC controller to remove functionality. I don't suppose you have a Linux live CD lying around that you can boot up into? My hope, would be that the Linux firewire stack would reset you controller back to a functional state. Then I could work on my original idea of flushing out fwcontrol. I just don't know or understand enough of the firewire driver yet to be able to repair this condition. I'd like to get you back to your original state, and possibly diagnose the failure in the first place. >> 3. Is there a bug reported on your VIA VT6307? >> > > yes > > http://www.FreeBSD.org/cgi/query-pr.cgi?pr=113785&cat=kern > > If we assume that I need to get the VIA into non-CYCLEMASTER mode, > (since that worked with the NEC), any ideas why > > fwcontrol -u 0 -f 0 > fwcontrol -u 0 -r > > doesn't force the VIA into non-CYCLEMASTER mode the way > it (with -u 1) works for NEC? > I will review this bug later in the morning and see if I can understand your current implementation. This seems a strange way to use your camera to me ... all of this setting and resetting parameters mess may be higher on my list than I wanted it to be initially. :) -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Cell 503-358-6832 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com From owner-freebsd-firewire@FreeBSD.ORG Thu Aug 21 17:47:20 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 277CC106567C for ; Thu, 21 Aug 2008 17:47:20 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 9C33F8FC19 for ; Thu, 21 Aug 2008 17:47:19 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7LHl9P59574; Thu, 21 Aug 2008 10:47:09 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id RAA12308; Thu, 21 Aug 2008 17:44:56 GMT Message-Id: <200808211744.RAA12308@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Wed, 20 Aug 2008 20:18:27 PDT." <48ACDE83.1040408@miralink.com> Date: Thu, 21 Aug 2008 10:44:56 +0100 From: Dieter Cc: freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Aug 2008 17:47:20 -0000 > > More accurately: > > > > the camera itself works > > > > VIA controller can do fwcontrol -R > > > > VIA controller attempting to do fwcontrol -S gives dropouts > > on a regular basis, every couple seconds. NEC does the same > > thing if in CYCLEMASTER mode. I have not been able to get > > the VIA into non-CYCLEMASTER mode. See today's attempt to > > do so using fwcontrol -f above. > > > > NEC controller can do fwcontrol -S (after switching to > > non-CYCLEMASTER mode) > > > > NEC controller used to do fwcontrol -R > > > > Now, if camera is connected to NEC controller and I press play > > (sending DV data to computer), lots of bus resets happen. The > > resets have nothing to do with running fwcontrol. The resets > > happen even if fwcontrol has not been run at all since FreeBSD > > was rebooted. > So, at this point I have done "something" to the NEC controller to > remove functionality. Maybe, maybe not. It might have been fwcontrol, or it might have been putting the camera in "camera" mode instead of "vcr" mode. The previous time I tried that, nothing at all happened. I don't remember which controller it was connected to last time, so it might have been the VIA. The goal being to capture video live, rather than having to record it on tape, rewind, play back. Previously I got no indication that the camera was sending any data to the computer, this time I got the bus reset spewage. I would think that the data would be the same either way (live or tape), but perhaps there is some difference which messed up the NCR. In hindsight, that was a bad time to throw in another variable. :-( I tried booting NetBSD, looks like they ported FreeBSD's firewire over, but an older version without the -f option I need. As you might expect, I get similar spewage from NetBSD: fwohci1: BUS reset fwohci1: node_id=0xc000ffc0, gen=53, CYCLEMASTER mode ieee1394if1: 1 nodes, maxhop <= 0, cable IRM = 0 (me) ieee1394if1: bus manager 0 (me) fwohci1: BUS reset fwohci1: node_id=0xc000ffc1, gen=72, CYCLEMASTER mode ieee1394if1: 2 nodes, maxhop <= 1, cable IRM = 1 (me) ieee1394if1: bus manager 0 ieee1394if1: split transaction timeout dst=0xffc0 tl=0x18 state=3 fwohci1: BUS reset fwohci1: node_id=0xc000ffc0, gen=76, CYCLEMASTER mode ieee1394if1: 1 nodes, maxhop <= 0, cable IRM = 0 (me) ieee1394if1: bus manager 0 (me) fwohci1: BUS reset fwohci1: node_id=0xc000ffc1, gen=103, CYCLEMASTER mode ieee1394if1: 2 nodes, maxhop <= 1, cable IRM = 1 (me) ieee1394if1: bus manager 0 > >> 3. Is there a bug reported on your VIA VT6307? > >> > > > > yes > > > > http://www.FreeBSD.org/cgi/query-pr.cgi?pr=113785&cat=kern > > > > If we assume that I need to get the VIA into non-CYCLEMASTER mode, > > (since that worked with the NEC), any ideas why > > > > fwcontrol -u 0 -f 0 > > fwcontrol -u 0 -r > > > > doesn't force the VIA into non-CYCLEMASTER mode the way > > it (with -u 1) works for NEC? > > > > I will review this bug later in the morning and see if I can understand > your current implementation. Thanks. > This seems a strange way to use your camera to me Strange how? From owner-freebsd-firewire@FreeBSD.ORG Thu Aug 21 18:18:56 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C7F7F106564A for ; Thu, 21 Aug 2008 18:18:56 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id 9A0788FC1B for ; Thu, 21 Aug 2008 18:18:56 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 554EE1A90FE; Thu, 21 Aug 2008 11:10:53 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xvQZvaZFvMPU; Thu, 21 Aug 2008 11:10:52 -0700 (PDT) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id E7C731A90DE; Thu, 21 Aug 2008 11:10:52 -0700 (PDT) Message-ID: <48ADB18F.3000507@miralink.com> Date: Thu, 21 Aug 2008 11:18:55 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808211744.RAA12308@sopwith.solgatos.com> In-Reply-To: <200808211744.RAA12308@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Aug 2008 18:18:56 -0000 Dieter wrote: >>> More accurately: >>> >>> the camera itself works >>> >>> VIA controller can do fwcontrol -R >>> >>> VIA controller attempting to do fwcontrol -S gives dropouts >>> on a regular basis, every couple seconds. NEC does the same >>> thing if in CYCLEMASTER mode. I have not been able to get >>> the VIA into non-CYCLEMASTER mode. See today's attempt to >>> do so using fwcontrol -f above. >>> >>> NEC controller can do fwcontrol -S (after switching to >>> non-CYCLEMASTER mode) >>> >>> NEC controller used to do fwcontrol -R >>> >>> Now, if camera is connected to NEC controller and I press play >>> (sending DV data to computer), lots of bus resets happen. The >>> resets have nothing to do with running fwcontrol. The resets >>> happen even if fwcontrol has not been run at all since FreeBSD >>> was rebooted. >>> > > >> So, at this point I have done "something" to the NEC controller to >> remove functionality. >> > > Maybe, maybe not. It might have been fwcontrol, or it might have > been putting the camera in "camera" mode instead of "vcr" mode. > The previous time I tried that, nothing at all happened. I don't > remember which controller it was connected to last time, so it might > have been the VIA. The goal being to capture video live, rather than > having to record it on tape, rewind, play back. Previously I got > no indication that the camera was sending any data to the computer, > this time I got the bus reset spewage. I would think that the data > would be the same either way (live or tape), but perhaps there is > some difference which messed up the NCR. > > In hindsight, that was a bad time to throw in another variable. :-( > > Ummm...ok. Is the unit in "vcr" mode now when it generates the spewage? Are we worse or better than when we started? :) > > >> This seems a strange way to use your camera to me >> > > Strange how? > It's strange to me that you don't have any applications other than fwcontrol to pull and push files from your camera. -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com From owner-freebsd-firewire@FreeBSD.ORG Thu Aug 21 19:57:26 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B601F1065687 for ; Thu, 21 Aug 2008 19:57:26 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 4DD768FC1B for ; Thu, 21 Aug 2008 19:57:26 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7LJvIT59759; Thu, 21 Aug 2008 12:57:18 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id TAA13561; Thu, 21 Aug 2008 19:56:08 GMT Message-Id: <200808211956.TAA13561@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Thu, 21 Aug 2008 11:18:55 PDT." <48ADB18F.3000507@miralink.com> Date: Thu, 21 Aug 2008 12:56:08 +0100 From: Dieter Cc: freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Aug 2008 19:57:26 -0000 > Ummm...ok. Is the unit in "vcr" mode now when it generates the spewage? Yes, vcr mode. I only tried camera mode twice, once many months ago with 6.x, and once a couple days ago with 7.0. > Are we worse or better than when we started? :) Well... I found a few things in fwcontrol that could use improvement, most of which have been fixed. I found that the NEC appariently isn't getting reset/initialized sufficiently. I found that NetBSD has ported FreeBSD's fw support and thus now works with camcorders. On the other hand if I want to upload data from the camera I now have to move the cable. I still don't know exactly what messed up the NEC, and the VIA still doesn't work properly with -S. > >> This seems a strange way to use your camera to me > >> > > > > Strange how? > > > It's strange to me that you don't have any applications other than fwcontrol > to pull and push files from your camera. I figured cat and dd probably wouldn't work. From owner-freebsd-firewire@FreeBSD.ORG Thu Aug 21 20:35:01 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A99031065682 for ; Thu, 21 Aug 2008 20:35:01 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id 845268FC51 for ; Thu, 21 Aug 2008 20:35:01 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 328E51A9183; Thu, 21 Aug 2008 13:26:57 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jR1HSr0GVqel; Thu, 21 Aug 2008 13:26:56 -0700 (PDT) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id DC7A71A9182; Thu, 21 Aug 2008 13:26:56 -0700 (PDT) Message-ID: <48ADD174.90002@miralink.com> Date: Thu, 21 Aug 2008 13:35:00 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808211956.TAA13561@sopwith.solgatos.com> In-Reply-To: <200808211956.TAA13561@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Aug 2008 20:35:01 -0000 Dieter wrote: >> Ummm...ok. Is the unit in "vcr" mode now when it generates the spewage? >> > > Yes, vcr mode. I only tried camera mode twice, once many months ago > with 6.x, and once a couple days ago with 7.0. > > oh...well then. Can you run a live linux distro(unbuntu or knoppix) and see if linux can "reset" your NEC f/w controller? Otherwise, I will be going down a very long and tedious path to try and discover what has broken. This will take me a long time. -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com From owner-freebsd-firewire@FreeBSD.ORG Fri Aug 22 01:28:02 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 42E0C1065682 for ; Fri, 22 Aug 2008 01:28:02 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id CDD3D8FC18 for ; Fri, 22 Aug 2008 01:28:01 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7M1Rsg60239; Thu, 21 Aug 2008 18:27:54 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id BAA25657; Fri, 22 Aug 2008 01:26:13 GMT Message-Id: <200808220126.BAA25657@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Thu, 21 Aug 2008 13:35:00 PDT." <48ADD174.90002@miralink.com> Date: Thu, 21 Aug 2008 18:26:13 +0100 From: Dieter Cc: freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Aug 2008 01:28:02 -0000 > Can you run a live linux distro(unbuntu or knoppix) and see if linux can > "reset" > your NEC f/w controller? Grumble... If I get penguinix to boot will you look at http://www.freebsd.org/cgi/query-pr.cgi?pr=113785 http://www.freebsd.org/cgi/query-pr.cgi?pr=118093 These two are more problematic than the NEC. > Otherwise, I will be going down a very long and tedious path to try and > discover what has > broken. This will take me a long time. Before you do that... What path are you planning on going down? We don't know what broke it: fwcontrol, camera in camera mode, or something else we haven't thought of. Seems to me that the solution is to look at the datasheet and the device driver and figure out what isn't getting initialized. So we need to find the datasheet for the NEC. From owner-freebsd-firewire@FreeBSD.ORG Fri Aug 22 02:12:41 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CD0E5106566C for ; Fri, 22 Aug 2008 02:12:41 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id A155B8FC1B for ; Fri, 22 Aug 2008 02:12:41 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 253C41A9183; Thu, 21 Aug 2008 19:04:34 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ptw5+9nNnHxI; Thu, 21 Aug 2008 19:04:33 -0700 (PDT) Received: from [10.47.1.18] (vpn.office.miralink.com [10.0.0.5]) by plato.miralink.com (Postfix) with ESMTP id 8586C1A90DE; Thu, 21 Aug 2008 19:04:33 -0700 (PDT) Message-ID: <48AE2080.7050409@miralink.com> Date: Thu, 21 Aug 2008 19:12:16 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808220126.BAA25657@sopwith.solgatos.com> In-Reply-To: <200808220126.BAA25657@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Aug 2008 02:12:41 -0000 Dieter wrote: >> Can you run a live linux distro(unbuntu or knoppix) and see if linux can >> "reset" >> your NEC f/w controller? >> > > Grumble... If I get penguinix to boot will you look at > > http://www.freebsd.org/cgi/query-pr.cgi?pr=113785 > http://www.freebsd.org/cgi/query-pr.cgi?pr=118093 > > These two are more problematic than the NEC. > > Cool. It's either that or I consider buying you a new camera? :) >> Otherwise, I will be going down a very long and tedious path to try and >> discover what has >> broken. This will take me a long time. >> > > Before you do that... > > What path are you planning on going down? > We don't know what broke it: fwcontrol, camera in > camera mode, or something else we haven't thought of. > > Seems to me that the solution is to look at the > datasheet and the device driver and figure out what > isn't getting initialized. So we need to find the > datasheet for the NEC. > My current understanding of the firewire stack and fwohci is not very good. I've fixed a few things in my tree(mainly in sbp_targ), but it will take some time for me to fully understand what's going on. We can either get the data sheet off of the NEC or look at what the linux code is doing and attempt a patch to emulate that behavior. -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Cell 503-358-6832 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com From owner-freebsd-firewire@FreeBSD.ORG Fri Aug 22 04:42:06 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BA027106564A for ; Fri, 22 Aug 2008 04:42:06 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 3566F8FC0C for ; Fri, 22 Aug 2008 04:42:05 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7M4ftH60515; Thu, 21 Aug 2008 21:41:55 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id EAA09835; Fri, 22 Aug 2008 04:40:43 GMT Message-Id: <200808220440.EAA09835@sopwith.solgatos.com> To: Sean Bruno , freebsd-firewire@freebsd.org In-reply-to: Your message of "Thu, 21 Aug 2008 18:26:13 BST." Date: Thu, 21 Aug 2008 21:40:43 +0100 From: Dieter Cc: Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Aug 2008 04:42:06 -0000 > Seems to me that the solution is to look at the > datasheet and the device driver and figure out what > isn't getting initialized. So we need to find the > datasheet for the NEC. http://chipdig.com/datasheets/download_datasheet.php?id=1024801&part-number=UPD72871 345130 bytes 48 page pdf Oddly I didn't find any timing diagrams, but there is a list of registers. Some of them even have descriptions that make sense. And we have useful info like: "VGA color palette invalidate is always disabled." Why a firewire controller would know or care about VGA color palette is beyond me. From owner-freebsd-firewire@FreeBSD.ORG Fri Aug 22 16:43:06 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A204C106566C for ; Fri, 22 Aug 2008 16:43:06 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 5E22D8FC1C for ; Fri, 22 Aug 2008 16:43:04 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7MGgkx62084; Fri, 22 Aug 2008 09:42:46 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id QAA21663; Fri, 22 Aug 2008 16:39:59 GMT Message-Id: <200808221639.QAA21663@sopwith.solgatos.com> To: Sean Bruno , freebsd-firewire@freebsd.org Date: Fri, 22 Aug 2008 09:39:59 +0100 From: Dieter Cc: Subject: VIA VT6307 datasheet X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Aug 2008 16:43:06 -0000 http://www.datasheetarchive.com/pdf-datasheets/Datasheets-6/DSA-113181.pdf 453914 bytes 54 pages pdf Questions for firewire wizards: Is "cycle master" the same as "bus master" ? Is "cycle master" the same as being the "root" node ?