Adding DFU check to validate that we aren't trying to flash too far
- Add _app_rom_end address location that points to the end of flash - Check when flashing each page whether the end of the page exceeds the end of the flash
This commit is contained in:
parent
5162980791
commit
2f03f34877
@ -1,5 +1,5 @@
|
|||||||
/* Copyright (c) 2011,2012 Simon Schubert <2@0x2c.org>.
|
/* Copyright (c) 2011,2012 Simon Schubert <2@0x2c.org>.
|
||||||
* Modifications by Jacob Alexander 2014-2015 <haata@kiibohd.com>
|
* Modifications by Jacob Alexander 2014-2016 <haata@kiibohd.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -141,9 +141,15 @@ static enum dfu_status setup_write( size_t off, size_t len, void **buf )
|
|||||||
static enum dfu_status finish_write( void *buf, size_t off, size_t len )
|
static enum dfu_status finish_write( void *buf, size_t off, size_t len )
|
||||||
{
|
{
|
||||||
void *target;
|
void *target;
|
||||||
|
|
||||||
|
// If nothing left to flash, this is still ok
|
||||||
if ( len == 0 )
|
if ( len == 0 )
|
||||||
return (DFU_STATUS_OK);
|
return (DFU_STATUS_OK);
|
||||||
|
|
||||||
|
// If the binary is larger than the internal flash, error
|
||||||
|
if ( off + (uintptr_t)&_app_rom + len > (uintptr_t)&_app_rom_end )
|
||||||
|
return (DFU_STATUS_errADDRESS);
|
||||||
|
|
||||||
target = flash_get_staging_area( off + (uintptr_t)&_app_rom, USB_DFU_TRANSFER_SIZE );
|
target = flash_get_staging_area( off + (uintptr_t)&_app_rom, USB_DFU_TRANSFER_SIZE );
|
||||||
if ( !target )
|
if ( !target )
|
||||||
return (DFU_STATUS_errADDRESS);
|
return (DFU_STATUS_errADDRESS);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* Teensyduino Core Library
|
/* Teensyduino Core Library
|
||||||
* http://www.pjrc.com/teensy/
|
* http://www.pjrc.com/teensy/
|
||||||
* Copyright (c) 2013 PJRC.COM, LLC.
|
* Copyright (c) 2013 PJRC.COM, LLC.
|
||||||
* Modifications by Jacob Alexander 2014 for use with McHCK
|
* Modifications by Jacob Alexander 2014,2016 for use with McHCK
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* a copy of this software and associated documentation files (the
|
||||||
@ -37,7 +37,9 @@ MEMORY
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Starting Address of the application ROM */
|
/* Starting Address of the application ROM */
|
||||||
|
_bootloader = ORIGIN( FLASH );
|
||||||
_app_rom = ORIGIN( FLASH_APP );
|
_app_rom = ORIGIN( FLASH_APP );
|
||||||
|
_app_rom_end = ORIGIN( FLASH ) + LENGTH( FLASH );
|
||||||
|
|
||||||
FlexRAM = 0x14000000;
|
FlexRAM = 0x14000000;
|
||||||
FTFL = 0x40020000;
|
FTFL = 0x40020000;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* Teensyduino Core Library
|
/* Teensyduino Core Library
|
||||||
* http://www.pjrc.com/teensy/
|
* http://www.pjrc.com/teensy/
|
||||||
* Copyright (c) 2013 PJRC.COM, LLC.
|
* Copyright (c) 2013 PJRC.COM, LLC.
|
||||||
* Modifications by Jacob Alexander 2014 for use with McHCK
|
* Modifications by Jacob Alexander 2014,2016 for use with McHCK
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* a copy of this software and associated documentation files (the
|
||||||
@ -35,6 +35,10 @@ MEMORY
|
|||||||
RAM (rwx) : ORIGIN = 0x20000000 - 16K / 2, LENGTH = 16K
|
RAM (rwx) : ORIGIN = 0x20000000 - 16K / 2, LENGTH = 16K
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Starting Address of the application ROM */
|
||||||
|
_app_rom = ORIGIN( FLASH );
|
||||||
|
_app_rom_end = ORIGIN( FLASH ) + LENGTH( FLASH );
|
||||||
|
|
||||||
/* Section Definitions */
|
/* Section Definitions */
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* Teensyduino Core Library
|
/* Teensyduino Core Library
|
||||||
* http://www.pjrc.com/teensy/
|
* http://www.pjrc.com/teensy/
|
||||||
* Copyright (c) 2013 PJRC.COM, LLC.
|
* Copyright (c) 2013 PJRC.COM, LLC.
|
||||||
* Modifications by Jacob Alexander 2014-2015 for use with McHCK and Kiibohd-dfu
|
* Modifications by Jacob Alexander 2014-2016 for use with McHCK and Kiibohd-dfu
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* a copy of this software and associated documentation files (the
|
||||||
@ -39,6 +39,7 @@ MEMORY
|
|||||||
/* Starting Address of the application ROM */
|
/* Starting Address of the application ROM */
|
||||||
_bootloader = ORIGIN( FLASH );
|
_bootloader = ORIGIN( FLASH );
|
||||||
_app_rom = ORIGIN( FLASH_APP );
|
_app_rom = ORIGIN( FLASH_APP );
|
||||||
|
_app_rom_end = ORIGIN( FLASH ) + LENGTH( FLASH );
|
||||||
|
|
||||||
FlexRAM = 0x14000000;
|
FlexRAM = 0x14000000;
|
||||||
FTFL = 0x40020000;
|
FTFL = 0x40020000;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* Teensyduino Core Library
|
/* Teensyduino Core Library
|
||||||
* http://www.pjrc.com/teensy/
|
* http://www.pjrc.com/teensy/
|
||||||
* Copyright (c) 2013 PJRC.COM, LLC.
|
* Copyright (c) 2013 PJRC.COM, LLC.
|
||||||
* Modifications by Jacob Alexander 2014-2015 for use with McHCK and Kiibohd-dfu
|
* Modifications by Jacob Alexander 2014-2016 for use with McHCK and Kiibohd-dfu
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* a copy of this software and associated documentation files (the
|
||||||
@ -35,6 +35,10 @@ MEMORY
|
|||||||
RAM (rwx) : ORIGIN = 0x20000000 - 64K / 2, LENGTH = 64K
|
RAM (rwx) : ORIGIN = 0x20000000 - 64K / 2, LENGTH = 64K
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Starting Address of the application ROM */
|
||||||
|
_app_rom = ORIGIN( FLASH );
|
||||||
|
_app_rom_end = ORIGIN( FLASH ) + LENGTH( FLASH );
|
||||||
|
|
||||||
/* Section Definitions */
|
/* Section Definitions */
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user