VanceVagell / kv4p-ht

Open source handheld ham radio project KV4P-HT
GNU General Public License v3.0
316 stars 35 forks source link

[Android] Add ability to flash firmware directly from the Android app (no PC required) #72

Closed VanceVagell closed 5 days ago

VanceVagell commented 2 weeks ago

I think we can use one of these 2 libraries (probably the second one which is for Android):

https://github.com/bdureau/ESPLoader https://github.com/bdureau/BearConsole2/tree/master/app/src/main/java/com/altimeter/bdureau/bearconsole/Flash

VanceVagell commented 2 weeks ago

Actually it looks like the library used in that 2nd project is actually this one, which is a purer implementation:

https://github.com/ksksue/PhysicaloidLibrary

I will probably use this.

VanceVagell commented 2 weeks ago

Turns out Physicaloid can only be used with Arduino devices. However, the BearConsole2 project linked above extends it to also support ESP32. So we actually need to use both to get this to work.

VanceVagell commented 2 weeks ago

Turns out BearConsole2 was easy to update to remove the Physicaloid dependency, and we can use our existing UsbSerialPort object to reduce dependencies. I have this working locally, now adding a new activity to display flashing status / steps.

VanceVagell commented 5 days ago

I've got this working at a slow flashing speed, it takes about 5-10 minutes to completely flash a new firmware with it. This is still better than requiring people to go to the website, since it lets us package known-compatible firmware with each Android app release and they can install it with a single tap (and pushing buttons on the ESP32).

I'll file a separate feature request to get the stub loader working in RAM, which would speed this up considerably. I spent a day trying to get that to work, and could not. It's definitely possible, I'm just not familiar enough with ESP32 communication and debugging to iron out the kinks. The library we're using (bearconsole) doesn't use the stub loader either, so we have to build it ourselves.

I did already include a JSON version of the stub loader bytes in the project (under raw/) so we can install it once we figure out how.

VanceVagell commented 5 days ago

Issue #97 tracks the future speed-up using the stub loader in RAM would offer.