9 Notify(PSTR(
"CSW:Sig error\r\n"), 0x80);
13 Notify(PSTR(
"CSW:Wrong tag\r\n"), 0x80);
44 uint8_t buf[constBufSize];
131 goto FailSetDevTblEntry;
135 for (uint8_t i = 0; i < num_of_conf; i++) {
146 goto FailGetConfDescr;
164 goto FailSetConfDescr;
172 ErrorMessage<uint8_t > (PSTR(
"MaxLUN"),
bMaxLUN);
180 for (uint8_t lun = 0; lun <=
bMaxLUN; lun++) {
181 ErrorMessage<uint8_t > (PSTR(
"\r\nLUN"), lun);
182 Notify(PSTR(
"--------\r\n"), 0x80);
195 Notify(PSTR(
"Not ready...\r\n"), 0x80);
211 ErrorMessage<uint8_t > (PSTR(
"Inquiry"), rcode);
218 ErrorMessage<uint8_t > (PSTR(
"ReadCapacity"), rcode);
220 for (uint8_t i = 0; i<
sizeof (
Capacity); i++)
221 PrintHex<uint8_t > (capacity.
data[i], 0x80);
222 Notify(PSTR(
"\r\n\r\n"), 0x80);
224 uint32_t c = ((uint32_t)capacity.
data[4] << 24) + ((uint32_t)capacity.
data[5] << 16) + ((uint32_t)capacity.
data[6] << 8) + (uint32_t)capacity.
data[7];
225 if (c != 0x0200LU && c != 0x0400LU && c != 0x0800LU && c != 0x1000LU) {
227 goto FailInvalidSectorSize;
235 rcode =
Read(lun, 0, 512, 1, buf);
238 ErrorMessage<uint8_t > (PSTR(
"Read"), rcode);
240 Notify(PSTR(
"Read: OK\r\n\r\n"), 0x80);
252 rcode =
ModeSense(lun, 0, 0x3f, 0, 192, buf);
255 ErrorMessage<uint8_t > (PSTR(
"ModeSense"), rcode);
257 Notify(PSTR(
"ModeSense: OK\r\n\r\n"), 0x80);
261 Notify(PSTR(
"==========\r\n"), 0x80);
265 Notify(PSTR(
"Unit not ready\r\n"), 0x80);
315 FailInvalidSectorSize:
316 USBTRACE(
"Sector Size is NOT VALID: ");
337 ErrorMessage<uint8_t > (PSTR(
"Conf.Val"), conf);
338 ErrorMessage<uint8_t > (PSTR(
"Iface Num"), iface);
339 ErrorMessage<uint8_t > (PSTR(
"Alt.Set"), alt);
389 return (
pUsb->
ctrlReq(
bAddress, 0,
bmREQ_MASSOUT,
MASS_REQ_BOMSR, 0, 0,
bIface, 0, 0, NULL, NULL));
393 uint8_t ret =
pUsb->
ctrlReq(
bAddress, 0,
bmREQ_MASSIN,
MASS_REQ_GET_MAX_LUN, 0, 0,
bIface, 1, 1, plun, NULL);
406 while (error && count) {
408 ErrorMessage<uint8_t > (PSTR(
"USB Error"), error);
409 ErrorMessage<uint8_t > (PSTR(
"Index"), index);
435 ErrorMessage<uint8_t > (PSTR(
"\r\nUSB"), error);
457 ErrorMessage<uint8_t > (PSTR(
"ClearEpHalt"), ret);
466 Notify(PSTR(
"\r\nResetRecovery\r\n"), 0x80);
467 Notify(PSTR(
"-----------------\r\n"), 0x80);
491 Notify(PSTR(
"\r\nInquiry\r\n"), 0x80);
492 Notify(PSTR(
"---------\r\n"), 0x80);
503 for (uint8_t i = 0; i < 16; i++)
507 cbw.
CBWCB[4] = bsize;
513 Notify(PSTR(
"\r\nRequestSense\r\n"), 0x80);
514 Notify(PSTR(
"----------------\r\n"), 0x80);
525 for (uint8_t i = 0; i < 16; i++)
535 Notify(PSTR(
"\r\nReadCapacity\r\n"), 0x80);
536 Notify(PSTR(
"---------------\r\n"), 0x80);
547 for (uint8_t i = 0; i < 16; i++)
560 Notify(PSTR(
"\r\nTestUnitReady\r\n"), 0x80);
561 Notify(PSTR(
"-----------------\r\n"), 0x80);
572 for (uint8_t i = 0; i < 16; i++)
593 for (uint8_t i = 0; i < 16; i++)
597 cbw.
CBWCB[4] = ctl & 0x03;
604 uint8_t
BulkOnly::Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf) {
605 Notify(PSTR(
"\r\nRead\r\n"), 0x80);
606 Notify(PSTR(
"---------\r\n"), 0x80);
617 for (uint8_t i = 0; i < 16; i++)
621 cbw.
CBWCB[8] = blocks;
622 cbw.
CBWCB[2] = ((addr >> 24) & 0xff);
623 cbw.
CBWCB[3] = ((addr >> 16) & 0xff);
624 cbw.
CBWCB[4] = ((addr >> 8) & 0xff);
625 cbw.
CBWCB[5] = (addr & 0xff);
632 Notify(PSTR(
"\r\nRead (With parser)\r\n"), 0x80);
633 Notify(PSTR(
"---------\r\n"), 0x80);
644 for (uint8_t i = 0; i < 16; i++)
648 cbw.
CBWCB[8] = blocks;
649 cbw.
CBWCB[2] = ((addr >> 24) & 0xff);
650 cbw.
CBWCB[3] = ((addr >> 16) & 0xff);
651 cbw.
CBWCB[4] = ((addr >> 8) & 0xff);
652 cbw.
CBWCB[5] = (addr & 0xff);
658 uint8_t
BulkOnly::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks,
const uint8_t *buf) {
659 Notify(PSTR(
"\r\nWrite\r\n"), 0x80);
660 Notify(PSTR(
"---------\r\n"), 0x80);
672 for (uint8_t i = 0; i < 16; i++)
677 cbw.
CBWCB[5] = (addr & 0xff);
678 cbw.
CBWCB[4] = ((addr >> 8) & 0xff);
679 cbw.
CBWCB[3] = ((addr >> 16) & 0xff);
680 cbw.
CBWCB[2] = ((addr >> 24) & 0xff);
685 uint8_t
BulkOnly::ModeSense(uint8_t lun, uint8_t pc, uint8_t page, uint8_t subpage, uint8_t len, uint8_t *pbuf) {
686 Notify(PSTR(
"\r\rModeSense\r\n"), 0x80);
687 Notify(PSTR(
"------------\r\n"), 0x80);
698 for (uint8_t i = 0; i < 16; i++)
702 cbw.
CBWCB[2] = ((pc << 6) | page);
703 cbw.
CBWCB[3] = subpage;
713 ErrorMessage<uint8_t > (PSTR(
"CBW.dCBWTag"), pcbw->
dCBWTag);
718 ErrorMessage<uint8_t > (PSTR(
"CBW"), ret);
721 Notify(PSTR(
"CBW:\t\tOK\r\n"), 0x80);
736 ErrorMessage<uint8_t > (PSTR(
"RDR"), err);
747 ErrorMessage<uint8_t > (PSTR(
"DAT"), ret);
751 Notify(PSTR(
"Data Stage:\tOK\r\n"), 0x80);
763 ErrorMessage<uint8_t > (PSTR(
"CSW"), ret);
768 ErrorMessage<uint8_t > (PSTR(
"CSW.dCBWTag"), csw.
dCSWTag);
769 ErrorMessage<uint8_t > (PSTR(
"bCSWStatus"), csw.
bCSWStatus);
771 Notify(PSTR(
"CSW:\t\tOK\r\n\r\n"), 0x80);
774 Notify(PSTR(
"Invalid CSW\r\n"), 0x80);
801 ErrorMessage<uint8_t > (PSTR(
"Phase"), status);
805 ErrorMessage<uint8_t > (PSTR(
"SCSI Error"), status);
813 ErrorMessage<uint8_t > (PSTR(
"Response Code"), rsp.bResponseCode);
814 ErrorMessage<uint8_t > (PSTR(
"Sense Key"), rsp.bmSenseKey);
815 ErrorMessage<uint8_t > (PSTR(
"Add Sense Code"), rsp.bAdditionalSenseCode);
816 ErrorMessage<uint8_t > (PSTR(
"Add Sense Qual"), rsp.bAdditionalSenseQualifier);
817 switch (rsp.bmSenseKey) {
821 switch (rsp.bAdditionalSenseCode) {
828 switch (rsp.bAdditionalSenseCode) {
839 ErrorMessage<uint8_t > (PSTR(
"Gen SCSI Err"), status);
845 Notify(PSTR(
"Endpoint descriptor:"), 0x80);
846 Notify(PSTR(
"\r\nLength:\t\t"), 0x80);
847 PrintHex<uint8_t > (ep_ptr->
bLength, 0x80);
848 Notify(PSTR(
"\r\nType:\t\t"), 0x80);
850 Notify(PSTR(
"\r\nAddress:\t"), 0x80);
852 Notify(PSTR(
"\r\nAttributes:\t"), 0x80);
854 Notify(PSTR(
"\r\nMaxPktSize:\t"), 0x80);
856 Notify(PSTR(
"\r\nPoll Intrv:\t"), 0x80);
857 PrintHex<uint8_t > (ep_ptr->
bInterval, 0x80);
858 Notify(PSTR(
"\r\n"), 0x80);