// 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();
}
// FS formatting function
// Returns 1 if OK, 0 for error
int myspiffs_format( void )
{
  SPIFFS_unmount(&fs);
  u32_t sect_first, sect_last;
#ifdef SPIFFS_FIXED_LOCATION
  sect_first = SPIFFS_FIXED_LOCATION;
#else
  sect_first = ( u32_t )platform_flash_get_first_free_block_address( NULL ); 
#endif
  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\n", sect_first, sect_last);
  while( sect_first <= sect_last )
    if( platform_flash_erase_sector( sect_first ++ ) == PLATFORM_ERR )
      return 0;
  myspiffs_mount();
  return 1;
}