How to import Arduino library into optiboot loader to include I2C communication?


I am trying to add i2c instead of serial to flash Arduino. How can I import Wire library into your code using Atmel studio IDE?

I have done the library import by the particular file structure but that thing I am unable to find into your code. If possible could you help me regarding this query?

  • i2c communications with WHAT, exactly? optiboot doesn't speak to "serial" in general, it specifically interacts with software on the other end of the serial port that uses the STK500v1 protocol (or parts of it, anyway.) You'd need an equivalent protocol for I2C, except I2C isn't usually considered the same class of communications, so it would probably be much different.
  • About 90% of optiboot consists of dealing with the serial port and the stk500 protocol. if you want to replace that code with i2c to an eeprom, for example, there would be very little of optiboot left, and it's probably not worth trying to start with optiboot.
  • You can't use the "Wire Library" inside a bootloader, because it uses other features from the "Arduino Environment" that are not available in a bootloader. You can't write bootloaders as an Arduino sketch...

I want to update the Arduino from external EEPROM and I have created the code for external EEPROM using twi library but now its size increased to 3.5Kb. Is there any way to increase bootloader space in Arduino?

Yes, through fuse settings: high fuse, BOOTSZ bits. ATmega 328P can have 4kB max.