From 43f7ca7985768c974b6881957b21d687c34413ba Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 9 Nov 2018 11:33:56 -0800 Subject: Incorporate feedback: * Clean up board defines. * Add flush on eject and stay ejected. * Swith back to NONE protocol for CDC. --- supervisor/shared/external_flash/external_flash.h | 2 +- supervisor/shared/usb/usb_msc_flash.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'supervisor/shared') diff --git a/supervisor/shared/external_flash/external_flash.h b/supervisor/shared/external_flash/external_flash.h index 852d183a7..72b619a2a 100644 --- a/supervisor/shared/external_flash/external_flash.h +++ b/supervisor/shared/external_flash/external_flash.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2013, 2014 Damien P. George + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries LLC * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/supervisor/shared/usb/usb_msc_flash.c b/supervisor/shared/usb/usb_msc_flash.c index 72dc40204..13b5c3966 100644 --- a/supervisor/shared/usb/usb_msc_flash.c +++ b/supervisor/shared/usb/usb_msc_flash.c @@ -38,6 +38,8 @@ #define MSC_FLASH_BLOCK_SIZE 512 +static bool ejected[1]; + // The root FS is always at the end of the list. static fs_user_mount_t* get_vfs(int lun) { // TODO(tannewt): Return the mount which matches the lun where 0 is the end @@ -60,7 +62,7 @@ static fs_user_mount_t* get_vfs(int lun) { // - READ10 and WRITE10 have their own callbacks int32_t tud_msc_scsi_cb (uint8_t lun, const uint8_t scsi_cmd[16], void* buffer, uint16_t bufsize) { const void* response = NULL; - uint16_t resplen = 0; + int32_t resplen = 0; switch ( scsi_cmd[0] ) { case SCSI_CMD_TEST_UNIT_READY: @@ -73,6 +75,9 @@ int32_t tud_msc_scsi_cb (uint8_t lun, const uint8_t scsi_cmd[16], void* buffer, if (current_mount == NULL) { resplen = -1; } + if (ejected[lun]) { + resplen = -1; + } } break; @@ -96,6 +101,11 @@ int32_t tud_msc_scsi_cb (uint8_t lun, const uint8_t scsi_cmd[16], void* buffer, if (current_mount == NULL) { resplen = -1; } + if (disk_ioctl(current_mount, CTRL_SYNC, NULL) != RES_OK) { + resplen = -1; + } else { + ejected[lun] = true; + } } } } -- cgit v1.2.3