projects
/
pub
/
USBasp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0b95817
)
Restrict HID bootloader programming region (thanks to NicoHood).
author
Dean Camera
<dean@fourwalledcubicle.com>
Sun, 29 Jan 2017 04:36:02 +0000
(15:36 +1100)
committer
Dean Camera
<dean@fourwalledcubicle.com>
Sun, 29 Jan 2017 04:36:02 +0000
(15:36 +1100)
Bootloaders/HID/BootloaderHID.c
patch
|
blob
|
blame
|
history
Bootloaders/HID/BootloaderHID.h
patch
|
blob
|
blame
|
history
Bootloaders/HID/Descriptors.c
patch
|
blob
|
blame
|
history
Bootloaders/HID/Descriptors.h
patch
|
blob
|
blame
|
history
Bootloaders/HID/makefile
patch
|
blob
|
blame
|
history
diff --git
a/Bootloaders/HID/BootloaderHID.c
b/Bootloaders/HID/BootloaderHID.c
index
04fd0df
..
ec094b1
100644
(file)
--- a/
Bootloaders/HID/BootloaderHID.c
+++ b/
Bootloaders/HID/BootloaderHID.c
@@
-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 ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
{
/* 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))
{
+ /* Turn off the watchdog */
+ MCUSR &= ~(1 << WDRF);
+ wdt_disable();
+
+ /* Clear the boot key and jump to the user application */
MagicBootKey = 0;
// cppcheck-suppress constStatement
MagicBootKey = 0;
// cppcheck-suppress constStatement
@@
-98,6
+103,9
@@
static void SetupHardware(void)
MCUSR &= ~(1 << WDRF);
wdt_disable();
MCUSR &= ~(1 << WDRF);
wdt_disable();
+ /* Disable clock division */
+ clock_prescale_set(clock_div_1);
+
/* Relocate the interrupt vector table to the bootloader section */
MCUCR = (1 << IVCE);
MCUCR = (1 << IVSEL);
/* Relocate the interrupt vector table to the bootloader section */
MCUCR = (1 << IVCE);
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 */
boot_page_erase(PageAddress);
{
/* Erase the given FLASH page, ready to be programmed */
boot_page_erase(PageAddress);
diff --git
a/Bootloaders/HID/BootloaderHID.h
b/Bootloaders/HID/BootloaderHID.h
index
74cb267
..
0eaba46
100644
(file)
--- a/
Bootloaders/HID/BootloaderHID.h
+++ b/
Bootloaders/HID/BootloaderHID.h
@@
-67,7
+67,5
@@
void Application_Jump_Check(void) ATTR_INIT_SECTION(3);
void EVENT_USB_Device_ConfigurationChanged(void);
void Application_Jump_Check(void) ATTR_INIT_SECTION(3);
void EVENT_USB_Device_ConfigurationChanged(void);
- void EVENT_USB_Device_UnhandledControlRequest(void);
#endif
#endif
-
diff --git
a/Bootloaders/HID/Descriptors.c
b/Bootloaders/HID/Descriptors.c
index
4c475db
..
70dc9d0
100644
(file)
--- a/
Bootloaders/HID/Descriptors.c
+++ b/
Bootloaders/HID/Descriptors.c
@@
-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,
.TotalEndpoints = 1,
.AlternateSetting = 0x00,
.TotalEndpoints = 1,
diff --git
a/Bootloaders/HID/Descriptors.h
b/Bootloaders/HID/Descriptors.h
index
08d87e6
..
179fa31
100644
(file)
--- a/
Bootloaders/HID/Descriptors.h
+++ b/
Bootloaders/HID/Descriptors.h
@@
-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: */
diff --git
a/Bootloaders/HID/makefile
b/Bootloaders/HID/makefile
index
a76faf0
..
3176a5a
100644
(file)
--- a/
Bootloaders/HID/makefile
+++ b/
Bootloaders/HID/makefile
@@
-20,7
+20,7
@@
OPTIMIZATION = s
TARGET = BootloaderHID
SRC = $(TARGET).c Descriptors.c $(LUFA_SRC_USB)
LUFA_PATH = ../../LUFA
TARGET = BootloaderHID
SRC = $(TARGET).c Descriptors.c $(LUFA_SRC_USB)
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)
# Flash size and bootloader section sizes of the target, in KB. These must
LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET)
# Flash size and bootloader section sizes of the target, in KB. These must