NetBSD Problem Report #17432

Received: (qmail 24746 invoked by uid 605); 29 Jun 2002 23:01:02 -0000
Message-Id: <200206292300.g5TN0ve26181@ficus.home>
Date: Sun, 30 Jun 2002 01:00:57 +0200 (CEST)
From: Anthony Mallet <anthony.mallet@useless-ficus.net>
Sender: gnats-bugs-owner@netbsd.org
Reply-To: Anthony Mallet <anthony.mallet@useless-ficus.net>
To: gnats-bugs@gnats.netbsd.org
Subject: ieee1394 camera device CRC calculation
X-Send-Pr-Version: 3.95

>Number:         17432
>Category:       kern
>Synopsis:       ieee1394 camera device CRC calculation
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jun 29 23:02:00 +0000 2002
>Closed-Date:    Sat Nov 12 16:35:10 +0000 2005
>Last-Modified:  Sat Nov 12 16:35:10 +0000 2005
>Originator:     Anthony Mallet
>Release:        NetBSD 1.5ZC
>Organization:
>Environment:
System: NetBSD ficus 1.5ZC NetBSD 1.5ZC (FICUS) #3: Sat May 4 20:51:04 CEST 2002 toto@ficus:/home/src/netbsd-current/sys/arch/i386/compile/FICUS i386
Architecture: i386
Machine: i386
>Description:

I have a 1394 camera device whose config. ROM didn't pass the CRC
test. Since I have only one firewire device, it's difficult for 
me to know whether it's a general problem or not.

In case it's useful, here's the content of the rom, as output by
fwnode_dump_rom()

      0x04205b5e, 0x31333934, 0x20ff4000, 0x00d0f540,
      0x00070285, 0x000446b3, 0x0300d0f5, 0x06070198, 
      0x8d000002, 0xd1000004, 0x0002d192, 0x00d0f540, 
      0x00070285, 0x00034462, 0x1200a02d, 0x13000100, 
      0xd4000001, 0x00031226, 0x403c0000, 0x81000002, 
      0x82000008, 0x000642dd, 0x00000000, 0x00000000, 
      0x4f52414e, 0x4745204d, 0x4943524f, 0x00000000,
      0x000448cb, 0x00000000, 0x00000000, 0x49424f54, 
      0x00000000

The following patch in p1212_calc_crc() in ieee1212.c works for
me. I simply removed calls to ntohl(data[i]) and swapped the two bytes of
the crc-16 at the end (the latter because of the way the CRC is fetched
into the rom).

>How-To-Repeat:

>Fix:
Index: ieee1212.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/std/ieee1212.ēv
retrieving revision 1.2
diff -u -r1.2 ieee1212.c
--- ieee1212.c  2002/04/02 10:10:54     1.2
+++ ieee1212.c  2002/06/29 22:57:45
@@ -1191,7 +1191,7 @@

        for (i = 0; i < len; i++) {
                for (shift = 28; shift > 0; shift -= 4) {
-                       sum = ((crc » 12) ^ (ntohl(data[i]) » shift)) &
+                       sum = ((crc » 12) ^ (data[i] » shift)) &
                            0x0000000f;
                        crc = (crc « 4) ^ (sum « 12) ^ (sum « 5) ^ sum;
                }
@@ -1199,11 +1199,11 @@

                /* The broken implementation doesn't do the last
shift. */
                if (!broke) {
-                       sum = ((crc » 12) ^ ntohl(data[i])) & 0x0000000f;
+                       sum = ((crc » 12) ^ data[i]) & 0x0000000f;
                        crc = (crc « 4) ^ (sum « 12) ^ (sum « 5) ^ sum;
                }
        }
-       return (u_int16_t)crc;
+       return htons((u_int16_t)crc);
 }

 /*

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: chs@netbsd.org
State-Changed-When: Sat, 12 Nov 2005 16:35:10 +0000
State-Changed-Why:
the firewire code has been replaced with the freebsd implementation
in -current.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.