spi_flash_write and / or spi_flash_read not work above 0x80000

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

Re: spi_flash_write and / or spi_flash_read not work above 0x80000

Postby ESP_Faye » Thu Jun 02, 2016 2:03 pm

Hi,

Please select "32Mbit-C1" on the "Flash Size" area of the ESP Flash Download Tool, and download it again.

Thanks for your interest in ESP8266 !

gustavo
Posts: 24
Joined: Thu Apr 28, 2016 6:01 pm

Re: spi_flash_write and / or spi_flash_read not work above 0x80000

Postby gustavo » Thu Jun 02, 2016 4:51 pm

It did work!
Could you explain please?

Is there a way to flash with these settings with esptool?
Or can I use this flash tool on Linux?

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

Re: spi_flash_write and / or spi_flash_read not work above 0x80000

Postby ESP_Faye » Fri Jun 03, 2016 11:29 am

Hi,

You can refer to the esptool on github https://github.com/themadinventor/esptool, it can set the corresponding flash size.

Thanks for your interest in ESP8266 !

gustavo
Posts: 24
Joined: Thu Apr 28, 2016 6:01 pm

Re: spi_flash_write and / or spi_flash_read not work above 0x80000

Postby gustavo » Fri Jun 03, 2016 10:44 pm

You should also give an explanation about the problem or people will not know how to resolve similar issues.
At the very least point to some documentation which explains the difference.

Nonetheless I'm still having problems:

The following code:

Code: Select all

void user_init(void)
{
    printf("SDK version:%s\n", system_get_sdk_version());
   
    uint32 temp[4]={0x05, 0x06, 0x07, 0x08};
    uint32 temp1[4]={0};
   
    int l = 0x90000;
    printf("l: %d - 0x%x\n", l, l);
    int i = spi_flash_erase_sector(l);
    printf("spi_flash_erase_sector: %d\n", i);
    int o = spi_flash_write(l, temp, sizeof(temp));
    printf("spi_flash_write: %d\n", o);

    int p = spi_flash_read(l, temp1, sizeof(temp1));
    printf("spi_flash_read: %d\n", p);

    printf("read :0x%x, 0x%x, 0x%x, 0x%x\n", temp1[0], temp1[1], temp1[2], temp1[3]);

    uint32 temp2[4] = {0x01, 0x02, 0x03, 0x04};
    i = spi_flash_erase_sector(l);
    printf("spi_flash_erase_sector: %d\n", i);
    o = spi_flash_write(l, temp2, sizeof(temp2));
    printf("spi_flash_write: %d\n", o);

    p = spi_flash_read(l, temp1, sizeof(temp1));
    printf("spi_flash_read: %d\n", p);
   
    printf("read :0x%x, 0x%x, 0x%x, 0x%x\n", temp1[0], temp1[1], temp1[2], temp1[3]);
}

prints:

Code: Select all

2nd boot version : 1.5
  SPI Speed      : 40MHz
  SPI Mode       : QIO
  SPI Flash Size & Map: 32Mbit(1024KB+1024KB)
jump to run user1 @ 1000

OS SDK ver: 1.4.0(c599790) compiled @ Mar  1 2016 17:25:17

SDK version:1.4.0(c599790)
l: 589824 - 0x90000
spi_flash_erase_sector: 0
spi_flash_write: 0
spi_flash_read: 0
read :0x1, 0x2, 0x3, 0x0
spi_flash_erase_sector: 0
spi_flash_write: 0
spi_flash_read: 0
read :0x1, 0x2, 0x3, 0x0

There's a 0x4 missing.

And If I try some other position, for example 0x250000
I get:

Code: Select all

2nd boot version : 1.5
  SPI Speed      : 40MHz
  SPI Mode       : QIO
  SPI Flash Size & Map: 32Mbit(1024KB+1024KB)
jump to run user1 @ 1000

OS SDK ver: 1.4.0(c599790) compiled @ Mar  1 2016 17:25:17

SDK version:1.4.0(c599790)
l: 2424832 - 0x250000
spi_flash_erase_sector: 0
spi_flash_write: 0
spi_flash_read: 0
read :0x0, 0x0, 0x0, 0x0
spi_flash_erase_sector: 0
spi_flash_write: 0
spi_flash_read: 0
read :0x0, 0x0, 0x0, 0x0

And can't run the same code again without flashing:

Code: Select all

ets Jan  8 2013,rst cause:2, boot mode:(3,6)

ets_main.c


By my understanding, based on the 99c-esp8266_ota_upgrade_en_v1.6.pdf document, user data should go from 0x200000 to 0x3FC000.

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

Re: spi_flash_write and / or spi_flash_read not work above 0x80000

Postby ESP_Faye » Tue Jun 07, 2016 1:34 pm

Hi,

spi_flash_erase_sector(0x90); // Here should be the sector number 0x90

spi_flash_write(0x90000, temp, sizeof(temp)); // Here should be the flash address 0x90000

gustavo
Posts: 24
Joined: Thu Apr 28, 2016 6:01 pm

Re: spi_flash_write and / or spi_flash_read not work above 0x80000

Postby gustavo » Wed Jun 08, 2016 6:47 pm

Oh, right.

Thank you :)

Who is online

Users browsing this forum: No registered users and 5 guests