ESP8266 Developer Zone The Official ESP8266 Forum 2016-07-01T15:49:39+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=2367 2016-07-01T15:49:39+08:00 2016-07-01T15:49:39+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2367&p=7650#p7650 <![CDATA[Re: 关于FLASH的使用问题]]> #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 — Fri Jul 01, 2016 3:49 pm


]]>
2016-07-01T10:12:36+08:00 2016-07-01T10:12:36+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2367&p=7627#p7627 <![CDATA[Re: 关于FLASH的使用问题]]> Statistics: Posted by maike — Fri Jul 01, 2016 10:12 am


]]>
2016-06-30T10:54:30+08:00 2016-06-30T10:54:30+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2367&p=7573#p7573 <![CDATA[【Feedback】关于FLASH的使用问题]]> Statistics: Posted by ESP_Rubin — Thu Jun 30, 2016 10:54 am


]]>
2016-06-29T18:52:04+08:00 2016-06-29T18:52:04+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2367&p=7560#p7560 <![CDATA[关于FLASH的使用问题]]> 就是如果我的板子是2MB的 SPI flash,如果我在编译和烧写固件的时候都选择的是1MB的配置,我还能在自己的程序里面时候后面的1MB来做自己的一些存储吗?

Statistics: Posted by maike — Wed Jun 29, 2016 6:52 pm


]]>