-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update firmware over the FILE Upload handling. #35
Comments
This is the basic of it, but you need the latest git version of the ESP core as well (Update.runAsync was added yesterday). static void handle_update_progress_cb(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
uint32_t free_space = (system_free_sketch_space() - 0x1000) & 0xFFFFF000;
if (!index){
Update.runAsync(true);
if (!Update.begin(free_space)) {
Update.printError(Serial);
}
}
if (Update.write(data, len) != len) {
Update.printError(Serial);
}
if (final) {
if (!Update.end(true)){
Update.printError(Serial);
}
}
} |
Thanks. |
Please show the full example of the sketch for the update! |
Here is my complete working example, in case it is useful for someone:
|
Hi @klaasdc i'm looking for a way to update firmware in AP mode only directly connected to the ESP32 AP Here my code
|
Did you manage to make this work on the ESP32 ? |
hi @GeorgeFlorian, yep i manage it! |
Great ! Thank you ! Also, what kind of files do you upload to perform the update ? What extension do they need to have ? Will a simple .cpp suffice ? |
nope ! you have to send .bin file |
Wait, what ? Isn't this a method to update the code that's on the ESP32 ? There seems something that I don't get. |
In Arduino IDE menu -> Sketch -> Export Compiled Binary (https://arduino.stackexchange.com/questions/48431/how-to-get-the-firmware-hex-file-from-a-ino-file-containing-the-code/48564) - Use the Google, Luke... |
What is your dev env? For example in platformio when you launch "pio run"command, all files are parsed and compiled to make .bin file and then .bin file is flash in esp32. The ESP32 doesn't do anything about compiling his firmware. |
I am using Platformio IDE on VSCode.
Thank you, mate ! |
So you are looking for OTA Update or to Upload firmware through handle file from webserver? To perform OTA update through your network you need do this thing : |
Ok, so if you are using PIO you have to add extra script to your platformio.ini. This script can (for example) look like this: Import("env")
import shutil
import os
#
# Dump build environment (for debug)
#print env.Dump()
#
#
# Upload actions
#
def after_build(source, target, env):
shutil.copy(firmware_source, 'bin/firmware.bin')
# env.Execute("pio run -t buildfs")
# shutil.copy(spiffs_source, 'bin/spiffs.bin')
env.AddPostAction("buildprog", after_build)
firmware_source = os.path.join(env.subst("$BUILD_DIR"), "firmware.bin")
spiffs_source = os.path.join(env.subst("$BUILD_DIR"), "spiffs.bin") I'm using this with my ESP8266 PIO target, but I didn't see why this shouldn't work for ESP32 too... |
Which framework are you use? |
Shouldn't both methods end up with the same result: updating/changing the code that's running on the ESP32 ?
|
Try to add this line into your platformio.ini
save my Python code from my previous message to scripts/pio_copy.py and try to compile your sketch. After compiling there has to be bin/ directory in your project directory with firmware.bin file... |
The 2 methods have the same result: update the esp32 firmware. But they have to different workflow. With OTA, you can run firmware update platformio IDE like arduino IDE by using this command if you want the end-user perform update through web view by uploading file through html form you need to give the .bin file access for the end-user, or you need to give access to the source-code and the right to perform firmware build by run command |
So I have added
Then I've hit
So I've created a |
on platformio project, you can find the .bin file into |
I've tested this just now and it works. My platformi.ini looks like: ; PlatformIO Project Configuration File
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
http://git.xpablo.cz/xPablo.cz/encipheredEEPROMStrings.git
http://git.xpablo.cz/pablo2048/Interval.git
https://github.com/me-no-dev/AsyncTCP.git
https://github.com/me-no-dev/ESPAsyncWebServer.git
http://git.xpablo.cz/pablo2048/Trace.git
http://git.xpablo.cz/pablo2048/WiFiConfig.git
framework = arduino
upload_port = esp32.local
;upload_port=192.168.4.1
upload_speed = 230400
;board_build.partitions = xpablo.csv
;board_build.partitions = xpablo_noEEPROM.csv
build_flags =
;-fexceptions
;-D CORE_DEBUG_LEVEL=0
-D DEBUG_ESP_PORT=Serial
-D BOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
-D CORS_DEBUG
-D USE_OTA
-D USE_TRACE
-D FORMAT_SPIFFS_WHEN_FAILED=true
-D USE_WIFICONFIG
-D USE_NTP
;-D USE_PROFILING
-D USE_EDITOR
-D USE_HTTPUPDATE
extra_scripts = post:scripts/pio_copy.py
monitor_speed=115200 |
So, it makes a |
:-) My script just copies this file to non-hidden directory... |
yep |
I am sorry, I am a moron with 0 knowledge of Python. Build sometimes works, sometimes doesn't. It doesn't always produces a Also, I have some questions related to the firmware.bin file :
|
IIRC there is some guidance on how to upload binary files into ESP32 somewhere in PIO documentation... |
Also, I have no idea what to do with this: I am amazed of how much I don't know, and how lacking is the documentation. |
Ok - you are using VSCode so click on the terminal icon in Platformio toolbar ("PlatformIO: New Terminal") and then just type |
That does nothing. It doesn't even work. Actually, I don't have Also un-commenting your py script:
should do the same things as EDIT:By using Arduino IDE to upload files I did not have a spiffs.bin. My god, this feels good. I am genuinely happy right now. xD |
Can you please post screenshot what happen when you click on the terminal icon? |
By using Arduino IDE to upload files I did not have a spiffs.bin. My god, this feels good. I am genuinely happy right now. xD Thank you both so much !!! |
Soo, returning with a quick update: uploading
I have followed @lbernstone 's example |
Well, hard to guess - I'll do some tests at the weekend (if I get some spare time :-) )... |
I have a problem with updating firmware from AsyncWebServer.
In Serial I received:
Is there some kind of solution to this problem?
The text was updated successfully, but these errors were encountered: