forked from mfulz_github/qmk_firmware
Added new NO_BLOCK_SUPPORT, NO_EEPROM_BYTE_SUPPORT, NO_FLASH_BYTE_SUPPORT and NO_LOCK_BYTE_SUPPORT compile time options to the CDC class bootloader.
This commit is contained in:
parent
46f2e488b0
commit
475323e400
|
@ -155,6 +155,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
}
|
||||
}
|
||||
|
||||
#if !defined(NO_BLOCK_SUPPORT)
|
||||
/** Reads or writes a block of EEPROM or FLASH memory to or from the appropriate CDC data endpoint, depending
|
||||
* on the AVR910 protocol command issued.
|
||||
*
|
||||
|
@ -236,15 +237,13 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
|||
|
||||
/* Increment the address counter after use */
|
||||
CurrAddress += 2;
|
||||
|
||||
HighByte = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
LowByte = FetchNextCommandByte();
|
||||
|
||||
HighByte = true;
|
||||
}
|
||||
|
||||
HighByte = !HighByte;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -270,6 +269,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
|||
WriteNextResponseByte('\r');
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Retrieves the next byte from the host in the CDC data OUT endpoint, and clears the endpoint bank if needed
|
||||
* to allow reception of the next data packet from the host.
|
||||
|
@ -389,14 +389,6 @@ void CDC_Task(void)
|
|||
WriteNextResponseByte(AVR_SIGNATURE_2);
|
||||
WriteNextResponseByte(AVR_SIGNATURE_1);
|
||||
}
|
||||
else if (Command == 'b')
|
||||
{
|
||||
WriteNextResponseByte('Y');
|
||||
|
||||
/* Send block size to the host */
|
||||
WriteNextResponseByte(SPM_PAGESIZE >> 8);
|
||||
WriteNextResponseByte(SPM_PAGESIZE & 0xFF);
|
||||
}
|
||||
else if (Command == 'e')
|
||||
{
|
||||
/* Clear the application section of flash */
|
||||
|
@ -413,6 +405,7 @@ void CDC_Task(void)
|
|||
/* Send confirmation byte back to the host */
|
||||
WriteNextResponseByte('\r');
|
||||
}
|
||||
#if !defined(NO_LOCK_BYTE_SUPPORT)
|
||||
else if (Command == 'l')
|
||||
{
|
||||
/* Set the lock bits to those given by the host */
|
||||
|
@ -421,6 +414,7 @@ void CDC_Task(void)
|
|||
/* Send confirmation byte back to the host */
|
||||
WriteNextResponseByte('\r');
|
||||
}
|
||||
#endif
|
||||
else if (Command == 'r')
|
||||
{
|
||||
WriteNextResponseByte(boot_lock_fuse_bits_get(GET_LOCK_BITS));
|
||||
|
@ -437,6 +431,22 @@ void CDC_Task(void)
|
|||
{
|
||||
WriteNextResponseByte(boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS));
|
||||
}
|
||||
#if !defined(NO_BLOCK_SUPPORT)
|
||||
else if (Command == 'b')
|
||||
{
|
||||
WriteNextResponseByte('Y');
|
||||
|
||||
/* Send block size to the host */
|
||||
WriteNextResponseByte(SPM_PAGESIZE >> 8);
|
||||
WriteNextResponseByte(SPM_PAGESIZE & 0xFF);
|
||||
}
|
||||
else if ((Command == 'B') || (Command == 'g'))
|
||||
{
|
||||
/* Delegate the block write/read to a separate function for clarity */
|
||||
ReadWriteMemoryBlock(Command);
|
||||
}
|
||||
#endif
|
||||
#if !defined(NO_FLASH_BYTE_SUPPORT)
|
||||
else if (Command == 'C')
|
||||
{
|
||||
/* Write the high byte to the current flash page */
|
||||
|
@ -448,7 +458,7 @@ void CDC_Task(void)
|
|||
else if (Command == 'c')
|
||||
{
|
||||
/* Write the low byte to the current flash page */
|
||||
boot_page_fill(CurrAddress | 1, FetchNextCommandByte());
|
||||
boot_page_fill(CurrAddress | 0x01, FetchNextCommandByte());
|
||||
|
||||
/* Increment the address */
|
||||
CurrAddress += 2;
|
||||
|
@ -467,11 +477,6 @@ void CDC_Task(void)
|
|||
/* Send confirmation byte back to the host */
|
||||
WriteNextResponseByte('\r');
|
||||
}
|
||||
else if ((Command == 'B') || (Command == 'g'))
|
||||
{
|
||||
/* Delegate the block write/read to a separate function for clarity */
|
||||
ReadWriteMemoryBlock(Command);
|
||||
}
|
||||
else if (Command == 'R')
|
||||
{
|
||||
#if (FLASHEND > 0xFFFF)
|
||||
|
@ -483,6 +488,8 @@ void CDC_Task(void)
|
|||
WriteNextResponseByte(ProgramWord >> 8);
|
||||
WriteNextResponseByte(ProgramWord & 0xFF);
|
||||
}
|
||||
#endif
|
||||
#if !defined(NO_EEPROM_BYTE_SUPPORT)
|
||||
else if (Command == 'D')
|
||||
{
|
||||
/* Read the byte from the endpoint and write it to the EEPROM */
|
||||
|
@ -502,13 +509,10 @@ void CDC_Task(void)
|
|||
/* Increment the address after use */
|
||||
CurrAddress += 2;
|
||||
}
|
||||
else if (Command == 27)
|
||||
#endif
|
||||
else if (Command != 27)
|
||||
{
|
||||
/* Escape is sync, ignore */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Unknown command, return fail code */
|
||||
/* Unknown (non-sync) command, return fail code */
|
||||
WriteNextResponseByte('?');
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,9 @@
|
|||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
|
||||
#if defined(INCLUDE_FROM_BOOTLOADERCDC_C) || defined(__DOXYGEN__)
|
||||
#if !defined(NO_BLOCK_SUPPORT)
|
||||
static void ReadWriteMemoryBlock(const uint8_t Command);
|
||||
#endif
|
||||
static uint8_t FetchNextCommandByte(void);
|
||||
static void WriteNextResponseByte(const uint8_t Response);
|
||||
#endif
|
||||
|
|
|
@ -64,9 +64,27 @@
|
|||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td>
|
||||
* None
|
||||
* </td>
|
||||
* <td>NO_BLOCK_SUPPORT</td>
|
||||
* <td>Makefile LUFA_OPTS</td>
|
||||
* <td>Define to disable memory block read/write support in the bootloader, requiring all reads and writes to be made
|
||||
* using the byte-level commands.
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>NO_EEPROM_BYTE_SUPPORT</td>
|
||||
* <td>Makefile LUFA_OPTS</td>
|
||||
* <td>Define to disable EEPROM memory byte read/write support in the bootloader, requiring all EEPROM reads and writes
|
||||
* to be made using the block-level commands.
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>NO_FLASH_BYTE_SUPPORT</td>
|
||||
* <td>Makefile LUFA_OPTS</td>
|
||||
* <td>Define to disable FLASH memory byte read/write support in the bootloader, requiring all FLASH reads and writes
|
||||
* to be made using the block-level commands.
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>NO_LOCK_BYTE_SUPPORT</td>
|
||||
* <td>Makefile LUFA_OPTS</td>
|
||||
* <td>Define to disable lock byte write support in the bootloader, preventing the lock bits from being set progmatically.
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
|
|
@ -124,6 +124,11 @@ LUFA_OPTS += -D NO_DEVICE_REMOTE_WAKEUP
|
|||
LUFA_OPTS += -D NO_STREAM_CALLBACKS
|
||||
LUFA_OPTS += -D NO_SOF_EVENTS
|
||||
|
||||
#LUFA_OPTS += -D NO_BLOCK_SUPPORT
|
||||
#LUFA_OPTS += -D NO_EEPROM_BYTE_SUPPORT
|
||||
#LUFA_OPTS += -D NO_FLASH_BYTE_SUPPORT
|
||||
#LUFA_OPTS += -D NO_LOCK_BYTE_SUPPORT
|
||||
|
||||
|
||||
# Create the LUFA source path variables by including the LUFA root makefile
|
||||
include $(LUFA_PATH)/LUFA/makefile
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include "Descriptors.h"
|
||||
|
||||
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
||||
/** Device descriptor structure. This descriptor, located in SRAM memory, describes the overall
|
||||
* device characteristics, including the supported USB version, control endpoint size and the
|
||||
* number of device configurations. The descriptor is read out by the USB host when the enumeration
|
||||
* process begins.
|
||||
|
@ -64,7 +64,7 @@ USB_Descriptor_Device_t DeviceDescriptor =
|
|||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
|
||||
/** Configuration descriptor structure. This descriptor, located in SRAM memory, describes the usage
|
||||
* of the device in one of its supported configurations, including information about any device interfaces
|
||||
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
|
||||
* a configuration so that the host may correctly communicate with the USB device.
|
||||
|
@ -115,7 +115,7 @@ USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
|||
}
|
||||
};
|
||||
|
||||
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
|
||||
/** Language descriptor structure. This descriptor, located in SRAM memory, is returned when the host requests
|
||||
* the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
|
||||
* via the language ID table available at USB.org what languages the device supports for its string descriptors.
|
||||
*/
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
* tasks for each driver is called
|
||||
* - Added standard keyboard HID report scancode defines (thanks to László Monda)
|
||||
* - Added new Pipe_GetBusyBanks(), Endpoint_GetBusyBanks() and Endpoint_AbortPendingIN() functions
|
||||
* - Added new NO_BLOCK_SUPPORT, NO_EEPROM_BYTE_SUPPORT, NO_FLASH_BYTE_SUPPORT and NO_LOCK_BYTE_SUPPORT compile time options to the
|
||||
* CDC class bootloader
|
||||
*
|
||||
* <b>Changed:</b>
|
||||
* - Removed complicated logic for the Endpoint_ConfigureEndpoint() function to use inlined or function called versions
|
||||
|
|
Loading…
Reference in New Issue