Skip to content

Uploading to esp32-s3 (4MB) corrupts file #17865

@gohai

Description

@gohai

Port, board and/or hardware

esp32-s3 (on a ESP32-S3 (QFN56) (revision v0.2), with 4 MB flash)

MicroPython version

MicroPython v1.26.0-preview.527.g593ae04ee on 2025-08-07; Generic ESP32S3 module with ESP32S3

mpremote 1.25.0, on macOS

Reproduction

  1. Upload a file to the board (e.g. mpremote cp bar.py :/bar.py)
  2. Download the file again (mpremote cp :/bar.py bar2.py)
  3. Compare the file content (diff -u bar.py bar2.py)

The files reproducibly differ for me. (Seeing syntax errors in repl as well, so the corruption doesn't seem to be caused by the second transfer back to the computer.)

Expected behaviour

No file corruption. (Content should be identical.)

Observed behaviour

File corruption, e.g.

 def create_wav_header(sampleRate, bitsPerSample, num_channels, num_samples):
     datasize = num_samples * num_channels * bitsPerSample // 8
     o = bytes("RIFF", "ascii")  # (4byte) Marks file as RIFF
     o += (datasize + 36).to_bytes(
         4, "little"
+    )  # (4byte) File size in bytes excluding this and Rittle"
     )  # (4byte) File size in bytes excluding this and RIFF marker
     o += bytes("WAVE", "ascii")  # (4byte) File type
     o += bytes("fmt ", "ascii")  # (4byte) Format Chunk Marker
     o += (16).to_bytes(4, "little")  # (4byte) Length of above format data
+    o += (1).to_bytes(2, "little")  # (2byte) Format tyat data
     o += (1).to_bytes(2, "little")  # (2byte) Format type (1 - PCM)
     o += (num_channels).to_bytes(2, "little")  # (2byte)
     o += (sampleRate).to_bytes(4, "little")  # (4byte)
     o += (sampleRate * num_channels * bitsPerSample // 8).to_bytes(4, "little")  # (4byte)
+    o += (num_channels * bitsPerSample /, "little")  # (4byte)
     o += (num_channels * bitsPerSample // 8).to_bytes(2, "little")  # (2byte)
     o += (bitsPerSample).to_bytes(2, "little")  # (2byte)
     o += bytes("data", "ascii")  # (4byte) Data Chunk Marker
     o += (datasize).to_bytes(4, "little")  # (4byte) Data size in bytes
     return o

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions