Projectkk2glider/usb hardening (#4125)
* USB fixes: * USB initialized when USB cable is inserted and de-initialized when disconnected (this was the original way, which proved itself unreliable in the past. Now with the new USB library it appears to work without any problems. Used in this way result in safer operation - USB controller is disabled while unconnected) Works without force device mod * Serial: initialization of global variables * Reduced RAM usage - data moved to FLASH * Detailed USB interrupt counters (+ debug print fix)
This commit is contained in:
committed by
Bertrand Songis
parent
c3238ee38c
commit
29c43d9e33
@@ -9,6 +9,7 @@ option(DEBUG_TRACE_BUFFER "Debug Trace Screen" OFF)
|
||||
option(MULTIMODULE "DIY Multiprotocol TX Module (https://github.com/pascallanger/DIY-Multiprotocol-TX-Module)" OFF)
|
||||
option(SUPPORT_D16_EU_ONLY "XJT module only supports D16-EU and LR12-EU" OFF) # TODO rename to XJT_EU_ONLY
|
||||
option(DEBUG_INTERRUPTS "Count interrupts" OFF)
|
||||
option(DEBUG_USB_INTERRUPTS "Count individual USB interrupts" OFF)
|
||||
option(DEBUG_TASKS "Task switching statistics" OFF)
|
||||
option(DEBUG_TIMERS "Time critical parts of the code" OFF)
|
||||
|
||||
@@ -41,6 +42,9 @@ endif()
|
||||
if(DEBUG_INTERRUPTS)
|
||||
add_definitions(-DDEBUG_INTERRUPTS)
|
||||
set(DEBUG ON)
|
||||
if(DEBUG_USB_INTERRUPTS)
|
||||
add_definitions(-DDEBUG_USB_INTERRUPTS)
|
||||
endif()
|
||||
endif()
|
||||
if(DEBUG_TASKS)
|
||||
add_definitions(-DDEBUG_TASKS)
|
||||
|
||||
@@ -51,9 +51,7 @@ static uint16_t VCP_DeInit (void);
|
||||
static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len);
|
||||
static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len);
|
||||
|
||||
// static uint16_t VCP_COMConfig(uint8_t Conf);
|
||||
|
||||
CDC_IF_Prop_TypeDef VCP_fops =
|
||||
extern "C" const CDC_IF_Prop_TypeDef VCP_fops =
|
||||
{
|
||||
VCP_Init,
|
||||
VCP_DeInit,
|
||||
|
||||
@@ -96,7 +96,7 @@ int8_t STORAGE_Write (uint8_t lun,
|
||||
|
||||
int8_t STORAGE_GetMaxLun (void);
|
||||
|
||||
USBD_STORAGE_cb_TypeDef USBD_MICRO_SDIO_fops =
|
||||
const USBD_STORAGE_cb_TypeDef USBD_MICRO_SDIO_fops = // modified my OpenTX
|
||||
{
|
||||
STORAGE_Init,
|
||||
STORAGE_GetCapacity,
|
||||
@@ -108,9 +108,7 @@ USBD_STORAGE_cb_TypeDef USBD_MICRO_SDIO_fops =
|
||||
(int8_t *)STORAGE_Inquirydata,
|
||||
};
|
||||
|
||||
USBD_STORAGE_cb_TypeDef *USBD_STORAGE_fops = &USBD_MICRO_SDIO_fops;
|
||||
|
||||
__IO uint32_t count = 0;
|
||||
const USBD_STORAGE_cb_TypeDef * const USBD_STORAGE_fops = &USBD_MICRO_SDIO_fops; // modified my OpenTX
|
||||
|
||||
#if defined(__cplusplus) && !defined(SIMU)
|
||||
}
|
||||
@@ -172,14 +170,9 @@ uint8_t lunReady[STORAGE_LUN_NBR];
|
||||
|
||||
void usbPluggedIn()
|
||||
{
|
||||
if (lunReady[STORAGE_SDCARD_LUN] == 0) {
|
||||
lunReady[STORAGE_SDCARD_LUN] = 1;
|
||||
}
|
||||
|
||||
lunReady[STORAGE_SDCARD_LUN] = 1;
|
||||
#if defined(EEPROM)
|
||||
if (lunReady[STORAGE_EEPROM_LUN] == 0) {
|
||||
lunReady[STORAGE_EEPROM_LUN] = 1;
|
||||
}
|
||||
lunReady[STORAGE_EEPROM_LUN] = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -719,7 +712,7 @@ int32_t fat12Write(const uint8_t * buffer, uint16_t sector, uint16_t count)
|
||||
FATWRITE_FIRMWARE
|
||||
};
|
||||
|
||||
static unsigned int operation = FATWRITE_NONE;
|
||||
static uint8_t operation = FATWRITE_NONE;
|
||||
|
||||
TRACE("FAT12 Write(sector=%d, count=%d)", sector, count);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user