ESP8266 Developer Zone The Official ESP8266 Forum 2016-07-29T14:18:23+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=2215 2016-07-29T14:18:23+08:00 2016-07-29T14:18:23+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2215&p=8189#p8189 <![CDATA[Re: 【Feedback】spiffs: "spi_flash_read failed: 1"]]>
I also encoutered the same problems , when using the SPIFF sample code api in FreeRTOS Ver1.4 SDK, it seems to show spi_flash_read_failed:1 messages.
I do not know what's the problems happens ~!!

My code is shown below:

Code:

#include "esp_common.h"
#include "spiffs.h"
#include "spiffs_nucleus.h"
#include "testrunner.h"
#include "test_spiffs.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
//#include <dirent.h>
#include <unistd.h>
#include "spiffs_test_params.h"

spiffs __fs;
static char _path[256];
char *name = "hello.txt";
#define TEST_PATH "test_data/"

char *make_test_fname(const char *name) {
  sprintf(_path, "%s%s", TEST_PATH, name);
  return _path;
}

int test_create_file(char *name) {
  spiffs_stat s;
  spiffs_file fd;
  int res = SPIFFS_creat(FS, name, 0);
  CHECK_RES(res);
  fd = SPIFFS_open(FS, name, SPIFFS_RDONLY, 0);
  CHECK(fd >= 0);
  res = SPIFFS_fstat(FS, fd, &s);
  CHECK_RES(res);
  CHECK(strcmp((char*)s.name, name) == 0);
  CHECK(s.size == 0);
  SPIFFS_close(FS, fd);
  return 0;
}


int read_and_verify_fd(spiffs_file fd, char *name) {
  s32_t res;
  int pfd = open(make_test_fname(name), O_RDONLY);
  spiffs_stat s;
  res = SPIFFS_fstat(&__fs, fd, &s);
  if (res < 0) {
    printf("  read_and_verify: could not stat file %s\n", name);
    return res;
  }
  if (s.size == 0) {
    SPIFFS_close(&__fs, fd);
    close(pfd);
    return 0;
  }

  //printf("verifying %s, len %i\n", name, s.size);
  int offs = 0;
  u8_t buf_d[256];
  u8_t buf_v[256];
  while (offs < s.size) {
    int read_len = MIN(s.size - offs, sizeof(buf_d));
    res = SPIFFS_read(&__fs, fd, buf_d, read_len);
    if (res < 0) {
      printf("  read_and_verify: could not read file %s offs:%i len:%i filelen:%i\n", name, offs, read_len, s.size);
      return res;
    }
    int pres = read(pfd, buf_v, read_len);
    (void)pres;
    //printf("reading offs:%i len:%i spiffs_res:%i posix_res:%i\n", offs, read_len, res, pres);
    int i;
    int veri_ok = 1;
    for (i = 0; veri_ok && i < read_len; i++) {
      if (buf_d[i] != buf_v[i]) {
        printf("file verification mismatch @ %i, %02x %c != %02x %c\n", offs+i, buf_d[i], buf_d[i], buf_v[i], buf_v[i]);
        int j = MAX(0, i-16);
        int k = MIN(sizeof(buf_d), i+16);
        k = MIN(s.size-offs, k);
        int l;
        for (l = j; l < k; l++) {
          printf("%c", buf_d[l] > 31 ? buf_d[l] : '.');
        }
        printf("\n");
        for (l = j; l < k; l++) {
          printf("%c", buf_v[l] > 31 ? buf_v[l] : '.');
        }
        printf("\n");
        veri_ok = 0;
      }
    }
    if (!veri_ok) {
      SPIFFS_close(&__fs, fd);
      close(pfd);
      printf("data mismatch\n");
      return -1;
    }

    offs += read_len;
  }

  SPIFFS_close(&__fs, fd);
  close(pfd);

  return 0;
}


int read_and_verify(char *name) {
  s32_t res;
  int fd = SPIFFS_open(&__fs, name, SPIFFS_RDONLY, 0);
  if (fd < 0) {
    printf("  read_and_verify: could not open file %s\n", name);
    return fd;
  }
  return read_and_verify_fd(fd, name);
}

