-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remote reboot #180
Comments
You'll need to clear MCUSR and jump to bootloader directly without using watchdog. Something like that (should work, not tested):
|
What is the address (FLASHEND-511)>>1? |
When I call
I'v tried different serial rates - 19200 and 57600, result is the same. |
Optiboot typically (on Atmega328) fits in last 512 bytes of memory, so FLASHEND-511 is first location of bootloader. Because AVR use word adressing, so that's why it's divided by two (>>1). About you issue: Optiboot assumes few things to minimize size. I think it could be problem with enabled interrupts. If I'm right, placing cli() (or noInterrupts() in Arduino) before do_reboot() should fix this. |
Great, |
I guess the first location of bootloader address must be saved somewhere. I want to make general solution for other arduino boards. Is it possible to read it from the memory or get constant pointed to the address? |
Nice to hear that it works :-) About location: you could always read fuses and interpret it for every chip - hardcore way :-) But for standard Optiboot (without VIRTUAL_BOOT_PARTITION and BIGBOOT for smaller chips) it could be much easier: just check in #ifdef for RAMPZ and use 1023 for chips with it, and 511 otherwise. |
You can derive the bootloader start address from the fuse bits (which can be read by an application.) Note that there are still ATmega328 Arduino boards that use the older (2k) bootloader... |
Thanks for your help! |
Please tell me, that it's not possible to get optiboot baudrate from code? I just want to be sure. |
I am also trying to remotely upload sketches (without physical access to the slave AVR). I tried the jump to bootloader code (suggested by @majekw ) which seems to partially work but the bootloader flashing LEDs blink way too rapidly, and I cannot upload, almost like the bootloader is running in hyperspeed. (maybe because the chip is really a 328PB running a bootloader claiming to be a 328p, i dunno) I believe I have a safe solution that will allow a watchdog to reset into the bootloader, but I am stuck on manually setting the MCUSR flags in the application, if that's possible.
With the above modification (taken from post 3 here) the only thing that matters is the external reset flag. The key is being able to set the _BV(EXTRF flag manually within the application when a special packet is received over the RS485 link. This would effectively "fake" an external reset (for the next boot only) since my bootloader no longer cares if the watchdog was used. |
You can't set bits in MCUSR from a program; you can only clear them. |
there must be a way to use the watchdog to get into the bootloader to upload a sketch. I guess I will look into using GPIO registers or eeprom, unless someone else sees some glaring problem there too. |
With v7, you can now set MCUSR to zero and jump to the bootloader start address. |
I have tried this (for a similar bluetooth flashing scenario as the original issue) and it works very well. I set MCUSR to zero prior to jumping to the bootloader, but the only issue I have remaining is that optiboot doesn't exit after successfully flashing. I have the flash-on-data option enabled, so the LED continuously flashes, and it continuously sends mostly zeroes over serial. Superficially the reason might appear to be that the watchdog reset which should run the sketch never happens, somehow, though I can't think why. Any ideas? EDIT: may be relevant that I'm running master (55d1e6b) and using the TIMEOUT=4 build option. |
Did you do the whole "reset peripherals and disable interrupts before jumping to the bootloader" (that would include disabling the watchdog, if you had turned it on.) |
Hi,
I want to upload arduino sketch over the air.
My arduino's (pro mini 8M) rx tx pins connected to bluetooth HC-05. I've made software, witch handle avrdude's events and sends special command (e.g. RESET\n). When arduino receive this command, it must reboot and wait new sketch. It works well with 1 wire connected to the RESET pin. But when I do the same without a wire, but with watchdog and when I call
wdt_enable(WDTO_15MS);
I don't see flashing of onboard LED. Program just restart without entering to stk500 command mode.It would be perfect if I had something like this:
But I don't know how to set MCUSR flag correct and come over this expression in optiboot.c file.
Do you have any ideas?
The text was updated successfully, but these errors were encountered: