Code Monkey home page Code Monkey logo

dualoptiboot's Introduction

DualOptiboot

Customized Optiboot bootloader allows reflashing Moteino/AVR boards from an external serial FLASH memory chip. This makes it possible to wirelessly program a Moteino remotely by first transferring the compiled HEX binary wirelessly (ex. with an RFM69 transceiver), then restarting the board to allow the bootloader to pick it up and reflash the atmega's program area. Copyright Felix Rusu (2013-2019), lowpowerlab.com/contact More at: http://lowpowerlab.com/Moteino

This Optiboot version is modified to add the capability of reflashing from an external SPI flash memory chip. As configured this will work with Moteinos provided a SPI flash chip is present on the dedicated onboard footprint.

Summary of how this Optiboot version works:

  • it looks for an external flash chip
  • if one is found (SPI returns valid data) it will further look for a new sketch flash image signature and size starting at address 0: FLXIMG:9999:XXXXXXXXXXX where: - 'FLXIMG' is fixed signature indicating FLASH chip contains a valid new flash image to be burned - '9999' are 4 size bytes indicating how long the new flash image is (how many bytes to read) - 'XXXXXX' are the de-hexified bytes of the flash pages to be burned - ':' colons have fixed positions (delimiters)
  • if no valid signature/size are found, it will skip and function as it normally would (listen to STK500 protocol on serial port)

The added code will result in a compiled size of just under 1kb (Originally Optiboot takes just under 0.5kb)


To compile copy the Optiboot.c and Makefile files where Optiboot is originally located, mine is at: arduino-install-dir\hardware\arduino\bootloaders\optiboot
Backup the original files andbefore overwrite both files.

Then compile by running:

  • make atmega328
  • make atmega1284p
  • For Moteino-8Mhz: make atmega328 AVR_FREQ=8000000L BAUD_RATE=57600

License

GPL 3.0. See License.txt file.

dualoptiboot's People

Contributors

lowpowerlab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dualoptiboot's Issues

Image size is 2 bytes but should be 4 bytes

The README refers to the image size as a 4-byte value. However, it is implemented in Optiboot.c as a 2-byte value. This means that images can be no larger than 64KiB, which is smaller than the 128KiB program memory of a MoteinoMEGA. In order to support larger programs, at least one more image size byte should be added.

WDRF bit is not cleared when the watchdog is turned off

Hi!

While troubleshooting some reset loops occurring when doing soft restarts, I noticed that WDRF is not cleared when turning off the watchdog. WDE is always set when WDRF is set causing a reset loop. Clearing it fixed my problem.

Many thanks for the great code!

void watchdogConfig(uint8_t x) {
  if (x == WATCHDOG_OFF)
	MCUSR &= ~(_BV(WDRF));
  WDTCSR = _BV(WDCE) | _BV(WDE);
  WDTCSR = x;
}

SAMD21 Support

Does this support the SAMD21?

This line suggests that it doesn't, but I've read that the Moteino M0 supports OTA updating?

Thanks!

SPI hardware enable

I just encountered a bug on a project that I traced to DualOptiboot.

The issue was that raw writes to the SPI pins (SK, MO, MI) were not working as expected in the main code. This only occurred on firmware reloads, not during normal power ons making it a particularly devious bug.

I think the issue is that in some situations DualOptiboot exits after loading new firmware but does not disable the SPI pins.

I fixed the problems by adding this line to my code. Perhaps you should check the codepaths and make sure this is done before the bootloader exits.

SPCR &= ~_BV(SPE);

DualOptiboot fails on arduino pro mini 8 MHz

I burned the Dualoptiboot_v5.0_atmega328_8mhz_57600baud_BlinkD9.hex to an Arduino pro mini (8MHz) using Sparkfun's pocket AVR programmer with AVRDude.

I changed the fuse values according to this diagram:
https://www.flickr.com/photos/15304611@N03/10585364014

Then I tried to program the board within Arduino IDE version 1.8.13, using an FTDI USB-to-Serial adaptor, with the Blink program.

Arduino terminal gets stuck at the synchronization stage. It seems that the STK-500 emulator cannot communicate with the board.

Am I doing something wrong? Is there any solution to this problem?

Thank you very much!

Header description of size bytes

The header bytes are described as:

"FLXIMG:9999:XXXXXXXXXXX where: ... -'9999' are 4 size bytes indicating how long the new flash image is (how many bytes to read)"

Should these four size bytes be in big or little endian format? Neither of them seem to work on my setup, so I assume that I'm doing something else wrong, but I would like to eliminate this as an issue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.