void spiffs_fs1_init(void)
{
    struct esp_spiffs_config config;

    config.phys_size = FS1_FLASH_SIZE;
    config.phys_addr = FS1_FLASH_ADDR;
    config.phys_erase_block = SECTOR_SIZE;
    config.log_block_size = LOG_BLOCK;
    config.log_page_size = LOG_PAGE;
    config.fd_buf_size = FD_BUF_SIZE * 2;
    config.cache_buf_size = CACHE_BUF_SIZE;

    esp_spiffs_init(&config);
}


void user_init(void)
{
 spiffs_fs1_init();
 test_create_file(name);
 //make_test_fname(name);
 //read_and_verify(name);
}

Statistics: Posted by PaulTsai111 — Fri Jul 29, 2016 2:18 pm


]]>
2016-07-08T10:41:42+08:00 2016-07-08T10:41:42+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2215&p=7847#p7847 <![CDATA[Re: 【Feedback】spiffs: "spi_flash_read failed: 1"]]> if you choose flash map as 6, the macro "FS1_FLASH_ADDR" should be large then 2028*1000, suggest you choose 3000 and try again.
For Makefile, you can get default from path: ESP8266_RTOS_SDK-master/examples/spiffs_test

Statistics: Posted by ESP_Rubin — Fri Jul 08, 2016 10:41 am


]]>
2016-07-07T22:43:46+08:00 2016-07-07T22:43:46+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2215&p=7836#p7836 <![CDATA[Re: 【Feedback】spiffs: "spi_flash_read failed: 1"]]>
First, this is the makeile that I use to bulid and flash the project:

Code:

#############################################################
#
# Root Level Makefile ESP8266 + RTOS
#
# (c) by CHERTS <sleuthhound@gmail.com>
#
#############################################################

BUILD_BASE   = build
FW_BASE      = firmware

TOOLS_ROOT ?= c:/Espressif

# Base directory for the compiler
XTENSA_TOOLS_ROOT ?= c:/Espressif/xtensa-lx106-elf/bin

# base directory of the ESP8266 SDK package, absolute
SDK_BASE   ?= c:/Espressif/ESP8266_RTOS_SDK
SDK_TOOLS   ?= c:/Espressif/utils/ESP8266

# esptool path and port
ESPTOOL ?= $(SDK_TOOLS)/esptool.exe
ESPPORT ?= COM5
# Baud rate for programmer
BAUD ?= 256000

# SPI_SPEED = 40, 26, 20, 80
SPI_SPEED ?= 80
# SPI_MODE: qio, qout, dio, dout
SPI_MODE ?= qio
# SPI_SIZE_MAP
# 0 : 512 KB (256 KB + 256 KB)
# 1 : 256 KB
# 2 : 1024 KB (512 KB + 512 KB)
# 3 : 2048 KB (512 KB + 512 KB)
# 4 : 4096 KB (512 KB + 512 KB)
# 5 : 2048 KB (1024 KB + 1024 KB)
# 6 : 4096 KB (1024 KB + 1024 KB)
SPI_SIZE_MAP ?= 5

ifeq ($(SPI_SPEED), 26.7)
    freqdiv = 1
    flashimageoptions = -ff 26m
else
    ifeq ($(SPI_SPEED), 20)
        freqdiv = 2
        flashimageoptions = -ff 20m
    else
        ifeq ($(SPI_SPEED), 80)
            freqdiv = 15
            flashimageoptions = -ff 80m
        else
            freqdiv = 0
            flashimageoptions = -ff 40m
        endif
    endif
endif

ifeq ($(SPI_MODE), QOUT)
    mode = 1
    flashimageoptions += -fm qout
else
    ifeq ($(SPI_MODE), DIO)
      mode = 2
      flashimageoptions += -fm dio
    else
        ifeq ($(SPI_MODE), DOUT)
            mode = 3
            flashimageoptions += -fm dout
        else
            mode = 0
            flashimageoptions += -fm qio
        endif
    endif
endif

ifeq ($(SPI_SIZE_MAP), 1)
  size_map = 1
  flash = 256
  flashimageoptions += -fs 2m
