HomeACcessoryKid / life-cycle-manager

Initial install, WiFi settings and over the air firmware upgrades for any esp-open-rtos repository on GitHub
Apache License 2.0
60 stars 11 forks source link

How to adjust the user app #7

Closed kesselborn closed 5 years ago

kesselborn commented 5 years ago

hey, super excited about this project, thanks a lot for your work. I am currently playing around with it and doing the first OTA worked like a charm. However: how can I do subsequent updates. In the README.md it says "The user app only requires a few simple lines of code so no increase in RAM usage or complexity and an overall smaller flash footprint". Do you have an example of those necessary lines? Can't really find any -- or perhaps I am misunderstanding something ... very well possible.

So, currently my device seems to immediately boot into the user app (as it starts blinking really fast), how can I force it to boot into the OTA part again?

Thanks

kesselborn commented 5 years ago

ah.. or do I just always copy the ota_task function into my app?

HomeACcessoryKid commented 5 years ago

You are right that I forgot to mention it in the LCM repo itself.

the answer is to add this to your code = user code

// the below two lines are the ONLY thing needed for a repo to support ota after having started with ota-boot
rboot_set_temp_rom(1); //select the OTA main routine
sdk_system_restart();  //#include <rboot-api.h>
// there is a bug in the esp SDK such that if you do not power cycle the chip after flashing, restart is unreliable

Where to put this in your code is up to you. Make it a response to a gpio input, a web page button, a timer (but avoid that if your code gets used by a lot of devices, all devices trigger in the same moment!) etc...

See https://github.com/HomeACcessoryKid/ota-demo for an example...

kesselborn commented 5 years ago

great! thanks a lot for your swift response -- I got everything working and am super happy with this.

Thanks again for your work -- closing this as fixed