mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
Modifications for fs profiling tool
This commit is contained in:
@@ -1,97 +1,98 @@
|
||||
COMPONENT=spiffs
|
||||
ifndef COMPONENT
|
||||
COMPONENT := spiffs
|
||||
endif
|
||||
|
||||
TEST_PROGRAM=test_$(COMPONENT)
|
||||
COMPONENT_LIB := lib$(COMPONENT).a
|
||||
TEST_PROGRAM := test_$(COMPONENT)
|
||||
|
||||
#Expose as a library
|
||||
COMPONENT_LIB=lib$(COMPONENT).a
|
||||
STUBS_LIB_DIR := ../../../components/spi_flash/sim/stubs
|
||||
STUBS_LIB_BUILD_DIR := $(STUBS_LIB_DIR)/build
|
||||
STUBS_LIB := libstubs.a
|
||||
|
||||
SPI_FLASH=spi_flash
|
||||
SPI_FLASH_DIR=../../$(SPI_FLASH)
|
||||
SPI_FLASH_SIM_DIR=$(SPI_FLASH_DIR)/sim
|
||||
SPI_FLASH_LIB=lib$(SPI_FLASH).a
|
||||
SPI_FLASH_SIM_DIR := ../../../components/spi_flash/sim
|
||||
SPI_FLASH_SIM_BUILD_DIR := $(SPI_FLASH_SIM_DIR)/build
|
||||
SPI_FLASH_SIM_LIB := libspi_flash.a
|
||||
|
||||
all: $(TEST_PROGRAM)
|
||||
include Makefile.files
|
||||
|
||||
SOURCE_FILES = \
|
||||
../spiffs_api.c \
|
||||
$(addprefix ../spiffs/src/, \
|
||||
spiffs_cache.c \
|
||||
spiffs_check.c \
|
||||
spiffs_gc.c \
|
||||
spiffs_hydrogen.c \
|
||||
spiffs_nucleus.c \
|
||||
) \
|
||||
$(addprefix ./stubs/, \
|
||||
log/log.c \
|
||||
)
|
||||
all: test
|
||||
|
||||
ifndef SDKCONFIG
|
||||
SDKCONFIG_DIR := $(dir $(realpath sdkconfig/sdkconfig.h))
|
||||
SDKCONFIG := $(SDKCONFIG_DIR)sdkconfig.h
|
||||
else
|
||||
SDKCONFIG_DIR := $(dir $(realpath $(SDKCONFIG)))
|
||||
endif
|
||||
|
||||
INCLUDE_FLAGS := $(addprefix -I, $(INCLUDE_DIRS) $(SDKCONFIG_DIR) ../../../tools/catch)
|
||||
|
||||
CPPFLAGS += $(INCLUDE_FLAGS) -g -m32
|
||||
CXXFLAGS += $(INCLUDE_FLAGS) -std=c++11 -g -m32
|
||||
|
||||
# Build libraries that this component is dependent on
|
||||
$(STUBS_LIB_BUILD_DIR)/$(STUBS_LIB): force
|
||||
$(MAKE) -C $(STUBS_LIB_DIR) lib SDKCONFIG=$(SDKCONFIG)
|
||||
|
||||
$(SPI_FLASH_SIM_BUILD_DIR)/$(SPI_FLASH_SIM_LIB): force
|
||||
$(MAKE) -C $(SPI_FLASH_SIM_DIR) lib SDKCONFIG=$(SDKCONFIG)
|
||||
|
||||
# Create target for building this component as a library
|
||||
CFILES := $(filter %.c, $(SOURCE_FILES))
|
||||
CPPFILES := $(filter %.cpp, $(SOURCE_FILES))
|
||||
|
||||
CTARGET = ${2}/$(patsubst %.c,%.o,$(notdir ${1}))
|
||||
CPPTARGET = ${2}/$(patsubst %.cpp,%.o,$(notdir ${1}))
|
||||
|
||||
ifndef BUILD_DIR
|
||||
BUILD_DIR := build
|
||||
endif
|
||||
|
||||
OBJ_FILES := $(addprefix $(BUILD_DIR)/, $(filter %.o, $(notdir $(SOURCE_FILES:.cpp=.o) $(SOURCE_FILES:.c=.o))))
|
||||
|
||||
define COMPILE_C
|
||||
$(call CTARGET, ${1}, $(BUILD_DIR)) : ${1} $(SDKCONFIG)
|
||||
mkdir -p $(BUILD_DIR)
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $(call CTARGET, ${1}, $(BUILD_DIR)) ${1}
|
||||
endef
|
||||
|
||||
define COMPILE_CPP
|
||||
$(call CPPTARGET, ${1}, $(BUILD_DIR)) : ${1} $(SDKCONFIG)
|
||||
mkdir -p $(BUILD_DIR)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $(call CPPTARGET, ${1}, $(BUILD_DIR)) ${1}
|
||||
endef
|
||||
|
||||
$(BUILD_DIR)/$(COMPONENT_LIB): $(OBJ_FILES) $(SDKCONFIG)
|
||||
mkdir -p $(BUILD_DIR)
|
||||
$(AR) rcs $@ $^
|
||||
|
||||
clean:
|
||||
$(MAKE) -C $(STUBS_LIB_DIR) clean
|
||||
$(MAKE) -C $(SPI_FLASH_SIM_DIR) clean
|
||||
rm -f $(OBJ_FILES) $(TEST_OBJ_FILES) $(TEST_PROGRAM) $(COMPONENT_LIB) partition_table.bin
|
||||
|
||||
lib: $(BUILD_DIR)/$(COMPONENT_LIB)
|
||||
|
||||
$(foreach cfile, $(CFILES), $(eval $(call COMPILE_C, $(cfile))))
|
||||
$(foreach cxxfile, $(CPPFILES), $(eval $(call COMPILE_CPP, $(cxxfile))))
|
||||
|
||||
# Create target for building this component as a test
|
||||
TEST_SOURCE_FILES = \
|
||||
test_spiffs.cpp \
|
||||
main.cpp \
|
||||
test_utils.c
|
||||
|
||||
INCLUDE_FLAGS = $(addprefix -I,\
|
||||
. \
|
||||
.. \
|
||||
../spiffs/src \
|
||||
../include \
|
||||
$(addprefix ./stubs/, \
|
||||
log/include \
|
||||
freertos/include \
|
||||
newlib/include \
|
||||
vfs/include \
|
||||
) \
|
||||
../../esp32/include \
|
||||
$(SPI_FLASH_DIR)/include \
|
||||
../../../tools/catch \
|
||||
)
|
||||
|
||||
GCOV ?= gcov
|
||||
|
||||
CPPFLAGS += $(INCLUDE_FLAGS) -D CONFIG_LOG_DEFAULT_LEVEL -g -m32
|
||||
CFLAGS += -fprofile-arcs -ftest-coverage
|
||||
CXXFLAGS += -std=c++11 -Wall -Werror -fprofile-arcs -ftest-coverage
|
||||
LDFLAGS += -lstdc++ -fprofile-arcs -ftest-coverage
|
||||
|
||||
OBJ_FILES = $(filter %.o, $(SOURCE_FILES:.cpp=.o) $(SOURCE_FILES:.c=.o))
|
||||
TEST_OBJ_FILES = $(filter %.o, $(TEST_SOURCE_FILES:.cpp=.o) $(TEST_SOURCE_FILES:.c=.o))
|
||||
|
||||
$(SPI_FLASH_SIM_DIR)/$(SPI_FLASH_LIB): force
|
||||
$(MAKE) -C $(SPI_FLASH_SIM_DIR) lib
|
||||
|
||||
force:
|
||||
|
||||
$(COMPONENT_LIB): $(OBJ_FILES)
|
||||
$(AR) rcs $@ $^
|
||||
|
||||
lib: $(COMPONENT_LIB)
|
||||
|
||||
partitions_table.bin: partitions_table.csv
|
||||
python ../../partition_table/gen_esp32part.py $< $@
|
||||
|
||||
$(TEST_PROGRAM): lib $(TEST_OBJ_FILES) $(SPI_FLASH_SIM_DIR)/$(SPI_FLASH_LIB) partitions_table.bin
|
||||
g++ $(LDFLAGS) -o $(TEST_PROGRAM) $(TEST_OBJ_FILES) -L$(abspath .) -l:$(COMPONENT_LIB) -L$(SPI_FLASH_SIM_DIR) -l:$(SPI_FLASH_LIB) -g -m32
|
||||
$(TEST_PROGRAM): lib $(TEST_OBJ_FILES) $(SPI_FLASH_SIM_BUILD_DIR)/$(SPI_FLASH_SIM_LIB) $(STUBS_LIB_BUILD_DIR)/$(STUBS_LIB) partition_table.bin $(SDKCONFIG)
|
||||
g++ $(LDFLAGS) $(CXXFLAGS) -o $@ $(TEST_OBJ_FILES) -L$(BUILD_DIR) -l:$(COMPONENT_LIB) -L$(SPI_FLASH_SIM_BUILD_DIR) -l:$(SPI_FLASH_SIM_LIB) -L$(STUBS_LIB_BUILD_DIR) -l:$(STUBS_LIB)
|
||||
|
||||
test: $(TEST_PROGRAM)
|
||||
./$(TEST_PROGRAM)
|
||||
|
||||
COVERAGE_FILES = $(OBJ_FILES:.o=.gc*) $(TEST_OBJ_FILES:.o=.gc*)
|
||||
# Create other necessary targets
|
||||
partition_table.bin: partition_table.csv
|
||||
python ../../../components/partition_table/gen_esp32part.py --verify $< $@
|
||||
|
||||
$(COVERAGE_FILES): test
|
||||
force:
|
||||
|
||||
coverage.info: $(COVERAGE_FILES)
|
||||
find ../ -name "*.gcno" -exec $(GCOV) -r -pb {} +
|
||||
lcov --capture --directory ../ --no-external --output-file coverage.info --gcov-tool $(GCOV)
|
||||
|
||||
coverage_report: coverage.info
|
||||
genhtml coverage.info --output-directory coverage_report
|
||||
@echo "Coverage report is in coverage_report/index.html"
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ_FILES) $(TEST_OBJ_FILES) $(TEST_PROGRAM) $(COMPONENT_LIB) partitions_table.bin
|
||||
$(MAKE) -C $(SPI_FLASH_SIM_DIR) clean
|
||||
rm -f $(COVERAGE_FILES) *.gcov
|
||||
rm -rf coverage_report/
|
||||
rm -f coverage.info
|
||||
|
||||
.PHONY: clean all test lib
|
||||
.PHONY: all lib test clean force
|
||||
|
33
components/spiffs/test_spiffs_host/Makefile.files
Normal file
33
components/spiffs/test_spiffs_host/Makefile.files
Normal file
@@ -0,0 +1,33 @@
|
||||
SOURCE_FILES := \
|
||||
../spiffs_api.c \
|
||||
$(addprefix ../spiffs/src/, \
|
||||
spiffs_cache.c \
|
||||
spiffs_check.c \
|
||||
spiffs_gc.c \
|
||||
spiffs_hydrogen.c \
|
||||
spiffs_nucleus.c \
|
||||
)
|
||||
|
||||
INCLUDE_DIRS := \
|
||||
. \
|
||||
.. \
|
||||
../spiffs/src \
|
||||
../include \
|
||||
$(addprefix ../../spi_flash/sim/stubs/, \
|
||||
app_update/include \
|
||||
driver/include \
|
||||
esp32/include \
|
||||
freertos/include \
|
||||
log/include \
|
||||
newlib/include \
|
||||
sdmmc/include \
|
||||
vfs/include \
|
||||
) \
|
||||
$(addprefix ../../../components/, \
|
||||
soc/esp32/include \
|
||||
esp32/include \
|
||||
bootloader_support/include \
|
||||
app_update/include \
|
||||
spi_flash/include \
|
||||
wear_levelling/include \
|
||||
)
|
17
components/spiffs/test_spiffs_host/component.mk
Normal file
17
components/spiffs/test_spiffs_host/component.mk
Normal file
@@ -0,0 +1,17 @@
|
||||
include $(COMPONENT_PATH)/Makefile.files
|
||||
|
||||
COMPONENT_OWNBUILDTARGET := 1
|
||||
COMPONENT_OWNCLEANTARGET := 1
|
||||
|
||||
COMPONENT_ADD_INCLUDEDIRS := $(INCLUDE_DIRS)
|
||||
|
||||
.PHONY: build
|
||||
build: $(SDKCONFIG_HEADER)
|
||||
$(MAKE) -C $(COMPONENT_PATH) lib SDKCONFIG=$(SDKCONFIG_HEADER) BUILD_DIR=$(COMPONENT_BUILD_DIR) COMPONENT=$(COMPONENT_NAME)
|
||||
|
||||
CLEAN_FILES := component_project_vars.mk
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(summary) RM $(CLEAN_FILES)
|
||||
rm -f $(CLEAN_FILES)
|
||||
$(MAKE) -C $(COMPONENT_PATH) clean SDKCONFIG=$(SDKCONFIG_HEADER) BUILD_DIR=$(COMPONENT_BUILD_DIR) COMPONENT=$(COMPONENT_NAME)
|
@@ -11,4 +11,9 @@
|
||||
#define CONFIG_SPIFFS_USE_MAGIC 1
|
||||
#define CONFIG_SPIFFS_PAGE_CHECK 1
|
||||
#define CONFIG_SPIFFS_USE_MTIME 1
|
||||
|
||||
#define CONFIG_WL_SECTOR_SIZE 4096
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL 3
|
||||
#define CONFIG_PARTITION_TABLE_OFFSET 0x8000
|
||||
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE "8MB"
|
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "projdefs.h"
|
||||
#include "semphr.h"
|
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define pdTRUE 1
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
@@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define vSemaphoreDelete( xSemaphore )
|
||||
#define xSemaphoreCreateMutex() ((void*)(1))
|
||||
#define xSemaphoreGive( xSemaphore )
|
||||
#define xSemaphoreTake( xSemaphore, xBlockTime ) pdTRUE
|
||||
|
||||
typedef void* SemaphoreHandle_t;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
@@ -1 +0,0 @@
|
||||
#pragma once
|
@@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#define strlcpy(a, b, c)
|
||||
#define strlcat(a, b, c)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
|
||||
|
||||
typedef enum {
|
||||
ESP_LOG_NONE, /*!< No log output */
|
||||
ESP_LOG_ERROR, /*!< Critical errors, software module can not recover on its own */
|
||||
ESP_LOG_WARN, /*!< Error conditions from which recovery measures have been taken */
|
||||
ESP_LOG_INFO, /*!< Information messages which describe normal flow of events */
|
||||
ESP_LOG_DEBUG, /*!< Extra information which is not necessary for normal use (values, pointers, sizes, etc). */
|
||||
ESP_LOG_VERBOSE /*!< Bigger chunks of debugging information, or frequent messages which can potentially flood the output. */
|
||||
} esp_log_level_t;
|
||||
|
||||
#define LOG_COLOR_E
|
||||
#define LOG_COLOR_W
|
||||
#define LOG_COLOR_I
|
||||
#define LOG_COLOR_D
|
||||
#define LOG_COLOR_V
|
||||
#define LOG_RESET_COLOR
|
||||
|
||||
#undef _Static_assert
|
||||
#define _Static_assert(cond, message)
|
||||
|
||||
uint32_t esp_log_timestamp(void);
|
||||
void esp_log_write(esp_log_level_t level, const char* tag, const char* format, ...) __attribute__ ((format (printf, 3, 4)));
|
||||
|
||||
#define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%d) %s: " format LOG_RESET_COLOR "\n"
|
||||
|
||||
#define ESP_LOGE( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
|
||||
|
||||
#define ESP_LOGV( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_VERBOSE) { esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
|
||||
|
||||
#define ESP_LOGD( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG) { esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
|
||||
|
||||
#define ESP_LOGW( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_WARN) { esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
@@ -1,22 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "esp_log.h"
|
||||
|
||||
void esp_log_write(esp_log_level_t level,
|
||||
const char *tag,
|
||||
const char *format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
vprintf(format, arg);
|
||||
va_end(arg);
|
||||
}
|
||||
|
||||
uint32_t esp_log_timestamp()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <time.h>
|
||||
|
||||
typedef int _lock_t;
|
||||
|
||||
void _lock_acquire(_lock_t *lock);
|
||||
void _lock_close(_lock_t *lock);
|
||||
void _lock_init(_lock_t *lock);
|
||||
void _lock_release(_lock_t *lock);
|
@@ -1,21 +0,0 @@
|
||||
#include "sys/lock.h"
|
||||
|
||||
void _lock_acquire(_lock_t *lock)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void _lock_close(_lock_t *lock)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void _lock_init(_lock_t *lock)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void _lock_release(_lock_t *lock)
|
||||
{
|
||||
return;
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#define ESP_VFS_FLAG_CONTEXT_PTR 1
|
||||
#define ESP_VFS_PATH_MAX 15
|
@@ -9,11 +9,11 @@
|
||||
|
||||
#include "catch.hpp"
|
||||
|
||||
extern "C" void init_spi_flash(size_t chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin);
|
||||
extern "C" void init_spi_flash(const char* chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin);
|
||||
|
||||
TEST_CASE("format disk, open file, write and read file", "[spiffs]")
|
||||
{
|
||||
init_spi_flash(0x00400000, CONFIG_WL_SECTOR_SIZE * 16, CONFIG_WL_SECTOR_SIZE, CONFIG_WL_SECTOR_SIZE, "partitions_table.bin");
|
||||
init_spi_flash(CONFIG_ESPTOOLPY_FLASHSIZE, CONFIG_WL_SECTOR_SIZE * 16, CONFIG_WL_SECTOR_SIZE, CONFIG_WL_SECTOR_SIZE, "partition_table.bin");
|
||||
|
||||
spiffs fs;
|
||||
spiffs_config cfg;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include "esp_spi_flash.h"
|
||||
#include "esp_partition.h"
|
||||
|
||||
void init_spi_flash(size_t chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin)
|
||||
void init_spi_flash(const char* chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin)
|
||||
{
|
||||
spi_flash_init(chip_size, block_size, sector_size, page_size, partition_bin);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user