else
  ifeq ($(SPI_SIZE_MAP), 2)
    size_map = 2
    flash = 1024
    flashimageoptions += -fs 8m
  else
    ifeq ($(SPI_SIZE_MAP), 3)
      size_map = 3
      flash = 2048
      flashimageoptions += -fs 16m
    else
      ifeq ($(SPI_SIZE_MAP), 4)
      size_map = 4
      flash = 4096
      flashimageoptions += -fs 32m
      else
        ifeq ($(SPI_SIZE_MAP), 5)
          size_map = 5
          flash = 2048
          flashimageoptions += -fs 16m
        else
          ifeq ($(SPI_SIZE_MAP), 6)
            size_map = 6
            flash = 4096
            flashimageoptions += -fs 32m
          else
            size_map = 0
            flash = 512
            flashimageoptions += -fs 4m
          endif
        endif
      endif
    endif
  endif
endif

# name for the target project
TARGET      = app

# which modules (subdirectories) of the project to include in compiling
MODULES   = user driver
EXTRA_INCDIR = include

#LIBS       = cirom gccirom hal phy pp net80211 wpa main freertos lwip udhcp
# linking libgccirom.a instead of libgcc.a causes reset when working with flash memory (ie spi_flash_erase_sector)
LIBS      = gcc hal phy pp net80211 wpa crypto main freertos lwip minic espconn cirom mirom json ssl pwm spiffs phy

# compiler flags using during compilation of source files
CFLAGS      = -g -save-temps -std=gnu90 -Os -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -mno-serialize-volatile -D__ets__ -DICACHE_FLASH
CXXFLAGS   = $(CFLAGS) -fno-rtti -fno-exceptions

# linker flags used to generate the main object file
LDFLAGS      = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static

# linker script used for the above linkier step
LD_SCRIPT   = eagle.app.v6.ld

# various paths from the SDK used in this project
SDK_LIBDIR   = lib
SDK_LDDIR   = ld
SDK_INCDIR   = extra_include include include/espressif include/json include/udhcp include/lwip include/lwip/lwip include/lwip/ipv4 include/lwip/ipv6

# select which tools to use as compiler, librarian and linker
CC      := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
CXX      := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-g++
AR      := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar
LD      := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
OBJCOPY := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objcopy
OBJDUMP := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objdump

SRC_DIR      := $(MODULES)
BUILD_DIR   := $(addprefix $(BUILD_BASE)/,$(MODULES))

SDK_LIBDIR   := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR))
SDK_INCDIR   := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))

SRC      := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c*))
C_OBJ      := $(patsubst %.c,%.o,$(SRC))
CXX_OBJ      := $(patsubst %.cpp,%.o,$(C_OBJ))
OBJ      := $(patsubst %.o,$(BUILD_BASE)/%.o,$(CXX_OBJ))
LIBS      := $(addprefix -l,$(LIBS))
APP_AR      := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a)
TARGET_OUT   := $(addprefix $(BUILD_BASE)/,$(TARGET).out)

LD_SCRIPT   := $(addprefix -T$(SDK_BASE)/$(SDK_LDDIR)/,$(LD_SCRIPT))

INCDIR   := $(addprefix -I,$(SRC_DIR))
EXTRA_INCDIR   := $(addprefix -I,$(EXTRA_INCDIR))
MODULE_INCDIR   := $(addsuffix /include,$(INCDIR))

V ?= $(VERBOSE)
ifeq ("$(V)","1")
Q :=
vecho := @true
else
Q := @
vecho := @echo
endif

vpath %.c $(SRC_DIR)
vpath %.cpp $(SRC_DIR)

define compile-objects
$1/%.o: %.c
   $(vecho) "CC $$<"
   $(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS)  -c $$< -o $$@
$1/%.o: %.cpp
   $(vecho) "C+ $$<"
   $(Q) $(CXX) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CXXFLAGS)  -c $$< -o $$@
endef

.PHONY: all checkdirs clean firmware flashonefile flash flashinit rebuild

all: checkdirs $(TARGET_OUT)

$(TARGET_OUT): $(APP_AR)
   $(vecho) "LD $@"
   $(Q) $(LD) -L$(SDK_LIBDIR) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@
   $(vecho) "------------------------------------------------------------------------------"
   $(vecho) "Section info:"
   $(Q) $(OBJDUMP) -h -j .data -j .rodata -j .bss -j .text -j .irom0.text $@
   $(vecho) "------------------------------------------------------------------------------"
   $(Q) $(ESPTOOL) elf2image $(TARGET_OUT) -o$(FW_BASE)/ $(flashimageoptions)
   $(vecho) "------------------------------------------------------------------------------"
   $(vecho) "Generate 0x00000.bin and 0x40000.bin successully in folder $(FW_BASE)."
   $(vecho) "0x00000.bin-------->0x00000"
   $(vecho) "0x40000.bin-------->0x40000"
   $(vecho) "Done"

