Skip to content

getFreeSketchSpace #3501

@Adrianotiger

Description

@Adrianotiger

Hardware:

Board: ESP32 Dev Module
Core Installation version: 1.0.4
IDE name: Arduino IDE
Flash Frequency: 40Mhz
PSRAM enabled: no
Upload Speed: 115200
Computer OS: Windows 10

Description:

I changed my partition table, to have OTA_0 with 1.5MB and OTA_1 with just 1MB:
image

The idea is to create an "update" partition with a small sketch that will update my big sketch on the other partition.

And now the 2 problems on getFreeSketchSpace function:
1- It does not return the free space, but the size of the entire partition.
2- It does not return the space of the entire partition, but the space of the next partition.

The output if I call getFreeSketchSpace and getSketchSize is:

Sketch size: 880 kb
Free size: 1024 kb
We are on: OTA 1

But the partition should be OTA 0 and with 1536kb!

So I begun to check the code.

The code on the ESP.cpp core is this one:

Sketch:

From https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/Esp.cpp#L205

uint32_t EspClass::getFreeSketchSpace () {
    const esp_partition_t* _partition = esp_ota_get_next_update_partition(NULL);
    if(!_partition){
        return 0;
    }

    return _partition->size;
}

The function name is completly wrong! It would have sense on the Update library. But if you call this function on the ESP, you think about free space after the sketch was uploaded and on the current partition.

But it returns the available space for a new sketch upload.

Probably it is too late to change the name or change the function code. But the returned value is not "Free Sketch Space", but "OTA Update Available Space".

To get the space of the active partition, esp_ota_get_running_partition()should be called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleIssue is stale stage (outdated/stuck)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions