spi_flash_write and / or spi_flash_read not work above 0x80000

septijo
Posts: 3
Joined: Thu Jul 30, 2015 3:13 pm

spi_flash_write and / or spi_flash_read not work above 0x80000

Postby septijo » Fri Sep 11, 2015 8:00 pm

Hi all,

I've encountered weird problem upon (erase+)write and read it back, on SPI flash above 0x80000,
no matter which option i choose when compiling :
* make COMPILE=gcc BOOT=none APP=0 SPI_SPEED=40 SPI_MODE=QIO SPI_SIZE_MAP=6
>> i flashed :
** "eagle.flash.bin" @ 0x00000
** "eagle.irom0text.bin" @ 0x40000
* make COMPILE=gcc BOOT=new APP=1 SPI_SPEED=40 SPI_MODE=QIO SPI_SIZE_MAP=6
>> i flashed :
** "boot_v1.4(b1).bin" @ 0x00000
** "upgrade\user1.4096.new.6.bin" @ 0x01000

if i (erase+)write the data to SPI Flash @ 0x3C000 (i've also tried 0x7C000), i can read it back successfully.
but when i try to (erase+)write the data @ 0x8C000, i can not read it back (the data returned is not my previously saved).

my sourcecode :

Code: Select all

//#define PRIV_PARAM_START_SEC      0x3C // >> ok
//#define PRIV_PARAM_START_SEC      0x7C // >> ok
#define PRIV_PARAM_START_SEC      0x8C // >> fail

struct structConfigData {
  char magic[16];
  uint8_t switch1_mode;
  uint8_t switch1_timerHourOn1;
  uint8_t switch1_timerMinuteOn1;
  uint8_t switch1_timerHourOff1;
  uint8_t switch1_timerMinuteOff1;
  uint8_t switch1_timerRandomMinute1;
  uint8_t wifi_mode; // 0 = none, 1=AP, 2=Station 3=Both
  char wifi_station_SSID[32];
  char wifi_station_password[64];
  char wifi_softAP_SSID[32];
  char wifi_softAP_password[64];
  uint8 wifi_softAP_channel;
  AUTH_MODE wifi_softAP_authMode;
  uint8 wifi_softAP_SSID_hidden;
};
struct structConfigData npConfigData;

// save data to flash
spi_flash_erase_sector(PRIV_PARAM_START_SEC + PRIV_PARAM_SAVE);
spi_flash_write((PRIV_PARAM_START_SEC + PRIV_PARAM_SAVE) * SPI_FLASH_SEC_SIZE,
  (uint32 *) &npConfigData, sizeof(struct structConfigData));

// read it back, i can get my previously saved data, only if i set the sector below 0x80000
spi_flash_read((PRIV_PARAM_START_SEC + PRIV_PARAM_SAVE) * SPI_FLASH_SEC_SIZE,
  (uint32 *) &npConfigData, sizeof(struct structConfigData));


here is my flash downlaod tools screenshoot
Image

any advice ? anyone ?

pvvx
Posts: 1
Joined: Sun Sep 13, 2015 7:56 am

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

Postby pvvx » Sun Sep 13, 2015 8:08 am

septijo wrote:Hi all,
I've encountered weird problem upon (erase+)write and read it back, on SPI flash above 0x80000,
....
any advice ? anyone ?

Code: Select all

extern SpiFlashChip * flashchip; // in RAM-BIOS: 0x3fffc714
....
uint32 save_chip_size = flashchip->chip_size;
flashchip->chip_size = 0x01000000; // Open all 16Mbytes
// save data to flash
spi_flash_erase_sector(PRIV_PARAM_START_SEC + PRIV_PARAM_SAVE);
spi_flash_write((PRIV_PARAM_START_SEC + PRIV_PARAM_SAVE) * SPI_FLASH_SEC_SIZE,
  (uint32 *) &npConfigData, sizeof(struct structConfigData));

// read it back, i can get my previously saved data, only if i set the sector below 0x80000
spi_flash_read((PRIV_PARAM_START_SEC + PRIV_PARAM_SAVE) * SPI_FLASH_SEC_SIZE,
  (uint32 *) &npConfigData, sizeof(struct structConfigData));
flashchip->chip_size = save_chip_size;

septijo
Posts: 3
Joined: Thu Jul 30, 2015 3:13 pm

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

Postby septijo » Fri Sep 18, 2015 10:51 am

dear pvvx,

tried your code with no luck, fatal exception happened in this line :

Code: Select all

flashchip->chip_size = 0x01000000;


the "fatal exception thingy" even happened when i just only try to peek the flashchip->chip_size using this code :

Code: Select all

uint32 save_chip_size = flashchip->chip_size;
printf("flashchip->chip_size=%d\n",save_chip_size);
//flashchip->chip_size = 0x01000000; // Open all 16Mbytes

( i just only peek the var, not even alter it -- already commented the line below the printf(bla bla) )

Fatal exception (9):
epc1=0x4027200a
epc2=0x00000000
epc3=0x00000000
epcvaddr=0x001640f3
depc=0x00000000
rtn_add=0x40271fff

nb:
i use RTOS SDK v 2015-Aug-21 ( system_get_sdk_version() return "1.1.0(6009786)"), so the first time i try your code, the compiler gave me error :

Code: Select all

error: unknown type name 'SpiFlashChip'
 extern SpiFlashChip * flashchip; // in RAM-BIOS: 0x3fffc714
 ^

in order to make it compiled, i have to overwrite the spi_flash.h file at the include/espressif folder (of the RTOS SDK) with the spi_flash.h file from the NON RTOS SDK (version 2015-Aug-08).

best regards,

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 » Tue May 24, 2016 5:25 pm

Dear septijo,
did you find the problem with the flash?

I'm having the same issue.

ESP_Faye
Posts: 1643
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 May 27, 2016 5:08 pm

Hi,

Sorry that we can not reproduce your problem.
Here is our test code

Code: Select all

void user_init(void)
{
    os_printf("SDK version:%s\n", system_get_sdk_version());
   
    uint32 temp[4]={0x05, 0x06, 0x07, 0x08};
    uint32 temp1[4]={0};
   
    spi_flash_erase_sector(0x8c);
    spi_flash_write(0x8c000, temp, sizeof(temp));

    spi_flash_read(0x8c000, temp1, sizeof(temp1));
   
    os_printf("read :%x, %x, %x, %x\n", temp1[0], temp1[1], temp1[2], temp1[3]);

}


If your problem is still unsolved, please provide your whole test project, we will help debug it.

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 » Mon May 30, 2016 11:15 pm

I used your code (added some more debug).

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 i = spi_flash_erase_sector(0x8c);
    printf("spi_flash_erase_sector: %d\n", i);
    int o = spi_flash_write(0x8c000, temp, sizeof(temp));
    printf("spi_flash_write: %d\n", o);

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


And I got the following output:

Code: Select all

spi_flash_erase_sector: 1
spi_flash_write: 1
spi_flash_read: 1
read :0, 0, 0, 0


Which is SPI_FLASH_RESULT_ERR for all the calls.
I'm running the RTOS version of the SDK.

I also posted this as a discussion on the esp8266.com forum: http://www.esp8266.com/viewtopic.php?f=6&t=10116

My flash is marked BergMicro 25Q32ASSIG (32Mbits).

ESP_Faye
Posts: 1643
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 May 31, 2016 11:36 am

Hi,

Sorry that we can not reproduce your problem. We tested the code you provided, it works fine.

Can you provide the datasheet of your flash (BergMicro 25Q32ASSIG) ?

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 » Tue May 31, 2016 5:38 pm

Yes.
You can find a copy in: http://www.darkwire.com.au/Downloads/BG25Q32A.pdf

I bought an ESP12E from eBay.

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

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

Postby ESP_Faye » Wed Jun 01, 2016 11:22 am

Hi,

Please use the ESP Flash Download Tool to download your bin files into flash.

If your problem is still unsolved, please provide the captured picture of ESP Flash Download Tool while downloading, and your bin files, we will have a try.

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 » Wed Jun 01, 2016 6:02 pm

There you go.
Attachments
bins.zip
(205.55 KiB) Downloaded 236 times
flash.png

Who is online

Users browsing this forum: No registered users and 1 guest