5 years, 10 months ago.

How to slove the "error: Unknown error (-4001)"

I use the application “mbed-os-filesystem” and nucleo.when i download into my board.The led is on and off and the error occurs.I don't know how to solve it .Can you help me?Thanks.

1 Answer

5 years, 10 months ago.

What application? Could you provide a link?

Try with the official example. https://github.com/ARMmbed/mbed-os-example-filesystem

That is :https://os.mbed.com/users/pokrovsci/code/mbed-os-example-filesystem/ And i changed the type of blockdevice to SPIFblockdevice.my spif flash is w25x and i config the pin .but the error is still .I don't know how to do.

posted by Carmelo Ning 24 Jan 2019
  1. include "mbed.h"
  2. include "SPIFBlockDevice.h"

Create flash device on SPI bus with PTE5 as chip select SPIFBlockDevice spif(PTE2, PTE4, PTE1, PTE5); /*SPIFBlockDevice spif( MBED_CONF_SPIF_DRIVER_SPI_MOSI, MBED_CONF_SPIF_DRIVER_SPI_MISO, MBED_CONF_SPIF_DRIVER_SPI_CLK, MBED_CONF_SPIF_DRIVER_SPI_CS);*/ SPIFBlockDevice spif(D11, D12, D13, D10); int freq = 40000000; SPIFBlockDevice spif(PA_7, PA_6, PA_5,PB_6,freq); int main() { printf("spif test\n");

  1. ifdef MBED_MAJOR_VERSION printf("Mbed OS version %d.%d.%d\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
  2. endif Initialize the SPI flash device and print the memory layout int err = spif.init(); printf("%s\n", (err ? "Fail :(" : "OK")); if (err) { error("error: %s (%d)\n", strerror(-err), err); } printf("spif size: %llu\n", spif.size()); printf("spif read size: %llu\n", spif.get_read_size()); printf("spif program size: %llu\n", spif.get_program_size()); printf("spif erase size: %llu\n", spif.get_erase_size());

Write "Hello World!" to the first block char *buffer = (char*)malloc(spif.get_erase_size()); sprintf(buffer, "Hello World!\n"); spif.erase(0, spif.get_erase_size()); spif.program(buffer, 0, spif.get_erase_size());

Read back what was stored spif.read(buffer, 0, spif.get_erase_size()); printf("%s", buffer);

Deinitialize the device spif.deinit(); } That is the application.The os is 5.11.2 and spiffilesystem.The Flash Memory is W25xx. The other error is : ++ MbedOS Error Info ++ Error Status: 0x80FF0100 Code: 256 Module: 255 Error Message: Fatal Run-time error Location: 0x8009CF9 Error Value: 0x0 Current Thread: main Id: 0x200023B8 Entry: 0x800A539 StackSize: 0x1000 StackMem: 0x200013B8 SP: 0x20002338 For more info, visit: https://armmbed.github.io/mbedos-error/?error=0x80FF0100 MbedOS Error Info error: Unknown error (-4002) HMMMM I'm trapped...

posted by Carmelo Ning 24 Jan 2019

I believe you should configure your pins for initializing the Block Device API overriding the mbed_app.json with something similar to

{
    "target_overrides": {
        "NUCLEO-L476RG": {
             "target.features_add": ["STORAGE"],
             "target.components_add": ["SPIF"],
             "spif-driver.SPI_MOSI": "PTE2",
             "spif-driver.SPI_MISO": "PTE4",
             "spif-driver.SPI_CLK":  "PTE1",
             "spif-driver.SPI_CS":   "PTE5"
         },
    }
}

The initialize de BlockDevice with

SPIFBlockDevice spif( MBED_CONF_SPIF_DRIVER_SPI_MOSI, MBED_CONF_SPIF_DRIVER_SPI_MISO, MBED_CONF_SPIF_DRIVER_SPI_CLK, MBED_CONF_SPIF_DRIVER_SPI_CS);
posted by Jose Marquez 25 Jan 2019