Skip to content

NVS and compiler_builtins collision #4

Closed
@lexxvir

Description

@lexxvir

Hi @MabezDev,

It is not issue of your fork, but I just want to publish my experience with NVS (Non Volatile Storage of ESP32). I think we could track it here.

ESP IDF has such component as NVS. It is key-value storage built upon flash. Any action with NVS translates to flash interactions. Because application runs also from flash, IDF internally use some locks, to prevent flash interaction until NVS operation is done. Also, NVS uses some low level functions such memcpy. Such functions in IDF marked as IRAM, so they are placed in the Internal RAM, not in flash. So, locks and IRAM functions allows NVS does things while application runs from flash.

When we compiling rust application, rust compiler implicitly add libcompiler_builtins library to the linker parameters. libcompiler_builtins also contains low level functions such as memcpy, but these functions don't marked as IRAM. Because libcompiler_builtins appears first in linker arguments, linker uses memcpy from libcompiler_builtins instead of right version from Espressif's libc.

This issue appears as Guru Meditation Error: Core N panic'ed (IllegalInstruction) when you try to call nvs_flash_init() from IDF. Unfortunately, NVS is required for normal work of builtin WiFI, it is too hard to use WiFi without NVS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions