Zephyr flash_erase(w25q32jv@0, 524288, 4096) faild -19

I use Zephyr flash_erase() to erase Winbond W25Q32JV NOR flash. But I flash_erase() return error code -19. What is meaning of error code -19? And how to fix this issue?

The following is code to call flash_erase().

int flashNorEraseData(const off_t offset, const size_t len) {
    if (!flashNorGetInitialzed()) {
        return ERROR_NOR_UNINITIALIZED;
    }

    const int ret = flash_erase(_gFlashDev, offset, len);
    if (ret < 0) {
        printk("flash_erase(%s, %ld, %u) faild %d\n", _gFlashDev->name, offset, len, ret);
        return ERROR_FSTORAGE_ERASE_FAIL;
    }

    return 0;
}

The following are log messages.

*** Booting Zephyr OS build v3.2.99-ncs2 *
jedec-id = [ef 40 16]
_gDensity=4194304
flash_erase(w25q32jv@0, 524288, 4096) faild -19
Erasing from 524288 to 528383 failed

Parents
  • Hiow about the devicetree file setting in your code?

    I think that the issue is happened in the overlay file for the jedec-id

    or other device tree matrix 

    For example

    &spi3 {
    pinctrl-0 = <&spi3_default_alt>;
    pinctrl-1 = <&spi3_sleep_alt>;
    pinctrl-names = "default", "sleep";
    cs-gpios = <&gpio0 20 GPIO_ACTIVE_LOW>,
    <&gpio0 10 GPIO_ACTIVE_LOW>;

    at45db0: at45db041e@0 {
    compatible = "atmel,at45";
    reg = <0>;
    spi-max-frequency = <15000000>;
    jedec-id = [1f 24 00];
    size = <4194304>;
    sector-size = <65536>;
    block-size = <2048>;
    page-size = <256>;
    enter-dpd-delay = <2000>;
    exit-dpd-delay = <35000>;
    status = "disabled";
    };

    }

    You have to check the flash specification is math the overlay file or not.

  • Thanks for your reply! I don't use overlay file. The dts file I use is custom_nrf52832.dts in custom_nrf52832.zip file. It should match datasheet W25Q32JV RevI 05042021 Plus.pdf.

    &spi1 {
    status = "okay";

    cs-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
    pinctrl-0 = <&spi1_default>;
    pinctrl-1 = <&spi1_sleep>;
    pinctrl-names = "default", "sleep";

    w25q32: w25q32jv@0 {
    compatible = "jedec,spi-nor";
    reg = <0>;
    spi-max-frequency = <8000000>;
    jedec-id = [ef 40 16];
    size = <0x400000>;
    has-dpd;
    t-enter-dpd = <3500>;
    t-exit-dpd = <3500>;
    };

    w25q256: w25q256jv@0 {
    compatible = "jedec,spi-nor";
    reg = <0>;
    spi-max-frequency = <8000000>;
    jedec-id = [ef 40 19];
    size = <0x2000000>;
    has-dpd;
    t-enter-dpd = <3500>;
    t-exit-dpd = <3500>;
    };
    };

Reply
  • Thanks for your reply! I don't use overlay file. The dts file I use is custom_nrf52832.dts in custom_nrf52832.zip file. It should match datasheet W25Q32JV RevI 05042021 Plus.pdf.

    &spi1 {
    status = "okay";

    cs-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
    pinctrl-0 = <&spi1_default>;
    pinctrl-1 = <&spi1_sleep>;
    pinctrl-names = "default", "sleep";

    w25q32: w25q32jv@0 {
    compatible = "jedec,spi-nor";
    reg = <0>;
    spi-max-frequency = <8000000>;
    jedec-id = [ef 40 16];
    size = <0x400000>;
    has-dpd;
    t-enter-dpd = <3500>;
    t-exit-dpd = <3500>;
    };

    w25q256: w25q256jv@0 {
    compatible = "jedec,spi-nor";
    reg = <0>;
    spi-max-frequency = <8000000>;
    jedec-id = [ef 40 19];
    size = <0x2000000>;
    has-dpd;
    t-enter-dpd = <3500>;
    t-exit-dpd = <3500>;
    };
    };

Children
Related