File tree 1 file changed +20
-3
lines changed
1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -227,16 +227,33 @@ avr_interrupt_reti(
227
227
table -> running [table -> running_ptr - 1 ]-> vector : 0 );
228
228
}
229
229
230
+ static int bootloader_size_avr328 (avr_t * avr )
231
+ {
232
+ const char efuse = avr -> fuse [2 ];
233
+ const char bootsz = (efuse >> 1 ) & 0x3 ;
234
+
235
+ switch (bootsz )
236
+ {
237
+ case 0 :
238
+ return 256 * 2 ;
239
+ case 1 :
240
+ return 512 * 2 ;
241
+ case 2 :
242
+ return 1024 * 2 ;
243
+ default :
244
+ return 2048 * 2 ;
245
+ }
246
+ }
247
+
230
248
static int interrupt_table_offset (avr_t * avr )
231
249
{
232
250
const int mcucr = _SFR_IO8 (0x35 );
233
251
const int ivsel = 1 ;
234
252
const char interrupt_sector_moved_to_bootloader = avr -> data [mcucr ] & (1 << ivsel );
235
253
236
- const int bootloader_size = 0x800 ;
237
-
254
+ const int flash_size = avr -> flashend + 1 ;
238
255
if (interrupt_sector_moved_to_bootloader )
239
- return avr -> flashend - bootloader_size + 1 ;
256
+ return flash_size - bootloader_size_avr328 ( avr ) ;
240
257
241
258
return 0 ;
242
259
}
You can’t perform that action at this time.
0 commit comments