//----------------------- void lua_spiffs_mount() { mico_logic_partition_t* part; spiffs_config cfg; part = MicoFlashGetInfo( MICO_PARTITION_LUA ); cfg.phys_size = part->partition_length; cfg.phys_addr = part->partition_start_addr; // start spiffs at start of spi flash cfg.phys_erase_block = 65536/2; // according to datasheet cfg.log_block_size = 65536; // let us not complicate things cfg.log_page_size = LOG_PAGE_SIZE; // as we said */ cfg.hal_read_f = lspiffs_read; cfg.hal_write_f = lspiffs_write; cfg.hal_erase_f = lspiffs_erase; //if (part == NULL) // goto exit; //MicoFlashInitialize(MICO_FLASH_FOR_LUA); if(SPIFFS_mounted(&fs)) return; int res = SPIFFS_mount(&fs, &cfg, spiffs_work_buf, spiffs_fds, sizeof(spiffs_fds), spiffs_cache_buf, sizeof(spiffs_cache_buf), 0); }
void lua_spiffs_mount() { spiffs_config cfg; cfg.phys_size = LUA_FLASH_SIZE; cfg.phys_addr = LUA_START_ADDRESS; // start spiffs at start of spi flash cfg.phys_erase_block = 65536/2; // according to datasheet cfg.log_block_size = 65536; // let us not complicate things cfg.log_page_size = LOG_PAGE_SIZE; // as we said */ cfg.hal_read_f = lspiffs_read; cfg.hal_write_f = lspiffs_write; cfg.hal_erase_f = lspiffs_erase; MicoFlashInitialize(MICO_FLASH_FOR_LUA); if(SPIFFS_mounted(&fs)) return; int res = SPIFFS_mount(&fs, &cfg, spiffs_work_buf, spiffs_fds, sizeof(spiffs_fds), spiffs_cache_buf, sizeof(spiffs_cache_buf), 0); }
bool esp_spiffs_mounted(const char* partition_label) { int index; if (esp_spiffs_by_label(partition_label, &index) != ESP_OK) { return false; } return (SPIFFS_mounted(_efs[index]->fs)); }
// FS formatting function bool spiffs_format() { if (_filesystemStorageHandle.user_data) { return SPIFFS_ERR_NOT_MOUNTED; } if (SPIFFS_mounted(&_filesystemStorageHandle)) { return SPIFFS_ERR_MOUNTED; } SPIFFS_format(&_filesystemStorageHandle); return true; }
//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; }