Skip to content

External flash write #8669

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

Closed
1 task done
savagerex opened this issue Sep 25, 2023 · 6 comments
Closed
1 task done

External flash write #8669

savagerex opened this issue Sep 25, 2023 · 6 comments
Labels
Type: Question Only question

Comments

@savagerex
Copy link

Board

ESP32 Wrover e

Device Description

External flash

Hardware Configuration

NONE

Version

v2.0.11

IDE Name

Arduino IDE

Operating System

Windows 11

Flash frequency

80M

PSRAM enabled

yes

Upload speed

921600

Description

i use "fwrite"API to write flash about 1.7M.

it need 22 seconds.

I think it spends too much time.

Is there any other API that can be faster?

Sketch

// Create a file in FAT FS
    ESP_LOGI(TAG, "Opening file");
    FILE *f = fopen("/extflash/hello.txt", "wb");
    if (f == NULL) {
        ESP_LOGE(TAG, "Failed to open file for writing");
        return;
    }
    //fprintf(f, "Written using ESP-IDF %s\n", esp_get_idf_version());
    for (i = 0; i < 1781999; i++) {
                DataBufWrite[i] = '1';
                //Serial.print(i);
    }
    StartTestTime = millis();                  
    fwrite (DataBufWrite, sizeof(uint8_t), 1782000, f);
    
    fclose(f);
    //ESP_LOGI(TAG, "File written");
    Serial.println("File written");
    EndTestTime = millis();
    Serial.print("**************Flash Write Time*************");
    Serial.println(EndTestTime - StartTestTime);

Debug Message

NONE

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@savagerex savagerex added the Status: Awaiting triage Issue is waiting for triage label Sep 25, 2023
@SuGlider
Copy link
Collaborator

I don't think that it can be speeded up. External flash shall be erased and then written, sector by sector, in sequence.
It takes time to write it for 1.7MB. For instance, flashing a new firmware with about 2MB will take longer as well.

Anyway, this code is based on an IDF component. Maybe asking in the IDF Forum may be better.

@SuGlider SuGlider added Type: Question Only question and removed Status: Awaiting triage Issue is waiting for triage labels Sep 25, 2023
@igrr
Copy link
Member

igrr commented Sep 27, 2023

@savagerex which flash chip are you connecting?

For example, GD25Q32 datasheet indicates a typical 50ms erase time for a single sector. So even without data transfer, write operation is limited by 4kB/50ms = 80kB/s. Which is very close to the speed you are getting.

@SuGlider
Copy link
Collaborator

Based on the last related issue #8479 - it seems that the Flash chip is the W25Q256JV

@savagerex
Copy link
Author

OK, Thanks

@VojtechBartoska
Copy link
Contributor

Closing this as answered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question Only question
Projects
None yet
Development

No branches or pull requests

4 participants