reset via bat file?

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was wondering, if a flash app can flash via bootloader and reset my device, there must be away to do this. Is there a means of resetting an app via a small tool or from a bat file?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Depends on what programmer you have and what software you are using. Do you want to reset the AVR even when the programmer isn't attached? What's wrong with a reset button?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

surely the bootloader has a reset command.

"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is not for me its for users, but yeah I left out an important note. I'm using the bootloader via usb. I guess this is more of a question for the boot loader author huh?

On a second note, I do have a more appropriate similar question.

For my device I want to reset the chip via code ( my reset pin is pc6 so its disabled ).I do this by looping the watch dog.

wdt_disable();
wdt_enable(WDTO_15MS);
while (1) {}

but it never comes back to life. If I were to use the reset pin, it does. Again this may be related to the usb, not sure. as long as re-runs the firmware it should work. Now the strange thing is when I use the watch dog trick I can no longer reset via my avr isp. I really dont get that at all? If I unplug the usb its back to normal. Its as though the watch dog is freezing it indefinitely .

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

the bootloader might detect the reason for reset was WDT, and is refusing to start the app for safety reasons ?

why not use

// disable watchdog
wdt_disable();

// disable interrupts
cli();

// jump to (call) bootloader at 0xE00
((void(*)(void))0x0E00)());

The stack will get reinitialised anyway, so it's safe to "call" the reset vector or bootloader.

"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

but it never comes back to life.

When it attempts to it's the bootloader that takes control first. Wonder if it's written to take note of:
Quote:
Note that for newer devices (ATmega88 and newer, effectively any AVR that has the option to also generate interrupts), the watchdog timer remains active even after a system reset (except a power-on condition), using the fastest prescaler value (approximately 15 ms). It is therefore required to turn off the watchdog early during program startup, the datasheet recommends a sequence like the following:

from:

http://www.nongnu.org/avr-libc/u...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah that is what that link was saying. so how do you get this jump to work?

((void(*)(void))0x0E00)());
main.c:442: error: expected ';' before ')' token

oh
( ( (void(*)(void) ) 0x0E00) () );

---hmm that just froze the usb. but I thing the 328 has a different start address. bootsize is 1024 and 3c00 didnt work.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A 328 has 32K of memory addressed (in bytes) from 0x0000 to 0x7FFF. A bootloader is therefore going to be up in the 0x7000's. I'd try something like:

typedef void (*f_ptr_t)(void);

f_ptr_t boot_entry = (f_ptr_t) 0x7800;

boot_entry();

Adjust the 0x7800 to the right value.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
((void(*)(void))0x0E00)());
main.c:442: error: expected ';' before ')' token 

Ooh, that bracket must of fallen off when editing the post. Clawson's solution is more elegant anyway, and both generate code that is exactly the same.

"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yup that got it!