From a5e17644518290cf7e0a239de85c05fc58dbff18 Mon Sep 17 00:00:00 2001 From: loboris Date: Fri, 29 Dec 2017 15:02:48 +0100 Subject: [PATCH 1/7] Added directory support --- README.md | 4 ++ include/spiffs_config.h | 80 +++++++++++++----------- main.cpp | 133 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 175 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 6d9a275..fe343db 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # mkspiffs Tool to build and unpack [SPIFFS](https://github.com/pellepl/spiffs) images. +**IMPORTANT** +The **sdkconfig.h** from your application using spiffs is used in build process! +Before building **mkspiffs**, copy the **sdkconfig.h** from your application **build/include** directory to **mkspiffs/include** + ## Usage diff --git a/include/spiffs_config.h b/include/spiffs_config.h index 7820909..cbfda33 100755 --- a/include/spiffs_config.h +++ b/include/spiffs_config.h @@ -18,6 +18,7 @@ #include #include #include +#include // Set generic spiffs debug output call. #ifndef SPIFFS_DBG @@ -71,39 +72,51 @@ typedef uint8_t u8_t; // Enable/disable API functions to determine exact number of bytes // for filedescriptor and cache buffers. Once decided for a configuration, // this can be disabled to reduce flash. -#ifndef SPIFFS_BUFFER_HELP #define SPIFFS_BUFFER_HELP 0 -#endif // Enables/disable memory read caching of nucleus file system operations. // If enabled, memory area must be provided for cache in SPIFFS_mount. -#ifndef SPIFFS_CACHE -#define SPIFFS_CACHE 1 +#ifdef CONFIG_SPIFFS_CACHE +#define SPIFFS_CACHE (1) +#else +#define SPIFFS_CACHE (0) #endif #if SPIFFS_CACHE // Enables memory write caching for file descriptors in hydrogen -#ifndef SPIFFS_CACHE_WR -#define SPIFFS_CACHE_WR 1 +#ifdef CONFIG_SPIFFS_CACHE_WR +#define SPIFFS_CACHE_WR (1) +#else +#define SPIFFS_CACHE_WR (0) #endif // Enable/disable statistics on caching. Debug/test purpose only. -#ifndef SPIFFS_CACHE_STATS -#define SPIFFS_CACHE_STATS 0 +#ifdef CONFIG_SPIFFS_CACHE_STATS +#define SPIFFS_CACHE_STATS (1) +#else +#define SPIFFS_CACHE_STATS (0) #endif #endif // Always check header of each accessed page to ensure consistent state. // If enabled it will increase number of reads, will increase flash. -#ifndef SPIFFS_PAGE_CHECK -#define SPIFFS_PAGE_CHECK 1 +#ifdef CONFIG_SPIFFS_PAGE_CHECK +#define SPIFFS_PAGE_CHECK (1) +#else +#define SPIFFS_PAGE_CHECK (0) #endif // Define maximum number of gc runs to perform to reach desired free pages. +#ifdef CONFIG_SPIFFS_GC_MAX_RUNS +#define SPIFFS_GC_MAX_RUNS CONFIG_SPIFFS_GC_MAX_RUNS +#else #define SPIFFS_GC_MAX_RUNS 10 +#endif // Enable/disable statistics on gc. Debug/test purpose only. -#ifndef SPIFFS_GC_STATS -#define SPIFFS_GC_STATS 0 +#ifdef CONFIG_SPIFFS_GC_STATS +#define SPIFFS_GC_STATS (1) +#else +#define SPIFFS_GC_STATS (0) #endif // Garbage collecting examines all pages in a block which and sums up @@ -125,8 +138,11 @@ typedef uint8_t u8_t; // Object name maximum length. Note that this length include the // zero-termination character, meaning maximum string of characters // can at most be SPIFFS_OBJ_NAME_LEN - 1. +#ifdef CONFIG_SPIFFS_OBJ_NAME_LEN +#define SPIFFS_OBJ_NAME_LEN (CONFIG_SPIFFS_OBJ_NAME_LEN) +#else #define SPIFFS_OBJ_NAME_LEN (32) - +#endif // Maximum length of the metadata associated with an object. // Setting to non-zero value enables metadata-related API but also // changes the on-disk format, so the change is not backward-compatible. @@ -137,21 +153,25 @@ typedef uint8_t u8_t; // This is derived from following: // logical_page_size - (SPIFFS_OBJ_NAME_LEN + sizeof(spiffs_page_header) + // spiffs_object_ix_header fields + at least some LUT entries) +#ifdef CONFIG_SPIFFS_META_LENGTH +#define SPIFFS_OBJ_META_LEN (CONFIG_SPIFFS_META_LENGTH) +#else #define SPIFFS_OBJ_META_LEN (0) +#endif // Size of buffer allocated on stack used when copying data. // Lower value generates more read/writes. No meaning having it bigger // than logical page size. -#ifndef SPIFFS_COPY_BUFFER_STACK #define SPIFFS_COPY_BUFFER_STACK (256) -#endif // Enable this to have an identifiable spiffs filesystem. This will look for // a magic in all sectors to determine if this is a valid spiffs system or // not on mount point. If not, SPIFFS_format must be called prior to mounting // again. -#ifndef SPIFFS_USE_MAGIC +#ifdef CONFIG_SPIFFS_USE_MAGIC #define SPIFFS_USE_MAGIC (1) +#else +#define SPIFFS_USE_MAGIC (0) #endif #if SPIFFS_USE_MAGIC @@ -160,8 +180,10 @@ typedef uint8_t u8_t; // For example, a filesystem configured and formatted for 4 megabytes will not // be accepted for mounting with a configuration defining the filesystem as 2 // megabytes. -#ifndef SPIFFS_USE_MAGIC_LENGTH +#ifdef CONFIG_SPIFFS_USE_MAGIC_LENGTH #define SPIFFS_USE_MAGIC_LENGTH (1) +#else +#define SPIFFS_USE_MAGIC_LENGTH (0) #endif #endif @@ -179,14 +201,10 @@ typedef uint8_t u8_t; #define SPIFFS_SINGLETON 0 // Enable this if your target needs aligned data for index tables -#ifndef SPIFFS_ALIGNED_OBJECT_INDEX_TABLES #define SPIFFS_ALIGNED_OBJECT_INDEX_TABLES 0 -#endif // Enable this if you want the HAL callbacks to be called with the spiffs struct -#ifndef SPIFFS_HAL_CALLBACK_EXTRA -#define SPIFFS_HAL_CALLBACK_EXTRA 0 -#endif +#define SPIFFS_HAL_CALLBACK_EXTRA 1 // Enable this if you want to add an integer offset to all file handles // (spiffs_file). This is useful if running multiple instances of spiffs on @@ -194,9 +212,7 @@ typedef uint8_t u8_t; // belongs. // NB: This adds config field fh_ix_offset in the configuration struct when // mounting, which must be defined. -#ifndef SPIFFS_FILEHDL_OFFSET #define SPIFFS_FILEHDL_OFFSET 0 -#endif // Enable this to compile a read only version of spiffs. // This will reduce binary size of spiffs. All code comprising modification @@ -208,9 +224,7 @@ typedef uint8_t u8_t; // SPIFFS_USE_MAGIC is enabled, SPIFFS_ERR_RO_ABORTED_OPERATION will be // returned. // Might be useful for e.g. bootloaders and such. -#ifndef SPIFFS_READ_ONLY #define SPIFFS_READ_ONLY 0 -#endif // Enable this to add a temporal file cache using the fd buffer. // The effects of the cache is that SPIFFS_open will find the file faster in @@ -230,18 +244,14 @@ typedef uint8_t u8_t; // fd is closed. If the file is opened again, the location of the file is found // directly. If all available descriptors become opened, all cache memory is // lost. -#ifndef SPIFFS_TEMPORAL_FD_CACHE #define SPIFFS_TEMPORAL_FD_CACHE 1 -#endif // Temporal file cache hit score. Each time a file is opened, all cached files // will lose one point. If the opened file is found in cache, that entry will // gain SPIFFS_TEMPORAL_CACHE_HIT_SCORE points. One can experiment with this // value for the specific access patterns of the application. However, it must // be between 1 (no gain for hitting a cached entry often) and 255. -#ifndef SPIFFS_TEMPORAL_CACHE_HIT_SCORE #define SPIFFS_TEMPORAL_CACHE_HIT_SCORE 4 -#endif // Enable to be able to map object indices to memory. // This allows for faster and more deterministic reading if cases of reading @@ -255,15 +265,15 @@ typedef uint8_t u8_t; // collecting or when modifying the indices. The latter is invoked by when the // file is modified in some way. The index buffer is tied to the file // descriptor. -#ifndef SPIFFS_IX_MAP #define SPIFFS_IX_MAP 1 -#endif // Set SPIFFS_TEST_VISUALISATION to non-zero to enable SPIFFS_vis function // in the api. This function will visualize all filesystem using given printf -// function.. -#ifndef SPIFFS_TEST_VISUALISATION -#define SPIFFS_TEST_VISUALISATION 1 +// function. +#ifdef CONFIG_SPIFFS_TEST_VISUALISATION +#define SPIFFS_TEST_VISUALISATION 1 +#else +#define SPIFFS_TEST_VISUALISATION 0 #endif #if SPIFFS_TEST_VISUALISATION #ifndef spiffs_printf diff --git a/main.cpp b/main.cpp index e6482db..d0fc95c 100644 --- a/main.cpp +++ b/main.cpp @@ -9,6 +9,8 @@ #include #include "spiffs.h" +#include "spiffs_nucleus.h" +#include #include #include #include @@ -21,6 +23,21 @@ #include "tclap/CmdLine.h" #include "tclap/UnlabeledValueArg.h" +#if defined (CONFIG_SPIFFS_USE_MTIME) || defined (CONFIG_SPIFFS_USE_DIR) +/** + * @brief SPIFFS metadata structure + */ +typedef struct { +#ifdef CONFIG_SPIFFS_USE_MTIME + s32_t mtime; /*!< file modification time */ +#endif +#ifdef CONFIG_SPIFFS_USE_DIR + u8_t type; /*!< file type */ +#endif +} __attribute__((packed, aligned(1))) spiffs_meta_t; +#endif + + static std::vector s_flashmem; static std::string s_dirName; @@ -49,6 +66,22 @@ static const char* ignored_file_names[] = { ".gitmodules" }; +#if SPIFFS_HAL_CALLBACK_EXTRA +static s32_t api_spiffs_read(struct spiffs_t *fs, u32_t addr, u32_t size, u8_t *dst){ + memcpy(dst, &s_flashmem[0] + addr, size); + return SPIFFS_OK; +} + +static s32_t api_spiffs_write(struct spiffs_t *fs, u32_t addr, u32_t size, u8_t *src){ + memcpy(&s_flashmem[0] + addr, src, size); + return SPIFFS_OK; +} + +static s32_t api_spiffs_erase(struct spiffs_t *fs, u32_t addr, u32_t size){ + memset(&s_flashmem[0] + addr, 0xff, size); + return SPIFFS_OK; +} +#else static s32_t api_spiffs_read(u32_t addr, u32_t size, u8_t *dst){ memcpy(dst, &s_flashmem[0] + addr, size); return SPIFFS_OK; @@ -63,7 +96,7 @@ static s32_t api_spiffs_erase(u32_t addr, u32_t size){ memset(&s_flashmem[0] + addr, 0xff, size); return SPIFFS_OK; } - +#endif @@ -85,8 +118,8 @@ int spiffsTryMount(){ const int maxOpenFiles = 4; s_spiffsWorkBuf.resize(s_pageSize * 2); - s_spiffsFds.resize(32 * maxOpenFiles); - s_spiffsCache.resize((32 + s_pageSize) * maxOpenFiles); + s_spiffsFds.resize(sizeof(spiffs_fd) * maxOpenFiles); + s_spiffsCache.resize(sizeof(spiffs_cache) + maxOpenFiles * (sizeof(spiffs_cache_page) + cfg.log_page_size)); return SPIFFS_mount(&s_fs, &cfg, &s_spiffsWorkBuf[0], @@ -116,6 +149,60 @@ void spiffsUnmount(){ SPIFFS_unmount(&s_fs); } +static void spiffs_update_meta(spiffs *fs, spiffs_file fd, u8_t type) +{ +#if defined (CONFIG_SPIFFS_USE_MTIME) || defined (CONFIG_SPIFFS_USE_DIR) + spiffs_meta_t meta; +#ifdef CONFIG_SPIFFS_USE_MTIME + meta.mtime = time(NULL); +#endif //CONFIG_SPIFFS_USE_MTIME + +#ifdef CONFIG_SPIFFS_USE_DIR + // Add file type (directory or regular file) to the last byte of metadata + meta.type = type; +#endif + int ret = SPIFFS_fupdate_meta(fs, fd, (uint8_t *)&meta); + if (ret != SPIFFS_OK) { + std::cerr << "error: Failed to update metadata: " << ret << std::endl; + } +#endif +} + +static time_t spiffs_get_mtime(const spiffs_stat* s) +{ + time_t t = 0; +#ifdef CONFIG_SPIFFS_USE_MTIME + spiffs_meta_t meta; + memcpy(&meta, s->meta, sizeof(meta)); + t = meta.mtime; +#endif + return t; +} + +static int get_spiffs_stat(const char * path, struct stat * st) +{ + spiffs_stat s; + off_t res = SPIFFS_stat(&s_fs, path, &s); + if (res < 0) { + SPIFFS_clearerr(&s_fs); + return -1; + } + + st->st_size = s.size; +#ifdef CONFIG_SPIFFS_USE_DIR + spiffs_meta_t *meta = (spiffs_meta_t *)&s.meta; + if (meta->type == SPIFFS_TYPE_DIR) st->st_mode = S_IFDIR; + else st->st_mode = S_IRWXU | S_IRWXG | S_IRWXO | S_IFREG; +#else + st->st_mode = S_IRWXU | S_IRWXG | S_IRWXO; + st->st_mode |= (s.type == SPIFFS_TYPE_DIR)?S_IFDIR:S_IFREG; +#endif + st->st_mtime = spiffs_get_mtime(&s); + st->st_atime = 0; + st->st_ctime = 0; + return res; +} + int addFile(char* name, const char* path) { FILE* src = fopen(path, "rb"); if (!src) { @@ -124,6 +211,7 @@ int addFile(char* name, const char* path) { } spiffs_file dst = SPIFFS_open(&s_fs, name, SPIFFS_CREAT | SPIFFS_TRUNC | SPIFFS_RDWR, 0); + spiffs_update_meta(&s_fs, dst, SPIFFS_TYPE_FILE); // read file size fseek(src, 0, SEEK_END); @@ -213,6 +301,29 @@ int addFiles(const char* dirname, const char* subPath) { if (!S_ISREG(path_stat.st_mode)) { // Check if path is a directory. if (S_ISDIR(path_stat.st_mode)) { +#ifdef CONFIG_SPIFFS_USE_DIR + std::string dirpath = subPath; + dirpath += ent->d_name; + std::cout << dirpath << " [D]" << std::endl; + spiffs_file dst = SPIFFS_open(&s_fs, (char*)dirpath.c_str(), SPIFFS_CREAT | SPIFFS_WRONLY, 0); + if (dst < 0) { + std::cerr << "error adding directory (open)!" << std::endl; + error = true; + if (s_debugLevel > 0) { + std::cout << std::endl; + } + break; + } + spiffs_update_meta(&s_fs, dst, SPIFFS_TYPE_DIR); + if (SPIFFS_close(&s_fs, dst) < 0) { + std::cerr << "error adding directory (close)!" << std::endl; + error = true; + if (s_debugLevel > 0) { + std::cout << std::endl; + } + break; + } +#endif // Prepare new sub path. std::string newSubPath = subPath; newSubPath += ent->d_name; @@ -259,6 +370,7 @@ int addFiles(const char* dirname, const char* subPath) { void listFiles() { spiffs_DIR dir; spiffs_dirent ent; + struct stat sb = {0}; SPIFFS_opendir(&s_fs, 0, &dir); spiffs_dirent* it; @@ -267,7 +379,8 @@ void listFiles() { if (!it) break; - std::cout << it->size << '\t' << it->name << std::endl; + get_spiffs_stat((const char *)it->name, &sb); + std::cout << sb.st_mode << '\t' << it->size << '\t' << it->name << std::endl; } SPIFFS_closedir(&dir); } @@ -450,6 +563,7 @@ int actionPack() { spiffsFormat(); int result = addFiles(s_dirName.c_str(), "/"); + listFiles(); spiffsUnmount(); fwrite(&s_flashmem[0], 4, s_flashmem.size()/4, fdres); @@ -476,7 +590,7 @@ int actionUnpack(void) { } // read content into s_flashmem - fread(&s_flashmem[0], 4, s_flashmem.size()/4, fdsrc); + ret = fread(&s_flashmem[0], 4, s_flashmem.size()/4, fdsrc); // close fiel handle fclose(fdsrc); @@ -505,7 +619,11 @@ int actionList() { return 1; } - fread(&s_flashmem[0], 4, s_flashmem.size()/4, fdsrc); + int ret = fread(&s_flashmem[0], 4, s_flashmem.size()/4, fdsrc); + if (ret < 0) { + std::cerr << "error: failed to read from image file" << std::endl; + return 1; + } fclose(fdsrc); spiffsMount(); listFiles(); @@ -514,6 +632,7 @@ int actionList() { } int actionVisualize() { +#if SPIFFS_TEST_VISUALISATION s_flashmem.resize(s_imageSize, 0xff); FILE* fdsrc = fopen(s_imageName.c_str(), "rb"); @@ -531,7 +650,7 @@ int actionVisualize() { SPIFFS_info(&s_fs, &total, &used); std::cout << "total: " << total << std::endl << "used: " << used << std::endl; spiffsUnmount(); - +#endif return 0; } From e9e851feabd0df68fccc51265ed62223101d357d Mon Sep 17 00:00:00 2001 From: loboris Date: Fri, 29 Dec 2017 15:48:01 +0100 Subject: [PATCH 2/7] Added default 'sdkconfig.h' --- include/sdkconfig.h | 214 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 include/sdkconfig.h diff --git a/include/sdkconfig.h b/include/sdkconfig.h new file mode 100644 index 0000000..177e8e8 --- /dev/null +++ b/include/sdkconfig.h @@ -0,0 +1,214 @@ +/* + * + * Automatically generated file; DO NOT EDIT. + * Espressif IoT Development Framework Configuration + * + */ +#define CONFIG_ESP32_PHY_MAX_TX_POWER 20 +#define CONFIG_TRACEMEM_RESERVE_DRAM 0x0 +#define CONFIG_FREERTOS_MAX_TASK_NAME_LEN 16 +#define CONFIG_FATFS_LFN_NONE 1 +#define CONFIG_TCP_RECVMBOX_SIZE 6 +#define CONFIG_FATFS_CODEPAGE_437 1 +#define CONFIG_LWIP_ETHARP_TRUST_IP_MAC 1 +#define CONFIG_TCP_WND_DEFAULT 5744 +#define CONFIG_SPIFFS_USE_MAGIC_LENGTH 1 +#define CONFIG_ESPTOOLPY_FLASHSIZE_4MB 1 +#define CONFIG_IPC_TASK_STACK_SIZE 1024 +#define CONFIG_FATFS_PER_FILE_CACHE 1 +#define CONFIG_ESPTOOLPY_FLASHFREQ "40m" +#define CONFIG_MBEDTLS_KEY_EXCHANGE_RSA 1 +#define CONFIG_UDP_RECVMBOX_SIZE 6 +#define CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE 0 +#define CONFIG_MBEDTLS_AES_C 1 +#define CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED 1 +#define CONFIG_MBEDTLS_GCM_C 1 +#define CONFIG_ESPTOOLPY_FLASHSIZE "4MB" +#define CONFIG_HEAP_POISONING_DISABLED 1 +#define CONFIG_SPIFFS_CACHE_WR 1 +#define CONFIG_BROWNOUT_DET_LVL_SEL_0 1 +#define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER 1 +#define CONFIG_SPIFFS_CACHE 1 +#define CONFIG_INT_WDT 1 +#define CONFIG_MBEDTLS_SSL_PROTO_TLS1 1 +#define CONFIG_MBEDTLS_ECDSA_C 1 +#define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1 +#define CONFIG_LOG_BOOTLOADER_LEVEL_INFO 1 +#define CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE 0 +#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 2 +#define CONFIG_MBEDTLS_ECDH_C 1 +#define CONFIG_SPIFFS_USE_DIR 1 +#define CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE 1 +#define CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM 16 +#define CONFIG_MBEDTLS_SSL_ALPN 1 +#define CONFIG_MBEDTLS_PEM_WRITE_C 1 +#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1 +#define CONFIG_BT_RESERVE_DRAM 0x0 +#define CONFIG_FATFS_FS_LOCK 0 +#define CONFIG_IP_LOST_TIMER_INTERVAL 120 +#define CONFIG_SPIFFS_META_LENGTH 5 +#define CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED 1 +#define CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED 1 +#define CONFIG_CONSOLE_UART_BAUDRATE 115200 +#define CONFIG_LWIP_MAX_SOCKETS 10 +#define CONFIG_LWIP_NETIF_LOOPBACK 1 +#define CONFIG_EMAC_TASK_PRIORITY 20 +#define CONFIG_TIMER_TASK_STACK_DEPTH 2048 +#define CONFIG_TCP_MSS 1436 +#define CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED 1 +#define CONFIG_FATFS_CODEPAGE 437 +#define CONFIG_ULP_COPROC_RESERVE_MEM 0 +#define CONFIG_LWIP_MAX_UDP_PCBS 16 +#define CONFIG_ESPTOOLPY_BAUD 921600 +#define CONFIG_INT_WDT_CHECK_CPU1 1 +#define CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED 1 +#define CONFIG_LWIP_DHCPS_MAX_STATION_NUM 8 +#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-" +#define CONFIG_MBEDTLS_ECP_C 1 +#define CONFIG_FREERTOS_IDLE_TASK_STACKSIZE 1024 +#define CONFIG_MBEDTLS_RC4_DISABLED 1 +#define CONFIG_CONSOLE_UART_NUM 0 +#define CONFIG_ESP32_APPTRACE_LOCK_ENABLE 1 +#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC 1 +#define CONFIG_TCP_OVERSIZE_MSS 1 +#define CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS 1 +#define CONFIG_CONSOLE_UART_DEFAULT 1 +#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 8192 +#define CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS 4 +#define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1 +#define CONFIG_PARTITION_TABLE_CUSTOM 1 +#define CONFIG_TIMER_TASK_STACK_SIZE 3584 +#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1 +#define CONFIG_MBEDTLS_X509_CRL_PARSE_C 1 +#define CONFIG_LWIP_DHCPS_LEASE_UNIT 60 +#define CONFIG_SPIFFS_USE_MAGIC 1 +#define CONFIG_TCPIP_TASK_STACK_SIZE 8192 +#define CONFIG_TASK_WDT 1 +#define CONFIG_MAIN_TASK_STACK_SIZE 16384 +#define CONFIG_SPIFFS_PAGE_CHECK 1 +#define CONFIG_LWIP_MAX_ACTIVE_TCP 16 +#define CONFIG_TASK_WDT_TIMEOUT_S 30 +#define CONFIG_INT_WDT_TIMEOUT_MS 300 +#define CONFIG_ESPTOOLPY_FLASHMODE "dio" +#define CONFIG_NEWLIB_STDIN_LINE_ENDING_CR 1 +#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA 1 +#define CONFIG_ESPTOOLPY_BEFORE "default_reset" +#define CONFIG_LOG_DEFAULT_LEVEL 3 +#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1 +#define CONFIG_TIMER_QUEUE_LENGTH 10 +#define CONFIG_MAKE_WARN_UNDEFINED_VARIABLES 1 +#define CONFIG_FATFS_TIMEOUT_MS 10000 +#define CONFIG_BOOTLOADER_SPI_WP_PIN 7 +#define CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM 32 +#define CONFIG_MBEDTLS_CCM_C 1 +#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20 +#define CONFIG_ESP32_RTC_CLK_CAL_CYCLES 1024 +#define CONFIG_ESP32_WIFI_TX_BA_WIN 6 +#define CONFIG_ESP32_WIFI_NVS_ENABLED 1 +#define CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED 1 +#define CONFIG_LIBSODIUM_USE_MBEDTLS_SHA 1 +#define CONFIG_DMA_RX_BUF_NUM 10 +#define CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED 1 +#define CONFIG_TCP_SYNMAXRTX 6 +#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA 1 +#define CONFIG_PYTHON "python" +#define CONFIG_MBEDTLS_ECP_NIST_OPTIM 1 +#define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1 +#define CONFIG_ESPTOOLPY_COMPRESSED 1 +#define CONFIG_PARTITION_TABLE_FILENAME "partitions_example.csv" +#define CONFIG_TCP_SND_BUF_DEFAULT 5744 +#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1 +#define CONFIG_TCP_MSL 60000 +#define CONFIG_MBEDTLS_SSL_PROTO_TLS1_1 1 +#define CONFIG_LWIP_SO_REUSE_RXTOALL 1 +#define CONFIG_WIFI_SSID "LoBoInternet" +#define CONFIG_ESP32_WIFI_RX_BA_WIN 6 +#define CONFIG_MBEDTLS_X509_CSR_PARSE_C 1 +#define CONFIG_SPIFFS_USE_MTIME 1 +#define CONFIG_FLASHMODE_QIO 1 +#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA 1 +#define CONFIG_LWIP_DHCP_DOES_ARP_CHECK 1 +#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 2048 +#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 2000 +#define CONFIG_BROWNOUT_DET_LVL 0 +#define CONFIG_MBEDTLS_PEM_PARSE_C 1 +#define CONFIG_SPIFFS_GC_MAX_RUNS 10 +#define CONFIG_ESP32_APPTRACE_DEST_NONE 1 +#define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000 +#define CONFIG_MBEDTLS_SSL_PROTO_TLS1_2 1 +#define CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA 1 +#define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM 32 +#define CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED 1 +#define CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED 1 +#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 1 +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240 +#define CONFIG_MBEDTLS_HARDWARE_AES 1 +#define CONFIG_FREERTOS_HZ 1000 +#define CONFIG_LOG_COLORS 1 +#define CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE 1 +#define CONFIG_STACK_CHECK_NONE 1 +#define CONFIG_EXAMPLE_RUN_MULTITASK_TEST 1 +#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1 +#define CONFIG_BROWNOUT_DET 1 +#define CONFIG_ESP32_XTAL_FREQ 40 +#define CONFIG_MONITOR_BAUD_115200B 1 +#define CONFIG_LOG_BOOTLOADER_LEVEL 3 +#define CONFIG_MBEDTLS_TLS_ENABLED 1 +#define CONFIG_LWIP_MAX_RAW_PCBS 16 +#define CONFIG_MBEDTLS_SSL_SESSION_TICKETS 1 +#define CONFIG_SPIFFS_MAX_PARTITIONS 3 +#define CONFIG_MBEDTLS_SSL_RENEGOTIATION 1 +#define CONFIG_ESPTOOLPY_BEFORE_RESET 1 +#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200 +#define CONFIG_SPIFFS_OBJ_NAME_LEN 32 +#define CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT 5 +#define CONFIG_TCPIP_RECVMBOX_SIZE 32 +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1 +#define CONFIG_TCP_MAXRTX 12 +#define CONFIG_ESPTOOLPY_AFTER "no_reset" +#define CONFIG_LWIP_SO_REUSE 1 +#define CONFIG_ESP32_XTAL_FREQ_40 1 +#define CONFIG_DMA_TX_BUF_NUM 10 +#define CONFIG_LWIP_MAX_LISTENING_TCP 16 +#define CONFIG_FREERTOS_INTERRUPT_BACKTRACE 1 +#define CONFIG_WL_SECTOR_SIZE 4096 +#define CONFIG_ESP32_DEBUG_OCDAWARE 1 +#define CONFIG_TIMER_TASK_PRIORITY 1 +#define CONFIG_MBEDTLS_TLS_CLIENT 1 +#define CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED 1 +#define CONFIG_MONITOR_BAUD 115200 +#define CONFIG_FREERTOS_CORETIMER_0 1 +#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions_example.csv" +#define CONFIG_MBEDTLS_HAVE_TIME 1 +#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1 +#define CONFIG_TCP_QUEUE_OOSEQ 1 +#define CONFIG_MBEDTLS_TLS_SERVER 1 +#define CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT 1 +#define CONFIG_ESPTOOLPY_AFTER_NORESET 1 +#define CONFIG_FREERTOS_ISR_STACKSIZE 1536 +#define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1 +#define CONFIG_WL_SECTOR_SIZE_4096 1 +#define CONFIG_OPTIMIZATION_LEVEL_DEBUG 1 +#define CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED 1 +#define CONFIG_BOOTLOADER_VDDSDIO_BOOST 1 +#define CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED 1 +#define CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED 1 +#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA 1 +#define CONFIG_WIFI_PASSWORD "1412lobo956" +#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32 +#define CONFIG_ESP32_WIFI_TX_BUFFER_TYPE 1 +#define CONFIG_ESPTOOLPY_BAUD_921600B 1 +#define CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED 1 +#define CONFIG_LWIP_LOOPBACK_MAX_PBUFS 8 +#define CONFIG_APP_OFFSET 0x10000 +#define CONFIG_MEMMAP_SMP 1 +#define CONFIG_SPI_FLASH_ROM_DRIVER_PATCH 1 +#define CONFIG_EXAMPLE_USE_WIFI 1 +#define CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED 1 +#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0 1 +#define CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT 3072 +#define CONFIG_MONITOR_BAUD_OTHER_VAL 115200 +#define CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF 1 +#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB1" +#define CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS 1 +#define CONFIG_ESP32_PANIC_PRINT_HALT 1 From ed64f8219d1aae83443d25706cb0d6b345751bd3 Mon Sep 17 00:00:00 2001 From: loboris Date: Fri, 29 Dec 2017 15:59:19 +0100 Subject: [PATCH 3/7] Update --- main.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index d0fc95c..9910abc 100644 --- a/main.cpp +++ b/main.cpp @@ -192,10 +192,9 @@ static int get_spiffs_stat(const char * path, struct stat * st) #ifdef CONFIG_SPIFFS_USE_DIR spiffs_meta_t *meta = (spiffs_meta_t *)&s.meta; if (meta->type == SPIFFS_TYPE_DIR) st->st_mode = S_IFDIR; - else st->st_mode = S_IRWXU | S_IRWXG | S_IRWXO | S_IFREG; + else st->st_mode = S_IFREG; #else - st->st_mode = S_IRWXU | S_IRWXG | S_IRWXO; - st->st_mode |= (s.type == SPIFFS_TYPE_DIR)?S_IFDIR:S_IFREG; + st->st_mode = (s.type == SPIFFS_TYPE_DIR)?S_IFDIR:S_IFREG; #endif st->st_mtime = spiffs_get_mtime(&s); st->st_atime = 0; From 067fa8172cfd70301751d591aebf62dd56fe2c1e Mon Sep 17 00:00:00 2001 From: loboris Date: Fri, 29 Dec 2017 18:28:28 +0100 Subject: [PATCH 4/7] Changes to make tests pass --- include/spiffs_config.h | 62 +++++++++++++++++++++++++++++++---------- main.cpp | 12 +++++--- 2 files changed, 55 insertions(+), 19 deletions(-) diff --git a/include/spiffs_config.h b/include/spiffs_config.h index cbfda33..0a7bc60 100755 --- a/include/spiffs_config.h +++ b/include/spiffs_config.h @@ -72,37 +72,48 @@ typedef uint8_t u8_t; // Enable/disable API functions to determine exact number of bytes // for filedescriptor and cache buffers. Once decided for a configuration, // this can be disabled to reduce flash. +#ifndef SPIFFS_BUFFER_HELP #define SPIFFS_BUFFER_HELP 0 +#endif // Enables/disable memory read caching of nucleus file system operations. // If enabled, memory area must be provided for cache in SPIFFS_mount. -#ifdef CONFIG_SPIFFS_CACHE -#define SPIFFS_CACHE (1) -#else +#ifndef SPIFFS_CACHE +#ifndef CONFIG_SPIFFS_CACHE #define SPIFFS_CACHE (0) +#else +#define SPIFFS_CACHE (1) #endif +#endif + #if SPIFFS_CACHE // Enables memory write caching for file descriptors in hydrogen -#ifdef CONFIG_SPIFFS_CACHE_WR -#define SPIFFS_CACHE_WR (1) -#else +#ifndef SPIFFS_CACHE_WR +#ifndef CONFIG_SPIFFS_CACHE_WR #define SPIFFS_CACHE_WR (0) +#else +#define SPIFFS_CACHE_WR (1) +#endif #endif // Enable/disable statistics on caching. Debug/test purpose only. +#ifndef SPIFFS_CACHE_STATS #ifdef CONFIG_SPIFFS_CACHE_STATS #define SPIFFS_CACHE_STATS (1) #else #define SPIFFS_CACHE_STATS (0) #endif #endif +#endif // Always check header of each accessed page to ensure consistent state. // If enabled it will increase number of reads, will increase flash. -#ifdef CONFIG_SPIFFS_PAGE_CHECK -#define SPIFFS_PAGE_CHECK (1) -#else +#ifndef SPIFFS_PAGE_CHECK +#ifndef CONFIG_SPIFFS_PAGE_CHECK #define SPIFFS_PAGE_CHECK (0) +#else +#define SPIFFS_PAGE_CHECK (1) +#endif #endif // Define maximum number of gc runs to perform to reach desired free pages. @@ -113,11 +124,13 @@ typedef uint8_t u8_t; #endif // Enable/disable statistics on gc. Debug/test purpose only. +#ifndef SPIFFS_GC_STATS #ifdef CONFIG_SPIFFS_GC_STATS #define SPIFFS_GC_STATS (1) #else #define SPIFFS_GC_STATS (0) #endif +#endif // Garbage collecting examines all pages in a block which and sums up // to a block score. Deleted pages normally gives positive score and @@ -162,7 +175,9 @@ typedef uint8_t u8_t; // Size of buffer allocated on stack used when copying data. // Lower value generates more read/writes. No meaning having it bigger // than logical page size. +#ifndef SPIFFS_COPY_BUFFER_STACK #define SPIFFS_COPY_BUFFER_STACK (256) +#endif // Enable this to have an identifiable spiffs filesystem. This will look for // a magic in all sectors to determine if this is a valid spiffs system or @@ -180,12 +195,14 @@ typedef uint8_t u8_t; // For example, a filesystem configured and formatted for 4 megabytes will not // be accepted for mounting with a configuration defining the filesystem as 2 // megabytes. -#ifdef CONFIG_SPIFFS_USE_MAGIC_LENGTH -#define SPIFFS_USE_MAGIC_LENGTH (1) -#else +#ifndef SPIFFS_USE_MAGIC_LENGTH +#ifndef CONFIG_SPIFFS_USE_MAGIC_LENGTH #define SPIFFS_USE_MAGIC_LENGTH (0) +#else +#define SPIFFS_USE_MAGIC_LENGTH (1) #endif #endif +#endif // SPIFFS_USE_MAGIC // SPIFFS_LOCK and SPIFFS_UNLOCK protects spiffs from reentrancy on api level // These should be defined on a multithreaded system @@ -201,10 +218,14 @@ typedef uint8_t u8_t; #define SPIFFS_SINGLETON 0 // Enable this if your target needs aligned data for index tables +#ifndef SPIFFS_ALIGNED_OBJECT_INDEX_TABLES #define SPIFFS_ALIGNED_OBJECT_INDEX_TABLES 0 +#endif // Enable this if you want the HAL callbacks to be called with the spiffs struct +#ifndef SPIFFS_HAL_CALLBACK_EXTRA #define SPIFFS_HAL_CALLBACK_EXTRA 1 +#endif // Enable this if you want to add an integer offset to all file handles // (spiffs_file). This is useful if running multiple instances of spiffs on @@ -224,7 +245,9 @@ typedef uint8_t u8_t; // SPIFFS_USE_MAGIC is enabled, SPIFFS_ERR_RO_ABORTED_OPERATION will be // returned. // Might be useful for e.g. bootloaders and such. +#ifndef SPIFFS_READ_ONLY #define SPIFFS_READ_ONLY 0 +#endif // Enable this to add a temporal file cache using the fd buffer. // The effects of the cache is that SPIFFS_open will find the file faster in @@ -244,14 +267,18 @@ typedef uint8_t u8_t; // fd is closed. If the file is opened again, the location of the file is found // directly. If all available descriptors become opened, all cache memory is // lost. +#ifndef SPIFFS_TEMPORAL_FD_CACHE #define SPIFFS_TEMPORAL_FD_CACHE 1 +#endif // Temporal file cache hit score. Each time a file is opened, all cached files // will lose one point. If the opened file is found in cache, that entry will // gain SPIFFS_TEMPORAL_CACHE_HIT_SCORE points. One can experiment with this // value for the specific access patterns of the application. However, it must // be between 1 (no gain for hitting a cached entry often) and 255. +#ifndef SPIFFS_TEMPORAL_CACHE_HIT_SCORE #define SPIFFS_TEMPORAL_CACHE_HIT_SCORE 4 +#endif // Enable to be able to map object indices to memory. // This allows for faster and more deterministic reading if cases of reading @@ -265,16 +292,21 @@ typedef uint8_t u8_t; // collecting or when modifying the indices. The latter is invoked by when the // file is modified in some way. The index buffer is tied to the file // descriptor. +#ifndef SPIFFS_IX_MAP #define SPIFFS_IX_MAP 1 +#endif // Set SPIFFS_TEST_VISUALISATION to non-zero to enable SPIFFS_vis function // in the api. This function will visualize all filesystem using given printf // function. -#ifdef CONFIG_SPIFFS_TEST_VISUALISATION -#define SPIFFS_TEST_VISUALISATION 1 -#else +#ifndef SPIFFS_TEST_VISUALISATION +#ifndef CONFIG_SPIFFS_TEST_VISUALISATION #define SPIFFS_TEST_VISUALISATION 0 +#else +#define SPIFFS_TEST_VISUALISATION 1 #endif +#endif + #if SPIFFS_TEST_VISUALISATION #ifndef spiffs_printf #define spiffs_printf(...) printf(__VA_ARGS__) diff --git a/main.cpp b/main.cpp index 9910abc..507a80e 100644 --- a/main.cpp +++ b/main.cpp @@ -168,6 +168,7 @@ static void spiffs_update_meta(spiffs *fs, spiffs_file fd, u8_t type) #endif } +/* static time_t spiffs_get_mtime(const spiffs_stat* s) { time_t t = 0; @@ -179,6 +180,7 @@ static time_t spiffs_get_mtime(const spiffs_stat* s) return t; } + static int get_spiffs_stat(const char * path, struct stat * st) { spiffs_stat s; @@ -201,6 +203,7 @@ static int get_spiffs_stat(const char * path, struct stat * st) st->st_ctime = 0; return res; } +*/ int addFile(char* name, const char* path) { FILE* src = fopen(path, "rb"); @@ -369,7 +372,7 @@ int addFiles(const char* dirname, const char* subPath) { void listFiles() { spiffs_DIR dir; spiffs_dirent ent; - struct stat sb = {0}; + //struct stat sb = {0}; SPIFFS_opendir(&s_fs, 0, &dir); spiffs_dirent* it; @@ -378,8 +381,9 @@ void listFiles() { if (!it) break; - get_spiffs_stat((const char *)it->name, &sb); - std::cout << sb.st_mode << '\t' << it->size << '\t' << it->name << std::endl; + //get_spiffs_stat((const char *)it->name, &sb); + //std::cout << sb.st_mode << '\t' << it->size << '\t' << it->name << std::endl; + std::cout << it->size << '\t' << it->name << std::endl; } SPIFFS_closedir(&dir); } @@ -562,7 +566,7 @@ int actionPack() { spiffsFormat(); int result = addFiles(s_dirName.c_str(), "/"); - listFiles(); + //listFiles(); spiffsUnmount(); fwrite(&s_flashmem[0], 4, s_flashmem.size()/4, fdres); From 42878cdfc5bb67cbe204618c0abe94f18c6c2b67 Mon Sep 17 00:00:00 2001 From: loboris Date: Fri, 29 Dec 2017 18:43:13 +0100 Subject: [PATCH 5/7] Updated default (dummy) sdkconfig.h Updated README.md --- README.md | 8 +- include/sdkconfig.h | 200 +------------------------------------- include/sdkconfig_esp32.h | 17 ++++ 3 files changed, 23 insertions(+), 202 deletions(-) create mode 100644 include/sdkconfig_esp32.h diff --git a/README.md b/README.md index fe343db..4d1fa33 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ # mkspiffs Tool to build and unpack [SPIFFS](https://github.com/pellepl/spiffs) images. -**IMPORTANT** -The **sdkconfig.h** from your application using spiffs is used in build process! -Before building **mkspiffs**, copy the **sdkconfig.h** from your application **build/include** directory to **mkspiffs/include** +## **IMPORTANT - building for ESP32 esp-idf spiffs** +--- +The **sdkconfig.h** from your application using spiffs has to be used in build process! +Before building **mkspiffs**, copy the **sdkconfig.h** from your application **build/include** directory to **mkspiffs/include** +After every change to spiffs configuration **rebuild mkspiffs** ## Usage diff --git a/include/sdkconfig.h b/include/sdkconfig.h index 177e8e8..37ad077 100644 --- a/include/sdkconfig.h +++ b/include/sdkconfig.h @@ -1,214 +1,16 @@ /* * - * Automatically generated file; DO NOT EDIT. - * Espressif IoT Development Framework Configuration + * Dummy sdkconfig.h file. * */ -#define CONFIG_ESP32_PHY_MAX_TX_POWER 20 -#define CONFIG_TRACEMEM_RESERVE_DRAM 0x0 -#define CONFIG_FREERTOS_MAX_TASK_NAME_LEN 16 -#define CONFIG_FATFS_LFN_NONE 1 -#define CONFIG_TCP_RECVMBOX_SIZE 6 -#define CONFIG_FATFS_CODEPAGE_437 1 -#define CONFIG_LWIP_ETHARP_TRUST_IP_MAC 1 -#define CONFIG_TCP_WND_DEFAULT 5744 #define CONFIG_SPIFFS_USE_MAGIC_LENGTH 1 -#define CONFIG_ESPTOOLPY_FLASHSIZE_4MB 1 -#define CONFIG_IPC_TASK_STACK_SIZE 1024 -#define CONFIG_FATFS_PER_FILE_CACHE 1 -#define CONFIG_ESPTOOLPY_FLASHFREQ "40m" -#define CONFIG_MBEDTLS_KEY_EXCHANGE_RSA 1 -#define CONFIG_UDP_RECVMBOX_SIZE 6 -#define CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE 0 -#define CONFIG_MBEDTLS_AES_C 1 -#define CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED 1 -#define CONFIG_MBEDTLS_GCM_C 1 -#define CONFIG_ESPTOOLPY_FLASHSIZE "4MB" -#define CONFIG_HEAP_POISONING_DISABLED 1 #define CONFIG_SPIFFS_CACHE_WR 1 -#define CONFIG_BROWNOUT_DET_LVL_SEL_0 1 -#define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER 1 #define CONFIG_SPIFFS_CACHE 1 -#define CONFIG_INT_WDT 1 -#define CONFIG_MBEDTLS_SSL_PROTO_TLS1 1 -#define CONFIG_MBEDTLS_ECDSA_C 1 -#define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1 -#define CONFIG_LOG_BOOTLOADER_LEVEL_INFO 1 -#define CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE 0 -#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 2 -#define CONFIG_MBEDTLS_ECDH_C 1 #define CONFIG_SPIFFS_USE_DIR 1 -#define CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE 1 -#define CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM 16 -#define CONFIG_MBEDTLS_SSL_ALPN 1 -#define CONFIG_MBEDTLS_PEM_WRITE_C 1 -#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1 -#define CONFIG_BT_RESERVE_DRAM 0x0 -#define CONFIG_FATFS_FS_LOCK 0 -#define CONFIG_IP_LOST_TIMER_INTERVAL 120 #define CONFIG_SPIFFS_META_LENGTH 5 -#define CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED 1 -#define CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED 1 -#define CONFIG_CONSOLE_UART_BAUDRATE 115200 -#define CONFIG_LWIP_MAX_SOCKETS 10 -#define CONFIG_LWIP_NETIF_LOOPBACK 1 -#define CONFIG_EMAC_TASK_PRIORITY 20 -#define CONFIG_TIMER_TASK_STACK_DEPTH 2048 -#define CONFIG_TCP_MSS 1436 -#define CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED 1 -#define CONFIG_FATFS_CODEPAGE 437 -#define CONFIG_ULP_COPROC_RESERVE_MEM 0 -#define CONFIG_LWIP_MAX_UDP_PCBS 16 -#define CONFIG_ESPTOOLPY_BAUD 921600 -#define CONFIG_INT_WDT_CHECK_CPU1 1 -#define CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED 1 -#define CONFIG_LWIP_DHCPS_MAX_STATION_NUM 8 -#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-" -#define CONFIG_MBEDTLS_ECP_C 1 -#define CONFIG_FREERTOS_IDLE_TASK_STACKSIZE 1024 -#define CONFIG_MBEDTLS_RC4_DISABLED 1 -#define CONFIG_CONSOLE_UART_NUM 0 -#define CONFIG_ESP32_APPTRACE_LOCK_ENABLE 1 -#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC 1 -#define CONFIG_TCP_OVERSIZE_MSS 1 -#define CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS 1 -#define CONFIG_CONSOLE_UART_DEFAULT 1 -#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 8192 -#define CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS 4 -#define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1 -#define CONFIG_PARTITION_TABLE_CUSTOM 1 -#define CONFIG_TIMER_TASK_STACK_SIZE 3584 -#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1 -#define CONFIG_MBEDTLS_X509_CRL_PARSE_C 1 -#define CONFIG_LWIP_DHCPS_LEASE_UNIT 60 #define CONFIG_SPIFFS_USE_MAGIC 1 -#define CONFIG_TCPIP_TASK_STACK_SIZE 8192 -#define CONFIG_TASK_WDT 1 -#define CONFIG_MAIN_TASK_STACK_SIZE 16384 #define CONFIG_SPIFFS_PAGE_CHECK 1 -#define CONFIG_LWIP_MAX_ACTIVE_TCP 16 -#define CONFIG_TASK_WDT_TIMEOUT_S 30 -#define CONFIG_INT_WDT_TIMEOUT_MS 300 -#define CONFIG_ESPTOOLPY_FLASHMODE "dio" -#define CONFIG_NEWLIB_STDIN_LINE_ENDING_CR 1 -#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA 1 -#define CONFIG_ESPTOOLPY_BEFORE "default_reset" -#define CONFIG_LOG_DEFAULT_LEVEL 3 -#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1 -#define CONFIG_TIMER_QUEUE_LENGTH 10 -#define CONFIG_MAKE_WARN_UNDEFINED_VARIABLES 1 -#define CONFIG_FATFS_TIMEOUT_MS 10000 -#define CONFIG_BOOTLOADER_SPI_WP_PIN 7 -#define CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM 32 -#define CONFIG_MBEDTLS_CCM_C 1 -#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20 -#define CONFIG_ESP32_RTC_CLK_CAL_CYCLES 1024 -#define CONFIG_ESP32_WIFI_TX_BA_WIN 6 -#define CONFIG_ESP32_WIFI_NVS_ENABLED 1 -#define CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED 1 -#define CONFIG_LIBSODIUM_USE_MBEDTLS_SHA 1 -#define CONFIG_DMA_RX_BUF_NUM 10 -#define CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED 1 -#define CONFIG_TCP_SYNMAXRTX 6 -#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA 1 -#define CONFIG_PYTHON "python" -#define CONFIG_MBEDTLS_ECP_NIST_OPTIM 1 -#define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1 -#define CONFIG_ESPTOOLPY_COMPRESSED 1 -#define CONFIG_PARTITION_TABLE_FILENAME "partitions_example.csv" -#define CONFIG_TCP_SND_BUF_DEFAULT 5744 -#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1 -#define CONFIG_TCP_MSL 60000 -#define CONFIG_MBEDTLS_SSL_PROTO_TLS1_1 1 -#define CONFIG_LWIP_SO_REUSE_RXTOALL 1 -#define CONFIG_WIFI_SSID "LoBoInternet" -#define CONFIG_ESP32_WIFI_RX_BA_WIN 6 -#define CONFIG_MBEDTLS_X509_CSR_PARSE_C 1 #define CONFIG_SPIFFS_USE_MTIME 1 -#define CONFIG_FLASHMODE_QIO 1 -#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA 1 -#define CONFIG_LWIP_DHCP_DOES_ARP_CHECK 1 -#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 2048 -#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 2000 -#define CONFIG_BROWNOUT_DET_LVL 0 -#define CONFIG_MBEDTLS_PEM_PARSE_C 1 #define CONFIG_SPIFFS_GC_MAX_RUNS 10 -#define CONFIG_ESP32_APPTRACE_DEST_NONE 1 -#define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000 -#define CONFIG_MBEDTLS_SSL_PROTO_TLS1_2 1 -#define CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA 1 -#define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM 32 -#define CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED 1 -#define CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED 1 -#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 1 -#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240 -#define CONFIG_MBEDTLS_HARDWARE_AES 1 -#define CONFIG_FREERTOS_HZ 1000 -#define CONFIG_LOG_COLORS 1 -#define CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE 1 -#define CONFIG_STACK_CHECK_NONE 1 -#define CONFIG_EXAMPLE_RUN_MULTITASK_TEST 1 -#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1 -#define CONFIG_BROWNOUT_DET 1 -#define CONFIG_ESP32_XTAL_FREQ 40 -#define CONFIG_MONITOR_BAUD_115200B 1 -#define CONFIG_LOG_BOOTLOADER_LEVEL 3 -#define CONFIG_MBEDTLS_TLS_ENABLED 1 -#define CONFIG_LWIP_MAX_RAW_PCBS 16 -#define CONFIG_MBEDTLS_SSL_SESSION_TICKETS 1 #define CONFIG_SPIFFS_MAX_PARTITIONS 3 -#define CONFIG_MBEDTLS_SSL_RENEGOTIATION 1 -#define CONFIG_ESPTOOLPY_BEFORE_RESET 1 -#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200 #define CONFIG_SPIFFS_OBJ_NAME_LEN 32 -#define CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT 5 -#define CONFIG_TCPIP_RECVMBOX_SIZE 32 -#define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1 -#define CONFIG_TCP_MAXRTX 12 -#define CONFIG_ESPTOOLPY_AFTER "no_reset" -#define CONFIG_LWIP_SO_REUSE 1 -#define CONFIG_ESP32_XTAL_FREQ_40 1 -#define CONFIG_DMA_TX_BUF_NUM 10 -#define CONFIG_LWIP_MAX_LISTENING_TCP 16 -#define CONFIG_FREERTOS_INTERRUPT_BACKTRACE 1 -#define CONFIG_WL_SECTOR_SIZE 4096 -#define CONFIG_ESP32_DEBUG_OCDAWARE 1 -#define CONFIG_TIMER_TASK_PRIORITY 1 -#define CONFIG_MBEDTLS_TLS_CLIENT 1 -#define CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED 1 -#define CONFIG_MONITOR_BAUD 115200 -#define CONFIG_FREERTOS_CORETIMER_0 1 -#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions_example.csv" -#define CONFIG_MBEDTLS_HAVE_TIME 1 -#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1 -#define CONFIG_TCP_QUEUE_OOSEQ 1 -#define CONFIG_MBEDTLS_TLS_SERVER 1 -#define CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT 1 -#define CONFIG_ESPTOOLPY_AFTER_NORESET 1 -#define CONFIG_FREERTOS_ISR_STACKSIZE 1536 -#define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1 -#define CONFIG_WL_SECTOR_SIZE_4096 1 -#define CONFIG_OPTIMIZATION_LEVEL_DEBUG 1 -#define CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED 1 -#define CONFIG_BOOTLOADER_VDDSDIO_BOOST 1 -#define CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED 1 -#define CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED 1 -#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA 1 -#define CONFIG_WIFI_PASSWORD "1412lobo956" -#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32 -#define CONFIG_ESP32_WIFI_TX_BUFFER_TYPE 1 -#define CONFIG_ESPTOOLPY_BAUD_921600B 1 -#define CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED 1 -#define CONFIG_LWIP_LOOPBACK_MAX_PBUFS 8 -#define CONFIG_APP_OFFSET 0x10000 -#define CONFIG_MEMMAP_SMP 1 -#define CONFIG_SPI_FLASH_ROM_DRIVER_PATCH 1 -#define CONFIG_EXAMPLE_USE_WIFI 1 -#define CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED 1 -#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0 1 -#define CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT 3072 -#define CONFIG_MONITOR_BAUD_OTHER_VAL 115200 -#define CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF 1 -#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB1" -#define CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS 1 -#define CONFIG_ESP32_PANIC_PRINT_HALT 1 diff --git a/include/sdkconfig_esp32.h b/include/sdkconfig_esp32.h new file mode 100644 index 0000000..a06fe30 --- /dev/null +++ b/include/sdkconfig_esp32.h @@ -0,0 +1,17 @@ +/* + * + * Automatically generated file; DO NOT EDIT. + * Espressif IoT Development Framework Configuration + * + */ +#define CONFIG_SPIFFS_USE_MAGIC_LENGTH 1 +#define CONFIG_SPIFFS_CACHE_WR 1 +#define CONFIG_SPIFFS_CACHE 1 +#define CONFIG_SPIFFS_USE_DIR 1 +#define CONFIG_SPIFFS_META_LENGTH 5 +#define CONFIG_SPIFFS_USE_MAGIC 1 +#define CONFIG_SPIFFS_PAGE_CHECK 1 +#define CONFIG_SPIFFS_USE_MTIME 1 +#define CONFIG_SPIFFS_GC_MAX_RUNS 10 +#define CONFIG_SPIFFS_MAX_PARTITIONS 3 +#define CONFIG_SPIFFS_OBJ_NAME_LEN 32 From 2eb74c4f274cd0538392d39ca8d3ad30c88c5194 Mon Sep 17 00:00:00 2001 From: loboris Date: Fri, 29 Dec 2017 18:48:51 +0100 Subject: [PATCH 6/7] Updated default (dummy) sdkconfig.h Updated README.md --- README.md | 4 ++-- include/sdkconfig.h | 11 ----------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 4d1fa33..00601d9 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # mkspiffs Tool to build and unpack [SPIFFS](https://github.com/pellepl/spiffs) images. -## **IMPORTANT - building for ESP32 esp-idf spiffs** +## **IMPORTANT** - building for ESP32 esp-idf spiffs --- - The **sdkconfig.h** from your application using spiffs has to be used in build process! Before building **mkspiffs**, copy the **sdkconfig.h** from your application **build/include** directory to **mkspiffs/include** After every change to spiffs configuration **rebuild mkspiffs** + ## Usage ``` diff --git a/include/sdkconfig.h b/include/sdkconfig.h index 37ad077..be2b664 100644 --- a/include/sdkconfig.h +++ b/include/sdkconfig.h @@ -3,14 +3,3 @@ * Dummy sdkconfig.h file. * */ -#define CONFIG_SPIFFS_USE_MAGIC_LENGTH 1 -#define CONFIG_SPIFFS_CACHE_WR 1 -#define CONFIG_SPIFFS_CACHE 1 -#define CONFIG_SPIFFS_USE_DIR 1 -#define CONFIG_SPIFFS_META_LENGTH 5 -#define CONFIG_SPIFFS_USE_MAGIC 1 -#define CONFIG_SPIFFS_PAGE_CHECK 1 -#define CONFIG_SPIFFS_USE_MTIME 1 -#define CONFIG_SPIFFS_GC_MAX_RUNS 10 -#define CONFIG_SPIFFS_MAX_PARTITIONS 3 -#define CONFIG_SPIFFS_OBJ_NAME_LEN 32 From 0f0125f49516ff75c16919e47b5c3720e95d0e28 Mon Sep 17 00:00:00 2001 From: loboris Date: Fri, 29 Dec 2017 19:09:01 +0100 Subject: [PATCH 7/7] Updated 'spiffs_config.h' --- include/spiffs_config.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/include/spiffs_config.h b/include/spiffs_config.h index 0a7bc60..4eb36de 100755 --- a/include/spiffs_config.h +++ b/include/spiffs_config.h @@ -78,17 +78,13 @@ typedef uint8_t u8_t; // Enables/disable memory read caching of nucleus file system operations. // If enabled, memory area must be provided for cache in SPIFFS_mount. -#ifndef SPIFFS_CACHE -#ifndef CONFIG_SPIFFS_CACHE -#define SPIFFS_CACHE (0) -#else +#ifndef SPIFFS_CACHE #define SPIFFS_CACHE (1) #endif -#endif #if SPIFFS_CACHE // Enables memory write caching for file descriptors in hydrogen -#ifndef SPIFFS_CACHE_WR +#ifndef SPIFFS_CACHE_WR #ifndef CONFIG_SPIFFS_CACHE_WR #define SPIFFS_CACHE_WR (0) #else @@ -97,7 +93,7 @@ typedef uint8_t u8_t; #endif // Enable/disable statistics on caching. Debug/test purpose only. -#ifndef SPIFFS_CACHE_STATS +#ifndef SPIFFS_CACHE_STATS #ifdef CONFIG_SPIFFS_CACHE_STATS #define SPIFFS_CACHE_STATS (1) #else @@ -183,10 +179,12 @@ typedef uint8_t u8_t; // a magic in all sectors to determine if this is a valid spiffs system or // not on mount point. If not, SPIFFS_format must be called prior to mounting // again. -#ifdef CONFIG_SPIFFS_USE_MAGIC -#define SPIFFS_USE_MAGIC (1) -#else +#ifndef SPIFFS_USE_MAGIC +#ifndef CONFIG_SPIFFS_USE_MAGIC #define SPIFFS_USE_MAGIC (0) +#else +#define SPIFFS_USE_MAGIC (1) +#endif #endif #if SPIFFS_USE_MAGIC