Bootloader can check programming data from extrenal EEPROM

I want to write my own bootloader but with a difference . I want to check the programming data from extranal EEPROM.Is that possible?

What bootloader I have in Arduino Genuino?

What language use the bootloader?

death_soldier:
What language use the bootloader?

The optiboot bootloader is written in a mixture of the c and asm programming languages.

If you want to write your own to program from an external SPI flash/eeprom chip then it might be worth looking at this bootloader for some ideas.

Thanks, But what bootloader I Have in Uno? The site Arduino have many versions I can understand.
which is the correct

https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr/bootloaders

death_soldier:
Thanks, But what bootloader I Have in Uno?

Optiboot

Ok.Thanks a lot...I'll try to begin to write my own bootloader with that..
The Genuino have the same bootloader?

death_soldier:
The Genuino have the same bootloader?

What one, there are several.

Genuino UNO

To write a bootloader for arduino need to change the optiboot.c only ? or I need special programm like WINAVR?

death_soldier:
To write a bootloader for arduino need to change the optiboot.c only ? or I need special programm like WINAVR?

You will at least need to edit the optiboot.c file and possibly also the boot.h, pin_defs.h & stk500.h header files.
The AVR compiler is included as part of the Arduino IDE installation and the nice/helpful think about the optiboot setup is you only need to open a command prompt, navigate to the optiboot folder and execute the omake.bat file with the target chip your making for. Assuming you have not moved the directory structure around it should work as it uses relative paths to all the AVR compiler/linker.

There are other things to consider like bootloader size, bootloader burning & fusebits but that's a long long way down the line from where you are now

Some of this is a repeat of what Riva posted while I was writing but there's some additional information also:

death_soldier:
Genuino UNO

Yes the Arduino Uno and the Genuino Uno both use the optiboot source files from the link Riva posted. That's an outdated version of Optiboot so you may want to use the up to date Optiboot as the reference for your bootloader:

death_soldier:
To write a bootloader for arduino need to change the optiboot.c only ? or I need special programm like WINAVR?

After you modify the bootloader source code you need to compile it to a .hex file that will be uploaded to the Uno. Optiboot includes a makefile that makes this easy. Arduino IDE includes AVR-GCC, which is the compiler, but unfortunately Arduino stopped including make with the IDE around IDE version 1.0.6. So you can either get make from a copy of Arduino IDE 1.0.6 or from WinAVR. Other than that you can just use the tools included with the Arduino IDE

Is there a tutorial which explain the working of bootloader ?

My main task is to download a programm from the ESP8266 to an extrenal EEPROM and then to Arduino. I want to make update firmware OTA.

I think if I could read/write from extrenal EEPROM and update the frimware, I'll make the update. Is that correct??

There are already some projects around that allow you to update the firmware on your Uno over WiFi using an ESP8266. No need for the EEPROM or a special bootloader, it just uploads the sketch via serial using the standard bootloader. Just do some searching around, I'm sure you'll find it. The tutorial I saw(I think it was on Hackaday) had the terrible advice of directly connecting one of the Uno's pins to the reset pin to do the hard reset that activates the bootloader. That's a bad idea, specifically recommended against by Atmel because you may not get a long enough LOW pulse. There's probably some kind of a hardware workaround involving a capacitor or get crazy and throw an ATtiny in there. You could also use one of the ESP8266's GPIOs to reset the Uno but I believe they were using the AT firmware on the ESP8266 so that would be more work to write your own ESP8266 firmware. You could also fairly easily modify optiboot to activate the bootloader on watchdog resets instead of only on hard resets, a much easier task than your previous plan to write an EEPROM bootloader and still a great introduction into bootloaders.

I found that link ESP8266 Update the firmware Arduino OTA

Can someone tell me if that works?

I think that's the one I saw. They have pin 12 directly connected to reset. It might work but it's specifically not recommended by Atmel, the manufacturer of the ATmega328P. As I said before, one option is for you to modify the bootloader so that you could use a watchdog reset to activate it. I think this is a good solution because it won't use one of your pins and you were wanting to try your hand at modifying the bootloader anyway.

Have a look on this Bootloader: Bitbucket

It's a modified version of Optiboot which interacts with internal EEPROM and external Flash over SPI. It's designed to perform firmware upgrade from the data stored on the SPI Flash, which the main program can do it over-the-air. I tried to keep the code as easier as possible to read, but some parts might use some unsual coding just to save space.

Ok thanks a lot for that.. Where I can read the exactly work of the Bootloader?

Another Question is the update firmware can be done with sending only the .hex file?

The boot loader doesn't have any specific work or function. Imagine it as a second firmware/software that runs on the MCU every time it boots or powers-up.

The idea is to keep this software on a protected area in the MCU's flash memory, like a PC Bios, independent of the operating system you run, the Bios will always be there to define if the PC will boot from the internal HD, USB, CD, etc...

Although is very common to use the bootloader as a way to provide alternative methods to upload a new firmware, it can be used for anything. On Arduino it's basically used to accept upload via Serial as the Atmega doesn't support it.

Regarding the other question, yes, the idea is to upload the HEX file over the air so the main program can save it into the external flash, and, on the next boot cycle the bootloader will try to install it, copying from the external flash to the MCUs flash memory.