aboutsummaryrefslogtreecommitdiffstats
path: root/Bootloaders/CDC
diff options
context:
space:
mode:
Diffstat (limited to 'Bootloaders/CDC')
-rw-r--r--Bootloaders/CDC/BootloaderCDC.c52
-rw-r--r--Bootloaders/CDC/BootloaderCDC.h2
-rw-r--r--Bootloaders/CDC/BootloaderCDC.txt24
-rw-r--r--Bootloaders/CDC/makefile5
4 files changed, 56 insertions, 27 deletions
diff --git a/Bootloaders/CDC/BootloaderCDC.c b/Bootloaders/CDC/BootloaderCDC.c
index 0c93adfac..12a755707 100644
--- a/Bootloaders/CDC/BootloaderCDC.c
+++ b/Bootloaders/CDC/BootloaderCDC.c
@@ -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)
- {
- /* Escape is sync, ignore */
- }
- else
+ #endif
+ else if (Command != 27)
{
- /* Unknown command, return fail code */
+ /* Unknown (non-sync) command, return fail code */
WriteNextResponseByte('?');
}
diff --git a/Bootloaders/CDC/BootloaderCDC.h b/Bootloaders/CDC/BootloaderCDC.h
index b05aba2d8..bb13a80ed 100644
--- a/Bootloaders/CDC/BootloaderCDC.h
+++ b/Bootloaders/CDC/BootloaderCDC.h
@@ -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
diff --git a/Bootloaders/CDC/BootloaderCDC.txt b/Bootloaders/CDC/BootloaderCDC.txt
index ae1da0804..69a269d1f 100644
--- a/Bootloaders/CDC/BootloaderCDC.txt
+++ b/Bootloaders/CDC/BootloaderCDC.txt
@@ -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>
*/
diff --git a/Bootloaders/CDC/makefile b/Bootloaders/CDC/makefile
index 305c732b9..5eebaba53 100644
--- a/Bootloaders/CDC/makefile
+++ b/Bootloaders/CDC/makefile
@@ -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