mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/storage_host_test_ffs' into 'master'
fatfs: host test migrated to CMake and esp_partition emulation for linux See merge request espressif/esp-idf!23265
This commit is contained in:
commit
d8f2c0e715
@ -40,12 +40,6 @@ test_partition_table_on_host:
|
|||||||
- cd components/partition_table/test_gen_esp32part_host
|
- cd components/partition_table/test_gen_esp32part_host
|
||||||
- ./gen_esp32part_tests.py
|
- ./gen_esp32part_tests.py
|
||||||
|
|
||||||
test_fatfs_on_host:
|
|
||||||
extends: .host_test_template
|
|
||||||
script:
|
|
||||||
- cd components/fatfs/test_fatfs_host/
|
|
||||||
- make test
|
|
||||||
|
|
||||||
test_ldgen_on_host:
|
test_ldgen_on_host:
|
||||||
extends: .host_test_template
|
extends: .host_test_template
|
||||||
script:
|
script:
|
||||||
|
@ -1,16 +1,34 @@
|
|||||||
|
idf_build_get_property(target IDF_TARGET)
|
||||||
|
|
||||||
set(srcs "diskio/diskio.c"
|
set(srcs "diskio/diskio.c"
|
||||||
"diskio/diskio_rawflash.c"
|
"diskio/diskio_rawflash.c"
|
||||||
"diskio/diskio_sdmmc.c"
|
"diskio/diskio_wl.c"
|
||||||
"diskio/diskio_wl.c"
|
"src/ff.c"
|
||||||
"src/ff.c"
|
"src/ffunicode.c")
|
||||||
"port/freertos/ffsystem.c"
|
|
||||||
"src/ffunicode.c"
|
set(include_dirs "diskio" "src")
|
||||||
"vfs/vfs_fat.c"
|
|
||||||
"vfs/vfs_fat_sdmmc.c"
|
set(requires "wear_levelling")
|
||||||
"vfs/vfs_fat_spiflash.c")
|
|
||||||
|
# for linux, we do not have support for vfs and sdmmc, for real targets, add respective sources
|
||||||
|
if(${target} STREQUAL "linux")
|
||||||
|
list(APPEND srcs "port/linux/ffsystem.c")
|
||||||
|
else()
|
||||||
|
list(APPEND srcs "port/freertos/ffsystem.c"
|
||||||
|
"diskio/diskio_sdmmc.c"
|
||||||
|
"vfs/vfs_fat.c"
|
||||||
|
"vfs/vfs_fat_sdmmc.c"
|
||||||
|
"vfs/vfs_fat_spiflash.c")
|
||||||
|
|
||||||
|
list(APPEND include_dirs "vfs")
|
||||||
|
|
||||||
|
list(APPEND requires "sdmmc")
|
||||||
|
|
||||||
|
list(APPEND priv_requires "vfs")
|
||||||
|
endif()
|
||||||
|
|
||||||
idf_component_register(SRCS ${srcs}
|
idf_component_register(SRCS ${srcs}
|
||||||
INCLUDE_DIRS diskio vfs src
|
INCLUDE_DIRS ${include_dirs}
|
||||||
REQUIRES wear_levelling sdmmc
|
REQUIRES ${requires}
|
||||||
PRIV_REQUIRES vfs
|
PRIV_REQUIRES ${priv_requires}
|
||||||
)
|
)
|
||||||
|
10
components/fatfs/host_test/CMakeLists.txt
Normal file
10
components/fatfs/host_test/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
set(COMPONENTS main)
|
||||||
|
# Freertos is included via common components. However, CATCH isn't compatible with the FreeRTOS component yet, hence
|
||||||
|
# using the FreeRTOS mock component.
|
||||||
|
# target.
|
||||||
|
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/")
|
||||||
|
|
||||||
|
project(fatfs_host_test)
|
2
components/fatfs/host_test/README.md
Normal file
2
components/fatfs/host_test/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
| Supported Targets | Linux |
|
||||||
|
| ----------------- | ----- |
|
6
components/fatfs/host_test/main/CMakeLists.txt
Normal file
6
components/fatfs/host_test/main/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
idf_component_register(SRCS "main.cpp"
|
||||||
|
"test_fatfs.cpp"
|
||||||
|
INCLUDE_DIRS "$ENV{IDF_PATH}/tools/catch"
|
||||||
|
REQUIRES fatfs
|
||||||
|
WHOLE_ARCHIVE
|
||||||
|
)
|
7
components/fatfs/host_test/main/main.cpp
Normal file
7
components/fatfs/host_test/main/main.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
#include "catch.hpp"
|
@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -9,12 +14,8 @@
|
|||||||
|
|
||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
|
|
||||||
extern "C" void _spi_flash_init(const char* chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin);
|
|
||||||
|
|
||||||
TEST_CASE("create volume, open file, write and read back data", "[fatfs]")
|
TEST_CASE("create volume, open file, write and read back data", "[fatfs]")
|
||||||
{
|
{
|
||||||
_spi_flash_init(CONFIG_ESPTOOLPY_FLASHSIZE, CONFIG_WL_SECTOR_SIZE * 16, CONFIG_WL_SECTOR_SIZE, CONFIG_WL_SECTOR_SIZE, "partition_table.bin");
|
|
||||||
|
|
||||||
FRESULT fr_result;
|
FRESULT fr_result;
|
||||||
BYTE pdrv;
|
BYTE pdrv;
|
||||||
FATFS fs;
|
FATFS fs;
|
10
components/fatfs/host_test/pytest_fatfs_linux.py
Normal file
10
components/fatfs/host_test/pytest_fatfs_linux.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
import pytest
|
||||||
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.linux
|
||||||
|
@pytest.mark.host_test
|
||||||
|
def test_fatfs_linux(dut: Dut) -> None:
|
||||||
|
dut.expect_exact('All tests passed', timeout=120)
|
12
components/fatfs/host_test/sdkconfig.defaults
Normal file
12
components/fatfs/host_test/sdkconfig.defaults
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
CONFIG_IDF_TARGET="linux"
|
||||||
|
CONFIG_COMPILER_CXX_EXCEPTIONS=y
|
||||||
|
CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n
|
||||||
|
CONFIG_WL_SECTOR_SIZE=4096
|
||||||
|
CONFIG_LOG_DEFAULT_LEVEL=3
|
||||||
|
CONFIG_PARTITION_TABLE_OFFSET=0x8000
|
||||||
|
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||||
|
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partition_table.csv"
|
||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE="8MB"
|
||||||
|
CONFIG_MMU_PAGE_SIZE=0X10000
|
||||||
|
CONFIG_ESP_PARTITION_ENABLE_STATS=y
|
||||||
|
CONFIG_FATFS_VOLUME_COUNT=2
|
@ -1,106 +0,0 @@
|
|||||||
ifndef COMPONENT
|
|
||||||
COMPONENT := fatfs
|
|
||||||
endif
|
|
||||||
|
|
||||||
COMPONENT_LIB := lib$(COMPONENT).a
|
|
||||||
TEST_PROGRAM := test_$(COMPONENT)
|
|
||||||
|
|
||||||
STUBS_LIB_DIR := ../../../components/spi_flash/sim/stubs
|
|
||||||
STUBS_LIB_BUILD_DIR := $(STUBS_LIB_DIR)/build
|
|
||||||
STUBS_LIB := libstubs.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
|
|
||||||
|
|
||||||
WEAR_LEVELLING_DIR := ../../../components/wear_levelling/test_wl_host
|
|
||||||
WEAR_LEVELLING_BUILD_DIR := $(WEAR_LEVELLING_DIR)/build
|
|
||||||
WEAR_LEVELLING_LIB := libwl.a
|
|
||||||
|
|
||||||
include Makefile.files
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
$(WEAR_LEVELLING_BUILD_DIR)/$(WEAR_LEVELLING_LIB): force
|
|
||||||
$(MAKE) -C $(WEAR_LEVELLING_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 $@ $^
|
|
||||||
|
|
||||||
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_fatfs.cpp \
|
|
||||||
main.cpp \
|
|
||||||
|
|
||||||
TEST_OBJ_FILES = $(filter %.o, $(TEST_SOURCE_FILES:.cpp=.o) $(TEST_SOURCE_FILES:.c=.o))
|
|
||||||
|
|
||||||
$(TEST_PROGRAM): lib $(TEST_OBJ_FILES) $(WEAR_LEVELLING_BUILD_DIR)/$(WEAR_LEVELLING_LIB) $(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$(WEAR_LEVELLING_BUILD_DIR) -l:$(WEAR_LEVELLING_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)
|
|
||||||
|
|
||||||
# Create other necessary targets
|
|
||||||
partition_table.bin: partition_table.csv
|
|
||||||
python ../../../components/partition_table/gen_esp32part.py --verify $< $@
|
|
||||||
|
|
||||||
force:
|
|
||||||
|
|
||||||
# Create target to cleanup files
|
|
||||||
clean:
|
|
||||||
$(MAKE) -C $(STUBS_LIB_DIR) clean
|
|
||||||
$(MAKE) -C $(SPI_FLASH_SIM_DIR) clean
|
|
||||||
$(MAKE) -C $(WEAR_LEVELLING_DIR) clean
|
|
||||||
rm -f $(OBJ_FILES) $(TEST_OBJ_FILES) $(TEST_PROGRAM) $(COMPONENT_LIB) partition_table.bin
|
|
||||||
|
|
||||||
.PHONY: all lib test clean force
|
|
@ -1,44 +0,0 @@
|
|||||||
SOURCE_FILES := \
|
|
||||||
$(addprefix ../src/, \
|
|
||||||
ff.c \
|
|
||||||
ffunicode.c \
|
|
||||||
) \
|
|
||||||
$(addprefix ../diskio/,\
|
|
||||||
diskio.c \
|
|
||||||
diskio_wl.c \
|
|
||||||
) \
|
|
||||||
../port/linux/ffsystem.c
|
|
||||||
|
|
||||||
INCLUDE_DIRS := \
|
|
||||||
. \
|
|
||||||
../diskio \
|
|
||||||
../src \
|
|
||||||
$(addprefix ../../spi_flash/sim/stubs/, \
|
|
||||||
app_update/include \
|
|
||||||
driver/include \
|
|
||||||
freertos/include \
|
|
||||||
newlib/include \
|
|
||||||
sdmmc/include \
|
|
||||||
vfs/include \
|
|
||||||
) \
|
|
||||||
$(addprefix ../../../components/, \
|
|
||||||
esp_rom/include \
|
|
||||||
esp_hw_support/include \
|
|
||||||
esp_hw_support/include/soc \
|
|
||||||
esp_system/include \
|
|
||||||
log/include \
|
|
||||||
xtensa/include \
|
|
||||||
xtensa/esp32/include \
|
|
||||||
soc/esp32/include \
|
|
||||||
heap/include \
|
|
||||||
soc/include \
|
|
||||||
esp32/include \
|
|
||||||
esp_common/include \
|
|
||||||
bootloader_support/include \
|
|
||||||
bootloader_support/bootloader_flash/include \
|
|
||||||
app_update/include \
|
|
||||||
hal/include \
|
|
||||||
spi_flash/include \
|
|
||||||
wear_levelling/include \
|
|
||||||
esp_partition/include \
|
|
||||||
)
|
|
@ -1,17 +0,0 @@
|
|||||||
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)
|
|
@ -1,2 +0,0 @@
|
|||||||
#define CATCH_CONFIG_MAIN
|
|
||||||
#include "catch.hpp"
|
|
@ -1,14 +0,0 @@
|
|||||||
# pragma once
|
|
||||||
#define CONFIG_IDF_TARGET_ESP32 1
|
|
||||||
#define CONFIG_WL_SECTOR_SIZE 4096
|
|
||||||
|
|
||||||
// for the Linux log component
|
|
||||||
#define CONFIG_LOG_TIMESTAMP_SOURCE_RTOS 1
|
|
||||||
#define CONFIG_LOG_DEFAULT_LEVEL 3
|
|
||||||
#define CONFIG_LOG_MAXIMUM_LEVEL 3
|
|
||||||
|
|
||||||
#define CONFIG_PARTITION_TABLE_OFFSET 0x8000
|
|
||||||
#define CONFIG_ESPTOOLPY_FLASHSIZE "8MB"
|
|
||||||
|
|
||||||
#define CONFIG_FATFS_VOLUME_COUNT 2
|
|
||||||
#define CONFIG_MMU_PAGE_SIZE 0X10000 // 64KB
|
|
@ -1,65 +0,0 @@
|
|||||||
ifndef COMPONENT
|
|
||||||
COMPONENT := spi_flash
|
|
||||||
endif
|
|
||||||
|
|
||||||
COMPONENT_LIB := lib$(COMPONENT).a
|
|
||||||
|
|
||||||
include Makefile.files
|
|
||||||
|
|
||||||
all: lib
|
|
||||||
|
|
||||||
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))
|
|
||||||
|
|
||||||
CPPFLAGS += $(INCLUDE_FLAGS) -g -m32
|
|
||||||
CXXFLAGS += $(INCLUDE_FLAGS) -std=c++11 -g -m32
|
|
||||||
|
|
||||||
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))))
|
|
||||||
|
|
||||||
%.o : %.c $(SDKCONFIG)
|
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $< - o $@
|
|
||||||
|
|
||||||
%.o : %.cpp $(SDKCONFIG)
|
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $< - o $@
|
|
||||||
|
|
||||||
define COMPILE_C
|
|
||||||
$(call CTARGET, ${1}, $(BUILD_DIR)) : ${1}
|
|
||||||
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}
|
|
||||||
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:
|
|
||||||
rm -f $(OBJ_FILES) $(BUILD_DIR)/$(COMPONENT_LIB)
|
|
||||||
|
|
||||||
lib: $(BUILD_DIR)/$(COMPONENT_LIB)
|
|
||||||
|
|
||||||
$(foreach cfile, $(CFILES), $(eval $(call COMPILE_C, $(cfile))))
|
|
||||||
$(foreach cxxfile, $(CPPFILES), $(eval $(call COMPILE_CPP, $(cxxfile))))
|
|
||||||
|
|
||||||
.PHONY: all lib clean
|
|
@ -1,50 +0,0 @@
|
|||||||
SOURCE_FILES := \
|
|
||||||
SpiFlash.cpp \
|
|
||||||
flash_mock.cpp \
|
|
||||||
flash_mock_util.c \
|
|
||||||
$(addprefix ../, \
|
|
||||||
../esp_partition/partition.c \
|
|
||||||
../esp_partition/partition_target.c \
|
|
||||||
flash_ops.c \
|
|
||||||
../esp_rom/linux/esp_rom_efuse.c \
|
|
||||||
) \
|
|
||||||
|
|
||||||
INCLUDE_DIRS := \
|
|
||||||
. \
|
|
||||||
../ \
|
|
||||||
../include \
|
|
||||||
../private_include \
|
|
||||||
$(addprefix stubs/, \
|
|
||||||
app_update/include \
|
|
||||||
bsd/include \
|
|
||||||
driver/include \
|
|
||||||
esp_app_format/include \
|
|
||||||
esp_timer/include \
|
|
||||||
freertos/include \
|
|
||||||
log/include \
|
|
||||||
newlib/include \
|
|
||||||
sdmmc/include \
|
|
||||||
vfs/include \
|
|
||||||
) \
|
|
||||||
$(addprefix ../../../components/, \
|
|
||||||
esp_rom/include \
|
|
||||||
esp_common/include \
|
|
||||||
esp_hw_support/include \
|
|
||||||
esp_hw_support/include/soc \
|
|
||||||
esp_system/include \
|
|
||||||
xtensa/include \
|
|
||||||
xtensa/esp32/include \
|
|
||||||
soc/esp32/include \
|
|
||||||
heap/include \
|
|
||||||
soc/include \
|
|
||||||
esp32/include \
|
|
||||||
esp_timer/include \
|
|
||||||
bootloader_support/include \
|
|
||||||
bootloader_support/bootloader_flash/include \
|
|
||||||
app_update/include \
|
|
||||||
hal/include \
|
|
||||||
hal/esp32/include \
|
|
||||||
hal/platform_port/include \
|
|
||||||
spi_flash/include \
|
|
||||||
esp_partition/include \
|
|
||||||
)
|
|
@ -1,259 +0,0 @@
|
|||||||
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include "SpiFlash.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "sdkconfig.h"
|
|
||||||
#include "esp_flash_partitions.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#define DIV_AND_CEIL(x, y) ((x) / (y) + ((x) % (y) > 0))
|
|
||||||
|
|
||||||
SpiFlash::SpiFlash()
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SpiFlash::~SpiFlash()
|
|
||||||
{
|
|
||||||
deinit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpiFlash::init(uint32_t chip_size, uint32_t block_size, uint32_t sector_size, uint32_t page_size, const char* partitions_bin)
|
|
||||||
{
|
|
||||||
// De-initialize first
|
|
||||||
deinit();
|
|
||||||
|
|
||||||
// Initialize values and alloc memory
|
|
||||||
this->chip_size = chip_size;
|
|
||||||
this->block_size = block_size;
|
|
||||||
this->sector_size = sector_size;
|
|
||||||
this->page_size = page_size;
|
|
||||||
|
|
||||||
this->blocks = DIV_AND_CEIL(this->chip_size, this->block_size);
|
|
||||||
this->sectors = DIV_AND_CEIL(this->chip_size, this->sector_size);
|
|
||||||
this->pages = DIV_AND_CEIL(this->chip_size, this->page_size);
|
|
||||||
|
|
||||||
this->erase_cycles = (uint32_t*) calloc(this->sectors, sizeof(uint32_t));
|
|
||||||
this->erase_states = (bool*) calloc(this->sectors, sizeof(bool));
|
|
||||||
memset(this->erase_states, 0xFF, this->sectors * sizeof(bool));
|
|
||||||
|
|
||||||
this->total_erase_cycles_limit = 0;
|
|
||||||
this->erase_cycles_limit = 0;
|
|
||||||
|
|
||||||
this->total_erase_cycles = 0;
|
|
||||||
|
|
||||||
// Load partitions table bin
|
|
||||||
this->memory = (uint8_t *) malloc(this->chip_size);
|
|
||||||
memset(this->memory, 0xFF, this->chip_size);
|
|
||||||
|
|
||||||
ifstream ifd(partitions_bin, ios::binary | ios::ate);
|
|
||||||
int size = ifd.tellg();
|
|
||||||
|
|
||||||
ifd.seekg(0, ios::beg);
|
|
||||||
vector<char> buffer;
|
|
||||||
|
|
||||||
buffer.resize(size);
|
|
||||||
|
|
||||||
ifd.read(buffer.data(), size);
|
|
||||||
|
|
||||||
memcpy(&this->memory[CONFIG_PARTITION_TABLE_OFFSET], buffer.data(), buffer.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpiFlash::deinit()
|
|
||||||
{
|
|
||||||
// Free all allocated memory
|
|
||||||
free(this->memory);
|
|
||||||
|
|
||||||
free(this->erase_cycles);
|
|
||||||
free(this->erase_states);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t SpiFlash::get_chip_size()
|
|
||||||
{
|
|
||||||
return this->chip_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t SpiFlash::get_block_size()
|
|
||||||
{
|
|
||||||
return this->block_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t SpiFlash::get_sector_size()
|
|
||||||
{
|
|
||||||
return this->sector_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t SpiFlash::get_page_size()
|
|
||||||
{
|
|
||||||
return this->page_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_rom_spiflash_result_t SpiFlash::erase_block(uint32_t block)
|
|
||||||
{
|
|
||||||
uint32_t sectors_per_block = (this->block_size / this->sector_size);
|
|
||||||
uint32_t start_sector = block * sectors_per_block;
|
|
||||||
|
|
||||||
for (int i = start_sector; i < start_sector + sectors_per_block; i++) {
|
|
||||||
this->erase_sector(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ESP_ROM_SPIFLASH_RESULT_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_rom_spiflash_result_t SpiFlash::erase_sector(uint32_t sector)
|
|
||||||
{
|
|
||||||
if (this->total_erase_cycles_limit != 0 &&
|
|
||||||
this->total_erase_cycles >= this->total_erase_cycles_limit) {
|
|
||||||
return ESP_ROM_SPIFLASH_RESULT_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->erase_cycles_limit != 0 &&
|
|
||||||
this->erase_cycles[sector] >= this->erase_cycles_limit) {
|
|
||||||
return ESP_ROM_SPIFLASH_RESULT_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t pages_per_sector = (this->sector_size / this->page_size);
|
|
||||||
uint32_t start_page = sector * pages_per_sector;
|
|
||||||
|
|
||||||
if (this->erase_states[sector]) {
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = start_page; i < start_page + pages_per_sector; i++) {
|
|
||||||
this->erase_page(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->erase_cycles[sector]++;
|
|
||||||
this->total_erase_cycles++;
|
|
||||||
|
|
||||||
this->erase_states[sector] = true;
|
|
||||||
|
|
||||||
out:
|
|
||||||
return ESP_ROM_SPIFLASH_RESULT_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_rom_spiflash_result_t SpiFlash::erase_page(uint32_t page)
|
|
||||||
{
|
|
||||||
memset(&this->memory[page * this->page_size], 0xFF, this->page_size);
|
|
||||||
return ESP_ROM_SPIFLASH_RESULT_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_rom_spiflash_result_t SpiFlash::write(uint32_t dest_addr, const void *src, uint32_t size)
|
|
||||||
{
|
|
||||||
// Update reset states and check for failure
|
|
||||||
int start = 0;
|
|
||||||
int end = 0;
|
|
||||||
|
|
||||||
if (this->total_erase_cycles_limit != 0 &&
|
|
||||||
this->total_erase_cycles >= this->total_erase_cycles_limit) {
|
|
||||||
return ESP_ROM_SPIFLASH_RESULT_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
start = dest_addr / this->get_sector_size();
|
|
||||||
end = size > 0 ? (dest_addr + size - 1) / this->get_sector_size() : start;
|
|
||||||
|
|
||||||
for (int i = start; i <= end; i++) {
|
|
||||||
if (this->erase_cycles_limit != 0 &&
|
|
||||||
this->erase_cycles[i] >= this->erase_cycles_limit) {
|
|
||||||
return ESP_ROM_SPIFLASH_RESULT_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->erase_states[i] = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do the write
|
|
||||||
for(uint32_t ctr = 0; ctr < size; ctr++)
|
|
||||||
{
|
|
||||||
uint8_t data = ((uint8_t*)src)[ctr];
|
|
||||||
uint8_t written = this->memory[dest_addr + ctr];
|
|
||||||
|
|
||||||
// Emulate inability to set programmed bits without erasing
|
|
||||||
data &= written;
|
|
||||||
|
|
||||||
this->memory[dest_addr + ctr] = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ESP_ROM_SPIFLASH_RESULT_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_rom_spiflash_result_t SpiFlash::read(uint32_t src_addr, void *dest, uint32_t size)
|
|
||||||
{
|
|
||||||
// Check for failure
|
|
||||||
int start = 0;
|
|
||||||
int end = 0;
|
|
||||||
|
|
||||||
if (this->total_erase_cycles_limit != 0 &&
|
|
||||||
this->total_erase_cycles >= this->total_erase_cycles_limit) {
|
|
||||||
return ESP_ROM_SPIFLASH_RESULT_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
start = src_addr / this->get_sector_size();
|
|
||||||
end = size > 0 ? (src_addr + size - 1) / this->get_sector_size() : start;
|
|
||||||
|
|
||||||
for (int i = start; i <= end; i++) {
|
|
||||||
if (this->erase_cycles_limit != 0 &&
|
|
||||||
this->erase_cycles[i] >= this->erase_cycles_limit) {
|
|
||||||
return ESP_ROM_SPIFLASH_RESULT_ERR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do the read
|
|
||||||
memcpy(dest, &this->memory[src_addr], size);
|
|
||||||
return ESP_ROM_SPIFLASH_RESULT_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t* SpiFlash::get_memory_ptr(uint32_t src_address)
|
|
||||||
{
|
|
||||||
return &this->memory[src_address];
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t SpiFlash::get_erase_cycles(uint32_t sector)
|
|
||||||
{
|
|
||||||
return this->erase_cycles[sector];
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t SpiFlash::get_total_erase_cycles()
|
|
||||||
{
|
|
||||||
return this->total_erase_cycles;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpiFlash::set_erase_cycles_limit(uint32_t limit)
|
|
||||||
{
|
|
||||||
this->erase_cycles_limit = limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpiFlash::set_total_erase_cycles_limit(uint32_t limit)
|
|
||||||
{
|
|
||||||
this->total_erase_cycles_limit = limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpiFlash::reset_erase_cycles()
|
|
||||||
{
|
|
||||||
memset(this->erase_cycles, 0, sizeof(this->sectors * sizeof(uint32_t)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpiFlash::reset_total_erase_cycles()
|
|
||||||
{
|
|
||||||
this->total_erase_cycles = 0;
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SpiFlash_H_
|
|
||||||
#define _SpiFlash_H_
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "esp_err.h"
|
|
||||||
#include "esp_rom_spiflash.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This class is used to emulate flash devices.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class SpiFlash
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
SpiFlash();
|
|
||||||
~SpiFlash();
|
|
||||||
|
|
||||||
void init(uint32_t chip_size, uint32_t block_size, uint32_t sector_size, uint32_t page_size, const char* partitions_bin);
|
|
||||||
|
|
||||||
uint32_t get_chip_size();
|
|
||||||
uint32_t get_block_size();
|
|
||||||
uint32_t get_sector_size();
|
|
||||||
uint32_t get_page_size();
|
|
||||||
|
|
||||||
esp_rom_spiflash_result_t erase_block(uint32_t block);
|
|
||||||
esp_rom_spiflash_result_t erase_sector(uint32_t sector);
|
|
||||||
esp_rom_spiflash_result_t erase_page(uint32_t page);
|
|
||||||
|
|
||||||
esp_rom_spiflash_result_t write(uint32_t dest_addr, const void *src, uint32_t size);
|
|
||||||
esp_rom_spiflash_result_t read(uint32_t src_addr, void *dest, uint32_t size);
|
|
||||||
|
|
||||||
uint32_t get_erase_cycles(uint32_t sector);
|
|
||||||
uint32_t get_total_erase_cycles();
|
|
||||||
|
|
||||||
void set_erase_cycles_limit(uint32_t limit);
|
|
||||||
void set_total_erase_cycles_limit(uint32_t limit);
|
|
||||||
|
|
||||||
void reset_erase_cycles();
|
|
||||||
void reset_total_erase_cycles();
|
|
||||||
|
|
||||||
uint8_t* get_memory_ptr(uint32_t src_address);
|
|
||||||
|
|
||||||
private:
|
|
||||||
uint32_t chip_size;
|
|
||||||
uint32_t block_size;
|
|
||||||
uint32_t sector_size;
|
|
||||||
uint32_t page_size;
|
|
||||||
|
|
||||||
uint32_t blocks;
|
|
||||||
uint32_t sectors;
|
|
||||||
uint32_t pages;
|
|
||||||
|
|
||||||
uint8_t* memory;
|
|
||||||
|
|
||||||
bool* erase_states;
|
|
||||||
|
|
||||||
uint32_t* erase_cycles;
|
|
||||||
uint32_t erase_cycles_limit;
|
|
||||||
uint32_t total_erase_cycles;
|
|
||||||
uint32_t total_erase_cycles_limit;
|
|
||||||
|
|
||||||
void deinit();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // _SpiFlash_H_
|
|
@ -1,17 +0,0 @@
|
|||||||
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)
|
|
@ -1,145 +0,0 @@
|
|||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "SpiFlash.h"
|
|
||||||
#include "spi_flash_mmap.h"
|
|
||||||
#include "esp_err.h"
|
|
||||||
#include "esp_rom_spiflash.h"
|
|
||||||
#include "esp_flash.h"
|
|
||||||
#include "bsd_strings.h"
|
|
||||||
|
|
||||||
SpiFlash spiflash = SpiFlash();
|
|
||||||
|
|
||||||
esp_rom_spiflash_chip_t g_rom_flashchip;
|
|
||||||
|
|
||||||
size_t convert_chip_size_string(const char* chip_size_str)
|
|
||||||
{
|
|
||||||
int size = 0;
|
|
||||||
if (strcmp(chip_size_str, "1MB") == 0) {
|
|
||||||
size = 0x100000;
|
|
||||||
}
|
|
||||||
else if (strcmp(chip_size_str, "2MB") == 0) {
|
|
||||||
size = 0x200000;
|
|
||||||
}
|
|
||||||
else if (strcmp(chip_size_str, "4MB") == 0) {
|
|
||||||
size = 0x400000;
|
|
||||||
}
|
|
||||||
else if (strcmp(chip_size_str, "8MB") == 0) {
|
|
||||||
size = 0x800000;
|
|
||||||
}
|
|
||||||
else if (strcmp(chip_size_str, "16MB") == 0) {
|
|
||||||
size = 0x1000000;
|
|
||||||
} else {
|
|
||||||
size = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void _spi_flash_init(const char* chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partitions_bin)
|
|
||||||
{
|
|
||||||
size_t size = convert_chip_size_string(chip_size);
|
|
||||||
|
|
||||||
assert(size != 0);
|
|
||||||
|
|
||||||
spiflash.init(size, block_size, sector_size, page_size, partitions_bin);
|
|
||||||
|
|
||||||
g_rom_flashchip.chip_size = size;
|
|
||||||
g_rom_flashchip.block_size = block_size;
|
|
||||||
g_rom_flashchip.sector_size = sector_size;
|
|
||||||
g_rom_flashchip.page_size = page_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" esp_err_t spi_flash_mmap(size_t src_addr, size_t size, spi_flash_mmap_memory_t memory,
|
|
||||||
const void** out_ptr, spi_flash_mmap_handle_t* out_handle)
|
|
||||||
{
|
|
||||||
*out_handle = 0;
|
|
||||||
*out_ptr = (void*)spiflash.get_memory_ptr(src_addr);
|
|
||||||
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void spi_flash_munmap(spi_flash_mmap_handle_t handle)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" int spi_flash_get_total_erase_cycles(void)
|
|
||||||
{
|
|
||||||
return spiflash.get_total_erase_cycles();
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" int spi_flash_get_erase_cycles(size_t sector)
|
|
||||||
{
|
|
||||||
return spiflash.get_erase_cycles(sector);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" esp_err_t bootloader_flash_unlock(void)
|
|
||||||
{
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_rom_spiflash_result_t esp_rom_spiflash_read(uint32_t target, uint32_t *dest, int32_t len)
|
|
||||||
{
|
|
||||||
return spiflash.read(target, dest, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" esp_err_t esp_flash_read(esp_flash_t *chip, void *buffer, uint32_t address, uint32_t length)
|
|
||||||
{
|
|
||||||
return spiflash.read(address, buffer, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_rom_spiflash_result_t esp_rom_spiflash_erase_block(uint32_t block)
|
|
||||||
{
|
|
||||||
return spiflash.erase_block(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_rom_spiflash_result_t esp_rom_spiflash_erase_sector(uint32_t sector)
|
|
||||||
{
|
|
||||||
return spiflash.erase_sector(sector);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_rom_spiflash_result_t esp_rom_spiflash_erase_page(uint32_t page)
|
|
||||||
{
|
|
||||||
return spiflash.erase_page(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" esp_err_t esp_flash_erase_region(esp_flash_t *chip, uint32_t start_addr, uint32_t size)
|
|
||||||
{
|
|
||||||
size_t start = start_addr / SPI_FLASH_SEC_SIZE;
|
|
||||||
size_t end = start + size / SPI_FLASH_SEC_SIZE;
|
|
||||||
const size_t sectors_per_block = 65536 / SPI_FLASH_SEC_SIZE;
|
|
||||||
esp_rom_spiflash_result_t rc = ESP_ROM_SPIFLASH_RESULT_OK;
|
|
||||||
for (size_t sector = start; sector != end && rc == ESP_ROM_SPIFLASH_RESULT_OK; ) {
|
|
||||||
rc = spiflash.erase_sector(sector);
|
|
||||||
++sector;
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_rom_spiflash_result_t esp_rom_spiflash_write(uint32_t target, const uint32_t *src, int32_t len)
|
|
||||||
{
|
|
||||||
return spiflash.write(target, src, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" esp_err_t esp_flash_write(esp_flash_t *chip, const void *buffer, uint32_t address, uint32_t length)
|
|
||||||
{
|
|
||||||
return spiflash.write(address, buffer, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_rom_spiflash_result_t esp_rom_spiflash_write_encrypted(uint32_t flash_addr, uint32_t *data, uint32_t len)
|
|
||||||
{
|
|
||||||
return spiflash.write(flash_addr, data, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *heap_caps_malloc( size_t size, uint32_t caps )
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_rom_spiflash_result_t esp_rom_spiflash_write_disable(void)
|
|
||||||
{
|
|
||||||
return ESP_ROM_SPIFLASH_RESULT_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_flash_t* esp_flash_default_chip = NULL;
|
|
@ -1,47 +0,0 @@
|
|||||||
#include "esp_err.h"
|
|
||||||
#include "esp_rom_spiflash.h"
|
|
||||||
|
|
||||||
bool spi_flash_check_and_flush_cache(size_t start_addr, size_t length)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_rom_spiflash_result_t esp_rom_spiflash_unlock(void)
|
|
||||||
{
|
|
||||||
return ESP_ROM_SPIFLASH_RESULT_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void spi_flash_init_lock(void)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void spi_flash_op_lock(void)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void spi_flash_op_unlock(void)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void spi_flash_disable_interrupts_caches_and_other_cpu(void)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void spi_flash_enable_interrupts_caches_and_other_cpu(void)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void spi_flash_disable_interrupts_caches_and_other_cpu_no_os(void)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void spi_flash_enable_interrupts_caches_no_os(void)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#define CONFIG_PARTITION_TABLE_OFFSET 0x8000
|
|
@ -1,65 +0,0 @@
|
|||||||
ifndef COMPONENT
|
|
||||||
COMPONENT := stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
COMPONENT_LIB := lib$(COMPONENT).a
|
|
||||||
|
|
||||||
include Makefile.files
|
|
||||||
|
|
||||||
all: lib
|
|
||||||
|
|
||||||
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))
|
|
||||||
|
|
||||||
CPPFLAGS += $(INCLUDE_FLAGS) -g -m32
|
|
||||||
CXXFLAGS += $(INCLUDE_FLAGS) -std=c++11 -g -m32
|
|
||||||
|
|
||||||
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))))
|
|
||||||
|
|
||||||
%.o : %.c $(SDKCONFIG)
|
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $< - o $@
|
|
||||||
|
|
||||||
%.o : %.cpp $(SDKCONFIG)
|
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $< - o $@
|
|
||||||
|
|
||||||
define COMPILE_C
|
|
||||||
$(call CTARGET, ${1}, $(BUILD_DIR)) : ${1}
|
|
||||||
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}
|
|
||||||
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:
|
|
||||||
rm -f $(OBJ_FILES) $(BUILD_DIR)/$(COMPONENT_LIB)
|
|
||||||
|
|
||||||
lib: $(BUILD_DIR)/$(COMPONENT_LIB)
|
|
||||||
|
|
||||||
$(foreach cfile, $(CFILES), $(eval $(call COMPILE_C, $(cfile))))
|
|
||||||
$(foreach cxxfile, $(CPPFILES), $(eval $(call COMPILE_CPP, $(cxxfile))))
|
|
||||||
|
|
||||||
.PHONY: all lib clean
|
|
@ -1,42 +0,0 @@
|
|||||||
SOURCE_FILES := \
|
|
||||||
app_update/esp_ota_eps.c \
|
|
||||||
log/log.c \
|
|
||||||
newlib/lock.c \
|
|
||||||
esp32/crc.cpp \
|
|
||||||
esp32/esp_random.c \
|
|
||||||
esp_timer/src/esp_timer.c \
|
|
||||||
bsd/strlcpy.c\
|
|
||||||
bootloader_support/src/bootloader_common.c
|
|
||||||
|
|
||||||
INCLUDE_DIRS := \
|
|
||||||
../include \
|
|
||||||
../private_include \
|
|
||||||
app_update/include \
|
|
||||||
bsd/include \
|
|
||||||
driver/include \
|
|
||||||
esp_app_format/include \
|
|
||||||
esp_timer/include \
|
|
||||||
freertos/include \
|
|
||||||
log/include \
|
|
||||||
newlib/include \
|
|
||||||
sdmmc/include \
|
|
||||||
vfs/include \
|
|
||||||
$(addprefix ../../../../components/, \
|
|
||||||
esp_common/include \
|
|
||||||
esp_hw_support/include \
|
|
||||||
esp_hw_support/include/soc \
|
|
||||||
esp_system/include \
|
|
||||||
soc/esp32/include \
|
|
||||||
heap/include \
|
|
||||||
soc/include \
|
|
||||||
xtensa/include \
|
|
||||||
xtensa/esp32/include \
|
|
||||||
esp32/include \
|
|
||||||
esp_timer/include \
|
|
||||||
bootloader_support/include \
|
|
||||||
bootloader_support/bootloader_flash/include \
|
|
||||||
app_update/include \
|
|
||||||
hal/include \
|
|
||||||
esp_partition/include \
|
|
||||||
spi_flash/include \
|
|
||||||
)
|
|
@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The source file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#include "esp_ota_ops.h"
|
|
||||||
#include "esp_partition.h"
|
|
||||||
|
|
||||||
const esp_partition_t* esp_ota_get_running_partition(void)
|
|
||||||
{
|
|
||||||
// Return first instance of an app partition
|
|
||||||
const esp_partition_t* partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP,
|
|
||||||
ESP_PARTITION_SUBTYPE_ANY,
|
|
||||||
NULL);
|
|
||||||
assert(partition != NULL);
|
|
||||||
|
|
||||||
return partition;
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The header file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "esp_err.h"
|
|
||||||
|
|
||||||
esp_err_t bootloader_common_get_sha256_of_partition(uint32_t address, uint32_t size, int type, uint8_t *out_sha_256);
|
|
@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The source file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#include "esp_err.h"
|
|
||||||
|
|
||||||
esp_err_t bootloader_common_get_sha256_of_partition (uint32_t address, uint32_t size, int type, uint8_t *out_sha_256)
|
|
||||||
{
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
size_t strlcpy(char *dst, const char *src, size_t dsize);
|
|
@ -1,60 +0,0 @@
|
|||||||
/* $OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $ */
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. The name of the author may not be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
||||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
||||||
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
||||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copy string src to buffer dst of size dsize. At most dsize-1
|
|
||||||
* chars will be copied. Always NUL terminates (unless dsize == 0).
|
|
||||||
* Returns strlen(src); if retval >= dsize, truncation occurred.
|
|
||||||
*/
|
|
||||||
size_t
|
|
||||||
strlcpy(char *dst, const char *src, size_t dsize)
|
|
||||||
{
|
|
||||||
const char *osrc = src;
|
|
||||||
size_t nleft = dsize;
|
|
||||||
|
|
||||||
/* Copy as many bytes as will fit. */
|
|
||||||
if (nleft != 0) {
|
|
||||||
while (--nleft != 0) {
|
|
||||||
if ((*dst++ = *src++) == '\0')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Not enough room in dst, add NUL and traverse rest of src. */
|
|
||||||
if (nleft == 0) {
|
|
||||||
if (dsize != 0)
|
|
||||||
*dst = '\0'; /* NUL-terminate dst */
|
|
||||||
while (*src++)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
return(src - osrc - 1); /* count does not include NUL */
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
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)
|
|
@ -1,13 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The header file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "sdmmc_types.h"
|
|
@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The header file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef int sdmmc_card_t;
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The source file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
static const unsigned int crc32_le_table[256] = {
|
|
||||||
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L,
|
|
||||||
0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x90bf1d91L,
|
|
||||||
0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L,
|
|
||||||
0x136c9856L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 0xfa0f3d63L, 0x8d080df5L,
|
|
||||||
0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
|
|
||||||
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L,
|
|
||||||
0x26d930acL, 0x51de003aL, 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0xb8bda50fL,
|
|
||||||
0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL,
|
|
||||||
0x76dc4190L, 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 0x9fbfe4a5L, 0xe8b8d433L,
|
|
||||||
0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
|
|
||||||
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L,
|
|
||||||
0x65b0d9c6L, 0x12b7e950L, 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0xfbd44c65L,
|
|
||||||
0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL,
|
|
||||||
0x4369e96aL, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 0xaa0a4c5fL, 0xdd0d7cc9L,
|
|
||||||
0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
|
|
||||||
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL,
|
|
||||||
|
|
||||||
0xedb88320L, 0x9abfb3b6L, 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, 0x73dc1683L,
|
|
||||||
0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L,
|
|
||||||
0xf00f9344L, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, 0x196c3671L, 0x6e6b06e7L,
|
|
||||||
0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
|
|
||||||
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL,
|
|
||||||
0xd80d2bdaL, 0xaf0a1b4cL, 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0x4669be79L,
|
|
||||||
0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL,
|
|
||||||
0xc5ba3bbeL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, 0x2cd99e8bL, 0x5bdeae1dL,
|
|
||||||
0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
|
|
||||||
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L,
|
|
||||||
0x86d3d2d4L, 0xf1d4e242L, 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0x18b74777L,
|
|
||||||
0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L,
|
|
||||||
0xa00ae278L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, 0x4969474dL, 0x3e6e77dbL,
|
|
||||||
0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
|
|
||||||
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, 0xcdd70693L, 0x54de5729L, 0x23d967bfL,
|
|
||||||
0xb3667a2eL, 0xc4614ab8L, 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0x2d02ef8dL
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern "C" unsigned int crc32_le(unsigned int crc, unsigned char const * buf,unsigned int len)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
crc = ~crc;
|
|
||||||
for(i=0;i<len;i++){
|
|
||||||
crc = crc32_le_table[(crc^buf[i])&0xff]^(crc>>8);
|
|
||||||
}
|
|
||||||
return ~crc;
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The source file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#include "esp_system.h"
|
|
||||||
|
|
||||||
uint32_t esp_random(void)
|
|
||||||
{
|
|
||||||
return (uint32_t)rand();
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The source file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include "esp_err.h"
|
|
||||||
#include "esp_assert.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ESP_APP_DESC_MAGIC_WORD (0xABCD5432) /*!< The magic word for the esp_app_desc structure that is in DROM. */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Description about application.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
uint32_t magic_word; /*!< Magic word ESP_APP_DESC_MAGIC_WORD */
|
|
||||||
uint32_t secure_version; /*!< Secure version */
|
|
||||||
uint32_t reserv1[2]; /*!< reserv1 */
|
|
||||||
char version[32]; /*!< Application version */
|
|
||||||
char project_name[32]; /*!< Project name */
|
|
||||||
char time[16]; /*!< Compile time */
|
|
||||||
char date[16]; /*!< Compile date*/
|
|
||||||
char idf_ver[32]; /*!< Version IDF */
|
|
||||||
uint8_t app_elf_sha256[32]; /*!< sha256 of elf file */
|
|
||||||
uint32_t reserv2[20]; /*!< reserv2 */
|
|
||||||
} esp_app_desc_t;
|
|
||||||
|
|
||||||
/** @cond */
|
|
||||||
ESP_STATIC_ASSERT(sizeof(esp_app_desc_t) == 256, "esp_app_desc_t should be 256 bytes");
|
|
||||||
/** @endcond */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The header file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int64_t esp_timer_get_time(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The source file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#include "esp_timer.h"
|
|
||||||
|
|
||||||
int64_t esp_timer_get_time(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The header file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "projdefs.h"
|
|
||||||
#include "semphr.h"
|
|
@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The header file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define pdTRUE 1
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The header file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#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,9 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The header file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The header file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "sdkconfig.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define heap_caps_malloc(a, b) NULL
|
|
||||||
#define MALLOC_CAP_INTERNAL 0
|
|
||||||
#define MALLOC_CAP_8BIT 0
|
|
||||||
|
|
||||||
#define LOG_LOCAL_LEVEL CONFIG_LOG_DEFAULT_LEVEL
|
|
||||||
|
|
||||||
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 ESP_STATIC_ASSERT
|
|
||||||
#define ESP_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_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__); }
|
|
||||||
|
|
||||||
#define ESP_LOGI( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) { esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, 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_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_flash_encryption_enabled() false
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The source file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <time.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(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The header file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The source file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#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,8 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
@ -1,11 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The header file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "esp_err.h"
|
|
@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The header file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#ifndef __ESP_PARTITION_H__
|
|
||||||
#define __ESP_PARTITION_H__
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include "esp_err.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
ESP_PARTITION_TYPE_APP = 0x00, //!< Application partition type
|
|
||||||
ESP_PARTITION_TYPE_DATA = 0x01, //!< Data partition type
|
|
||||||
} esp_partition_type_t;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_FACTORY = 0x00, //!< Factory application partition
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_MIN = 0x10, //!< Base for OTA partition subtypes
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_0 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 0, //!< OTA partition 0
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_1 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 1, //!< OTA partition 1
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_2 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 2, //!< OTA partition 2
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_3 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 3, //!< OTA partition 3
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_4 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 4, //!< OTA partition 4
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_5 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 5, //!< OTA partition 5
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_6 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 6, //!< OTA partition 6
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_7 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 7, //!< OTA partition 7
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_8 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 8, //!< OTA partition 8
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_9 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 9, //!< OTA partition 9
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_10 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 10,//!< OTA partition 10
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_11 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 11,//!< OTA partition 11
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_12 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 12,//!< OTA partition 12
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_13 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 13,//!< OTA partition 13
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_14 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 14,//!< OTA partition 14
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_15 = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 15,//!< OTA partition 15
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_OTA_MAX = ESP_PARTITION_SUBTYPE_APP_OTA_MIN + 16,//!< Max subtype of OTA partition
|
|
||||||
ESP_PARTITION_SUBTYPE_APP_TEST = 0x20, //!< Test application partition
|
|
||||||
|
|
||||||
ESP_PARTITION_SUBTYPE_DATA_OTA = 0x00, //!< OTA selection partition
|
|
||||||
ESP_PARTITION_SUBTYPE_DATA_PHY = 0x01, //!< PHY init data partition
|
|
||||||
ESP_PARTITION_SUBTYPE_DATA_NVS = 0x02, //!< NVS partition
|
|
||||||
ESP_PARTITION_SUBTYPE_DATA_COREDUMP = 0x03, //!< COREDUMP partition
|
|
||||||
ESP_PARTITION_SUBTYPE_DATA_NVS_KEYS = 0x04, //!< Partition for NVS keys
|
|
||||||
ESP_PARTITION_SUBTYPE_DATA_EFUSE_EM = 0x05, //!< Partition for emulate eFuse bits
|
|
||||||
ESP_PARTITION_SUBTYPE_DATA_UNDEFINED = 0x06, //!< Undefined (or unspecified) data partition
|
|
||||||
|
|
||||||
ESP_PARTITION_SUBTYPE_DATA_ESPHTTPD = 0x80, //!< ESPHTTPD partition
|
|
||||||
ESP_PARTITION_SUBTYPE_DATA_FAT = 0x81, //!< FAT partition
|
|
||||||
ESP_PARTITION_SUBTYPE_DATA_SPIFFS = 0x82, //!< SPIFFS partition
|
|
||||||
|
|
||||||
ESP_PARTITION_SUBTYPE_ANY = 0xff, //!< Used to search for partitions with any subtype
|
|
||||||
} esp_partition_subtype_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Opaque partition iterator type
|
|
||||||
*/
|
|
||||||
typedef struct esp_partition_iterator_opaque_* esp_partition_iterator_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief partition information structure
|
|
||||||
*
|
|
||||||
* This is not the format in flash, that format is esp_partition_info_t.
|
|
||||||
*
|
|
||||||
* However, this is the format used by this API.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
void* flash_chip; /*!< SPI flash chip on which the partition resides */
|
|
||||||
esp_partition_type_t type; /*!< partition type (app/data) */
|
|
||||||
esp_partition_subtype_t subtype; /*!< partition subtype */
|
|
||||||
uint32_t address; /*!< starting address of the partition in flash */
|
|
||||||
uint32_t size; /*!< size of the partition, in bytes */
|
|
||||||
char label[17]; /*!< partition label, zero-terminated ASCII string */
|
|
||||||
bool encrypted; /*!< flag is set to true if partition is encrypted */
|
|
||||||
} esp_partition_t;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __ESP_PARTITION_H__ */
|
|
@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
|
|
||||||
* The header file used normally for ESP-IDF has the same name but is located elsewhere.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "esp_err.h"
|
|
||||||
|
|
||||||
#define ESP_VFS_FLAG_CONTEXT_PTR 1
|
|
||||||
#define ESP_VFS_PATH_MAX 15
|
|
@ -1,98 +0,0 @@
|
|||||||
ifndef COMPONENT
|
|
||||||
COMPONENT := wl
|
|
||||||
endif
|
|
||||||
|
|
||||||
COMPONENT_LIB := lib$(COMPONENT).a
|
|
||||||
TEST_PROGRAM := test_$(COMPONENT)
|
|
||||||
|
|
||||||
STUBS_LIB_DIR := ../../../components/spi_flash/sim/stubs
|
|
||||||
STUBS_LIB_BUILD_DIR := $(STUBS_LIB_DIR)/build
|
|
||||||
STUBS_LIB := libstubs.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
|
|
||||||
|
|
||||||
include Makefile.files
|
|
||||||
|
|
||||||
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) -I../../../heap/include/soc $(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_wl.cpp \
|
|
||||||
main.cpp \
|
|
||||||
|
|
||||||
TEST_OBJ_FILES = $(filter %.o, $(TEST_SOURCE_FILES:.cpp=.o) $(TEST_SOURCE_FILES:.c=.o))
|
|
||||||
|
|
||||||
$(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)
|
|
||||||
|
|
||||||
# Create other necessary targets
|
|
||||||
partition_table.bin: partition_table.csv
|
|
||||||
python ../../../components/partition_table/gen_esp32part.py --verify $< $@
|
|
||||||
|
|
||||||
force:
|
|
||||||
|
|
||||||
.PHONY: all lib test clean force
|
|
@ -1,44 +0,0 @@
|
|||||||
SOURCE_FILES := \
|
|
||||||
$(addprefix ../, \
|
|
||||||
wear_levelling.cpp \
|
|
||||||
crc32.cpp \
|
|
||||||
../esp_rom/linux/esp_rom_crc.c \
|
|
||||||
WL_Flash.cpp \
|
|
||||||
Partition.cpp \
|
|
||||||
)
|
|
||||||
|
|
||||||
INCLUDE_DIRS := \
|
|
||||||
. \
|
|
||||||
../ \
|
|
||||||
../include \
|
|
||||||
../private_include \
|
|
||||||
../../spi_flash/sim \
|
|
||||||
$(addprefix ../../spi_flash/sim/stubs/, \
|
|
||||||
app_update/include \
|
|
||||||
driver/include \
|
|
||||||
freertos/include \
|
|
||||||
log/include \
|
|
||||||
newlib/include \
|
|
||||||
sdmmc/include \
|
|
||||||
vfs/include \
|
|
||||||
) \
|
|
||||||
$(addprefix ../../../components/, \
|
|
||||||
heap/include \
|
|
||||||
esp_rom/include \
|
|
||||||
esp_system/include \
|
|
||||||
esp_common/include \
|
|
||||||
esp_hw_support/include \
|
|
||||||
esp_hw_support/include/soc \
|
|
||||||
xtensa/include \
|
|
||||||
xtensa/esp32/include \
|
|
||||||
soc/esp32/include \
|
|
||||||
heap/include \
|
|
||||||
soc/include \
|
|
||||||
esp32/include \
|
|
||||||
bootloader_support/include \
|
|
||||||
bootloader_support/bootloader_flash/include \
|
|
||||||
app_update/include \
|
|
||||||
hal/include \
|
|
||||||
spi_flash/include \
|
|
||||||
esp_partition/include \
|
|
||||||
)
|
|
@ -1,17 +0,0 @@
|
|||||||
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)
|
|
@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
#define CONFIG_IDF_TARGET_ESP32 1
|
|
||||||
#define CONFIG_WL_SECTOR_SIZE 4096
|
|
||||||
#define CONFIG_LOG_DEFAULT_LEVEL 3
|
|
||||||
#define CONFIG_PARTITION_TABLE_OFFSET 0x8000
|
|
||||||
#define CONFIG_ESPTOOLPY_FLASHSIZE "8MB"
|
|
||||||
//currently use the legacy implementation, since the stubs for new HAL are not done yet
|
|
||||||
#define CONFIG_SPI_FLASH_USE_LEGACY_IMPL 1
|
|
||||||
#define CONFIG_MMU_PAGE_SIZE 0X10000 // 64KB
|
|
@ -996,11 +996,6 @@ components/spi_flash/include/spi_flash_chip_generic.h
|
|||||||
components/spi_flash/include/spi_flash_chip_issi.h
|
components/spi_flash/include/spi_flash_chip_issi.h
|
||||||
components/spi_flash/include/spi_flash_chip_mxic.h
|
components/spi_flash/include/spi_flash_chip_mxic.h
|
||||||
components/spi_flash/include/spi_flash_chip_winbond.h
|
components/spi_flash/include/spi_flash_chip_winbond.h
|
||||||
components/spi_flash/sim/SpiFlash.cpp
|
|
||||||
components/spi_flash/sim/flash_mock.cpp
|
|
||||||
components/spi_flash/sim/flash_mock_util.c
|
|
||||||
components/spi_flash/sim/sdkconfig/sdkconfig.h
|
|
||||||
components/spi_flash/sim/stubs/bsd/strlcpy.c
|
|
||||||
components/spi_flash/spi_flash_chip_boya.c
|
components/spi_flash/spi_flash_chip_boya.c
|
||||||
components/spi_flash/spi_flash_chip_issi.c
|
components/spi_flash/spi_flash_chip_issi.c
|
||||||
components/spi_flash/spi_flash_chip_mxic.c
|
components/spi_flash/spi_flash_chip_mxic.c
|
||||||
|
Loading…
Reference in New Issue
Block a user