3 * Copyright (c) 2008,2011 Hans Petter Selasky. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * The following file contains code that will detect USB autoinstall
31 * TODO: Potentially we could add code to automatically detect USB
32 * mass storage quirks for not supported SCSI commands!
35 #include <sys/stdint.h>
36 #include <sys/stddef.h>
37 #include <sys/param.h>
38 #include <sys/queue.h>
39 #include <sys/types.h>
40 #include <sys/systm.h>
41 #include <sys/kernel.h>
43 #include <sys/module.h>
45 #include <sys/mutex.h>
46 #include <sys/condvar.h>
47 #include <sys/sysctl.h>
49 #include <sys/unistd.h>
50 #include <sys/callout.h>
51 #include <sys/malloc.h>
54 #include <dev/usb/usb.h>
55 #include <dev/usb/usbdi.h>
56 #include <dev/usb/usbdi_util.h>
58 #define USB_DEBUG_VAR usb_debug
60 #include <dev/usb/usb_busdma.h>
61 #include <dev/usb/usb_process.h>
62 #include <dev/usb/usb_transfer.h>
63 #include <dev/usb/usb_msctest.h>
64 #include <dev/usb/usb_debug.h>
65 #include <dev/usb/usb_device.h>
66 #include <dev/usb/usb_request.h>
67 #include <dev/usb/usb_util.h>
68 #include <dev/usb/quirk/usb_quirk.h>
86 #define SCSI_MAX_LEN 0x100
87 #define SCSI_INQ_LEN 0x24
88 #define SCSI_SENSE_LEN 0xFF
90 static uint8_t scsi_test_unit_ready[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
91 static uint8_t scsi_inquiry[] = { 0x12, 0x00, 0x00, 0x00, SCSI_INQ_LEN, 0x00 };
92 static uint8_t scsi_rezero_init[] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 };
93 static uint8_t scsi_start_stop_unit[] = { 0x1b, 0x00, 0x00, 0x00, 0x02, 0x00 };
94 static uint8_t scsi_ztestor_eject[] = { 0x85, 0x01, 0x01, 0x01, 0x18, 0x01,
95 0x01, 0x01, 0x01, 0x01, 0x00, 0x00 };
96 static uint8_t scsi_cmotech_eject[] = { 0xff, 0x52, 0x44, 0x45, 0x56, 0x43,
98 static uint8_t scsi_huawei_eject[] = { 0x11, 0x06, 0x00, 0x00, 0x00, 0x00,
99 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
100 0x00, 0x00, 0x00, 0x00 };
101 static uint8_t scsi_tct_eject[] = { 0x06, 0xf5, 0x04, 0x02, 0x52, 0x70 };
102 static uint8_t scsi_sync_cache[] = { 0x35, 0x00, 0x00, 0x00, 0x00, 0x00,
103 0x00, 0x00, 0x00, 0x00 };
104 static uint8_t scsi_request_sense[] = { 0x03, 0x00, 0x00, 0x00, 0x12, 0x00,
105 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
106 static uint8_t scsi_read_capacity[] = { 0x25, 0x00, 0x00, 0x00, 0x00, 0x00,
107 0x00, 0x00, 0x00, 0x00 };
109 #define BULK_SIZE 64 /* dummy */
110 #define ERR_CSW_FAILED -1
112 /* Command Block Wrapper */
114 uDWord dCBWSignature;
115 #define CBWSIGNATURE 0x43425355
117 uDWord dCBWDataTransferLength;
119 #define CBWFLAGS_OUT 0x00
120 #define CBWFLAGS_IN 0x80
123 #define CBWCDBLENGTH 16
124 uByte CBWCDB[CBWCDBLENGTH];
127 /* Command Status Wrapper */
129 uDWord dCSWSignature;
130 #define CSWSIGNATURE 0x53425355
132 uDWord dCSWDataResidue;
134 #define CSWSTATUS_GOOD 0x0
135 #define CSWSTATUS_FAILED 0x1
136 #define CSWSTATUS_PHASE 0x2
139 struct bbb_transfer {
145 struct usb_xfer *xfer[ST_MAX];
149 usb_size_t data_len; /* bytes */
150 usb_size_t data_rem; /* bytes */
151 usb_timeout_t data_timeout; /* ms */
152 usb_frlength_t actlen; /* bytes */
154 uint8_t cmd_len; /* bytes */
161 uint8_t buffer[SCSI_MAX_LEN] __aligned(4);
164 static usb_callback_t bbb_command_callback;
165 static usb_callback_t bbb_data_read_callback;
166 static usb_callback_t bbb_data_rd_cs_callback;
167 static usb_callback_t bbb_data_write_callback;
168 static usb_callback_t bbb_data_wr_cs_callback;
169 static usb_callback_t bbb_status_callback;
171 static void bbb_done(struct bbb_transfer *, int);
172 static void bbb_transfer_start(struct bbb_transfer *, uint8_t);
173 static void bbb_data_clear_stall_callback(struct usb_xfer *, uint8_t,
175 static int bbb_command_start(struct bbb_transfer *, uint8_t, uint8_t,
176 void *, size_t, void *, size_t, usb_timeout_t);
177 static struct bbb_transfer *bbb_attach(struct usb_device *, uint8_t);
178 static void bbb_detach(struct bbb_transfer *);
180 static const struct usb_config bbb_config[ST_MAX] = {
184 .endpoint = UE_ADDR_ANY,
185 .direction = UE_DIR_OUT,
186 .bufsize = sizeof(struct bbb_cbw),
187 .flags = {.ext_buffer = 1,},
188 .callback = &bbb_command_callback,
189 .timeout = 4 * USB_MS_HZ, /* 4 seconds */
194 .endpoint = UE_ADDR_ANY,
195 .direction = UE_DIR_IN,
196 .bufsize = BULK_SIZE,
197 .flags = {.ext_buffer = 1,.proxy_buffer = 1,.short_xfer_ok = 1,},
198 .callback = &bbb_data_read_callback,
199 .timeout = 4 * USB_MS_HZ, /* 4 seconds */
204 .endpoint = 0x00, /* Control pipe */
205 .direction = UE_DIR_ANY,
206 .bufsize = sizeof(struct usb_device_request),
207 .callback = &bbb_data_rd_cs_callback,
208 .timeout = 1 * USB_MS_HZ, /* 1 second */
213 .endpoint = UE_ADDR_ANY,
214 .direction = UE_DIR_OUT,
215 .bufsize = BULK_SIZE,
216 .flags = {.ext_buffer = 1,.proxy_buffer = 1,},
217 .callback = &bbb_data_write_callback,
218 .timeout = 4 * USB_MS_HZ, /* 4 seconds */
223 .endpoint = 0x00, /* Control pipe */
224 .direction = UE_DIR_ANY,
225 .bufsize = sizeof(struct usb_device_request),
226 .callback = &bbb_data_wr_cs_callback,
227 .timeout = 1 * USB_MS_HZ, /* 1 second */
232 .endpoint = UE_ADDR_ANY,
233 .direction = UE_DIR_IN,
234 .bufsize = sizeof(struct bbb_csw),
235 .flags = {.ext_buffer = 1,.short_xfer_ok = 1,},
236 .callback = &bbb_status_callback,
237 .timeout = 1 * USB_MS_HZ, /* 1 second */
242 bbb_done(struct bbb_transfer *sc, int error)
246 sc->state = ST_COMMAND;
252 bbb_transfer_start(struct bbb_transfer *sc, uint8_t xfer_index)
254 sc->state = xfer_index;
255 usbd_transfer_start(sc->xfer[xfer_index]);
259 bbb_data_clear_stall_callback(struct usb_xfer *xfer,
260 uint8_t next_xfer, uint8_t stall_xfer)
262 struct bbb_transfer *sc = usbd_xfer_softc(xfer);
264 if (usbd_clear_stall_callback(xfer, sc->xfer[stall_xfer])) {
265 switch (USB_GET_STATE(xfer)) {
267 case USB_ST_TRANSFERRED:
268 bbb_transfer_start(sc, next_xfer);
271 bbb_done(sc, USB_ERR_STALLED);
278 bbb_command_callback(struct usb_xfer *xfer, usb_error_t error)
280 struct bbb_transfer *sc = usbd_xfer_softc(xfer);
283 switch (USB_GET_STATE(xfer)) {
284 case USB_ST_TRANSFERRED:
286 (sc, ((sc->dir == DIR_IN) ? ST_DATA_RD :
287 (sc->dir == DIR_OUT) ? ST_DATA_WR :
293 tag = UGETDW(sc->cbw.dCBWTag) + 1;
294 USETDW(sc->cbw.dCBWSignature, CBWSIGNATURE);
295 USETDW(sc->cbw.dCBWTag, tag);
296 USETDW(sc->cbw.dCBWDataTransferLength, (uint32_t)sc->data_len);
297 sc->cbw.bCBWFlags = ((sc->dir == DIR_IN) ? CBWFLAGS_IN : CBWFLAGS_OUT);
298 sc->cbw.bCBWLUN = sc->lun;
299 sc->cbw.bCDBLength = sc->cmd_len;
300 if (sc->cbw.bCDBLength > sizeof(sc->cbw.CBWCDB)) {
301 sc->cbw.bCDBLength = sizeof(sc->cbw.CBWCDB);
302 DPRINTFN(0, "Truncating long command\n");
304 usbd_xfer_set_frame_data(xfer, 0, &sc->cbw, sizeof(sc->cbw));
305 usbd_transfer_submit(xfer);
315 bbb_data_read_callback(struct usb_xfer *xfer, usb_error_t error)
317 struct bbb_transfer *sc = usbd_xfer_softc(xfer);
318 usb_frlength_t max_bulk = usbd_xfer_max_len(xfer);
321 usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
323 switch (USB_GET_STATE(xfer)) {
324 case USB_ST_TRANSFERRED:
325 sc->data_rem -= actlen;
326 sc->data_ptr += actlen;
327 sc->actlen += actlen;
329 if (actlen < sumlen) {
334 DPRINTF("max_bulk=%d, data_rem=%d\n",
335 max_bulk, sc->data_rem);
337 if (sc->data_rem == 0) {
338 bbb_transfer_start(sc, ST_STATUS);
341 if (max_bulk > sc->data_rem) {
342 max_bulk = sc->data_rem;
344 usbd_xfer_set_timeout(xfer, sc->data_timeout);
345 usbd_xfer_set_frame_data(xfer, 0, sc->data_ptr, max_bulk);
346 usbd_transfer_submit(xfer);
350 if (error == USB_ERR_CANCELLED) {
353 bbb_transfer_start(sc, ST_DATA_RD_CS);
360 bbb_data_rd_cs_callback(struct usb_xfer *xfer, usb_error_t error)
362 bbb_data_clear_stall_callback(xfer, ST_STATUS,
367 bbb_data_write_callback(struct usb_xfer *xfer, usb_error_t error)
369 struct bbb_transfer *sc = usbd_xfer_softc(xfer);
370 usb_frlength_t max_bulk = usbd_xfer_max_len(xfer);
373 usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
375 switch (USB_GET_STATE(xfer)) {
376 case USB_ST_TRANSFERRED:
377 sc->data_rem -= actlen;
378 sc->data_ptr += actlen;
379 sc->actlen += actlen;
381 if (actlen < sumlen) {
386 DPRINTF("max_bulk=%d, data_rem=%d\n",
387 max_bulk, sc->data_rem);
389 if (sc->data_rem == 0) {
390 bbb_transfer_start(sc, ST_STATUS);
393 if (max_bulk > sc->data_rem) {
394 max_bulk = sc->data_rem;
396 usbd_xfer_set_timeout(xfer, sc->data_timeout);
397 usbd_xfer_set_frame_data(xfer, 0, sc->data_ptr, max_bulk);
398 usbd_transfer_submit(xfer);
402 if (error == USB_ERR_CANCELLED) {
405 bbb_transfer_start(sc, ST_DATA_WR_CS);
413 bbb_data_wr_cs_callback(struct usb_xfer *xfer, usb_error_t error)
415 bbb_data_clear_stall_callback(xfer, ST_STATUS,
420 bbb_status_callback(struct usb_xfer *xfer, usb_error_t error)
422 struct bbb_transfer *sc = usbd_xfer_softc(xfer);
426 usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
428 switch (USB_GET_STATE(xfer)) {
429 case USB_ST_TRANSFERRED:
431 /* very simple status check */
433 if (actlen < (int)sizeof(sc->csw)) {
434 bbb_done(sc, USB_ERR_SHORT_XFER);
435 } else if (sc->csw.bCSWStatus == CSWSTATUS_GOOD) {
436 bbb_done(sc, 0); /* success */
438 bbb_done(sc, ERR_CSW_FAILED); /* error */
443 usbd_xfer_set_frame_data(xfer, 0, &sc->csw, sizeof(sc->csw));
444 usbd_transfer_submit(xfer);
448 DPRINTF("Failed to read CSW: %s, try %d\n",
449 usbd_errstr(error), sc->status_try);
451 if (error == USB_ERR_CANCELLED || sc->status_try) {
455 bbb_transfer_start(sc, ST_DATA_RD_CS);
461 /*------------------------------------------------------------------------*
462 * bbb_command_start - execute a SCSI command synchronously
467 *------------------------------------------------------------------------*/
469 bbb_command_start(struct bbb_transfer *sc, uint8_t dir, uint8_t lun,
470 void *data_ptr, size_t data_len, void *cmd_ptr, size_t cmd_len,
471 usb_timeout_t data_timeout)
474 sc->dir = data_len ? dir : DIR_NONE;
475 sc->data_ptr = data_ptr;
476 sc->data_len = data_len;
477 sc->data_rem = data_len;
478 sc->data_timeout = (data_timeout + USB_MS_HZ);
480 sc->cmd_len = cmd_len;
481 memset(&sc->cbw.CBWCDB, 0, sizeof(sc->cbw.CBWCDB));
482 memcpy(&sc->cbw.CBWCDB, cmd_ptr, cmd_len);
483 DPRINTFN(1, "SCSI cmd = %*D\n", (int)cmd_len, (char *)sc->cbw.CBWCDB, ":");
486 usbd_transfer_start(sc->xfer[sc->state]);
488 while (usbd_transfer_pending(sc->xfer[sc->state])) {
489 cv_wait(&sc->cv, &sc->mtx);
491 mtx_unlock(&sc->mtx);
495 static struct bbb_transfer *
496 bbb_attach(struct usb_device *udev, uint8_t iface_index)
498 struct usb_interface *iface;
499 struct usb_interface_descriptor *id;
500 struct bbb_transfer *sc;
504 /* Prevent re-enumeration */
505 do_unlock = usbd_enum_lock(udev);
508 * Make sure any driver which is hooked up to this interface,
509 * like umass is gone:
511 usb_detach_device(udev, iface_index, 0);
514 usbd_enum_unlock(udev);
516 iface = usbd_get_iface(udev, iface_index);
521 if (id == NULL || id->bInterfaceClass != UICLASS_MASS)
524 switch (id->bInterfaceSubClass) {
525 case UISUBCLASS_SCSI:
527 case UISUBCLASS_SFF8020I:
528 case UISUBCLASS_SFF8070I:
534 switch (id->bInterfaceProtocol) {
535 case UIPROTO_MASS_BBB_OLD:
536 case UIPROTO_MASS_BBB:
542 sc = malloc(sizeof(*sc), M_USB, M_WAITOK | M_ZERO);
543 mtx_init(&sc->mtx, "USB autoinstall", NULL, MTX_DEF);
544 cv_init(&sc->cv, "WBBB");
546 err = usbd_transfer_setup(udev, &iface_index, sc->xfer, bbb_config,
547 ST_MAX, sc, &sc->mtx);
556 bbb_detach(struct bbb_transfer *sc)
558 usbd_transfer_unsetup(sc->xfer, ST_MAX);
559 mtx_destroy(&sc->mtx);
564 /*------------------------------------------------------------------------*
568 * 1: This interface is an auto install disk (CD-ROM)
569 * 0: Not an auto install disk.
570 *------------------------------------------------------------------------*/
572 usb_iface_is_cdrom(struct usb_device *udev, uint8_t iface_index)
574 struct bbb_transfer *sc;
580 sc = bbb_attach(udev, iface_index);
585 timeout = 4; /* tries */
587 err = bbb_command_start(sc, DIR_IN, 0, sc->buffer,
588 SCSI_INQ_LEN, &scsi_inquiry, sizeof(scsi_inquiry),
591 if (err == 0 && sc->actlen > 0) {
592 sid_type = sc->buffer[0] & 0x1F;
593 if (sid_type == 0x05)
596 } else if (err != ERR_CSW_FAILED)
597 break; /* non retryable error */
598 usb_pause_mtx(NULL, hz);
605 usb_msc_get_max_lun(struct usb_device *udev, uint8_t iface_index)
607 struct usb_device_request req;
612 /* The Get Max Lun command is a class-specific request. */
613 req.bmRequestType = UT_READ_CLASS_INTERFACE;
614 req.bRequest = 0xFE; /* GET_MAX_LUN */
615 USETW(req.wValue, 0);
616 req.wIndex[0] = iface_index;
618 USETW(req.wLength, 1);
620 err = usbd_do_request(udev, NULL, &req, &buf);
628 usb_msc_auto_quirk(struct usb_device *udev, uint8_t iface_index)
630 struct bbb_transfer *sc;
632 uint8_t is_no_direct;
636 sc = bbb_attach(udev, iface_index);
641 * Some devices need a delay after that the configuration
642 * value is set to function properly:
644 usb_pause_mtx(NULL, hz);
646 if (usb_msc_get_max_lun(udev, iface_index) == 0) {
647 DPRINTF("Device has only got one LUN.\n");
648 usbd_add_dynamic_quirk(udev, UQ_MSC_NO_GETMAXLUN);
652 for (timeout = 4; timeout != 0; timeout--) {
653 err = bbb_command_start(sc, DIR_IN, 0, sc->buffer,
654 SCSI_INQ_LEN, &scsi_inquiry, sizeof(scsi_inquiry),
657 if (err == 0 && sc->actlen > 0) {
658 sid_type = sc->buffer[0] & 0x1F;
659 if (sid_type == 0x00)
662 } else if (err != ERR_CSW_FAILED) {
663 DPRINTF("Device is not responding "
664 "properly to SCSI INQUIRY command.\n");
665 goto error; /* non retryable error */
667 usb_pause_mtx(NULL, hz);
671 DPRINTF("Device is not direct access.\n");
675 err = bbb_command_start(sc, DIR_IN, 0, NULL, 0,
676 &scsi_test_unit_ready, sizeof(scsi_test_unit_ready),
681 if (err != ERR_CSW_FAILED)
687 err = bbb_command_start(sc, DIR_IN, 0, NULL, 0,
688 &scsi_sync_cache, sizeof(scsi_sync_cache),
693 if (err != ERR_CSW_FAILED)
696 DPRINTF("Device doesn't handle synchronize cache\n");
698 usbd_add_dynamic_quirk(udev, UQ_MSC_NO_SYNC_CACHE);
703 * Certain Kingston memory sticks fail the first
704 * read capacity after a synchronize cache command
705 * has been issued. Disable the synchronize cache
706 * command for such devices.
709 err = bbb_command_start(sc, DIR_IN, 0, sc->buffer, 8,
710 &scsi_read_capacity, sizeof(scsi_read_capacity),
714 if (err != ERR_CSW_FAILED)
717 err = bbb_command_start(sc, DIR_IN, 0, sc->buffer, 8,
718 &scsi_read_capacity, sizeof(scsi_read_capacity),
723 goto retry_sync_cache;
725 DPRINTF("Device most likely doesn't "
726 "handle synchronize cache\n");
728 usbd_add_dynamic_quirk(udev,
729 UQ_MSC_NO_SYNC_CACHE);
731 if (err != ERR_CSW_FAILED)
737 /* clear sense status of any failed commands on the device */
739 err = bbb_command_start(sc, DIR_IN, 0, sc->buffer,
740 SCSI_INQ_LEN, &scsi_inquiry, sizeof(scsi_inquiry),
743 DPRINTF("Inquiry = %d\n", err);
747 if (err != ERR_CSW_FAILED)
751 err = bbb_command_start(sc, DIR_IN, 0, sc->buffer,
752 SCSI_SENSE_LEN, &scsi_request_sense,
753 sizeof(scsi_request_sense), USB_MS_HZ);
755 DPRINTF("Request sense = %d\n", err);
759 if (err != ERR_CSW_FAILED)
770 DPRINTF("Device did not respond, enabling all quirks\n");
772 usbd_add_dynamic_quirk(udev, UQ_MSC_NO_SYNC_CACHE);
773 usbd_add_dynamic_quirk(udev, UQ_MSC_NO_TEST_UNIT_READY);
775 /* Need to re-enumerate the device */
776 usbd_req_re_enumerate(udev, NULL);
778 return (USB_ERR_STALLED);
782 usb_msc_eject(struct usb_device *udev, uint8_t iface_index, int method)
784 struct bbb_transfer *sc;
787 sc = bbb_attach(udev, iface_index);
789 return (USB_ERR_INVAL);
793 case MSC_EJECT_STOPUNIT:
794 err = bbb_command_start(sc, DIR_IN, 0, NULL, 0,
795 &scsi_test_unit_ready, sizeof(scsi_test_unit_ready),
797 DPRINTF("Test unit ready status: %s\n", usbd_errstr(err));
798 err = bbb_command_start(sc, DIR_IN, 0, NULL, 0,
799 &scsi_start_stop_unit, sizeof(scsi_start_stop_unit),
802 case MSC_EJECT_REZERO:
803 err = bbb_command_start(sc, DIR_IN, 0, NULL, 0,
804 &scsi_rezero_init, sizeof(scsi_rezero_init),
807 case MSC_EJECT_ZTESTOR:
808 err = bbb_command_start(sc, DIR_IN, 0, NULL, 0,
809 &scsi_ztestor_eject, sizeof(scsi_ztestor_eject),
812 case MSC_EJECT_CMOTECH:
813 err = bbb_command_start(sc, DIR_IN, 0, NULL, 0,
814 &scsi_cmotech_eject, sizeof(scsi_cmotech_eject),
817 case MSC_EJECT_HUAWEI:
818 err = bbb_command_start(sc, DIR_IN, 0, NULL, 0,
819 &scsi_huawei_eject, sizeof(scsi_huawei_eject),
824 * TCTMobile needs DIR_IN flag. To get it, we
825 * supply a dummy data with the command.
827 err = bbb_command_start(sc, DIR_IN, 0, &sc->buffer,
828 sizeof(sc->buffer), &scsi_tct_eject,
829 sizeof(scsi_tct_eject), USB_MS_HZ);
832 printf("usb_msc_eject: unknown eject method (%d)\n", method);
835 DPRINTF("Eject CD command status: %s\n", usbd_errstr(err));