$(APP_AR): $(OBJ)
   $(vecho) "AR $@"
   $(Q) $(AR) cru $@ $^

checkdirs: $(BUILD_DIR) $(FW_BASE)

$(BUILD_DIR):
   $(Q) mkdir -p $@

$(FW_BASE):
   $(Q) mkdir -p $@

flashonefile: all
   $(SDK_TOOLS)/gen_flashbin.exe $(FW_BASE)/0x00000.bin $(FW_BASE)/0x40000.bin 0x40000
   $(Q) mv eagle.app.flash.bin $(FW_BASE)/
   $(vecho) "Generate eagle.app.flash.bin successully in folder $(FW_BASE)."
   $(vecho) "eagle.app.flash.bin-------->0x00000"
   $(ESPTOOL) -p $(ESPPORT) -b $(BAUD) write_flash $(flashimageoptions) 0x00000 $(FW_BASE)/eagle.app.flash.bin

flash: all
   $(ESPTOOL) -p $(ESPPORT) -b $(BAUD) write_flash $(flashimageoptions) 0x00000 $(FW_BASE)/0x00000.bin 0x20000 $(FW_BASE)/0x20000.bin

# ===============================================================
# From http://bbs.espressif.com/viewtopic.php?f=10&t=305
# master-device-key.bin is only need if using espressive services
# master_device_key.bin 0x3e000 is not used , write blank
# See 2A-ESP8266__IOT_SDK_User_Manual__EN_v1.1.0.pdf
# http://bbs.espressif.com/download/file.php?id=532
#
# System parameter area is the last 16KB of flash
# 512KB flash - system parameter area starts from 0x7C000
#    download blank.bin to 0x7E000 as initialization.
# 1024KB flash - system parameter area starts from 0xFC000
#    download blank.bin to 0xFE000 as initialization.
# 2048KB flash - system parameter area starts from 0x1FC000
#    download blank.bin to 0x1FE000 as initialization.
# 4096KB flash - system parameter area starts from 0x3FC000
#    download blank.bin to 0x3FE000 as initialization.
# ===============================================================

# FLASH SIZE
flashinit:
   $(vecho) "Flash init data:"
   $(vecho) "Default config (Clear SDK settings):"
   $(vecho) "blank.bin-------->0x3e000"
   $(vecho) "blank.bin-------->0x3fc000"
   $(vecho) "esp_init_data_default.bin-------->0x3fc000"
   $(ESPTOOL) -p $(ESPPORT) write_flash $(flashimageoptions) \
      0x3e000 $(SDK_BASE)/bin/blank.bin \
      0x3fc000 $(SDK_BASE)/bin/esp_init_data_default.bin \
      0x3fe000 $(SDK_BASE)/bin/blank.bin

rebuild: clean all

clean:
   $(Q) rm -f $(APP_AR)
   $(Q) rm -f $(TARGET_OUT)
   $(Q) rm -f *.bin
   $(Q) rm -f *.sym
   $(Q) rm -f *.ii
   $(Q) rm -f *.i
   $(Q) rm -f *.s
   $(Q) rm -rf $(BUILD_DIR)
   $(Q) rm -rf $(BUILD_BASE)
   $(Q) rm -rf $(FW_BASE)

$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))


Second, I use the module ESP-12 and ESP-12F.

To end, my module have a 4Mb flash memory, and how you see in the make file that i post above, I use the size map "SIZE_MAP = 6"" , so that the configuration is "6: 4,096 KB ( 1,024 KB + 1,024 KB ) ".

if you need anything more feel free to ask, thank you very much for your interest !!!!

Statistics: Posted by iolaso — Thu Jul 07, 2016 10:43 pm


]]>
2016-07-06T10:26:05+08:00 2016-07-06T10:26:05+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2215&p=7774#p7774 <![CDATA[Re: 【Feedback】spiffs: "spi_flash_read failed: 1"]]> Statistics: Posted by ESP_Rubin — Wed Jul 06, 2016 10:26 am


]]>
2016-07-02T00:11:19+08:00 2016-07-02T00:11:19+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2215&p=7663#p7663 <![CDATA[Re: 【Feedback】spiffs: "spi_flash_read failed: 1"]]>

