One change involved eliminating the wdt_reset() call, which seems fine since 1) the wdt is disabled at the beginning of main(), b) it's not re-enabled anywhere I can see in this code or the usbdrv/ code, and c) it's not reset anywhere else in the code, so if say a fuse bit had it locked on all the time, the code wouldn't have worked to begin with.
(I'm sending this to the maintainers too)
Code: Select all
--- USBaspLoader.2012-12-08/firmware/main.c
+++ USBaspLoader.2012-12-08-opt/firmware/main.c
@@ -265,7 +265,7 @@
if(len > bytesRemaining)
len = bytesRemaining;
bytesRemaining -= len;
- for(i = 0; i < len; i++){
+ for(i = len; i > 0; i--){
if(currentRequest >= USBASP_FUNC_READEEPROM){
*data = eeprom_read_byte((void *)currentAddress.w[0]);
}else{
@@ -281,20 +281,15 @@
static void initForUsbConnectivity(void)
{
-uchar i = 0;
-
usbInit();
/* enforce USB re-enumerate: */
usbDeviceDisconnect(); /* do this while interrupts are disabled */
- while(--i){ /* fake USB disconnect for > 250 ms */
- wdt_reset();
- _delay_ms(1);
- }
+ _delay_ms(251); /* fake USB disconnect for > 250 ms */
usbDeviceConnect();
sei();
}
-int __attribute__((noreturn)) main(void)
+int __attribute__((noreturn,OS_main)) main(void)
{
/* initialize */
wdt_disable(); /* main app may have enabled watchdog */
@@ -306,14 +301,13 @@
GICR = (1 << IVSEL); /* move interrupts to boot flash section */
#endif
if(bootLoaderCondition()){
- uchar i = 0, j = 0;
+ unsigned i = 0;
initForUsbConnectivity();
do{
usbPoll();
#if BOOTLOADER_CAN_EXIT
if(requestBootLoaderExit){
if(--i == 0){
- if(--j == 0)
break;
}
}