i'm trying to implement a "jump to bootloader" command, so that i don't have to press the reset button to reprogram.
as i understand it, the usual way to do this is by enabling the watchdog, but from looking at the bootloader source on github:
https://github.com/adafruit/lufa-lib/bl ... CDC.c#L139
it seems that a simple watchdog won't do it, since accessing the bootloader requires that the EXTRF bit in MCUSR be set. i.e., it needs to be an external reset, not a watchdog. i was hoping i could simply set the EXTRF bit before watchdogging, but that's not working.
does anyone have a recipe (from C, not Arduinoland) to accomplish what i need?
paul
atmega32u4 jump to bootloader?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: atmega32u4 jump to bootloader?
I don't have the ATmega32u4 datasheet in easy reach, but IIRC its watchdog timer has three output options: it can generate an interrupt internally, it can trigger a hardware reset, or it can do both.
The datasheet will have a section that covers the WDT's behavior and settings. Take a look at that to get the register settings necessary.
The datasheet will have a section that covers the WDT's behavior and settings. Take a look at that to get the register settings necessary.
- pgf
- Posts: 5
- Joined: Mon Apr 04, 2011 9:01 pm
Re: atmega32u4 jump to bootloader?
i'm definitely getting a reset. that's not the problem. the problem is that after the reset, my code starts immediately. i want the bootloader to start, instead.adafruit_support_mike wrote:I don't have the ATmega32u4 datasheet in easy reach, but IIRC its watchdog timer has three output options: it can generate an interrupt internally, it can trigger a hardware reset, or it can do both.
The datasheet will have a section that covers rhe WDT's behavior and settings. Take a look at that to get the resister settings necessary.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: atmega32u4 jump to bootloader?
I did some more digging once I got my hands on the datasheet again.
Use table 27-8 from the Memory Programming section of the datasheet to locate the starting address of bootloader memory, and write that to the WDT's interrupt vector (address 0x0018)
Use table 27-8 from the Memory Programming section of the datasheet to locate the starting address of bootloader memory, and write that to the WDT's interrupt vector (address 0x0018)
- pgf
- Posts: 5
- Joined: Mon Apr 04, 2011 9:01 pm
Re: atmega32u4 jump to bootloader?
oh, good idea! i'll try that.
Please be positive and constructive with your questions and comments.