- 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 flashblockKey
/* Copyright (c) 2011,2012 Simon Schubert <[email protected]>. | /* Copyright (c) 2011,2012 Simon Schubert <[email protected]>. | ||||
* Modifications by Jacob Alexander 2014-2015 <[email protected]> | |||||
* Modifications by Jacob Alexander 2014-2016 <[email protected]> | |||||
* | * | ||||
* 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 | ||||
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); |
/* 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 | ||||
MEMORY | MEMORY | ||||
{ | { | ||||
FLASH (rx) : ORIGIN = 0x0, LENGTH = 128K | |||||
FLASH_APP (rx) : ORIGIN = 4K, LENGTH = 128K-4K | |||||
RAM (rwx) : ORIGIN = 0x20000000 - 16K / 2, LENGTH = 16K | |||||
FLASH (rx) : ORIGIN = 0x0, LENGTH = 128K | |||||
FLASH_APP (rx) : ORIGIN = 4K, LENGTH = 128K - 4K | |||||
RAM (rwx) : ORIGIN = 0x20000000 - 16K / 2, LENGTH = 16K | |||||
} | } | ||||
/* Starting Address of the application ROM */ | /* Starting Address of the application ROM */ | ||||
_app_rom = ORIGIN( FLASH_APP ); | |||||
_bootloader = ORIGIN( FLASH ); | |||||
_app_rom = ORIGIN( FLASH_APP ); | |||||
_app_rom_end = ORIGIN( FLASH ) + LENGTH( FLASH ); | |||||
FlexRAM = 0x14000000; | FlexRAM = 0x14000000; | ||||
FTFL = 0x40020000; | FTFL = 0x40020000; |
/* 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 | ||||
MEMORY | MEMORY | ||||
{ | { | ||||
FLASH (rx) : ORIGIN = 4K, LENGTH = 128K-4K | |||||
FLASH (rx) : ORIGIN = 4K, LENGTH = 128K - 4K | |||||
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 | ||||
{ | { |
/* 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 | ||||
MEMORY | MEMORY | ||||
{ | { | ||||
FLASH (rx) : ORIGIN = 0x0, LENGTH = 256K | |||||
FLASH_APP (rx) : ORIGIN = 8K, LENGTH = 256K-8K | |||||
RAM (rwx) : ORIGIN = 0x20000000 - 64K / 2, LENGTH = 64K | |||||
FLASH (rx) : ORIGIN = 0x0, LENGTH = 256K | |||||
FLASH_APP (rx) : ORIGIN = 8K, LENGTH = 256K - 8K | |||||
RAM (rwx) : ORIGIN = 0x20000000 - 64K / 2, LENGTH = 64K | |||||
} | } | ||||
/* Starting Address of the application ROM */ | /* Starting Address of the application ROM */ | ||||
_bootloader = ORIGIN( FLASH ); | |||||
_app_rom = ORIGIN( FLASH_APP ); | |||||
_bootloader = ORIGIN( FLASH ); | |||||
_app_rom = ORIGIN( FLASH_APP ); | |||||
_app_rom_end = ORIGIN( FLASH ) + LENGTH( FLASH ); | |||||
FlexRAM = 0x14000000; | FlexRAM = 0x14000000; | ||||
FTFL = 0x40020000; | FTFL = 0x40020000; |
/* 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 | ||||
MEMORY | MEMORY | ||||
{ | { | ||||
FLASH (rx) : ORIGIN = 8K, LENGTH = 256K-8K | |||||
FLASH (rx) : ORIGIN = 8K, LENGTH = 256K - 8K | |||||
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 | ||||
{ | { |