Skip to content
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

Upload failed Server returned status code 0 / callbacks not shown in serial #230

Closed
juanmartin84 opened this issue Oct 28, 2024 · 8 comments
Labels

Comments

@juanmartin84
Copy link

Hello, i'm using ElegantOTA.h version 3.0.0 with AsyncDemo code in platformio.
After select the file.bin to apload nothing is shown in serial monitor.

10:43:39.699 > IP address: 192.168.1.18
10:43:39.715 > HTTP server started

At the end in the browser appears "Upload failed Server returned status code 0"

image

Below the .ini file

board_build.flash_mode = dio
board_upload.flash_size = 4MB

board_build.f_cpu = 240000000L ;set clock frequency to 240MHz
board_build.f_flash = 80000000L ; set flash frequency to 80MHz
board_build.partitions = partition_table_HUGE_APP.csv ;https://github.com/espressif/arduino-esp32/tree/master/tools/partitions
board_build.filesystem = littlefs

upload_speed = 921600
upload_port = COM[34]; COM3 or COM4

lib_deps = 
  mathieucarbou/ESPAsyncWebServer@^3.1.1
  mathieucarbou/AsyncTCP@^3.2.3
  bblanchon/ArduinoJson@^7.1.0
  knolleary/PubSubClient@^2.8
  fbiego/ESP32Time@^2.0.6
  adafruit/Adafruit ADS1X15@^2.5.0

lib_compat_mode = strict

Below the code:

AsyncWebServer otaServer(80);

unsigned long ota_progress_millis = 0;

void onOTAStart(void) {
  // Log when OTA has started
  Serial.println("OTA update started!");
  // <Add your own code here>
}

void onOTAProgress(size_t current, size_t final) {
  // Log every 1 second
  if (millis() - ota_progress_millis > 1000) {
    ota_progress_millis = millis();
    Serial.printf("OTA Progress Current: %u bytes, Final: %u bytes\n", current, final);
  }
}

void onOTAEnd(bool success) {
  // Log when OTA has finished
  if (success) {
    Serial.println("OTA update finished successfully!");
  } else {
    Serial.println("There was an error during OTA update!");
  }
  // <Add your own code here>
}

void otaSetup(void) {

  String RouterSSID = ReadEpromMaster(0,16,"RouterSSID");//setupWifi
  String RouterPASS = ReadEpromMaster(16,32,"RouterPASS");//setupWifi
  delay(10);

  WiFi.begin(RouterSSID.c_str(), RouterPASS.c_str());
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(RouterSSID);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  otaServer.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send(200, "text/plain", "Hi! This is ElegantOTA AsyncDemo.");
  });

  ElegantOTA.begin(&otaServer);    // Start ElegantOTA
  // ElegantOTA callbacks
  ElegantOTA.onStart(onOTAStart);
  ElegantOTA.onProgress(onOTAProgress);
  ElegantOTA.onEnd(onOTAEnd);

  otaServer.begin();
  Serial.println("HTTP server started");
}

void otaLoop(void) {
  ElegantOTA.loop();
}

What can be happening?
Thanks

@ayushsharma82
Copy link
Owner

@juanmartin84 You are using "Huge App" partition table, it doesn't contain any partition for OTA updates.

board_build.partitions = partition_table_HUGE_APP.csv ;https://github.com/espressif/arduino-esp32/tree/master/tools/partitions

@mathieucarbou
Copy link
Contributor

mathieucarbou commented Oct 28, 2024

@juanmartin84 : for big firmwares (more than 2Mb) you can use MycilaSafeBoot which allows to have a smaller recovery partition used for OTA flash and a bigger app partition, more than 3Mb / 7Mb depending on the flash size (4Mb or 8Mb). MycilaSafeBoot includes ElegantOTA.

https://github.com/mathieucarbou/MycilaSafeBoot

@juanmartin84
Copy link
Author

Hello @ayushsharma82 @mathieucarbou , thanks for recommendations.
I used this in the .ini file and since I have16mb flash available and seems to be working.

board_upload.flash_size = 16MB
board_build.partitions = app3M_spiffs9M_fact512k_16MB.csv
board_build.filesystem = littlefs

Best regards

@Gifford47
Copy link

Gifford47 commented Nov 3, 2024

Hi!
@ayushsharma82 @mathieucarbou
I have the same issue with an ESP32 S3.
INI:

[env:HCP_Giffordv2a]
board = adafruit_feather_esp32s3		# https://docs.platformio.org/en/latest/frameworks/espidf.html#boards
build_flags = ${env:esp32.build_flags} -D SENSORS -D USE_HCSR501 -D USE_BME

I also get "status code 0".
which partition type have i to use?

@mathieucarbou
Copy link
Contributor

mathieucarbou commented Nov 3, 2024

Example of one I like to use:

# Name,   Type, SubType, Offset,   Size,    Flags
nvs,      data, nvs,     0x9000,   0x5000,
otadata,  data, ota,     0xE000,   0x2000,
app0,     app,  ota_0,   0x10000,  0x1F0000,
app1,     app,  ota_1,   0x200000, 0x1F0000,
spiffs,   data, spiffs,  0x3F0000, 0x10000,

which can also be written as:

# Name   ,Type ,SubType  ,Offset ,Size  ,Flags
nvs      ,data ,nvs      ,36K    ,20K   ,
otadata  ,data ,ota      ,56K    ,8K    ,
app0     ,app  ,ota_0    ,64K    ,1984K ,
app1     ,app  ,ota_1    ,2048K  ,1984K ,
spiffs   ,data ,spiffs   ,4032K  ,64K   ,

But you can decide to reduce the ota size, add a coredump, etc.

But in my bigger apps, I use MycilaSafeboot and I have then a huge app partition of 3.2Mb for a 4Mb flash

# Name   ,Type ,SubType  ,Offset ,Size  ,Flags
nvs      ,data ,nvs      ,36K    ,20K   ,
otadata  ,data ,ota      ,56K    ,8K    ,
safeboot ,app  ,factory  ,64K    ,640K  ,
app      ,app  ,ota_0    ,704K   ,3264K ,
spiffs   ,data ,spiffs   ,3968K  ,64K   ,
coredump ,data ,coredump ,4032K  ,64K   ,

And 7.3Mb for a 8Mb flash

# Name   ,Type ,SubType  ,Offset ,Size  ,Flags
nvs      ,data ,nvs      ,36K    ,20K   ,
otadata  ,data ,ota      ,56K    ,8K    ,
safeboot ,app  ,factory  ,64K    ,640K  ,
app      ,app  ,ota_0    ,704K   ,7312K ,
spiffs   ,data ,spiffs   ,8128K  ,64K   ,
coredump ,data ,coredump ,8192K  ,64K   ,

@Gifford47
Copy link

thx, now it works!

Copy link

github-actions bot commented Dec 4, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Dec 4, 2024
Copy link

github-actions bot commented Dec 9, 2024

This issue was closed because it has been stalled for 5 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants