{"id":341161,"date":"2022-11-12T21:00:16","date_gmt":"2022-11-12T21:00:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=341161"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=341161","title":{"rendered":"<span>Stm32 + USB \u043d\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445 C++. \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435&#8217;. \u0414\u0435\u043b\u0430\u0435\u043c MSC<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u043e\u0448\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0443\u0442\u043e\u0440\u0430 \u043b\u0435\u0442 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e C++ \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0434\u043b\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e USB. \u0417\u0430 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043a\u0440\u044b\u0442\u044c USB OTG FS, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 &#8212; <strong>Mass Storage<\/strong>.<\/p>\n<p>\u0421\u0440\u0435\u0434\u0438 \u0438\u0437\u043e\u0431\u0438\u043b\u0438\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u0438 \u0445\u043e\u0441\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 \u0441\u0432\u044f\u0437\u043a\u0435 <strong>SCSI<\/strong> \u043f\u043e\u0432\u0435\u0440\u0445 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430 <strong>Bulk-Only<\/strong> (\u043e\u043d \u0436\u0435 <strong>Bulk\/Bulk\/Bulk<\/strong>), \u0442\u0430\u043a \u043a\u0430\u043a, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043d\u044f\u0442\u044c, \u044d\u0442\u0443 \u043f\u0430\u0440\u0443 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0447\u0435\u0441\u0442\u043d\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u044e\u0441\u044c, \u0447\u0442\u043e \u0448\u0435\u043b \u043f\u043e \u0441\u0442\u043e\u043f\u0430\u043c \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u043e\u0433\u043e <a class=\"mention\" href=\"\/users\/cokpoweheu\">@COKPOWEHEU<\/a>, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/549016\/\" rel=\"noopener noreferrer nofollow\">USB \u043d\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445: bulk endpoint \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 Mass Storage<\/a>.<\/p>\n<h2>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b<\/h2>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043a\u043b\u0430\u0441\u0441\u0430 <strong>MSC<\/strong> \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441 \u0434\u0432\u0443\u043c\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c\u0438 \u0442\u043e\u0447\u043a\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 <strong>Bulk<\/strong>. \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e <strong>Logical Unit<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0440\u0430\u0437 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 1.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5ed\/7a3\/f20\/5ed7a3f202e1d3911686a7b7225b00ca.png\" alt=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 1. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 USB-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c SCSI.\" title=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 1. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 USB-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c SCSI.\" width=\"401\" height=\"231\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5ed\/7a3\/f20\/5ed7a3f202e1d3911686a7b7225b00ca.png\"\/><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 1. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 USB-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c SCSI.<\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438 \u0432\u0441\u0435 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0442 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u0434\u0432\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0442 \u0445\u043e\u0441\u0442\u0430 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<\/p>\n<h4>\u0417\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 SCSI<\/h4>\n<p>\u041e\u0431\u0449\u0438\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u0431\u043c\u0435\u043d\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 2.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e23\/a6c\/560\/e23a6c5600950f1c012e143d2561923e.png\" alt=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 2. \u041e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 SCSI.\" title=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 2. \u041e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 SCSI.\" width=\"292\" height=\"152\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e23\/a6c\/560\/e23a6c5600950f1c012e143d2561923e.png\"\/><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 2. \u041e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 SCSI.<\/figcaption><\/figure>\n<p>\u041e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u044d\u0442\u0430\u043f \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043e\u0442 \u0445\u043e\u0441\u0442\u0430 \u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f 31-\u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 <strong>CBW (Command Wrapper Block)<\/strong>, \u0435\u0451 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"88\" width=\"88\">\n<p align=\"center\">\u0420\u0430\u0437\u043c\u0435\u0440 (\u0431\u0430\u0439\u0442\u043e\u0432)<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"center\">\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044f<\/p>\n<\/td>\n<td>\n<p align=\"center\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"88\" width=\"88\">\n<p align=\"center\">4<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">dCBWSignature<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0447\u0438\u0441\u043b\u043e 0x43425355 (\u043e\u043d\u043e \u0436\u0435 &#8216;USBC&#8217;).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"88\" width=\"88\">\n<p align=\"center\">4<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">dCBWTag<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \u043e\u0434\u043d\u043e\u0438\u043c\u0435\u043d\u043d\u044b\u043c \u043f\u043e\u043b\u0435\u043c \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043e\u0442\u0432\u0435\u0442\u0430).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"88\" width=\"88\">\n<p align=\"center\">4<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">dCBWDataTransferLength<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445          (OUT \u0438\u043b\u0438 IN).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"88\" width=\"88\">\n<p align=\"center\">1<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">bmCBWFlags<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0440\u0448\u0438\u0439 (\u0441\u0435\u0434\u044c\u043c\u043e\u0439) \u0431\u0438\u0442. \u0415\u0441\u043b\u0438 bmCBWFlags[7:7] = 0, \u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 OUT, \u0438\u043d\u0430\u0447\u0435 IN.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"88\" width=\"88\">\n<p align=\"center\">1<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">bCBWLUN<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u043e\u043c\u0435\u0440 LUN, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u043e\u0432\u0430\u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043b\u0430\u0434\u0448\u0438\u0435 4 \u0431\u0438\u0442\u0430 (bCBWLUN[0:3]).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"88\" width=\"88\">\n<p align=\"center\">1<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">bCBWCBLength<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u043b\u0438\u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u0431\u043b\u043e\u043a\u0435 CBWCB. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043b\u0430\u0434\u0448\u0438\u0435 5 \u0431\u0438\u0442 (bCBWCBLength[0:4]).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"88\" width=\"88\">\n<p align=\"center\">16<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">CBWCB[16]<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0411\u043b\u043e\u043a \u043a\u043e\u043c\u0430\u043d\u0434\u044b (\u0444\u043e\u0440\u043c\u0430\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b).<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 (OUT \u0438\u043b\u0438 IN), \u0442\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e (\u0442\u043e\u0447\u043d\u0435\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 <strong>Logical Unit<\/strong>) \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0433\u043e\u0442\u043e\u0432 \u043a \u043f\u0440\u0438\u0435\u043c\u0443 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435. \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u0435 (\u0438\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f <strong>CBW<\/strong>, \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043d\u0435 \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u043c\u0435\u043d), \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0445\u043e\u0441\u0442\u0443 \u043e\u0442\u0432\u0435\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f 5-\u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 <strong>CSW (Command Status Wrapper)<\/strong>, \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"center\">\u0420\u0430\u0437\u043c\u0435\u0440 (\u0431\u0430\u0439\u0442\u043e\u0432)<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"center\">\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044f<\/p>\n<\/td>\n<td>\n<p align=\"center\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"center\">4<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">dCSWSignature<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0447\u0438\u0441\u043b\u043e 0x53425355 (\u043e\u043d\u043e \u0436\u0435 &#8216;USBS&#8217;).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"center\">4<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">dCSWTag<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u0438\u0437 \u043f\u0440\u0438\u043d\u044f\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <strong>CBW<\/strong>).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"center\">4<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">dCSWDataResidue<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 OUT \u043f\u043e\u043b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 dCBWDataTransferLength \u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 (<em>\u043f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u044f \u043d\u0435 \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f &#171;\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u043c\u0438&#187; &#8212; \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0435 \u0438\u043b\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 &#171;\u043f\u043e\u043b\u0435\u0437\u043d\u044b&#187;<\/em>).<\/p>\n<p align=\"left\">\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 IN \u043f\u043e\u043b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 dCBWDataTransferLength (\u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u043c \u043e\u0431\u044a\u0435\u043c\u043e\u043c) \u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0431\u0430\u0439\u0442\u043e\u0432.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"center\">1<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">bCSWStatus<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u0442\u0430\u0442\u0443\u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. 0 &#8212; \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435, 1 &#8212; \u043e\u0448\u0438\u0431\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, 2 &#8212; \u043e\u0448\u0438\u0431\u043a\u0430 \u0444\u0430\u0437\u044b (<em>\u043a\u0430\u043a \u044f \u043f\u043e\u043d\u044f\u043b, \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0445\u043e\u0441\u0442\u0430<\/em>).<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u0430\u043a \u0438 \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a class=\"mention\" href=\"\/users\/cokpoweheu\">@COKPOWEHEU<\/a>, \u043f\u0435\u0440\u0432\u0430\u044f \u043f\u043e\u0441\u044b\u043b\u043a\u0430 \u0438\u0434\u0435\u0442 \u043e\u0442 \u0445\u043e\u0441\u0442\u0430 \u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 (\u0431\u043b\u043e\u043a <strong>CBW<\/strong>), \u0432\u0442\u043e\u0440\u0430\u044f (\u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438) &#8212; \u043b\u0438\u0431\u043e \u043e\u0442 \u0445\u043e\u0441\u0442\u0430, \u043b\u0438\u0431\u043e \u043e\u0442 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 (\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b), \u0438 \u0442\u0440\u0435\u0442\u044c\u044f &#8212; \u043e\u0442 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 (\u0431\u043b\u043e\u043a <strong>CSW<\/strong>). \u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 3 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043e\u043a\u043d\u0430 Wireshark \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0447\u0442\u0435\u043d\u0438\u044f, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438 \u043f\u0430\u043a\u0435\u0442\u043e\u0432.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/84d\/8f5\/9b5\/84d8f59b51b40ed1e879588856e0cccb.PNG\" alt=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 3. \u041f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 READ (10).\" title=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 3. \u041f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 READ (10).\" width=\"705\" height=\"104\"\/><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 3. \u041f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 READ (10).<\/figcaption><\/figure>\n<h4>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 SCSI<\/h4>\n<p>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<ol>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0431\u0449\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434, \u0430\u0434\u0440\u0435\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443. \u0422\u0430\u043a\u0438\u0445 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 SCSI \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0434\u0432\u0435: <strong>Bulk-Only Mass Storage Reset<\/strong> (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 bRequest \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 Setup \u0440\u0430\u0432\u043d\u043e 255) \u0438 <strong>Get Max LUN<\/strong> (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 bRequest \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 Setup \u0440\u0430\u0432\u043d\u043e 254). \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f \u043f\u043e\u043d\u044f\u043b, \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u043e\u0431\u043e \u043d\u0435 \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c <strong>\u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e LUN<\/strong>, Logical Unit-\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441 \u043d\u0443\u043b\u0435\u0432\u043e\u0433\u043e \u0438 \u0438\u0434\u0442\u0438 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c OUT-\u043f\u0430\u043a\u0435\u0442\u044b \u043e\u0442 \u0445\u043e\u0441\u0442\u0430 \u0438 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c Logical Unit-\u0430\u043c.<\/p>\n<\/li>\n<\/ol>\n<p>\u0415\u0441\u043b\u0438 \u0441 \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0443\u043d\u043a\u0442\u043e\u043c \u0432\u0441\u0451 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0430, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u0430\u044f \u0431\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 4 (\u043f\u0440\u043e\u0448\u0443 \u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0437\u0430 \u043c\u043e\u0438 \u0431\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u044b).<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8ff\/9db\/671\/8ff9db671e0b11acaca779e2462ef7c0.png\" alt=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 4. \u0411\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 OUT-\u043f\u0430\u043a\u0435\u0442\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 SCSI.\" title=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 4. \u0411\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 OUT-\u043f\u0430\u043a\u0435\u0442\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 SCSI.\" width=\"540\" height=\"571\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8ff\/9db\/671\/8ff9db671e0b11acaca779e2462ef7c0.png\"\/><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 4. \u0411\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 OUT-\u043f\u0430\u043a\u0435\u0442\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 SCSI.<\/figcaption><\/figure>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u041a\u043b\u0430\u0441\u0441 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u043c \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u043c \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 Interface:<\/p>\n<pre><code class=\"cpp\">template &lt;uint8_t _Number, uint8_t _AlternateSetting, typename _Ep0, typename _OutEp,          typename _InEp, typename... _Luns> class ScsiBulkInterface : public Interface&lt;_Number, _AlternateSetting,          InterfaceClass::Storage, static_cast&lt;uint8_t>(MscSubclass::Scsi),          static_cast&lt;uint8_t>(MscProtocol::Bbb), _Ep0, _OutEp, _InEp> {        using Base = Interface&lt;_Number, _AlternateSetting, InterfaceClass::Storage, static_cast&lt;uint8_t>(MscSubclass::Scsi), static_cast&lt;uint8_t>(MscProtocol::Bbb), _Ep0, _OutEp, _InEp>;    static constexpr std::add_pointer_t&lt;bool(void* buffer, uint16_t size)> _lunRxHandlers[]     = {_Luns::RxHandler...};   static constexpr std::add_pointer_t&lt;bool(const BulkOnlyCBW&amp; cbw, BulkOnlyCSW&amp; csw, InTransferCallback callback)> _lunCommandHandlers[]     = {(ScsiLun&lt;_Luns>::template CommandHandler&lt;_InEp>)...};   ...<\/code><\/pre>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f variadic-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <strong>Luns<\/strong>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u0432\u0430 constexpr-\u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 OUT-\u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043a\u043e\u043c\u0430\u043d\u0434 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0440\u0438\u0447\u0435\u043c &#171;\u0431\u0430\u0437\u043e\u0432\u044b\u0439&#187; \u043a\u043b\u0430\u0441\u0441 <strong>ScsiLun <\/strong>\u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442\u0441\u044f \u0437\u0430 \u0441\u0447\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432, \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u043d\u0435\u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0430 C++.<\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 OUT-\u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043d\u0435 \u0442\u0430\u043a \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043f\u0440\u044f\u0442\u0430\u043d\u0430 \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440.<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a OUT-\u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 SCSI<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">static void HandleRx(void* data, uint16_t size) {   static BulkOnlyCBW request;   static BulkOnlyCSW response;   static uint8_t cbwBytesReceived = 0;   static bool needReceive = false;    if(cbwBytesReceived &lt; sizeof(BulkOnlyCBW)) {     CopyFromUsbPma(reinterpret_cast&lt;uint8_t*>(&amp;request) + cbwBytesReceived, data, size);      cbwBytesReceived += size;      if(cbwBytesReceived == sizeof(BulkOnlyCBW)) {       needReceive = _lunCommandHandlers[request.Lun](request, response, [](){         cbwBytesReceived = 0;         _InEp::SendData(&amp;response, sizeof(response));       });     } else {       return;     }   } else if (needReceive) {     needReceive = _lunRxHandlers[request.Lun](data, size);     if(!needReceive) {       cbwBytesReceived = 0;       _InEp::SendData(&amp;response, sizeof(response));     }   } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>\u041a\u043b\u0430\u0441\u0441 Lun<\/h3>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0441\u0435, \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e (RAM, Flash, EEPROM, sd-\u043a\u0430\u0440\u0442\u0430), \u0442\u043e \u043a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0443 \u0443\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u0418\u0442\u043e\u0433\u043e\u043c \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439 \u043e\u0431 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441\u0442\u0430\u043b\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435: \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043a\u043e\u043c\u0430\u043d\u0434 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0431\u043b\u043e\u043a <strong>CSW<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0438\u043f, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u0447\u0435\u0442\u044b\u0440\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 (\u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c):<\/p>\n<ul>\n<li>\n<p><strong>GetLbaSize<\/strong> &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430 LBA;<\/p>\n<\/li>\n<li>\n<p><strong>GetLbaCount<\/strong>&#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u043b\u043e\u043a\u043e\u0432 LBA;<\/p>\n<\/li>\n<li>\n<p><strong>Read10Handler<\/strong> &#8212; \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a\u043e\u043c\u0430\u043d\u0434\u044b READ (10);<\/p>\n<\/li>\n<li>\n<p><strong>Write10Handler<\/strong> &#8212; \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a\u043e\u043c\u0430\u043d\u0434\u044b WRITE (10).<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043b\u0430\u0441\u0441 <strong>ScsiLun<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0442\u0438\u043f\u0430\u043c\u0438 <strong>Luns <\/strong>\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442, \u043f\u043e \u0441\u0443\u0442\u0438, \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a\u043e\u043c\u0430\u043d\u0434. \u0415\u0433\u043e \u043a\u043e\u0434 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c. \u041c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0432\u0437\u044f\u043b \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"\/users\/cokpoweheu\" rel=\"noopener noreferrer nofollow\">@COKPOWEHEU<\/a>.<\/p>\n<details class=\"spoiler\">\n<summary>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 (\u0445\u043e\u0442\u044f \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u044d\u0442\u043e \u044d\u043c\u0443\u043b\u044f\u0446\u0438\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438) \u043a\u043b\u0430\u0441\u0441 ScsiLun<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">template&lt;typename _LunSpecialization> class ScsiLun : public ScsiLunBase { public:   template&lt;typename _InEp>   static bool CommandHandler(const BulkOnlyCBW&amp; cbw, BulkOnlyCSW&amp; csw, InTransferCallback callback)   {     csw.Tag = cbw.Tag;     csw.Status = BulkOnlyCSW::CswStatus::Passed;     csw.DataResidue = 0;      switch (static_cast&lt;ScsiCommand>(cbw.CommandBlock[0]))     {     case ScsiCommand::Inquiry:       if(cbw.CommandBlock[1] &amp; 0x01) {         _InEp::SendData(inquiry_page00_data, cbw.DataLength &lt; sizeof(inquiry_page00_data) ? cbw.DataLength : sizeof(inquiry_page00_data), callback);       } else {         _InEp::SendData(inquiry_response, cbw.DataLength &lt; sizeof(inquiry_response) ? cbw.DataLength : sizeof(inquiry_response), callback);       }       break;     case ScsiCommand::MmcReadFormatCapacity: {       constexpr uint8_t buffer[] = { 0, 0, 0, 8,         (_LunSpecialization::GetLbaCount() >> 24) &amp; 0xff,         (_LunSpecialization::GetLbaCount() >> 16) &amp; 0xff,         (_LunSpecialization::GetLbaCount() >> 8) &amp; 0xff,         (_LunSpecialization::GetLbaCount() >> 0) &amp; 0xff,          0b10, \/\/ formatted media         (_LunSpecialization::GetLbaSize() >> 16) &amp; 0xff,         (_LunSpecialization::GetLbaSize() >> 8) &amp; 0xff,         (_LunSpecialization::GetLbaSize() >> 0) &amp; 0xff,       };       _InEp::SendData(buffer, sizeof(buffer), callback);       break;     }     case ScsiCommand::ReadCapacity: {       uint32_t buffer[] = { ConvertLeBe(_LunSpecialization::GetLbaCount() - 1), ConvertLeBe(_LunSpecialization::GetLbaSize()) };        _InEp::SendData(buffer, sizeof(buffer), callback);       break;     }     case ScsiCommand::ModeSense6: {       uint8_t buffer[] = {3, 0, 0, 0};       csw.DataResidue = cbw.DataLength - sizeof(buffer);       _InEp::SendData(buffer, sizeof(buffer), callback);       break;     }     case ScsiCommand::TestUnitReady : {       callback();       break;     }     case ScsiCommand::Read10: {       uint32_t startLba = ConvertLeBe(reinterpret_cast&lt;const ScsiReadWrite10Request*>(&amp;cbw.CommandBlock[0])->BlockAddress);       uint32_t lbaCount = ConvertLeBe(reinterpret_cast&lt;const ScsiReadWrite10Request*>(&amp;cbw.CommandBlock[0])->Length);        _LunSpecialization::template Read10Handler&lt;_InEp>(startLba, lbaCount, callback);       break;     }     case ScsiCommand::Write10: {       uint32_t startLba = ConvertLeBe(reinterpret_cast&lt;const ScsiReadWrite10Request*>(&amp;cbw.CommandBlock[0])->BlockAddress);       uint32_t lbaCount = ConvertLeBe(reinterpret_cast&lt;const ScsiReadWrite10Request*>(&amp;cbw.CommandBlock[0])->Length);        return _LunSpecialization::Write10Handler(startLba, lbaCount);     }     case ScsiCommand::MmcStartStopUnit:     case ScsiCommand::MmcPreventAllowRemoval:       callback();     default:       break;     }      return false;   } };<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 (\u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430 + \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<h2>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043a\u043b\u0430\u0441\u0441\u0430 Mass Storage <\/h2>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u0430 \u0432\u043d\u0435\u0434\u0440\u0435\u043d \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 <strong>Logical Unit<\/strong> \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432  &#8212; \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043a\u043e\u043c\u0430\u043d\u0434 READ (10) \u0438 WRITE (10), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 OUT, \u043e\u043d\u0438 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b.<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043a\u043e\u043c\u0430\u043d\u0434 READ\/WRITE \u0438 RxHandler<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">template&lt;typename _InEp> static void Read10Handler(uint32_t startLba, uint32_t lbaCount, InTransferCallback callback) {   _InEp::SendData(&amp;_buffer[startLba * _LbaSize], lbaCount * _LbaSize, callback); }<\/code><\/pre>\n<pre><code class=\"cpp\">static bool Write10Handler(uint32_t startLba, uint32_t lbaCount) {   _rxAddress = startLba * _LbaSize;   _rxBytesRemain = lbaCount * _LbaSize;      return lbaCount > 0; }<\/code><\/pre>\n<pre><code class=\"cpp\">static bool RxHandler(void* data, uint16_t size) {   CopyFromUsbPma(&amp;_buffer[_rxAddress], data, size);    _rxAddress += size;   _rxBytesRemain -= size;    return _rxBytesRemain > 0; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h4>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430<\/h4>\n<p>\u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 Stm32f401ccu6, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 64\u041a\u0431 RAM, \u0447\u0435\u0433\u043e, \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0434\u043b\u044f \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044f \u0441 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 FAT 12.<\/p>\n<p>\u041f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043a \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0443 Windows \u043e\u043f\u043e\u0432\u0435\u0449\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c \u043d\u0435 \u043e\u0442\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c (\u0441\u043c. \u0440\u0438\u0441\u0443\u043d\u043e\u043a 5), \u043e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f FAT 16 \u043c\u0435\u0441\u0442\u0430 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 mkdosfs, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 6.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/092\/dff\/d59\/092dffd59c2e444a0d73d025a55e484f.PNG\" alt=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 5. \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044f.\" title=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 5. \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044f.\" width=\"353\" height=\"172\"\/><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 5. \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044f.<\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/699\/9b8\/e89\/6999b8e895c747aa90d056915092bd39.PNG\" alt=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 6. \u0424\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e mkdosfs.\" title=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 6. \u0424\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e mkdosfs.\" width=\"617\" height=\"141\"\/><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 6. \u0424\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e mkdosfs.<\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u043a\u043d\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a, \u043a\u0430\u043a \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 7, \u0430 \u0441 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u0435\u043c \u0448\u0442\u0430\u0442\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0447\u0442\u0435\u043d\u0438\u044f.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e62\/638\/8bc\/e626388bc64da413aeeb7709431ca624.PNG\" alt=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 7. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044f.\" title=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 7. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044f.\" width=\"379\" height=\"502\"\/><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 7. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044f.<\/figcaption><\/figure>\n<h2>\u0417\u0430\u043c\u0435\u0440\u044b \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438<\/h2>\n<p>\u0414\u043b\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c LUN \u043e\u0431\u044a\u0435\u043c\u0430 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e, \u0447\u0435\u043c \u0435\u0441\u0442\u044c \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u0432\u0441\u0435 \u0441\u0442\u0430\u0440\u0448\u0438\u0435 LBA \u043f\u0435\u0440\u0435\u0430\u0434\u0440\u0435\u0441\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u043d\u0430\u0447\u0430\u043b\u043e \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044f (\u043a\u0430\u043a \u0440\u0430\u0437 \u0434\u043b\u044f \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b), \u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0447\u0442\u0435\u043d\u0438\u044e\/\u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0443\u0447\u0430\u0441\u0442\u043a\u0430 \u043f\u0430\u043c\u044f\u0442\u0438 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u0414\u043b\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0433\u043e\u0434\u0438\u0442\u0441\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u0448\u0438\u043d\u0435 USB (\u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435\/\u0437\u0430\u043f\u0438\u0441\u044c \u043a \u043f\u0430\u043c\u044f\u0442\u0438 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430).<\/p>\n<p>\u0417\u0430\u043f\u0438\u0441\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0438\u0437\u043a\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c (\u0441\u043c. \u0440\u0438\u0441\u0443\u043d\u043e\u043a 8), \u043d\u043e \u044d\u0442\u043e\u0442 \u0444\u0430\u043a\u0442 \u044f \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u044e \u0441 \u043d\u0435\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 USB OTG \u0432 \u0446\u0435\u043b\u043e\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f F0\/F1 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u043e\u0439\u043d\u0443\u044e \u0431\u0443\u0444\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044e, \u0434\u043b\u044f OTG \u043f\u043e\u043a\u0430 \u043d\u0435\u0442).<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f45\/419\/c8e\/f45419c8e8b73a59bf7c4beab35ac173.PNG\" alt=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 8. \u0417\u0430\u043f\u0438\u0441\u044c \u043a\u0440\u0443\u043f\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c.\" title=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 8. \u0417\u0430\u043f\u0438\u0441\u044c \u043a\u0440\u0443\u043f\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c.\" width=\"449\" height=\"177\"\/><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 8. \u0417\u0430\u043f\u0438\u0441\u044c \u043a\u0440\u0443\u043f\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c.<\/figcaption><\/figure>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c (\u043e\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u043e\u0441\u044c \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e, \u0432\u0438\u0434\u0438\u043c\u043e, Windows \u0437\u0430\u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u0430\u043d\u0435\u0435 \u0444\u0430\u0439\u043b \u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0437\u044f\u043b \u043f\u0435\u0440\u0432\u0443\u044e \u043f\u043e\u043f\u0430\u0432\u0448\u0443\u044e\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u0435\u0439, \u0435\u0451 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 9. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0447\u0443\u0442\u044c \u043b\u0443\u0447\u0448\u0435, \u043d\u043e \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u0434\u0432\u043e\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0440\u0435\u0434\u0435\u043b\u0430 \u0432 12,5 \u041c\u0431\u0438\u0442\/\u0441.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8ab\/245\/8bf\/8ab2458bf5b8a010b1c4acd0eb382938.PNG\" alt=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 9. \u0422\u0435\u0441\u0442 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435.\" title=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 9. \u0422\u0435\u0441\u0442 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435.\" width=\"315\" height=\"97\"\/><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 9. \u0422\u0435\u0441\u0442 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435.<\/figcaption><\/figure>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041d\u0430\u043b\u0438\u0447\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u044f\u0434\u0440\u0430 USB \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0440\u0430\u0437 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0443\u0441\u0438\u043b\u0438\u044f\u043c\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e SCSI \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0432\u0435\u0441\u044c\u043c\u0430 \u043e\u0431\u044a\u0435\u043c\u043d\u044b\u043c \u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u043e\u0434\u043d\u0430\u043a\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043d\u0430 \u043c\u043d\u043e\u0433\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0433\u043b\u0430\u0437\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c &#171;\u043c\u0430\u0433\u0438\u044e&#187; (\u0437\u043d\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u0435\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u0440\u0430\u0434\u0443\u0435\u0442, \u0447\u0442\u043e \u0442\u0430\u043a\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0435\u0441\u0442\u044c). \u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438, \u043a\u0430\u043a \u0438 \u0447\u0442\u0435\u043d\u0438\u044f, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0436\u0435\u043b\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0435\u0433\u043e, \u043d\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 USB \u0441\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u0441 OTG.<\/p>\n<p>\u0412 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 <a href=\"https:\/\/github.com\/azhel12\/Zhele\/blob\/master\/examples\/MscExample_f4.cpp\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/a> \u0438 <a href=\"https:\/\/github.com\/azhel12\/Zhele\/blob\/master\/Zhele\/include\/common\/usb\/msc.h\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/a>, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0438\u0445\u0441\u044f \u043a MSC.<\/p>\n<h2>P.S. \u041a\u043e\u043c\u043f\u043e\u0437\u0438\u0442\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e<\/h2>\n<p>\u0427\u0438\u0442\u0430\u044f \u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 \u0445\u0430\u0431\u0440\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0445 (\u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0442\u043d\u044b\u0445) \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043a\u0440\u0430\u0442\u043a\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441. \u041d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e \u044d\u0442\u043e \u043d\u0435 \u0442\u044f\u043d\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 &#171;\u0431\u043e\u043d\u0443\u0441\u043e\u043c&#187;.<\/p>\n<p>\u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0438\u0434\u0435\u0439 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043a\u0430 USB \u043d\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445 \u0431\u044b\u043b\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 USB-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e. \u0421\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u043c\u043d\u0435 \u044d\u0442\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043a\u043e\u0434 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e USB-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0449\u0435\u043c\u0443 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 \u0435\u0449\u0435 \u0438 HID.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0449\u0435\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438:<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 Mass Storage<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">constexpr Zhele::TemplateUtils::fixed_string_16 Manufacturer(u\"ZheleProduction\"); constexpr Zhele::TemplateUtils::fixed_string_16 Product(u\"MSDExample\"); constexpr Zhele::TemplateUtils::fixed_string_16 Serial(u\"88005553535\");  using MscOutEpBase = OutEndpointBase&lt;1, EndpointType::Bulk, 64, 0>; using MscInEpBase = InEndpointWithoutZlpBase&lt;2, EndpointType::Bulk, 64, 0>;  using EpInitializer = EndpointsInitializer&lt;DefaultEp0, MscOutEpBase, MscInEpBase>; using Ep0 = EpInitializer::ExtendEndpoint&lt;DefaultEp0>;  using MscOutEp = EpInitializer::ExtendEndpoint&lt;MscOutEpBase>; using MscInEp = EpInitializer::ExtendEndpoint&lt;MscInEpBase>;  using Lun0 = DefaultScsiLun&lt;512, 120>;  using Scsi = ScsiBulkInterface&lt;0, 0, Ep0, MscOutEp, MscInEp, Lun0>;  using Config = Configuration&lt;0, 250, false, false, Scsi>; using MyDevice = Device&lt;0x0200, DeviceAndInterfaceClass::Storage, 0, 0, 0x0483, 0x5711, 0, Ep0, Config>;<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0418\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 HID-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f report-\u0430, \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430, \u0438 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430, HID report \u0438 HID descriptor<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">using Report = HidReport&lt;         0x06, 0x00, 0xff,              \/\/ USAGE_PAGE (Generic Desktop)         0x09, 0x01,                    \/\/ USAGE (Vendor Usage 1)         0xa1, 0x01,                    \/\/ COLLECTION (Application)         0x85, 0x01,                    \/\/   REPORT_ID (1)         0x09, 0x01,                    \/\/   USAGE (Vendor Usage 1)         0x15, 0x00,                    \/\/   LOGICAL_MINIMUM (0)         0x25, 0x01,                    \/\/   LOGICAL_MAXIMUM (1)         0x75, 0x08,                    \/\/   REPORT_SIZE (8)         0x95, 0x01,                    \/\/   REPORT_COUNT (1)         0xb1, 0x82,                    \/\/   FEATURE (Data,Var,Abs,Vol)         0x85, 0x01,                    \/\/   REPORT_ID (1)         0x09, 0x01,                    \/\/   USAGE (Vendor Usage 1)         0x91, 0x82,                    \/\/   OUTPUT (Data,Var,Abs,Vol)         0xc0                           \/\/ END_COLLECTION     >;  using HidDesc = HidImpl&lt;0x1001, Report>;  using LedsControlEpBase = OutEndpointBase&lt;1, EndpointType::Interrupt, 4, 255>; using EpInitializer = EndpointsInitializer&lt;DefaultEp0, LedsControlEpBase>;  using Ep0 = EpInitializer::ExtendEndpoint&lt;DefaultEp0>; using LedsControlEp = EpInitializer::ExtendEndpoint&lt;LedsControlEpBase>;  using Hid = HidInterface&lt;0, 0, 0, 0, HidDesc, Ep0, LedsControlEp>;<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e &#8212; \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c\u0438, \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0434\u0432\u0443\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432:<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">using Report = HidReport&lt;         0x06, 0x00, 0xff,              \/\/ USAGE_PAGE (Generic Desktop)         0x09, 0x01,                    \/\/ USAGE (Vendor Usage 1)         0xa1, 0x01,                    \/\/ COLLECTION (Application)         0x85, 0x01,                    \/\/   REPORT_ID (1)         0x09, 0x01,                    \/\/   USAGE (Vendor Usage 1)         0x15, 0x00,                    \/\/   LOGICAL_MINIMUM (0)         0x25, 0x01,                    \/\/   LOGICAL_MAXIMUM (1)         0x75, 0x08,                    \/\/   REPORT_SIZE (8)         0x95, 0x01,                    \/\/   REPORT_COUNT (1)         0xb1, 0x82,                    \/\/   FEATURE (Data,Var,Abs,Vol)         0x85, 0x01,                    \/\/   REPORT_ID (1)         0x09, 0x01,                    \/\/   USAGE (Vendor Usage 1)         0x91, 0x82,                    \/\/   OUTPUT (Data,Var,Abs,Vol)         0xc0                           \/\/ END_COLLECTION     >;  using HidDesc = HidImpl&lt;0x1001, Report>;  \/\/ \u041a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 using MscOutEpBase = OutEndpointBase&lt;1, EndpointType::Bulk, 64, 0>; using MscInEpBase = InEndpointWithoutZlpBase&lt;2, EndpointType::Bulk, 64, 0>; using LedsControlEpBase = OutEndpointBase&lt;3, EndpointType::Interrupt, 4, 255>;  \/\/ \u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a using EpInitializer = EndpointsInitializer&lt;DefaultEp0, MscOutEpBase, MscInEpBase, LedsControlEpBase>; using Ep0 = EpInitializer::ExtendEndpoint&lt;DefaultEp0>; using MscOutEp = EpInitializer::ExtendEndpoint&lt;MscOutEpBase>; using MscInEp = EpInitializer::ExtendEndpoint&lt;MscInEpBase>; using LedsControlEp = EpInitializer::ExtendEndpoint&lt;LedsControlEpBase>;  \/\/ \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 MSC (\u043d\u043e\u043c\u0435\u0440 0) using Lun0 = DefaultScsiLun&lt;512, 120>; using Scsi = ScsiBulkInterface&lt;0, 0, Ep0, MscOutEp, MscInEp, Lun0>; \/\/ \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 HID (\u043d\u043e\u043c\u0435\u0440 1) using Hid = HidInterface&lt;1, 0, 0, 0, HidDesc, Ep0, LedsControlEp>;  using Config = Configuration&lt;0, 250, false, false, Scsi, Hid>; \/\/ \u041f\u0440\u043e\u0441\u0442\u043e \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u0432\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 using MyDevice = Device&lt;0x0200, DeviceAndInterfaceClass::InterfaceSpecified, 0x02, 0, 0x0483, 0x5711, 0, Ep0, Config>;<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0449\u0435\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0438 HID-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 10.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/abe\/0af\/9e4\/abe0af9e40f7038294c367e4866b5366.PNG\" alt=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 10. \u041a\u043e\u043c\u043f\u043e\u0437\u0438\u0442\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e.\" title=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 10. \u041a\u043e\u043c\u043f\u043e\u0437\u0438\u0442\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e.\" width=\"736\" height=\"415\"\/><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 10. \u041a\u043e\u043c\u043f\u043e\u0437\u0438\u0442\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e.<\/figcaption><\/figure>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0442\u043d\u043e\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 (\u0430 \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0443 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u0443\u0434\u0435\u043b\u0435\u043d\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435) \u0434\u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c &#171;\u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e&#187;.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/698916\/\"> https:\/\/habr.com\/ru\/post\/698916\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u043e\u0448\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0443\u0442\u043e\u0440\u0430 \u043b\u0435\u0442 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e C++ \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0434\u043b\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e USB. \u0417\u0430 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043a\u0440\u044b\u0442\u044c USB OTG FS, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 &#8212; <strong>Mass Storage<\/strong>.<\/p>\n<p>\u0421\u0440\u0435\u0434\u0438 \u0438\u0437\u043e\u0431\u0438\u043b\u0438\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u0438 \u0445\u043e\u0441\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 \u0441\u0432\u044f\u0437\u043a\u0435 <strong>SCSI<\/strong> \u043f\u043e\u0432\u0435\u0440\u0445 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0430 <strong>Bulk-Only<\/strong> (\u043e\u043d \u0436\u0435 <strong>Bulk\/Bulk\/Bulk<\/strong>), \u0442\u0430\u043a \u043a\u0430\u043a, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043d\u044f\u0442\u044c, \u044d\u0442\u0443 \u043f\u0430\u0440\u0443 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0447\u0435\u0441\u0442\u043d\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u044e\u0441\u044c, \u0447\u0442\u043e \u0448\u0435\u043b \u043f\u043e \u0441\u0442\u043e\u043f\u0430\u043c \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u043e\u0433\u043e <a class=\"mention\" href=\"\/users\/cokpoweheu\">@COKPOWEHEU<\/a>, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/549016\/\" rel=\"noopener noreferrer nofollow\">USB \u043d\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445: bulk endpoint \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 Mass Storage<\/a>.<\/p>\n<h2>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b<\/h2>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043a\u043b\u0430\u0441\u0441\u0430 <strong>MSC<\/strong> \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441 \u0434\u0432\u0443\u043c\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c\u0438 \u0442\u043e\u0447\u043a\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 <strong>Bulk<\/strong>. \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e <strong>Logical Unit<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0440\u0430\u0437 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 1.<\/p>\n<figure class=\"\"><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 1. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 USB-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c SCSI.<\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438 \u0432\u0441\u0435 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0442 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u0434\u0432\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0442 \u0445\u043e\u0441\u0442\u0430 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<\/p>\n<h4>\u0417\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 SCSI<\/h4>\n<p>\u041e\u0431\u0449\u0438\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u0431\u043c\u0435\u043d\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 2.<\/p>\n<figure class=\"\"><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 2. \u041e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 SCSI.<\/figcaption><\/figure>\n<p>\u041e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u044d\u0442\u0430\u043f \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043e\u0442 \u0445\u043e\u0441\u0442\u0430 \u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f 31-\u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 <strong>CBW (Command Wrapper Block)<\/strong>, \u0435\u0451 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"88\" width=\"88\">\n<p align=\"center\">\u0420\u0430\u0437\u043c\u0435\u0440 (\u0431\u0430\u0439\u0442\u043e\u0432)<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"center\">\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044f<\/p>\n<\/td>\n<td>\n<p align=\"center\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"88\" width=\"88\">\n<p align=\"center\">4<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">dCBWSignature<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0447\u0438\u0441\u043b\u043e 0x43425355 (\u043e\u043d\u043e \u0436\u0435 &#8216;USBC&#8217;).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"88\" width=\"88\">\n<p align=\"center\">4<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">dCBWTag<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \u043e\u0434\u043d\u043e\u0438\u043c\u0435\u043d\u043d\u044b\u043c \u043f\u043e\u043b\u0435\u043c \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043e\u0442\u0432\u0435\u0442\u0430).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"88\" width=\"88\">\n<p align=\"center\">4<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">dCBWDataTransferLength<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445          (OUT \u0438\u043b\u0438 IN).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"88\" width=\"88\">\n<p align=\"center\">1<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">bmCBWFlags<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0440\u0448\u0438\u0439 (\u0441\u0435\u0434\u044c\u043c\u043e\u0439) \u0431\u0438\u0442. \u0415\u0441\u043b\u0438 bmCBWFlags[7:7] = 0, \u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 OUT, \u0438\u043d\u0430\u0447\u0435 IN.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"88\" width=\"88\">\n<p align=\"center\">1<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">bCBWLUN<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u043e\u043c\u0435\u0440 LUN, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u043e\u0432\u0430\u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043b\u0430\u0434\u0448\u0438\u0435 4 \u0431\u0438\u0442\u0430 (bCBWLUN[0:3]).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"88\" width=\"88\">\n<p align=\"center\">1<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">bCBWCBLength<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u043b\u0438\u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u0431\u043b\u043e\u043a\u0435 CBWCB. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043b\u0430\u0434\u0448\u0438\u0435 5 \u0431\u0438\u0442 (bCBWCBLength[0:4]).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"88\" width=\"88\">\n<p align=\"center\">16<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">CBWCB[16]<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0411\u043b\u043e\u043a \u043a\u043e\u043c\u0430\u043d\u0434\u044b (\u0444\u043e\u0440\u043c\u0430\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b).<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 (OUT \u0438\u043b\u0438 IN), \u0442\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e (\u0442\u043e\u0447\u043d\u0435\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 <strong>Logical Unit<\/strong>) \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0433\u043e\u0442\u043e\u0432 \u043a \u043f\u0440\u0438\u0435\u043c\u0443 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435. \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u0435 (\u0438\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f <strong>CBW<\/strong>, \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043d\u0435 \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u043c\u0435\u043d), \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0445\u043e\u0441\u0442\u0443 \u043e\u0442\u0432\u0435\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f 5-\u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 <strong>CSW (Command Status Wrapper)<\/strong>, \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"center\">\u0420\u0430\u0437\u043c\u0435\u0440 (\u0431\u0430\u0439\u0442\u043e\u0432)<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"center\">\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044f<\/p>\n<\/td>\n<td>\n<p align=\"center\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"center\">4<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">dCSWSignature<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0447\u0438\u0441\u043b\u043e 0x53425355 (\u043e\u043d\u043e \u0436\u0435 &#8216;USBS&#8217;).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"center\">4<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">dCSWTag<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u0438\u0437 \u043f\u0440\u0438\u043d\u044f\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <strong>CBW<\/strong>).<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"center\">4<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">dCSWDataResidue<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 OUT \u043f\u043e\u043b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 dCBWDataTransferLength \u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 (<em>\u043f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u044f \u043d\u0435 \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f &#171;\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u043c\u0438&#187; &#8212; \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0435 \u0438\u043b\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 &#171;\u043f\u043e\u043b\u0435\u0437\u043d\u044b&#187;<\/em>).<\/p>\n<p align=\"left\">\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 IN \u043f\u043e\u043b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 dCBWDataTransferLength (\u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u043c \u043e\u0431\u044a\u0435\u043c\u043e\u043c) \u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0431\u0430\u0439\u0442\u043e\u0432.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"center\">1<\/p>\n<\/td>\n<td data-colwidth=\"199\" width=\"199\">\n<p align=\"left\">bCSWStatus<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u0442\u0430\u0442\u0443\u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. 0 &#8212; \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435, 1 &#8212; \u043e\u0448\u0438\u0431\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, 2 &#8212; \u043e\u0448\u0438\u0431\u043a\u0430 \u0444\u0430\u0437\u044b (<em>\u043a\u0430\u043a \u044f \u043f\u043e\u043d\u044f\u043b, \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0445\u043e\u0441\u0442\u0430<\/em>).<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u0430\u043a \u0438 \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a class=\"mention\" href=\"\/users\/cokpoweheu\">@COKPOWEHEU<\/a>, \u043f\u0435\u0440\u0432\u0430\u044f \u043f\u043e\u0441\u044b\u043b\u043a\u0430 \u0438\u0434\u0435\u0442 \u043e\u0442 \u0445\u043e\u0441\u0442\u0430 \u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 (\u0431\u043b\u043e\u043a <strong>CBW<\/strong>), \u0432\u0442\u043e\u0440\u0430\u044f (\u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438) &#8212; \u043b\u0438\u0431\u043e \u043e\u0442 \u0445\u043e\u0441\u0442\u0430, \u043b\u0438\u0431\u043e \u043e\u0442 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 (\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b), \u0438 \u0442\u0440\u0435\u0442\u044c\u044f &#8212; \u043e\u0442 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 (\u0431\u043b\u043e\u043a <strong>CSW<\/strong>). \u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 3 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043e\u043a\u043d\u0430 Wireshark \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0447\u0442\u0435\u043d\u0438\u044f, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438 \u043f\u0430\u043a\u0435\u0442\u043e\u0432.<\/p>\n<figure class=\"full-width\"><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 3. \u041f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 READ (10).<\/figcaption><\/figure>\n<h4>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 SCSI<\/h4>\n<p>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<ol>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0431\u0449\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434, \u0430\u0434\u0440\u0435\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443. \u0422\u0430\u043a\u0438\u0445 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 SCSI \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0434\u0432\u0435: <strong>Bulk-Only Mass Storage Reset<\/strong> (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 bRequest \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 Setup \u0440\u0430\u0432\u043d\u043e 255) \u0438 <strong>Get Max LUN<\/strong> (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 bRequest \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 Setup \u0440\u0430\u0432\u043d\u043e 254). \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f \u043f\u043e\u043d\u044f\u043b, \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u043e\u0431\u043e \u043d\u0435 \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c <strong>\u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e LUN<\/strong>, Logical Unit-\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441 \u043d\u0443\u043b\u0435\u0432\u043e\u0433\u043e \u0438 \u0438\u0434\u0442\u0438 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c OUT-\u043f\u0430\u043a\u0435\u0442\u044b \u043e\u0442 \u0445\u043e\u0441\u0442\u0430 \u0438 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c Logical Unit-\u0430\u043c.<\/p>\n<\/li>\n<\/ol>\n<p>\u0415\u0441\u043b\u0438 \u0441 \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0443\u043d\u043a\u0442\u043e\u043c \u0432\u0441\u0451 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0430, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u0430\u044f \u0431\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 4 (\u043f\u0440\u043e\u0448\u0443 \u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0437\u0430 \u043c\u043e\u0438 \u0431\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u044b).<\/p>\n<figure class=\"full-width\"><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 4. \u0411\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 OUT-\u043f\u0430\u043a\u0435\u0442\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 SCSI.<\/figcaption><\/figure>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u041a\u043b\u0430\u0441\u0441 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u043c \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u043c \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 Interface:<\/p>\n<pre><code class=\"cpp\">template &lt;uint8_t _Number, uint8_t _AlternateSetting, typename _Ep0, typename _OutEp,          typename _InEp, typename... _Luns> class ScsiBulkInterface : public Interface&lt;_Number, _AlternateSetting,          InterfaceClass::Storage, static_cast&lt;uint8_t>(MscSubclass::Scsi),          static_cast&lt;uint8_t>(MscProtocol::Bbb), _Ep0, _OutEp, _InEp> {        using Base = Interface&lt;_Number, _AlternateSetting, InterfaceClass::Storage, static_cast&lt;uint8_t>(MscSubclass::Scsi), static_cast&lt;uint8_t>(MscProtocol::Bbb), _Ep0, _OutEp, _InEp>;    static constexpr std::add_pointer_t&lt;bool(void* buffer, uint16_t size)> _lunRxHandlers[]     = {_Luns::RxHandler...};   static constexpr std::add_pointer_t&lt;bool(const BulkOnlyCBW&amp; cbw, BulkOnlyCSW&amp; csw, InTransferCallback callback)> _lunCommandHandlers[]     = {(ScsiLun&lt;_Luns>::template CommandHandler&lt;_InEp>)...};   ...<\/code><\/pre>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f variadic-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <strong>Luns<\/strong>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u0432\u0430 constexpr-\u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 OUT-\u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043a\u043e\u043c\u0430\u043d\u0434 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0440\u0438\u0447\u0435\u043c &#171;\u0431\u0430\u0437\u043e\u0432\u044b\u0439&#187; \u043a\u043b\u0430\u0441\u0441 <strong>ScsiLun <\/strong>\u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442\u0441\u044f \u0437\u0430 \u0441\u0447\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432, \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u043d\u0435\u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0430 C++.<\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 OUT-\u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043d\u0435 \u0442\u0430\u043a \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043f\u0440\u044f\u0442\u0430\u043d\u0430 \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440.<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a OUT-\u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 SCSI<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">static void HandleRx(void* data, uint16_t size) {   static BulkOnlyCBW request;   static BulkOnlyCSW response;   static uint8_t cbwBytesReceived = 0;   static bool needReceive = false;    if(cbwBytesReceived &lt; sizeof(BulkOnlyCBW)) {     CopyFromUsbPma(reinterpret_cast&lt;uint8_t*>(&amp;request) + cbwBytesReceived, data, size);      cbwBytesReceived += size;      if(cbwBytesReceived == sizeof(BulkOnlyCBW)) {       needReceive = _lunCommandHandlers[request.Lun](request, response, [](){         cbwBytesReceived = 0;         _InEp::SendData(&amp;response, sizeof(response));       });     } else {       return;     }   } else if (needReceive) {     needReceive = _lunRxHandlers[request.Lun](data, size);     if(!needReceive) {       cbwBytesReceived = 0;       _InEp::SendData(&amp;response, sizeof(response));     }   } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>\u041a\u043b\u0430\u0441\u0441 Lun<\/h3>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0441\u0435, \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e (RAM, Flash, EEPROM, sd-\u043a\u0430\u0440\u0442\u0430), \u0442\u043e \u043a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0443 \u0443\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u0418\u0442\u043e\u0433\u043e\u043c \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439 \u043e\u0431 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441\u0442\u0430\u043b\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435: \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043a\u043e\u043c\u0430\u043d\u0434 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0431\u043b\u043e\u043a <strong>CSW<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0438\u043f, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u0447\u0435\u0442\u044b\u0440\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 (\u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c):<\/p>\n<ul>\n<li>\n<p><strong>GetLbaSize<\/strong> &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430 LBA;<\/p>\n<\/li>\n<li>\n<p><strong>GetLbaCount<\/strong>&#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u043b\u043e\u043a\u043e\u0432 LBA;<\/p>\n<\/li>\n<li>\n<p><strong>Read10Handler<\/strong> &#8212; \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a\u043e\u043c\u0430\u043d\u0434\u044b READ (10);<\/p>\n<\/li>\n<li>\n<p><strong>Write10Handler<\/strong> &#8212; \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a\u043e\u043c\u0430\u043d\u0434\u044b WRITE (10).<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043b\u0430\u0441\u0441 <strong>ScsiLun<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0442\u0438\u043f\u0430\u043c\u0438 <strong>Luns <\/strong>\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442, \u043f\u043e \u0441\u0443\u0442\u0438, \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a\u043e\u043c\u0430\u043d\u0434. \u0415\u0433\u043e \u043a\u043e\u0434 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c. \u041c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0432\u0437\u044f\u043b \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"\/users\/cokpoweheu\" rel=\"noopener noreferrer nofollow\">@COKPOWEHEU<\/a>.<\/p>\n<details class=\"spoiler\">\n<summary>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 (\u0445\u043e\u0442\u044f \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u044d\u0442\u043e \u044d\u043c\u0443\u043b\u044f\u0446\u0438\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438) \u043a\u043b\u0430\u0441\u0441 ScsiLun<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">template&lt;typename _LunSpecialization> class ScsiLun : public ScsiLunBase { public:   template&lt;typename _InEp>   static bool CommandHandler(const BulkOnlyCBW&amp; cbw, BulkOnlyCSW&amp; csw, InTransferCallback callback)   {     csw.Tag = cbw.Tag;     csw.Status = BulkOnlyCSW::CswStatus::Passed;     csw.DataResidue = 0;      switch (static_cast&lt;ScsiCommand>(cbw.CommandBlock[0]))     {     case ScsiCommand::Inquiry:       if(cbw.CommandBlock[1] &amp; 0x01) {         _InEp::SendData(inquiry_page00_data, cbw.DataLength &lt; sizeof(inquiry_page00_data) ? cbw.DataLength : sizeof(inquiry_page00_data), callback);       } else {         _InEp::SendData(inquiry_response, cbw.DataLength &lt; sizeof(inquiry_response) ? cbw.DataLength : sizeof(inquiry_response), callback);       }       break;     case ScsiCommand::MmcReadFormatCapacity: {       constexpr uint8_t buffer[] = { 0, 0, 0, 8,         (_LunSpecialization::GetLbaCount() >> 24) &amp; 0xff,         (_LunSpecialization::GetLbaCount() >> 16) &amp; 0xff,         (_LunSpecialization::GetLbaCount() >> 8) &amp; 0xff,         (_LunSpecialization::GetLbaCount() >> 0) &amp; 0xff,          0b10, \/\/ formatted media         (_LunSpecialization::GetLbaSize() >> 16) &amp; 0xff,         (_LunSpecialization::GetLbaSize() >> 8) &amp; 0xff,         (_LunSpecialization::GetLbaSize() >> 0) &amp; 0xff,       };       _InEp::SendData(buffer, sizeof(buffer), callback);       break;     }     case ScsiCommand::ReadCapacity: {       uint32_t buffer[] = { ConvertLeBe(_LunSpecialization::GetLbaCount() - 1), ConvertLeBe(_LunSpecialization::GetLbaSize()) };        _InEp::SendData(buffer, sizeof(buffer), callback);       break;     }     case ScsiCommand::ModeSense6: {       uint8_t buffer[] = {3, 0, 0, 0};       csw.DataResidue = cbw.DataLength - sizeof(buffer);       _InEp::SendData(buffer, sizeof(buffer), callback);       break;     }     case ScsiCommand::TestUnitReady : {       callback();       break;     }     case ScsiCommand::Read10: {       uint32_t startLba = ConvertLeBe(reinterpret_cast&lt;const ScsiReadWrite10Request*>(&amp;cbw.CommandBlock[0])->BlockAddress);       uint32_t lbaCount = ConvertLeBe(reinterpret_cast&lt;const ScsiReadWrite10Request*>(&amp;cbw.CommandBlock[0])->Length);        _LunSpecialization::template Read10Handler&lt;_InEp>(startLba, lbaCount, callback);       break;     }     case ScsiCommand::Write10: {<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-341161","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/341161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=341161"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/341161\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=341161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=341161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=341161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}