@@ -28,11 +28,10 @@
|
||||
#include <soc/t210.h>
|
||||
#include <storage/sd.h>
|
||||
#include <storage/sdmmc.h>
|
||||
#include <storage/emmc.h>
|
||||
#include <storage/sdmmc_driver.h>
|
||||
#include <storage/emmc.h>
|
||||
#include <utils/btn.h>
|
||||
#include <utils/sprintf.h>
|
||||
#include <utils/util.h>
|
||||
|
||||
#include <memory_map.h>
|
||||
|
||||
@@ -287,7 +286,7 @@ static void raise_exception(usbd_gadget_ums_t *ums, enum ums_state new_state)
|
||||
|
||||
static void _handle_ep0_ctrl(usbd_gadget_ums_t *ums)
|
||||
{
|
||||
if (usb_ops.usbd_handle_ep0_ctrl_setup())
|
||||
if (usb_ops.usbd_handle_ep0_ctrl_setup(NULL))
|
||||
raise_exception(ums, UMS_STATE_PROTOCOL_RESET);
|
||||
}
|
||||
|
||||
@@ -328,11 +327,11 @@ static void _transfer_start(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt, u32
|
||||
|
||||
if (bulk_ctxt->bulk_in_status == USB_ERROR_XFER_ERROR)
|
||||
{
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#EP IN传输!");
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#端口IN传输错误!");
|
||||
_flush_endpoint(bulk_ctxt->bulk_in);
|
||||
}
|
||||
else if (bulk_ctxt->bulk_in_status == USB2_ERROR_XFER_NOT_ALIGNED)
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#EP IN缓冲区未对齐");
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#端口IN缓冲区未对齐!");
|
||||
|
||||
if (sync_timeout)
|
||||
bulk_ctxt->bulk_in_buf_state = BUF_STATE_EMPTY;
|
||||
@@ -345,11 +344,11 @@ static void _transfer_start(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt, u32
|
||||
|
||||
if (bulk_ctxt->bulk_out_status == USB_ERROR_XFER_ERROR)
|
||||
{
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#EP OUT传输!");
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#端口OUT传输错误!");
|
||||
_flush_endpoint(bulk_ctxt->bulk_out);
|
||||
}
|
||||
else if (bulk_ctxt->bulk_out_status == USB2_ERROR_XFER_NOT_ALIGNED)
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#EP OUT缓冲区未对齐!");
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#端口OUT缓冲区未对齐!");
|
||||
|
||||
if (sync_timeout)
|
||||
bulk_ctxt->bulk_out_buf_state = BUF_STATE_FULL;
|
||||
@@ -364,7 +363,7 @@ static void _transfer_out_big_read(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctx
|
||||
|
||||
if (bulk_ctxt->bulk_out_status == USB_ERROR_XFER_ERROR)
|
||||
{
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#EP OUT传输");
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#端口OUT传输错误!");
|
||||
_flush_endpoint(bulk_ctxt->bulk_out);
|
||||
}
|
||||
|
||||
@@ -380,7 +379,7 @@ static void _transfer_finish(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt, u32
|
||||
|
||||
if (bulk_ctxt->bulk_in_status == USB_ERROR_XFER_ERROR)
|
||||
{
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#EP IN传输!");
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#端口IN传输错误!");
|
||||
_flush_endpoint(bulk_ctxt->bulk_in);
|
||||
}
|
||||
|
||||
@@ -393,7 +392,7 @@ static void _transfer_finish(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt, u32
|
||||
|
||||
if (bulk_ctxt->bulk_out_status == USB_ERROR_XFER_ERROR)
|
||||
{
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#EP OUT传输!");
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#端口OUT传输!");
|
||||
_flush_endpoint(bulk_ctxt->bulk_out);
|
||||
}
|
||||
|
||||
@@ -463,7 +462,7 @@ static int _scsi_read(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt)
|
||||
}
|
||||
if (lba_offset >= ums->lun.num_sectors)
|
||||
{
|
||||
ums->set_text(ums->label, "#FF8000 警告:#读取 - 超出范围!已通知主机。");
|
||||
ums->set_text(ums->label, "#FF8000 警告:#读取超出范围!主机已通知。");
|
||||
ums->lun.sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
|
||||
|
||||
return UMS_RES_INVALID_ARG;
|
||||
@@ -515,7 +514,7 @@ static int _scsi_read(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt)
|
||||
// If an error occurred, report it and its position.
|
||||
if (!amount)
|
||||
{
|
||||
ums->set_text(ums->label, "#FFDD00 错误:# SDMMC读取!");
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#SDMMC读取失败!");
|
||||
ums->lun.sense_data = SS_UNRECOVERED_READ_ERROR;
|
||||
ums->lun.sense_data_info = lba_offset;
|
||||
ums->lun.info_valid = 1;
|
||||
@@ -553,7 +552,7 @@ static int _scsi_write(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt)
|
||||
|
||||
if (ums->lun.ro)
|
||||
{
|
||||
ums->set_text(ums->label, "#FF8000 警告:#写入 - 只读!已通知主机。");
|
||||
ums->set_text(ums->label, "#FF8000 警告:#写入受阻 - 只读模式! 已通知主机。");
|
||||
ums->lun.sense_data = SS_WRITE_PROTECTED;
|
||||
|
||||
return UMS_RES_INVALID_ARG;
|
||||
@@ -577,7 +576,7 @@ static int _scsi_write(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt)
|
||||
// Check that starting LBA is not past the end sector offset.
|
||||
if (lba_offset >= ums->lun.num_sectors)
|
||||
{
|
||||
ums->set_text(ums->label, "#FF8000 警告:#写入 - 超出范围!已通知主机。");
|
||||
ums->set_text(ums->label, "#FF8000 警告:#写入超出范围! 已通知主机。");
|
||||
ums->lun.sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
|
||||
|
||||
return UMS_RES_INVALID_ARG;
|
||||
@@ -599,7 +598,7 @@ static int _scsi_write(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt)
|
||||
|
||||
if (usb_lba_offset >= ums->lun.num_sectors)
|
||||
{
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#写入 - 超出最后扇区!");
|
||||
ums->set_text(ums->label, "#FFDD00 错误:# 写入超过最后一个扇区!");
|
||||
ums->lun.sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
|
||||
ums->lun.sense_data_info = usb_lba_offset;
|
||||
ums->lun.info_valid = 1;
|
||||
@@ -627,7 +626,7 @@ static int _scsi_write(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt)
|
||||
ums->lun.sense_data_info = lba_offset;
|
||||
ums->lun.info_valid = 1;
|
||||
|
||||
s_printf(txt_buf, "#FFDD00 错误:#写入 - 通讯失败 %d!", bulk_ctxt->bulk_out_status);
|
||||
s_printf(txt_buf, "#FFDD00 错误:#写入通信失败 %d!", bulk_ctxt->bulk_out_status);
|
||||
ums->set_text(ums->label, txt_buf);
|
||||
break;
|
||||
}
|
||||
@@ -665,7 +664,7 @@ DPRINTF("file write %X @ %X\n", amount, lba_offset);
|
||||
// If an error occurred, report it and its position.
|
||||
if (!amount)
|
||||
{
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#SDMMC写入!");
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#SDMMC写入失败!");
|
||||
ums->lun.sense_data = SS_WRITE_ERROR;
|
||||
ums->lun.sense_data_info = lba_offset;
|
||||
ums->lun.info_valid = 1;
|
||||
@@ -676,7 +675,7 @@ DPRINTF("file write %X @ %X\n", amount, lba_offset);
|
||||
// Did the host decide to stop early?
|
||||
if (bulk_ctxt->bulk_out_length_actual < bulk_ctxt->bulk_out_length)
|
||||
{
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#空写入");
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#空写入!");
|
||||
ums->short_packet_received = 1;
|
||||
break;
|
||||
}
|
||||
@@ -692,7 +691,7 @@ static int _scsi_verify(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt)
|
||||
u32 lba_offset = get_array_be_to_le32(&ums->cmnd[2]);
|
||||
if (lba_offset >= ums->lun.num_sectors)
|
||||
{
|
||||
ums->set_text(ums->label, "#FF8000 警告:#校验 - 超出范围!已通知主机。");
|
||||
ums->set_text(ums->label, "#FF8000 警告:#验证超出范围! 已通知主机。");
|
||||
ums->lun.sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
|
||||
|
||||
return UMS_RES_INVALID_ARG;
|
||||
@@ -731,7 +730,7 @@ DPRINTF("File read %X @ %X\n", amount, lba_offset);
|
||||
|
||||
if (!amount)
|
||||
{
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#文件检验!");
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#文件验证失败!");
|
||||
ums->lun.sense_data = SS_UNRECOVERED_READ_ERROR;
|
||||
ums->lun.sense_data_info = lba_offset;
|
||||
ums->lun.info_valid = 1;
|
||||
@@ -764,7 +763,7 @@ static int _scsi_inquiry(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt)
|
||||
switch (ums->lun.partition)
|
||||
{
|
||||
case 0:
|
||||
strcpy((char *)buf + strlen((char *)buf), "原始");
|
||||
strcpy((char *)buf + strlen((char *)buf), "RAW");
|
||||
break;
|
||||
case EMMC_GPP + 1:
|
||||
s_printf((char *)buf + strlen((char *)buf), "GPP");
|
||||
@@ -800,7 +799,7 @@ static int _scsi_inquiry(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt)
|
||||
switch (ums->lun.partition)
|
||||
{
|
||||
case 0:
|
||||
s_printf((char *)buf, "%s", "SD卡原始分区");
|
||||
s_printf((char *)buf, "%s", "SD RAW");
|
||||
break;
|
||||
case EMMC_GPP + 1:
|
||||
s_printf((char *)buf, "%s%s",
|
||||
@@ -1060,7 +1059,7 @@ static int _scsi_start_stop(usbd_gadget_ums_t *ums)
|
||||
// Check if we are allowed to unload the media.
|
||||
if (ums->lun.prevent_medium_removal)
|
||||
{
|
||||
ums->set_text(ums->label, "#C7EA46 状态:#卸载尝试已被阻止");
|
||||
ums->set_text(ums->label, "#C7EA46 状态:#尝试卸载被阻止");
|
||||
ums->lun.sense_data = SS_MEDIUM_REMOVAL_PREVENTED;
|
||||
|
||||
return UMS_RES_INVALID_ARG;
|
||||
@@ -1468,7 +1467,7 @@ static int _finish_reply(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt)
|
||||
{
|
||||
_set_ep_stall(bulk_ctxt->bulk_out);
|
||||
rc = _set_ep_stall(bulk_ctxt->bulk_in);
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#方向不明。两端EP已暂停!");
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#方向未知。已停止两个端口!");
|
||||
} // Else do nothing.
|
||||
break;
|
||||
|
||||
@@ -1489,7 +1488,7 @@ static int _finish_reply(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt)
|
||||
{
|
||||
_transfer_start(ums, bulk_ctxt, bulk_ctxt->bulk_in, USB_XFER_SYNCED_DATA);
|
||||
rc = _set_ep_stall(bulk_ctxt->bulk_in);
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#数据残留。EP IN已停止!");
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#残留。已停止端口IN!");
|
||||
}
|
||||
else
|
||||
rc = _pad_with_zeros(ums, bulk_ctxt);
|
||||
@@ -1562,7 +1561,7 @@ static int _received_cbw(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt)
|
||||
{
|
||||
if (usb_ops.usb_device_get_port_in_sleep())
|
||||
{
|
||||
ums->set_text(ums->label, "#C7EA46 状态:#EP已休眠");
|
||||
ums->set_text(ums->label, "#C7EA46 状态:#端口休眠中");
|
||||
ums->timeouts += 14;
|
||||
}
|
||||
else if (!ums->xusb) // Timeout only on USB2.
|
||||
@@ -1581,7 +1580,7 @@ static int _received_cbw(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt)
|
||||
|
||||
if (ums->lun.unmounted)
|
||||
{
|
||||
ums->set_text(ums->label, "#C7EA46 状态:#介质未挂载");
|
||||
ums->set_text(ums->label, "#C7EA46 状态:# 介质已卸载");
|
||||
ums->timeouts++;
|
||||
if (!bulk_ctxt->bulk_out_status)
|
||||
ums->timeouts += 3;
|
||||
@@ -1633,7 +1632,7 @@ static int _received_cbw(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt)
|
||||
{
|
||||
_set_ep_stall(bulk_ctxt->bulk_out);
|
||||
_set_ep_stall(bulk_ctxt->bulk_in);
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#CBW未知 - 两端EP已停止!");
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#CBW未知 - 已停止两个端口!");
|
||||
}
|
||||
|
||||
return UMS_RES_INVALID_ARG;
|
||||
@@ -1712,7 +1711,7 @@ static void _send_status(usbd_gadget_ums_t *ums, bulk_ctxt_t *bulk_ctxt)
|
||||
|
||||
if (ums->phase_error)
|
||||
{
|
||||
ums->set_text(ums->label, "#FFDD00 错误:#相位错误!");
|
||||
ums->set_text(ums->label, "#FFDD00 错误:# 阶段性错误!");
|
||||
status = USB_STATUS_PHASE_ERROR;
|
||||
sd = SS_INVALID_COMMAND;
|
||||
}
|
||||
@@ -1826,7 +1825,7 @@ int usb_device_gadget_ums(usb_ctxt_t *usbs)
|
||||
xusb_device_get_ops(&usb_ops);
|
||||
}
|
||||
|
||||
usbs->set_text(usbs->label, "#C7EA46 状态:#USB已开启");
|
||||
usbs->set_text(usbs->label, "#C7EA46 状态:#已启动USB");
|
||||
|
||||
if (usb_ops.usb_device_init())
|
||||
{
|
||||
@@ -1857,7 +1856,7 @@ int usb_device_gadget_ums(usb_ctxt_t *usbs)
|
||||
ums.set_text = usbs->set_text;
|
||||
ums.system_maintenance = usbs->system_maintenance;
|
||||
|
||||
ums.set_text(ums.label, "#C7EA46 状态:#磁盘挂载中");
|
||||
ums.set_text(ums.label, "#C7EA46 状态:#挂载磁盘");
|
||||
|
||||
// Initialize sdmmc.
|
||||
if (usbs->type == MMC_SD)
|
||||
@@ -1888,18 +1887,18 @@ int usb_device_gadget_ums(usb_ctxt_t *usbs)
|
||||
ums.lun.storage = &emmc_storage;
|
||||
}
|
||||
|
||||
ums.set_text(ums.label, "#C7EA46 状态:#连接等待中");
|
||||
ums.set_text(ums.label, "#C7EA46 状态:#正在等待连接");
|
||||
|
||||
// Initialize Control Endpoint.
|
||||
if (usb_ops.usb_device_enumerate(USB_GADGET_UMS))
|
||||
goto usb_enum_error;
|
||||
|
||||
ums.set_text(ums.label, "#C7EA46 状态:#LUN等待中");
|
||||
ums.set_text(ums.label, "#C7EA46 状态:#正在等待LUN");
|
||||
|
||||
if (usb_ops.usb_device_class_send_max_lun(0)) // One device for now.
|
||||
goto usb_enum_error;
|
||||
|
||||
ums.set_text(ums.label, "#C7EA46 状态:#UMS已开启");
|
||||
ums.set_text(ums.label, "#C7EA46 状态:#已启动UMS");
|
||||
|
||||
// If partition sectors are not set get them from hardware.
|
||||
if (!ums.lun.num_sectors)
|
||||
@@ -1920,7 +1919,7 @@ int usb_device_gadget_ums(usb_ctxt_t *usbs)
|
||||
{
|
||||
// Check if we are allowed to unload the media.
|
||||
if (ums.lun.prevent_medium_removal)
|
||||
ums.set_text(ums.label, "#C7EA46 状态:#卸载尝试已被阻止");
|
||||
ums.set_text(ums.label, "#C7EA46 状态:#尝试卸载被阻止");
|
||||
else
|
||||
break;
|
||||
}
|
||||
@@ -1952,13 +1951,13 @@ int usb_device_gadget_ums(usb_ctxt_t *usbs)
|
||||
} while (ums.state != UMS_STATE_TERMINATED);
|
||||
|
||||
if (ums.lun.prevent_medium_removal)
|
||||
ums.set_text(ums.label, "#FFDD00 错误:#磁盘已未安全弹出");
|
||||
ums.set_text(ums.label, "#FFDD00 错误:#磁盘不安全弹出");
|
||||
else
|
||||
ums.set_text(ums.label, "#C7EA46 状态:#磁盘已弹出");
|
||||
goto exit;
|
||||
|
||||
usb_enum_error:
|
||||
ums.set_text(ums.label, "#FFDD00 错误:#超时或已取消!");
|
||||
ums.set_text(ums.label, "#FFDD00 错误:#超时或取消!");
|
||||
res = 1;
|
||||
|
||||
exit:
|
||||
|
||||
Reference in New Issue
Block a user