Code:

spi_flash_read failed: 1 (4198524, 8)

spi_flash_read failed: 1 (4202620, 8)

spi_flash_read failed: 1 (4206716, 8)

spi_flash_read failed: 1 (4210812, 8)

spi_flash_read failed: 1 (4214908, 8)

spi_flash_read failed: 1 (4219004, 8)

spi_flash_read failed: 1 (4223100, 8)

spi_flash_read failed: 1 (4227196, 8)

spi_flash_read failed: 1 (4231292, 8)

spi_flash_read failed: 1 (4235388, 8)

spi_flash_read failed: 1 (4239484, 8)

spi_flash_read failed: 1 (4243580, 8)

spi_flash_read failed: 1 (4247676, 8)

spi_flash_read failed: 1 (4251772, 8)

spi_flash_read failed: 1 (4255868, 8)

spi_flash_read failed: 1 (4259964, 8)

spi_flash_read failed: 1 (4264060, 8)

spi_flash_read failed: 1 (4268156, 8)

spi_flash_read failed: 1 (4272252, 8)

spi_flash_read failed: 1 (4276348, 8)

spi_flash_read failed: 1 (4280444, 8)

spi_flash_read failed: 1 (4284540, 8)

spi_flash_read failed: 1 (4288636, 8)

spi_flash_read failed: 1 (4292732, 8)

spi_flash_read failed: 1 (4296828, 8)

spi_flash_read failed: 1 (4300924, 8)

spi_flash_read failed: 1 (4305020, 8)

spi_flash_read failed: 1 (4309116, 8)

spi_flash_read failed: 1 (4313212, 8)

spi_flash_read failed: 1 (4317308, 8)

spi_flash_read failed: 1 (4321404, 8)

spi_flash_read failed: 1 (4194304, 132)

spi_flash_read failed: 1 (4198400, 132)

spi_flash_read failed: 1 (4202496, 132)

spi_flash_read failed: 1 (4206592, 132)

spi_flash_read failed: 1 (4210688, 132)

spi_flash_read failed: 1 (4214784, 132)

spi_flash_read failed: 1 (4218880, 132)

spi_flash_read failed: 1 (4222976, 132)

spi_flash_read failed: 1 (4227072, 132)

spi_flash_read failed: 1 (4231168, 132)

spi_flash_read failed: 1 (4235264, 132)

spi_flash_read failed: 1 (4239360, 132)

spi_flash_read failed: 1 (4243456, 132)

spi_flash_read failed: 1 (4247552, 132)

spi_flash_read failed: 1 (4251648, 132)

spi_flash_read failed: 1 (4255744, 132)

spi_flash_read failed: 1 (4259840, 132)

spi_flash_read failed: 1 (4263936, 132)

spi_flash_read failed: 1 (4268032, 132)

spi_flash_read failed: 1 (4272128, 132)

spi_flash_read failed: 1 (4276224, 132)

spi_flash_read failed: 1 (4280320, 132)

spi_flash_read failed: 1 (4284416, 132)

spi_flash_read failed: 1 (4288512, 132)

spi_flash_read failed: 1 (4292608, 132)

spi_flash_read failed: 1 (4296704, 132)

spi_flash_read failed: 1 (4300800, 132)

spi_flash_read failed: 1 (4304896, 132)

spi_flash_read failed: 1 (4308992, 132)

spi_flash_read failed: 1 (4313088, 132)

spi_flash_read failed: 1 (4317184, 132)

spi_flash_read failed: 1 (4321280, 132)

spi_flash_read failed: 1 (4194304, 132)

spi_flash_read failed: 1 (4194428, 8)

spi_flash_read failed: 1 (4194304, 132)

spi_flash_read failed: 1 (4198400, 132)

spi_flash_read failed: 1 (4202496, 132)

spi_flash_read failed: 1 (4206592, 132)

spi_flash_read failed: 1 (4210688, 132)

spi_flash_read failed: 1 (4214784, 132)

spi_flash_read failed: 1 (4218880, 132)

spi_flash_read failed: 1 (4222976, 132)

spi_flash_read failed: 1 (4227072, 132)

spi_flash_read failed: 1 (4231168, 132)

