Skip to content

DataFlash & LFS: fails to format #10817

Closed
@pilotak

Description

@pilotak

Description

Following code worked fine just before #10478

#include <mbed.h>
#include "LittleFileSystem.h"
#include "DataFlashBlockDevice.h"

LittleFileSystem fs("fs");
DataFlashBlockDevice bd(PA_7, PA_6, PA_5, PA_4);

int main() {
    if (bd.init() == BD_ERROR_OK) {
        printf("BD initialized\n");

        if (fs.format(&bd) == BD_ERROR_OK) {
            printf("Storage formated\n");

        } else {
            printf("Storage failed to format\n");
        }

    } else {
        printf("Could not init BD\n");
    }

    return 0;
}

but after that i got an error

BD initialized
lfs info:243: format(0x20000d2c, 64, 64, 512, 512)


++ MbedOS Error Info ++
Error Status: 0x80FF0144 Code: 324 Module: 255
Error Message: Assertion failed: lfs->cfg->block_size % lfs->cfg->prog_size == 0
Location: 0x8004C39
File: .\mbed-os\features\storage\filesystem\littlefs\littlefs\lfs.c+2075
Error Value: 0x0
Current Thread: main  Id: 0x20001344 Entry: 0x8005957 StackSize: 0x1000 StackMem: 0x20001AD0 SP: 0x200028DC
For more info, visit: https://mbed.com/s/error?error=0x80FF0144&tgt=NUCLEO_F303RE
-- MbedOS Error Info --

the workaround is to specify block size directly to format.

fs.format(&bd, MBED_LFS_READ_SIZE, MBED_LFS_PROG_SIZE, 4224, MBED_LFS_LOOKAHEAD)

But is this a correct problem solver? or does MBED_LFS_BLOCK_SIZE need to be changed to 4224 but than if i'm right each file currently takes up an entire block as per documentation.

* kept small as each file currently takes up an entire block.

MCU: STM32F303RE
Flash: AT45DB161E-SSHD

Issue request type

[ ] Question
[ ] Enhancement
[x] Bug

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