File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed
hardware/pinoccio/avr/bootloaders/STK500RFR2/src Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -1122,20 +1122,19 @@ int main(void)
1122
1122
if ( msgBuffer [0 ] == CMD_PROGRAM_FLASH_ISP )
1123
1123
{
1124
1124
// erase only main section (bootloader protection)
1125
- if (address + size <= APP_END )
1125
+ if ((!( size % 2 )) && (!( address % SPM_PAGESIZE )) && ( size <= SPM_PAGESIZE ) && ( address + size <= APP_END ) )
1126
1126
{
1127
- if (address % SPM_PAGESIZE == 0 )
1128
- {
1129
- boot_page_erase (address ); // Perform page erase
1130
- boot_spm_busy_wait (); // Wait until the memory is erased.
1131
- }
1132
-
1127
+
1128
+ boot_page_erase (address ); // Perform page erase
1129
+ boot_spm_busy_wait (); // Wait until the memory is erased.
1130
+
1133
1131
/* Write FLASH */
1134
1132
tempAddress = address ;
1135
1133
do {
1134
+
1136
1135
lowByte = * p ++ ;
1137
1136
highByte = * p ++ ;
1138
-
1137
+
1139
1138
data = (highByte << 8 ) | lowByte ;
1140
1139
boot_page_fill (tempAddress ,data );
1141
1140
@@ -1162,10 +1161,10 @@ int main(void)
1162
1161
uint16_t ii = address >> 1 ;
1163
1162
/* write EEPROM */
1164
1163
while (size ) {
1165
- eeprom_write_byte ((uint8_t * )ii , * p ++ );
1166
- address += 2 ; // Select next EEPROM byte
1167
- ii ++ ;
1168
- size -- ;
1164
+ eeprom_write_byte ((uint8_t * )ii , * p ++ );
1165
+ address += 2 ; // Select next EEPROM byte
1166
+ ii ++ ;
1167
+ size -- ;
1169
1168
}
1170
1169
msgLength = 2 ;
1171
1170
msgBuffer [1 ] = STATUS_CMD_OK ;
You can’t perform that action at this time.
0 commit comments