spi_flash_read failed: 1 (4235264, 132)

spi_flash_read failed: 1 (4239360, 132)

spi_flash_read failed: 1 (4243456, 132)

spi_flash_read failed: 1 (4247552, 132)

spi_flash_read failed: 1 (4251648, 132)

spi_flash_read failed: 1 (4255744, 132)

spi_flash_read failed: 1 (4259840, 132)

spi_flash_read failed: 1 (4263936, 132)

spi_flash_read failed: 1 (4268032, 132)

spi_flash_read failed: 1 (4272128, 132)

spi_flash_read failed: 1 (4276224, 132)

spi_flash_read failed: 1 (4280320, 132)

spi_flash_read failed: 1 (4284416, 132)

spi_flash_read failed: 1 (4288512, 132)

spi_flash_read failed: 1 (4292608, 132)

spi_flash_read failed: 1 (4296704, 132)

spi_flash_read failed: 1 (4300800, 132)

spi_flash_read failed: 1 (4304896, 132)

spi_flash_read failed: 1 (4308992, 132)

spi_flash_read failed: 1 (4313088, 132)

spi_flash_read failed: 1 (4317184, 132)

spi_flash_read failed: 1 (4321280, 132)

spi_flash_read failed: 1 (4194304, 132)

spi_flash_read failed: 1 (4198400, 132)

spi_flash_read failed: 1 (4202496, 132)

spi_flash_read failed: 1 (4206592, 132)

spi_flash_read failed: 1 (4210688, 132)

spi_flash_read failed: 1 (4214784, 132)

spi_flash_read failed: 1 (4218880, 132)

spi_flash_read failed: 1 (4222976, 132)

spi_flash_read failed: 1 (4227072, 132)

spi_flash_read failed: 1 (4231168, 132)

spi_flash_read failed: 1 (4235264, 132)

spi_flash_read failed: 1 (4239360, 132)

spi_flash_read failed: 1 (4243456, 132)

spi_flash_read failed: 1 (4247552, 132)

spi_flash_read failed: 1 (4251648, 132)

spi_flash_read failed: 1 (4255744, 132)

spi_flash_read failed: 1 (4259840, 132)

spi_flash_read failed: 1 (4263936, 132)

spi_flash_read failed: 1 (4268032, 132)

spi_flash_read failed: 1 (4272128, 132)

spi_flash_read failed: 1 (4276224, 132)

spi_flash_read failed: 1 (4280320, 132)

spi_flash_read failed: 1 (4284416, 132)

spi_flash_read failed: 1 (4288512, 132)

spi_flash_read failed: 1 (4292608, 132)

spi_flash_read failed: 1 (4296704, 132)

spi_flash_read failed: 1 (4300800, 132)

spi_flash_read failed: 1 (4304896, 132)

spi_flash_read failed: 1 (4308992, 132)

spi_flash_read failed: 1 (4313088, 132)

spi_flash_read failed: 1 (4317184, 132)

spi_flash_read failed: 1 (4321280, 132)

open file error
write file error
spi_flash_read failed: 1 (4194304, 132)

read errno
-->  <--
----------------------SDK version:1.4.0(c599790)

Statistics: Posted by iolaso — Sat Jul 02, 2016 12:11 am


]]>
2016-06-30T16:42:22+08:00 2016-06-30T16:42:22+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2215&p=7602#p7602 <![CDATA[【Feedback】Re: spiffs: "spi_flash_read failed: 1"]]> #include "esp_common.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "spiffs.h"
#include "spiffs_nucleus.h"


#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#define FS1_FLASH_SIZE (128*1024)
#define FS1_FLASH_ADDR (4096*1024)
#define SECTOR_SIZE (4*1024)
#define LOG_BLOCK SECTOR_SIZE
#define LOG_PAGE (128)
#define FD_BUF_SIZE (32*4)
#define CACHE_BUF_SIZE (LOG_PAGE+32)*8


void spiffs_fs1_init(void)
{
struct esp_spiffs_config config;
config.phys_size = FS1_FLASH_SIZE;
config.phys_addr = FS1_FLASH_ADDR;
config.phys_erase_block = SECTOR_SIZE;
config.log_block_size = LOG_BLOCK;
config.log_page_size = LOG_PAGE;
config.fd_buf_size = FD_BUF_SIZE * 2;
config.cache_buf_size = CACHE_BUF_SIZE;
esp_spiffs_init(&config);
}

