spi_flash_erase_sector() api return error

gailu
Posts: 49
Joined: Fri May 29, 2015 2:03 pm

spi_flash_erase_sector() api return error

Postby gailu » Thu Jun 11, 2015 2:32 pm

Hi Experts,

I am using ESP-12E from AI Thinker and it has 4 MB flash. I can program any sector in 4MB flash from external programmer (Nodemcu Firmware Programmer). However when trying to erase sectors beyond 127, spi_flash_erase_sector() returns SPI_FLASH_RESULT_ERR so I am not able to use flash capacity that I have. Is there any restriction in spi_flash_erase_sector() to erase sectors beyond some limit. How to overcome this limit and store my data in the available flash sectors beyond 512KB.

I am using SDK1.1.0 (esp_iot_sdk_v1.1.0_15_05_26.zip).

When building image using ./gen_misc.sh, I am selecting option 6 (6=4096KB(1024KB+1024KB)) for spi size and map.

Please help.
Thanks

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: spi_flash_erase_sector() api return error

Postby ESP_Faye » Thu Jun 11, 2015 3:23 pm

Hi,

Please using own official flash download tool v1.2 http://bbs.espressif.com/viewtopic.php?f=5&t=433

Select option 6 in flash map area on flash download tool according to your option in compilation.

If your problem is still unsolved, please offer the capture picture of your flash download tool while downloading bin files.

gailu
Posts: 49
Joined: Fri May 29, 2015 2:03 pm

Re: spi_flash_erase_sector() api return error

Postby gailu » Thu Jun 11, 2015 3:58 pm

Dear Espressif_Faye,

Thanks for your reply. I am unable to use official download tool because it shows maximum COM port up to COM21. However on my both Windows 8 laptops COM30 is assigned to my USB adapter.

Anyway, the problem is not related to the tool or downloading image. I am running my image successfully on ESP-12E, all my wifi and other stuff is working fine. However when I am erasing flash using the following code (running on esp8266) it returns SPI_FLASH_RESULT_OK if I pass sector number 121 as argument but returns SPI_FLASH_RESULT_ERR when I pass argument 129.

Code: Select all

if(SPI_FLASH_RESULT_OK != (ret = spi_flash_erase_sector(129)))
{
    os_printf("ERROR: %d\r\n",ret);
    return -1;   
}


Question: Does spi_flash_erase_sector() have some checks not to allow erasing sector beyond 127?

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: spi_flash_erase_sector() api return error

Postby ESP_Faye » Thu Jun 11, 2015 4:14 pm

Hi,

So sorry for the inconvenience.

This problem is related to flash download tool, if you didn't choose the right flash map( option 6 according to your compilation), it will be considered as 512KB flash by default, so that you can't erase sector 129..

4*1024Byte per sector , 129 sector = 129*4*1024 Bytes is beyond 512KBytes..

We will update our flash download tool to support more COM.

Thanks for your interest in ESP8266 !

gailu
Posts: 49
Joined: Fri May 29, 2015 2:03 pm

Re: spi_flash_erase_sector() api return error

Postby gailu » Fri Jun 12, 2015 12:50 am

Dear Espressif_Faye,

Thank you very much for your help. It was indeed a flash download tool problem and solved with your suggestion of using Official Flash Download Tool.

I resolved to COM PORT issue by freeing some ports below COM 21 based on the details at following link. Hope it may help someone else.
http://www.istime.com/istdnn/portals/0/documents/proc%20and%20instru/computers/make%20com%20ports%20available.pdf


Thanks Again.

Who is online

Users browsing this forum: No registered users and 25 guests