FOTA example with custom Server

DomalysAlexis
Posts: 3
Joined: Thu Mar 02, 2017 11:01 pm

FOTA example with custom Server

Postby DomalysAlexis » Thu Apr 13, 2017 11:11 pm

Hello,

I have some difficulties to found example code for FOTA with custom server (without using espressif cloud). The application note is not enough clear for using with custom server.

Could you provide me some example code (esp side and server side)?

User avatar
pratik
Posts: 383
Joined: Wed Jun 29, 2016 7:17 pm
Location: India
Contact:

Re: FOTA example with custom Server

Postby pratik » Wed Apr 26, 2017 1:45 pm

The FOTA operation can be done using nonOS or RTOS SDK APIs for FOTA. Please consult the SDK API documentation on functions that write the flash.
We do not have a generic code for all this because the server architecture might be of any type of form. You can update ESP flash from anything... memory card, UART, server - just about anything! This makes creating an useful app note difficult. Just refer to the APIs, you should get the logic from there.

A suggestion - develop the server end first and program the ESP8266 accordingly using SDK APIs. Other way round will be more complex.
Regards,
Pratik Panda
Website: http://www.PratikPanda.com

Custom firmware, Knowledge base and freelancing (ESP8266/ESP32):
http://www.iot-bits.com

AgentSmithers
Posts: 19
Joined: Sat Apr 01, 2017 1:21 am

Re: FOTA example with custom Server

Postby AgentSmithers » Mon May 01, 2017 2:10 pm

DomalysAlexis wrote:Hello,

I have some difficulties to found example code for FOTA with custom server (without using espressif cloud). The application note is not enough clear for using with custom server.

Could you provide me some example code (esp side and server side)?



Domaly,
I am having the very same issue. If you like we can try to tackle the problem together, Maybe Via Skype if you like?
From my understanding the firmware has to be made using a MAKEFILE setting known as "Version 2". I went through the full documentation and there are points that are not totally clear. From my understanding is you call an API to see which BOOT file you are currently working out of then you write to the sector your not booted on, However I do not know which sector to really target. Judging by some of the doc's it seems that a FOTA layout is different then a normal layout and that isent really described well in the document from what I recall reading. One the Firmware is written you then reboot and call the same API again to see it swapped to the other boot partition then write to the other one.. Again, I am not clear on this at all. I am unable to find the answers I am looking for but I did go through some source code to try and identify a logic to the FOTA. I am using Blinky.c as an example and in my case I write my firmware to 0x10000, However the moment I try and write that during run time my chip crashes which is obviously a no no.
If anyone has ANY ticks on this process It would be greatly appreciated! Even point me to a place that has the answers on how the chip boots vs FOTA booting I will be glad to reach, But searching ALL over google I failed to find something that indicates a clear line being drawn on this topic.

User avatar
pratik
Posts: 383
Joined: Wed Jun 29, 2016 7:17 pm
Location: India
Contact:

Re: FOTA example with custom Server

Postby pratik » Sun May 14, 2017 8:53 pm

I can summarize the FOTA process for you.

The FOTA flash map specifies 2 copies of the firmware that can be executed. The boot.bin is responsible for deciding, at the time of booting, which copy of firmware will run. The info on which copy of firmware, user1.bin or user2.bin is latest and good is stored in system flash param area.

Now if you need to update the firmware, say when you are running user1.bin, you just need to download and write the area where user2.bin is stored. Then after verifying that the firmware is good, you can change the system param area to point to the updated bin file.

When the ESP8266 boots next the boot.bin will jump to the updated BIN!
user1.bin and user2.bin are the same thing. Just that you can modify user2.bin when running user1.bin and vice versa.

Hope this helps! How you download the new BIN does not matter. Could be over UART, or from a memory card or from a server - anywhere.
Regards,
Pratik Panda
Website: http://www.PratikPanda.com

Custom firmware, Knowledge base and freelancing (ESP8266/ESP32):
http://www.iot-bits.com