void spiffs_fs1_write_read(void)
{
char *buf="hello world";
char out[20] = {0};
int pfd = open("myfile", O_TRUNC | O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
if(pfd <= 3) {
printf("open file error \n");
}
int write_byte = write(pfd, buf, strlen(buf));
if (write_byte <= 0)
{
printf("write file error \n");
}

close(pfd);

open("myfile",O_RDWR);
if (read(pfd, out, 20) < 0)
printf("read errno \n");
close(pfd);
printf("--> %s <--\n", out);
}


/******************************************************************************
* FunctionName : user_init
* Description : entry of user application, init user function here
* Parameters : none
* Returns : none
*******************************************************************************/
void user_init(void)
{
spiffs_fs1_init();
spiffs_fs1_write_read();
printf("----------------------SDK version:%s\n", system_get_sdk_version());
}

Statistics: Posted by ESP_Rubin — Thu Jun 30, 2016 4:42 pm


]]>
2016-05-25T00:59:09+08:00 2016-05-25T00:59:09+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2215&p=7062#p7062 <![CDATA[【Feedback】spiffs: "spi_flash_read failed: 1"]]> I am using a SIZE_MAP = 6 , so that the configuration is 6: 4,096 KB ( 1,024 KB + 1,024 KB ) .

Below I leave my code along with the error:

Code:

// spiffs file system size
#define SPIFFS_FLASH_SIZE     (1024*1024) //2 KB
#define SPIFFS_PHYS_ADDR      (4096*1024) //4096KB

#define SECTOR_SIZE         4096         //4KB
#define PHYS_ERASE_BLOCK    SECTOR_SIZE*16//(SECTOR_SIZE*16) //64KB
#define LOG_BLOCK           SECTOR_SIZE*16//(SECTOR_SIZE*16) //128KB
#define LOG_PAGE            256//(LOG_BLOCK/256) //256 byte


#define FD_BUF_SIZE     32*4
#define CACHE_BUF_SIZE  (LOG_PAGE + 32)*4

    struct esp_spiffs_config conf;
    conf.phys_size = SPIFFS_FLASH_SIZE;
    conf.phys_addr = SPIFFS_PHYS_ADDR;
    conf.phys_erase_block = SECTOR_SIZE;
    conf.log_block_size = LOG_BLOCK;
    conf.log_page_size = LOG_PAGE;
    conf.fd_buf_size = FD_BUF_SIZE*2;
    conf.cache_buf_size = CACHE_BUF_SIZE;
    esp_spiffs_init(&conf);

    char *buf="hello world";
    char out[20] = {0};
    int pfd = open("myfile", O_TRUNC | O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
    if(pfd <= 3) {
     printf("open file error \n");
    }
    int write_byte = write(pfd, buf, strlen(buf));
    if (write_byte <= 0)
    {
     printf("write file error \n");
    }
    close(pfd);

    open("myfile",O_RDWR);
    if (read(pfd, out, 20) < 0)
     printf("read errno \n");
    close(pfd);
    printf("--> %s <--\n", out);



The os_printf message:

Code:

SDK version:1.4.0(c599790)
spi_flash_read failed: 1 (4194812, 8)
spi_flash_read failed: 1 (4260348, 8)
spi_flash_read failed: 1 (4325884, 8)
spi_flash_read failed: 1 (4391420, 8)
spi_flash_read failed: 1 (4456956, 8)
spi_flash_read failed: 1 (4522492, 8)
spi_flash_read failed: 1 (4588028, 8)
spi_flash_read failed: 1 (4653564, 8)
spi_flash_read failed: 1 (4719100, 8)
spi_flash_read failed: 1 (4784636, 8)
spi_flash_read failed: 1 (4850172, 8)
spi_flash_read failed: 1 (4915708, 8)
spi_flash_read failed: 1 (4981244, 8)
spi_flash_read failed: 1 (5046780, 8)
spi_flash_read failed: 1 (5112316, 8)
spi_flash_read failed: 1 (5177852, 8)
spi_flash_read failed: 1 (4194304, 260)


If anyone knows the subject, I would appreciate any advice .

Thanks in advance!!!

Statistics: Posted by iolaso — Wed May 25, 2016 12:59 am


]]>