Ejemplo n.º 1
0
// FS formatting function
// Returns 1 if OK, 0 for error
int myspiffs_format( void )
{
  SPIFFS_unmount(&fs);
  myspiffs_mount_internal(TRUE);
  SPIFFS_unmount(&fs);

  NODE_DBG("Formatting: size 0x%x, addr 0x%x\n", fs.cfg.phys_size, fs.cfg.phys_addr);

  if (SPIFFS_format(&fs) < 0) {
    return 0;
  }

  return myspiffs_mount();
}
Ejemplo n.º 2
0
void fs_reset_specific(uint32_t addr_offset, uint32_t phys_addr, uint32_t phys_size,
    uint32_t phys_sector_size,
    uint32_t log_block_size, uint32_t log_page_size) {
  fs_set_addr_offset(addr_offset);
  memset(area, 0xcc, sizeof(area));
  memset(&AREA(phys_addr), 0xff, phys_size);
  memset(&__fs, 0, sizeof(__fs));

  memset(erases,0,sizeof(erases));
  memset(_cache,0,sizeof(_cache));

  int32_t res = fs_mount_specific(phys_addr, phys_size, phys_sector_size, log_block_size, log_page_size);

#if SPIFFS_USE_MAGIC
  if (res == SPIFFS_OK) {
    SPIFFS_unmount(&__fs);
  }
  res = SPIFFS_format(&__fs);
  if (res != SPIFFS_OK) {
    printf("format failed, %i\n", SPIFFS_errno(&__fs));
  }
  res = fs_mount_specific(phys_addr, phys_size, phys_sector_size, log_block_size, log_page_size);
  if (res != SPIFFS_OK) {
    printf("mount failed, %i\n", SPIFFS_errno(&__fs));
  }
#endif

  clear_flash_ops_log();
  log_flash_ops = 1;
  fs_check_fixes = 0;
}
Ejemplo n.º 3
0
/**
 * addr_offset
 */
void fs_reset_specific(u32_t addr_offset, u32_t phys_addr, u32_t phys_size,
    u32_t phys_sector_size,
    u32_t log_block_size, u32_t log_page_size) {
  fs_create(phys_size + phys_addr - addr_offset,
            phys_sector_size,
            log_page_size,
            DEFAULT_NUM_FD,
            DEFAULT_NUM_CACHE_PAGES);
  fs_set_addr_offset(addr_offset);
  memset(&AREA(addr_offset), 0xcc, _area_sz);
  memset(&AREA(phys_addr), 0xff, phys_size);
  memset(&__fs, 0, sizeof(__fs));

  s32_t res = fs_mount_specific(phys_addr, phys_size, phys_sector_size, log_block_size, log_page_size);

#if SPIFFS_USE_MAGIC
  if (res == SPIFFS_OK) {
    SPIFFS_unmount(&__fs);
  }
  res = SPIFFS_format(&__fs);
  if (res != SPIFFS_OK) {
    printf("format failed, %i\n", SPIFFS_errno(&__fs));
  }
  res = fs_mount_specific(phys_addr, phys_size, phys_sector_size, log_block_size, log_page_size);
  if (res != SPIFFS_OK) {
    printf("mount failed, %i\n", SPIFFS_errno(&__fs));
  }
#endif

  clear_flash_ops_log();
  log_flash_ops = 1;
  fs_check_fixes = 0;
}
_i32 fs_umount(struct mount_info *m) {
  LOG(LL_INFO, ("Unmounting %s.%d", m->cpfx, m->cidx));
  SPIFFS_unmount(&m->fs);
  free(m->cpfx);
  free(m->work);
  free(m->fds);
  fs_close_container(m);
  memset(m, 0, sizeof(*m));
  return 1;
}
Ejemplo n.º 5
0
//file.format()
static int file_format( lua_State* L )
{
  if(SPIFFS_mounted(&fs)==false) lua_spiffs_mount();
   
  SPIFFS_unmount(&fs);
  
  int ret = SPIFFS_format(&fs);
  if(ret==SPIFFS_OK)
  {
    l_message(NULL,"format done\r\n");
    lua_spiffs_mount();    
  }
  else
    l_message(NULL,"format error\r\n");
  return 0;
}
Ejemplo n.º 6
0
// FS formatting function
// Returns 1 if OK, 0 for error
int myspiffs_format( void )
{
  SPIFFS_unmount(&fs);
  u32_t sect_first, sect_last;
  sect_first = ( u32_t )platform_flash_get_first_free_block_address( NULL ); 
  sect_first += 0x3000;
  sect_first &= 0xFFFFC000;  // align to 4 sector.
  sect_first = platform_flash_get_sector_of_address(sect_first);
  sect_last = INTERNAL_FLASH_SIZE + INTERNAL_FLASH_START_ADDRESS - 4;
  sect_last = platform_flash_get_sector_of_address(sect_last);
  NODE_DBG("sect_first: %x, sect_last: %x", sect_first, sect_last);
  while( sect_first <= sect_last )
    if( platform_flash_erase_sector( sect_first ++ ) == PLATFORM_ERR )
      return 0;
  spiffs_mount();
  return 1;
}
Ejemplo n.º 7
0
static void esp_spiffs_free(esp_spiffs_t ** efs)
{
    esp_spiffs_t * e = *efs;
    if (*efs == NULL) {
        return;
    }
    *efs = NULL;

    if (e->fs) {
        SPIFFS_unmount(e->fs);
        free(e->fs);
    }
    vSemaphoreDelete(e->lock);
    free(e->fds);
    free(e->cache);
    free(e->work);
    free(e);
}
Ejemplo n.º 8
0
} TEST_END


TEST(robert) {
  // create a clean file system starting at address 0, 2 megabytes big,
  // sector size 65536, block size 65536, page size 256
  fs_reset_specific(0, 0, 1024*1024*2, 65536, 65536, 256);

  int res;
  spiffs_file fd;
  char fname[32];

  sprintf(fname, "test.txt");
  fd = SPIFFS_open(FS, fname, SPIFFS_RDWR | SPIFFS_CREAT | SPIFFS_TRUNC, 0);
  TEST_CHECK(fd > 0);
  int i;
  res = SPIFFS_OK;
  char buf[500];
  memset(buf, 0xaa, 500);
  res = SPIFFS_write(FS, fd, buf, 500);
  TEST_CHECK(res >= SPIFFS_OK);
  SPIFFS_close(FS, fd);

  int errno = SPIFFS_errno(FS);
  TEST_CHECK(errno == SPIFFS_OK);

  //SPIFFS_vis(FS);
  // unmount
  SPIFFS_unmount(FS);

  // remount
  res = fs_mount_specific(0, 1024*1024*2, 65536, 65536, 256);
  TEST_CHECK(res== SPIFFS_OK);

  //SPIFFS_vis(FS);

  spiffs_stat s;
  TEST_CHECK(SPIFFS_stat(FS, fname, &s) == SPIFFS_OK);
  printf("file %s stat size %i\n", s.name, s.size);
  TEST_CHECK(s.size == 500);

  return TEST_RES_OK;

} TEST_END
Ejemplo n.º 9
0
void myspiffs_unmount() {
  SPIFFS_unmount(&fs);
}
Ejemplo n.º 10
0
void spiffs_unmount() {
    SPIFFS_unmount(&_filesystemStorageHandle);
}
Ejemplo n.º 11
0
void RamSpiffs::unmount(){
    SPIFFS_unmount(&m_fs);        
}