Skip to content

Filesystem fails to write file when there should be enough space available #105

Closed
@microbit-carlos

Description

@microbit-carlos

Edit: You can ignore the contents of this first message and start reading from comment #105 (comment)


Flashing this large Python file that tries to constantly write a tello.cfg file in the filesystem, which is less than a single fs block, works correctly for the first 19 writes, but then it fails:
fs-error.py

...
18
1 44000
2 4400
3 44000
4 43984
5 3712
6 43712
19
1 43712
2 43712
3 43712
[Errno 28] ENOSPC
MicroPython 569e361 on 2022-06-20; micro:bit v2.0.0 with nRF52833
Type "help()" for more information.

As the file is less than a fs block in size, and is constantly overwriting it with the same file name, any used fs blocks should be free to be reused, so there should always be available space.

The 1 xxxx, 2 xxxx, 3 xxxx lines are printing the gc.mem_free() output, so there is plenty of free RAM to hold a full page of flash into RAM.

Something might be going wrong at the point the file system is sweeping? https://github.com/bbcmicrobit/micropython/blob/v1.0.1/source/microbit/filesystem.c#L151

I cannot reproduce it with this smaller similar example:

from microbit import *

id = 0

def write_configuration(ssid,tx,rx,ID):
    global id
    id = ID
    cfg=open('tello.cfg','w')
    cfg.write(ssid + "@" + tx + "$" + rx + "%" + id)
    cfg.close()
    return("ok")
    
i = 0
while True:
    write_configuration("TELLO-9F856A", "pin2", "pin1", "9")
    i += 1
    print("Attempt {}: ".format(i))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions