Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Erik Strand
lufa
Commits
ba6d9c1a
Commit
ba6d9c1a
authored
Jan 22, 2018
by
Dean Camera
Browse files
Fixed bootloaders accepting flash writes to the bootloader region (thanks to NicoHood).
parent
8802907c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Bootloaders/CDC/BootloaderAPI.c
View file @
ba6d9c1a
...
...
@@ -35,8 +35,20 @@
#include
"BootloaderAPI.h"
static
bool
IsPageAddressValid
(
const
uint32_t
Address
)
{
/* Determine if the given page address is correctly aligned to the
start of a flash page. */
bool
PageAddressIsAligned
=
!
(
Address
&
(
SPM_PAGESIZE
-
1
));
return
(
Address
<
BOOT_START_ADDR
)
&&
PageAddressIsAligned
;
}
void
BootloaderAPI_ErasePage
(
const
uint32_t
Address
)
{
if
(
!
IsPageAddressValid
(
Address
))
return
;
ATOMIC_BLOCK
(
ATOMIC_RESTORESTATE
)
{
boot_page_erase_safe
(
Address
);
...
...
@@ -47,6 +59,9 @@ void BootloaderAPI_ErasePage(const uint32_t Address)
void
BootloaderAPI_WritePage
(
const
uint32_t
Address
)
{
if
(
!
IsPageAddressValid
(
Address
))
return
;
ATOMIC_BLOCK
(
ATOMIC_RESTORESTATE
)
{
boot_page_write_safe
(
Address
);
...
...
Bootloaders/DFU/BootloaderAPI.c
View file @
ba6d9c1a
...
...
@@ -35,8 +35,20 @@
#include
"BootloaderAPI.h"
static
bool
IsPageAddressValid
(
const
uint32_t
Address
)
{
/* Determine if the given page address is correctly aligned to the
start of a flash page. */
bool
PageAddressIsAligned
=
!
(
Address
&
(
SPM_PAGESIZE
-
1
));
return
(
Address
<
BOOT_START_ADDR
)
&&
PageAddressIsAligned
;
}
void
BootloaderAPI_ErasePage
(
const
uint32_t
Address
)
{
if
(
!
IsPageAddressValid
(
Address
))
return
;
ATOMIC_BLOCK
(
ATOMIC_RESTORESTATE
)
{
boot_page_erase_safe
(
Address
);
...
...
@@ -47,6 +59,9 @@ void BootloaderAPI_ErasePage(const uint32_t Address)
void
BootloaderAPI_WritePage
(
const
uint32_t
Address
)
{
if
(
!
IsPageAddressValid
(
Address
))
return
;
ATOMIC_BLOCK
(
ATOMIC_RESTORESTATE
)
{
boot_page_write_safe
(
Address
);
...
...
Bootloaders/HID/BootloaderHID.c
View file @
ba6d9c1a
...
...
@@ -152,6 +152,10 @@ void EVENT_USB_Device_ControlRequest(void)
uint16_t
PageAddress
=
Endpoint_Read_16_LE
();
#endif
/* Determine if the given page address is correctly aligned to the
start of a flash page. */
bool
PageAddressIsAligned
=
!
(
PageAddress
&
(
SPM_PAGESIZE
-
1
));
/* Check if the command is a program page command, or a start application command */
#if (FLASHEND > 0xFFFF)
if
((
uint16_t
)(
PageAddress
>>
8
)
==
COMMAND_STARTAPPLICATION
)
...
...
@@ -161,7 +165,7 @@ void EVENT_USB_Device_ControlRequest(void)
{
RunBootloader
=
false
;
}
else
if
(
PageAddress
<
BOOT_START_ADDR
)
else
if
(
(
PageAddress
<
BOOT_START_ADDR
)
&&
PageAddressIsAligned
)
{
/* Erase the given FLASH page, ready to be programmed */
ATOMIC_BLOCK
(
ATOMIC_RESTORESTATE
)
...
...
Bootloaders/MassStorage/BootloaderAPI.c
View file @
ba6d9c1a
...
...
@@ -35,8 +35,20 @@
#include
"BootloaderAPI.h"
static
bool
IsPageAddressValid
(
const
uint32_t
Address
)
{
/* Determine if the given page address is correctly aligned to the
start of a flash page. */
bool
PageAddressIsAligned
=
!
(
Address
&
(
SPM_PAGESIZE
-
1
));
return
(
Address
<
BOOT_START_ADDR
)
&&
PageAddressIsAligned
;
}
void
BootloaderAPI_ErasePage
(
const
uint32_t
Address
)
{
if
(
!
IsPageAddressValid
(
Address
))
return
;
ATOMIC_BLOCK
(
ATOMIC_RESTORESTATE
)
{
boot_page_erase_safe
(
Address
);
...
...
@@ -47,6 +59,9 @@ void BootloaderAPI_ErasePage(const uint32_t Address)
void
BootloaderAPI_WritePage
(
const
uint32_t
Address
)
{
if
(
!
IsPageAddressValid
(
Address
))
return
;
ATOMIC_BLOCK
(
ATOMIC_RESTORESTATE
)
{
boot_page_write_safe
(
Address
);
...
...
Bootloaders/Printer/BootloaderAPI.c
View file @
ba6d9c1a
...
...
@@ -35,8 +35,20 @@
#include
"BootloaderAPI.h"
static
bool
IsPageAddressValid
(
const
uint32_t
Address
)
{
/* Determine if the given page address is correctly aligned to the
start of a flash page. */
bool
PageAddressIsAligned
=
!
(
Address
&
(
SPM_PAGESIZE
-
1
));
return
(
Address
<
BOOT_START_ADDR
)
&&
PageAddressIsAligned
;
}
void
BootloaderAPI_ErasePage
(
const
uint32_t
Address
)
{
if
(
!
IsPageAddressValid
(
Address
))
return
;
ATOMIC_BLOCK
(
ATOMIC_RESTORESTATE
)
{
boot_page_erase_safe
(
Address
);
...
...
@@ -47,6 +59,9 @@ void BootloaderAPI_ErasePage(const uint32_t Address)
void
BootloaderAPI_WritePage
(
const
uint32_t
Address
)
{
if
(
!
IsPageAddressValid
(
Address
))
return
;
ATOMIC_BLOCK
(
ATOMIC_RESTORESTATE
)
{
boot_page_write_safe
(
Address
);
...
...
LUFA/DoxygenPages/ChangeLog.txt
View file @
ba6d9c1a
...
...
@@ -14,6 +14,7 @@
* character after a successful write (thanks to NicoHood)
* - Library Applications:
* - Fixed bootloaders not disabling global interrupts during erase and write operations (thanks to Zoltan)
* - Fixed bootloaders accepting flash writes to the bootloader region (thanks to NicoHood)
*
* \section Sec_ChangeLog170418 Version 170418
* <b>New:</b>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment