Code:
// spiffs file system size
#define SPIFFS_FLASH_SIZE (256*1024) //512 KB
// spiffs file system offset in emulated spi flash
#define SPIFFS_PHYS_ADDR (592*1024) //512KB
#define SECTOR_SIZE 4096 //4KB
#define PHYS_ERASE_BLOCK SECTOR_SIZE//(SECTOR_SIZE*16) //64KB
#define LOG_BLOCK SECTOR_SIZE//(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
Statistics: Posted by marhc_seven — Thu Nov 19, 2015 12:00 pm
Code:
#define LOG_PAGE_SIZE 256
#define FLASH_SECTOR_SIZE 4096
static s32_t flash_read(u32_t addr, u32_t size, u8_t *dst);
static s32_t flash_write(u32_t addr, u32_t size, u8_t *src);
static s32_t flash_erase(u32_t addr, u32_t size);
static u8_t spiffs_work_buf[LOG_PAGE_SIZE * 2];
static u8_t spiffs_fds[32 * 4];
static u8_t spiffs_cache_buf[(LOG_PAGE_SIZE + 32) * 4];
int16_t ZB_FUNC_ATTR_NORMAL
zbFlashMount(uint32_t addr, uint32_t size)
{
int result;
spiffs_config cfg;
cfg.phys_size = size;
cfg.phys_addr = addr;
cfg.phys_erase_block = FLASH_SECTOR_SIZE;
cfg.log_block_size = FLASH_SECTOR_SIZE;
cfg.log_page_size = LOG_PAGE_SIZE;
cfg.hal_read_f = flash_read;
cfg.hal_write_f = flash_write;
cfg.hal_erase_f = flash_erase;
result = SPIFFS_mount(&zb_SPIFFS_fs, &cfg, spiffs_work_buf, spiffs_fds, sizeof(spiffs_fds),
spiffs_cache_buf, sizeof(spiffs_cache_buf), NULL);
return(result);
}
The order doesn't matter - it's a File System. You access the content using a file system metaphor, i.e. open by name, read content, close the file.marhc_seven wrote:
if there are more than one html file need to be stored. when i want to store them in the flash IC.
is that ordered ?which one should be put in the first and which one should be second, and so on ?
Statistics: Posted by dkinzer — Wed Nov 18, 2015 11:49 pm
“The boundary of a logical block must coincide with one or more physical blocks”
test code
https://github.com/pellepl/spiffs/blob/master/docs/TECH_SPEC
If you're using a the standard linker script, there is unused space between 0x10000 and 0x40000. That would allow a SPIFFS area as large as 192KB without needing to modify the linker script.
Code:
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x18000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40210000, len = 0xfc000
}
Code:
// total emulated spi flash size
#define PHYS_FLASH_SIZE (1*1024*1024) //1MB
// spiffs file system size
#define SPIFFS_FLASH_SIZE (256*1024) //512 KB
// spiffs file system offset in emulated spi flash
#define SPIFFS_PHYS_ADDR (752*1024) //begin from 752KB ====> 0xbc000
#define SECTOR_SIZE 4096 //4KB
#define PHYS_ERASE_BLOCK (SECTOR_SIZE*16) //64KB
#define LOG_BLOCK (SECTOR_SIZE*16) //128KB
#define LOG_PAGE (LOG_BLOCK/256) //256 byte
#define FD_BUF_SIZE 64*6
#define CACHE_BUF_SIZE (LOG_PAGE + 32)*8
Code:
spi_flash_read failed: 1 (1360380, 8)
spi_flash_read failed: 1 (1425916, 8)
spi_flash_read failed: 1 (1491452, 8)
spi_flash_read failed: 1 (1556988, 8)
spi_flash_read failed: 1 (1622524, 8)
spi_flash_read failed: 1 (1688060, 8)
spi_flash_read failed: 1 (1753596, 8)
spi_flash_read failed: 1 (770048, 260)
spiffs config succes
"Spiffs"(stack_size = 4,task handle = 3fff3848) overflow the heap_size.
"Spiffs"(stack_size = 4,task handle = 3fff3848) overflow the heap_size.
"Spiffs"(stack_size = 4,task handle = 3fff3848) overflow the heap_size.
...
...
but if you don't modify the linker script to account for the Flash you removed for SPIFFS you won't get an error when the size of your application causes it to overlap the SPIFFS area.
Statistics: Posted by marhc_seven — Wed Nov 18, 2015 11:53 am
Code:
#define SPIFFS_CFG_PHYS_SZ(ignore) (1024*1024*2)
#define SPIFFS_CFG_PHYS_ERASE_SZ(ignore) (65536)
#define SPIFFS_CFG_PHYS_ADDR(ignore) (0)
#define SPIFFS_CFG_LOG_PAGE_SZ(ignore) (256)
#define SPIFFS_CFG_LOG_BLOCK_SZ(ignore) (65536)
But if you read more carefully you'll see that 4KB blocks can be erased and written.marhc_seven wrote:
actually the datasheet of W25X80 (1MB flash)shows the block size only one type and it is 64KB
It means where in the Flash chips should the SPIFFS area begins, relative to address 0 of the Flash chip. Where you actually put it depends on how you link your ESP8266 application. You could position it just before the system parameters area (which is always located 16K from the end of Flash) but if you don't modify the linker script to account for the Flash you removed for SPIFFS you won't get an error when the size of your application causes it to overlap the SPIFFS area.marhc_seven wrote:
what does SPIFFS_PHYS_ADDR mean, offset in the emulated spi flash
Search for "spiffy" on github. It's an application that builds a SPIFFS image using the files in a directory. After you have the image built you can install it in Flash at your chosen address using any of the available download tools.marhc_seven wrote:
if we want to put a html file in this file system, how could we do?
Statistics: Posted by dkinzer — Wed Nov 18, 2015 12:23 am
Code:
struct esp_spiffs_config {
uint32 phys_size; /**< physical size of the SPI Flash */
uint32 phys_addr; /**< physical offset in spi flash used for spiffs, must be on block boundary */
uint32 phys_erase_block; /**< physical size when erasing a block */
uint32 log_block_size; /**< logical size of a block, must be on physical block size boundary and must never be less than a physical block */
uint32 log_page_size; /**< logical size of a page, at least log_block_size/8 */
uint32 fd_buf_size; /**< file descriptor memory area size */
uint32 cache_buf_size; /**< cache buffer size */
};
Code:
// total emulated spi flash size
#define PHYS_FLASH_SIZE (16*1024*1024)
// spiffs file system size
#define SPIFFS_FLASH_SIZE (2*1024*1024)
// spiffs file system offset in emulated spi flash
#define SPIFFS_PHYS_ADDR (4*1024*1024)
#define SECTOR_SIZE 65536
#define LOG_BLOCK (SECTOR_SIZE*2)
#define LOG_PAGE (SECTOR_SIZE/256)
#define FD_BUF_SIZE 64*6
#define CACHE_BUF_SIZE (LOG_PAGE + 32)*8
Statistics: Posted by marhc_seven — Tue Nov 17, 2015 2:21 pm