mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-06-01 05:53:22 +00:00
Restrict HID bootloader programming region (thanks to NicoHood).
This commit is contained in:
parent
0b95817130
commit
f0c5dfe8b8
@ -58,6 +58,11 @@ void Application_Jump_Check(void)
|
|||||||
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application */
|
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application */
|
||||||
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
|
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
|
||||||
{
|
{
|
||||||
|
/* Turn off the watchdog */
|
||||||
|
MCUSR &= ~(1 << WDRF);
|
||||||
|
wdt_disable();
|
||||||
|
|
||||||
|
/* Clear the boot key and jump to the user application */
|
||||||
MagicBootKey = 0;
|
MagicBootKey = 0;
|
||||||
|
|
||||||
// cppcheck-suppress constStatement
|
// cppcheck-suppress constStatement
|
||||||
@ -98,6 +103,9 @@ static void SetupHardware(void)
|
|||||||
MCUSR &= ~(1 << WDRF);
|
MCUSR &= ~(1 << WDRF);
|
||||||
wdt_disable();
|
wdt_disable();
|
||||||
|
|
||||||
|
/* Disable clock division */
|
||||||
|
clock_prescale_set(clock_div_1);
|
||||||
|
|
||||||
/* Relocate the interrupt vector table to the bootloader section */
|
/* Relocate the interrupt vector table to the bootloader section */
|
||||||
MCUCR = (1 << IVCE);
|
MCUCR = (1 << IVCE);
|
||||||
MCUCR = (1 << IVSEL);
|
MCUCR = (1 << IVSEL);
|
||||||
@ -153,7 +161,7 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||||||
{
|
{
|
||||||
RunBootloader = false;
|
RunBootloader = false;
|
||||||
}
|
}
|
||||||
else
|
else if (PageAddress < BOOT_START_ADDR)
|
||||||
{
|
{
|
||||||
/* Erase the given FLASH page, ready to be programmed */
|
/* Erase the given FLASH page, ready to be programmed */
|
||||||
boot_page_erase(PageAddress);
|
boot_page_erase(PageAddress);
|
||||||
|
@ -67,7 +67,5 @@
|
|||||||
void Application_Jump_Check(void) ATTR_INIT_SECTION(3);
|
void Application_Jump_Check(void) ATTR_INIT_SECTION(3);
|
||||||
|
|
||||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||||
void EVENT_USB_Device_UnhandledControlRequest(void);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
|||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = INTERFACE_ID_Printer,
|
.InterfaceNumber = INTERFACE_ID_GenericHID,
|
||||||
.AlternateSetting = 0x00,
|
.AlternateSetting = 0x00,
|
||||||
|
|
||||||
.TotalEndpoints = 1,
|
.TotalEndpoints = 1,
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
*/
|
*/
|
||||||
enum InterfaceDescriptors_t
|
enum InterfaceDescriptors_t
|
||||||
{
|
{
|
||||||
INTERFACE_ID_Printer = 0, /**< Printer interface descriptor ID */
|
INTERFACE_ID_GenericHID = 0, /**< GenericHID interface descriptor ID */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
|
@ -20,7 +20,7 @@ OPTIMIZATION = s
|
|||||||
TARGET = BootloaderHID
|
TARGET = BootloaderHID
|
||||||
SRC = $(TARGET).c Descriptors.c $(LUFA_SRC_USB)
|
SRC = $(TARGET).c Descriptors.c $(LUFA_SRC_USB)
|
||||||
LUFA_PATH = ../../LUFA
|
LUFA_PATH = ../../LUFA
|
||||||
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/
|
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -DBOOT_START_ADDR=$(BOOT_START_OFFSET) -IConfig/
|
||||||
LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET)
|
LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET)
|
||||||
|
|
||||||
# Flash size and bootloader section sizes of the target, in KB. These must
|
# Flash size and bootloader section sizes of the target, in KB. These must
|
||||||
|
Loading…
Reference in New Issue
Block a user