AgentSmithers
Posts: 19
Joined: Sat Apr 01, 2017 1:21 am

Re: FOTA example with custom Server

Postby AgentSmithers » Mon May 15, 2017 5:30 am

pratik wrote:I can summarize the FOTA process for you.

The FOTA flash map specifies 2 copies of the firmware that can be executed. The boot.bin is responsible for deciding, at the time of booting, which copy of firmware will run. The info on which copy of firmware, user1.bin or user2.bin is latest and good is stored in system flash param area.

Now if you need to update the firmware, say when you are running user1.bin, you just need to download and write the area where user2.bin is stored. Then after verifying that the firmware is good, you can change the system param area to point to the updated bin file.

When the ESP8266 boots next the boot.bin will jump to the updated BIN!
user1.bin and user2.bin are the same thing. Just that you can modify user2.bin when running user1.bin and vice versa.

Hope this helps! How you download the new BIN does not matter. Could be over UART, or from a memory card or from a server - anywhere.


Yes sir, I am tottally aware of that process. Thank you Kindly for responding. The Part I cant see ANY documentation on is how to make the FOTA firmware with the Blinky.C example.. I think I need an updated make file. Again, I've gone through document after document and google search after google search for this information and I can not locate anything solid. I am referring to the NONSDK Blinky.c example.
Thanks again for chiming in!

Post Script: I think there is a Version=2 argument that needs to be passed to the makefile?

User avatar
pratik
Posts: 383
Joined: Wed Jun 29, 2016 7:17 pm
Location: India
Contact:

Re: FOTA example with custom Server

Postby pratik » Fri May 19, 2017 5:44 pm

Yes, without the version information, there is no way of knowing whether to update or not.
However, it all depends on your update server implementation.
Regards,
Pratik Panda
Website: http://www.PratikPanda.com

Custom firmware, Knowledge base and freelancing (ESP8266/ESP32):
http://www.iot-bits.com

AgentSmithers
Posts: 19
Joined: Sat Apr 01, 2017 1:21 am

Re: FOTA example with custom Server

Postby AgentSmithers » Sat May 20, 2017 12:42 am

pratik wrote:Yes, without the version information, there is no way of knowing whether to update or not.
However, it all depends on your update server implementation.


Thank you Pratik for responding to this. I am not sure we are talking about the same "version". I am the latest NONOS SDK with open-esp-sdk. Does that help with the version information you need to answer my question or is there some other version information you are asking for?

Thanks again for chiming in!!

User avatar
pratik
Posts: 383
Joined: Wed Jun 29, 2016 7:17 pm
Location: India
Contact:

Re: FOTA example with custom Server

Postby pratik » Sun May 21, 2017 12:17 am

Not that, I was refering to firmware version number.
You can also follow a nomenclature that helps determine version on server and if it is different from current firmware running on your ESP, such as user_x.bin
Regards,
Pratik Panda
Website: http://www.PratikPanda.com

Custom firmware, Knowledge base and freelancing (ESP8266/ESP32):
http://www.iot-bits.com

AgentSmithers
Posts: 19
Joined: Sat Apr 01, 2017 1:21 am

Re: FOTA example with custom Server

Postby AgentSmithers » Mon May 22, 2017 2:50 am

pratik wrote:Not that, I was refering to firmware version number.
You can also follow a nomenclature that helps determine version on server and if it is different from current firmware running on your ESP, such as user_x.bin


Thanks Pratik!
When I say Version=2 it seems that it does something within the makefile commands to spit out the FOTA firmware in LU of the original. I guess the main issue I am having is locating a Makefile that will work properly and generate both User_x.bin firmware. The makefile I have right now only gives the NON-FOTA firmware.
Thanks again for Chiming in!

AgentSmithers
Posts: 19
Joined: Sat Apr 01, 2017 1:21 am

Re: FOTA example with custom Server

Postby AgentSmithers » Tue May 30, 2017 11:34 pm

Does anyone have any insight on this process?
Thank you for chiming in.

Who is online

Users browsing this forum: No registered users and 4 guests