Flash through host and Esptool

shar_tkt
Posts: 11
Joined: Tue Apr 11, 2017 3:20 pm

Flash through host and Esptool

Postby shar_tkt » Thu Jun 15, 2017 12:22 pm

Hi ,
The scenario is to download ESP fw through some medium to host and flash through it but not seeing any custom implementation.
Also ,if somebody has tried this approach and any issues associated with the same?

Esptool as python script might not be used as some platforms might not support it.

Also , is there C/C++/C# port of the tool (even just flashing part) ?

Thanks in advance.

rgds,
Shar_tkt

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Flash through host and Esptool

Postby kolban » Thu Jun 15, 2017 1:42 pm

One idea would be to write a REST server that handles POST requests. The firmware could then be posted to that REST server which writes the image as a temporary file and then invoked esptool.py via a "System" like call and finally deletes the file. For a task like this that one wanted done quickly, I'd probably suggest using Node.js. Alternatives might include Servlets (Tomcat).
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

f.h-f.s.
Posts: 214
Joined: Thu Dec 08, 2016 2:53 pm

Re: Flash through host and Esptool

Postby f.h-f.s. » Thu Jun 15, 2017 3:39 pm

Why not update OTA?

shar_tkt
Posts: 11
Joined: Tue Apr 11, 2017 3:20 pm

Re: Flash through host and Esptool

Postby shar_tkt » Thu Jun 15, 2017 3:47 pm

Thanks both,

@kolban : I was specifically looking for c# as Compact Framework does not support any form of python.

@f.h-f.s.: The requirement is non-ota method as fail-safe method if esp has issues with connection to router or vice-versa.
This is in accordance with existing solution for other flashing devices.

f.h-f.s.
Posts: 214
Joined: Thu Dec 08, 2016 2:53 pm

Re: Flash through host and Esptool

Postby f.h-f.s. » Thu Jun 15, 2017 4:51 pm

Does the host pc have wifi?
You could put your ESP32 into AP mode and connect with host, then OTA.

**EDIT** also you can create pre-compiled binaries of esptool viewtopic.php?t=1029

shar_tkt
Posts: 11
Joined: Tue Apr 11, 2017 3:20 pm

Re: Flash through host and Esptool

Postby shar_tkt » Thu Jun 15, 2017 5:00 pm

Sorry it need to flash from host silicon to which ESP is exposed as module via ftdi as COM port.

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: Flash through host and Esptool

Postby loboris » Thu Jun 15, 2017 6:35 pm

shar_tkt wrote:Sorry it need to flash from host silicon to which ESP is exposed as module via ftdi as COM port.
You could use ymodem protocol to transfer the new firmware via serial port to ESP32, there are ymodem implementations in C/C++ & C#, for ESP32 implementation look at viewtopic.php?f=18&t=2148

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Flash through host and Esptool

Postby ESP_igrr » Fri Jun 16, 2017 1:35 am

esptool-ck (written in C) used to be able to flash ESP32, although I may have removed that support in recent commits seeing that this isn't being used. You may take a look at commit history and grab the version which still has ESP32 flashing support though.

shar_tkt
Posts: 11
Joined: Tue Apr 11, 2017 3:20 pm

Re: Flash through host and Esptool

Postby shar_tkt » Wed Jun 21, 2017 3:11 pm

Thanks both ,

@ESP_igrr
I took the esp32 support on the esptool-ck repo but seems some issues.

Commit Used:
Commits on Jan 25, 2016
@igrr
Update readme to mention ESP32
edb91368984ee13576667b8b7a865bea9f5035ee

Setup:
Trying as if using esptool.py , connect Wroom-23 to Linux VM , connection seems to be fine with no issue.

Command:
sudo ./esptool -cp /dev/ttyUSB0 -cd ck -cc esp32 -ca 0x10000 -cf esp-at.bin -v 4

Output:
Seems some issue during (FLASH_DOWNLOAD_BEGIN) , no response seen from module and exiting.
Let me know if customization required or if it is known issue (could not find in issue section).
I assume this is C port of esptool.py and has equivalent features of same.


Attaching verbose log.

esptool v0.4.6-9-gedb9136 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
setting port from /dev/ttyUSB0 to /dev/ttyUSB0
setting board to ck
setting chip to esp32
setting address from 0x00000000 to 0x00010000
espcomm_upload_file
stat esp-at.bin success
opening port /dev/ttyUSB0 at 115200
tcgetattr
tcsetattr
serial open
opening bootloader
resetting board
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: didn't receive command response
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: receiving 4 bytes of data
espcomm_send_command: received 4 bytes:
0x00
0x00
0x00
0x00
espcomm_send_command: response 0x55201207
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: receiving 4 bytes of data
espcomm_send_command: received 4 bytes:
0x00
0x00
0x00
0x00
espcomm_send_command: response 0x20120707
espcomm_send_command: receiving 4 bytes of data
espcomm_send_command: received 4 bytes:
0x00
0x00
0x00
0x00
espcomm_send_command: response 0x20120707
espcomm_send_command: receiving 4 bytes of data
espcomm_send_command: received 4 bytes:
0x00
0x00
0x00
0x00
espcomm_send_command: response 0x20120707
espcomm_send_command: receiving 4 bytes of data
espcomm_send_command: received 4 bytes:
0x00
0x00
0x00
0x00
espcomm_send_command: response 0x20120707
espcomm_send_command: receiving 4 bytes of data
espcomm_send_command: received 4 bytes:
0x00
0x00
0x00
0x00
espcomm_send_command: response 0x20120707
espcomm_send_command: receiving 4 bytes of data
espcomm_send_command: received 4 bytes:
0x00
0x00
0x00
0x00
espcomm_send_command: response 0x20120707
espcomm_send_command: receiving 4 bytes of data
espcomm_send_command: received 4 bytes:
0x00
0x00
0x00
0x00
espcomm_send_command: response 0x20120707
espcomm_send_command: receiving 4 bytes of data
espcomm_send_command: received 4 bytes:
0x00
0x00
0x00
0x00
espcomm_send_command: response 0x20120707
espcomm_open
Uploading 825696 bytes from esp-at.bin to flash at 0x00010000
erasing flash
size: 0c9960 address: 010000
espcomm_set_flash_params: 0 1000000 10000 1000 100 ffff
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: receiving 4 bytes of data
espcomm_send_command: received 4 bytes:
0x00
0x00
0x00
0x00
espcomm_send_command: response 0x20120707
erase_size: 0c9960
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
setting timeout 15000
setting character timeout 150
done
setting timeout 1
setting character timeout 1
done
warning: espcomm_send_command: didn't receive command response
warning: espcomm_send_command(FLASH_DOWNLOAD_BEGIN) failed
closing bootloader

Michael Santos
Posts: 1
Joined: Wed Jun 28, 2017 4:07 pm

Re: Flash through host and Esptool

Postby Michael Santos » Thu Jun 29, 2017 1:27 pm

Hello!

I find myself in a similar situation. I also need an over the wire firmware update solution in C/C++. The reason, also being that the host can only run C/C++. I tried using esptool-ck, but without any luck. The .bin files can be created using the esptool.py, I "just" need a way to flash the .bin files on the esp32 using C/C++. @shar_tkt, any luck in achieving something similar to this?

Thanks for the help!
P.S. It has been really fun playing with the esp32!

Who is online

Users browsing this forum: No registered users and 98 guests