usbasploader / wdt_disable

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
chrysn
Posts: 1
Joined: Sat Nov 06, 2010 5:22 pm

usbasploader / wdt_disable

Post by chrysn » Sat Nov 06, 2010 7:56 pm

i am using usbasploader in a setup where i define a vendor usb command in the flashed program that makes the avr reset via

Code: Select all

wdt_enable(WDTO_15MS);
for(;;)
    _delay_ms(1);


concerning changes to the default config in the first place, i disabled the check in the
default bootLoaderInit for MCUCSR. (NB: MCUCSR is defined as MCUSR on some chips)

when i reset like this with the bootLoaderCondition ==
  • false, the reset restarts the program i flashed on top of usbasploader. otherwise, when i reset with the condition
  • true, it seems like the programmer is stuck somehow (as soon as i remove the jumper, the bootloader boots into the flashed program).

it seems that the problem is related to the wdt_disable in usbasploader. according to the libavr documentation, MCUSR has to be set to 0 before wdt_disable().

would it be reasonable to generally (in the sense of the next version of usbasploader) move the wdt_disable call to bootLoaderInit, extract MCUC?SR to a mirror as described in the documentation after setting MCUCSR to 0?

the bootLoaderInit code i'm finally using is:

Code: Select all

    PORTD |= (1 << JUMPER_BIT);     /* activate pull-up */
    if(!(MCUCSR & ((1 << EXTRF) | (1 << WDRF))))    /* If this was not an external reset or a watchdog reset, ignore */
        leaveBootloader();
    MCUCSR = 0;                     /* clear all reset flags for next time */
    wdt_disable();                  /* main app may have enabled watchdog */

Post Reply