tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: MNT Reform2 USB LCP flash



Michael van Elst wrote:
On Sat, Feb 03, 2024 at 09:55:47PM +0200, Staffan Thomén wrote:
Staffan Thomen wrote:
[ 188.679957] sd0: 34816, 1 cyl, 64 head, 32 sec, 512 bytes/sect
x 68 sectors [ 188.689958] autoconfiguration error: sd0: unable
to open device, error = 5
Any thoughts of how to continue debugging this?


A kernel compiled with SCSI_DEBUG can show which commands to the
device actually fail and how. This should be the initial
TEST_UNIT_READY and possibly the START command. No idea why, it's
possible that these are not implemented and errors need to be
ignored.

I built a kernel with options SCSIDEBUG, SCSIVERBOSE and SCSI_DEBUG, and
saw nothing new in the dmesg.

The man page for scsi(4) says that SCSIDEBUG (not SCSI_DEBUG) enables
ioctls for extra printfs, so I wrote this small program to run the
ioctl, but it still fails on the open call with Input/output error (EIO).

I tried /dev/sd0, /dev/sd0d, /dev/rsd0, /dev/rsd0d, /dev/sd0c and
/dev/rsd0c.

For good measure, I tried it on /dev/scsibus0 and that gave me an EFAULT
from ioctl.

I just now noticed that scsictl actually implements this ioctl as well,
but it also errors out with EIO.

The man page for scsictl(8) says that SCSIPI_DEBUG is the required option...

I think I'm more confused than before now. What enables scsi command
debugging?

Staffan

--8<--

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/scsiio.h>

int main(int argc, char **argv) {
        if (argc < 2) {
                printf("Usage: %s <device>\n", getprogname());
                return -1;
        }

        int fd = open(argv[1], O_RDONLY);

        if (fd == -1) {
                perror("open");
                return -1;
        }

        int result = ioctl(fd, SCIOCDEBUG, 0x15);

        if (result == -1)
                perror("ioctl");

        close(fd);

        return 0;
}



Home | Main Index | Thread Index | Old Index