Skip to content

Commit

Permalink
去除磨捐赠均衡层
Browse files Browse the repository at this point in the history
  • Loading branch information
diskman88 committed Oct 7, 2019
1 parent 7db8819 commit 8d92aa2
Show file tree
Hide file tree
Showing 62 changed files with 267 additions and 3,357 deletions.
118 changes: 44 additions & 74 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
#CFLAGS ?= -std=gnu99 -Os -Wall
#CXXFLAGS ?= -std=gnu++11 -Os -Wall
BUILD ?= build
IDF_DIR = esp_idf
IDF_INCLUDES += -I $(IDF_DIR)
IDF_INCLUDES += -I $(IDF_DIR)/freertos

IDF_MODIFIED_DIR = idf/modified
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)/driver/include
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)/fatfs/src
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)/freertos/include
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)/log/include
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)/newlib/include
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)/vfs/include
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)/vfs/include/sys
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)/wear_levelling/include
FILESYSTEM_DIR = filesystem
IDF_INCLUDES += -I $(FILESYSTEM_DIR)/diskio
IDF_INCLUDES += -I $(FILESYSTEM_DIR)/fatfs
IDF_INCLUDES += -I $(FILESYSTEM_DIR)/vfs

TCLAP_DIR = tclap
IDF_INCLUDES += -I $(TCLAP_DIR)

IDF_ORIG_DIR = idf/orig
IDF_INCLUDES += -I $(IDF_ORIG_DIR)
IDF_INCLUDES += -I $(IDF_ORIG_DIR)/driver/include
IDF_INCLUDES += -I $(IDF_ORIG_DIR)/driver/include/driver
IDF_INCLUDES += -I $(IDF_ORIG_DIR)/esp32/include
IDF_INCLUDES += -I $(IDF_ORIG_DIR)/fatfs/src
IDF_INCLUDES += -I $(IDF_ORIG_DIR)/sdmmc/include
IDF_INCLUDES += -I $(IDF_ORIG_DIR)/spi_flash/include
IDF_INCLUDES += -I $(IDF_ORIG_DIR)/wear_levelling/private_include
# OS = 1
ifdef OS
ifeq ($(OS),Windows_NT)
Expand Down Expand Up @@ -74,28 +66,20 @@ else
TARGET := mkfatfs
endif

OBJ := main.o \
fatfs/fatfs.o \
fatfs/ccsbcs.o \
fatfs/crc.o \
fatfs/FatPartition.o \
$(IDF_MODIFIED_DIR)/fatfs/src/ff.o \
$(IDF_MODIFIED_DIR)/fatfs/src/vfs_fat.o \
$(IDF_MODIFIED_DIR)/freertos/include/freertos/semphr.o \
$(IDF_MODIFIED_DIR)/newlib/include/sys/lock.o \
$(IDF_MODIFIED_DIR)/newlib/include/sys/idf_reent.o \
$(IDF_MODIFIED_DIR)/newlib/include/sys/errno.o \
$(IDF_MODIFIED_DIR)/spi_flash/partition.o \
$(IDF_MODIFIED_DIR)/vfs/vfs.o \
$(IDF_MODIFIED_DIR)/wear_levelling/wear_levelling.o \
$(IDF_ORIG_DIR)/fatfs/src/diskio.o \
$(IDF_ORIG_DIR)/fatfs/src/diskio_spiflash.o \
$(IDF_ORIG_DIR)/fatfs/src/option/syscall.o \
$(IDF_ORIG_DIR)/wear_levelling/crc32.o \
$(IDF_ORIG_DIR)/wear_levelling/WL_Flash.o \
$(IDF_ORIG_DIR)/wear_levelling/WL_Ext_Perf.o \
$(IDF_ORIG_DIR)/wear_levelling/WL_Ext_Safe.o \

OBJ := $(BUILD)/main.o \
$(BUILD)/$(IDF_DIR)/errno.o \
$(BUILD)/$(IDF_DIR)/idf_reent.o \
$(BUILD)/$(IDF_DIR)/lock.o \
$(BUILD)/$(IDF_DIR)/freertos/semphr.o \
$(BUILD)/$(FILESYSTEM_DIR)/fatfs/ccsbcs.o \
$(BUILD)/$(FILESYSTEM_DIR)/fatfs/esp_vfs_fat.o \
$(BUILD)/$(FILESYSTEM_DIR)/fatfs/ff.o \
$(BUILD)/$(FILESYSTEM_DIR)/fatfs/syscall.o \
$(BUILD)/$(FILESYSTEM_DIR)/diskio/diskio_RAM.o \
$(BUILD)/$(FILESYSTEM_DIR)/diskio/diskio.o \
$(BUILD)/$(FILESYSTEM_DIR)/diskio/FatPartition.o \
$(BUILD)/$(FILESYSTEM_DIR)/vfs/user_vfs.o \
$(BUILD)/$(FILESYSTEM_DIR)/vfs/vfs.o \

VERSION ?= $(shell git describe --always)

Expand All @@ -105,41 +89,27 @@ all: $(TARGET)

$(TARGET):
@echo "Building mkfatfs ..."
$(CXX) $(TARGET_CXXFLAGS) -c main.cpp -o main.o
$(CC) $(TARGET_CFLAGS) -c fatfs/fatfs.c -o fatfs/fatfs.o
$(CC) $(TARGET_CFLAGS) -c fatfs/ccsbcs.c -o fatfs/ccsbcs.o
$(CXX) $(TARGET_CXXFLAGS) -c fatfs/crc.cpp -o fatfs/crc.o
$(CXX) $(TARGET_CXXFLAGS) -c fatfs/FatPartition.cpp -o fatfs/FatPartition.o
$(CC) $(TARGET_CFLAGS) -c $(IDF_MODIFIED_DIR)/fatfs/src/ff.c -o $(IDF_MODIFIED_DIR)/fatfs/src/ff.o
$(CC) $(TARGET_CFLAGS) -c $(IDF_MODIFIED_DIR)/fatfs/src/vfs_fat.c -o $(IDF_MODIFIED_DIR)/fatfs/src/vfs_fat.o
$(CC) $(TARGET_CFLAGS) -c $(IDF_MODIFIED_DIR)/freertos/include/freertos/semphr.c -o $(IDF_MODIFIED_DIR)/freertos/include/freertos/semphr.o
$(CC) $(TARGET_CFLAGS) -c $(IDF_MODIFIED_DIR)/newlib/include/sys/lock.c -o $(IDF_MODIFIED_DIR)/newlib/include/sys/lock.o
$(CC) $(TARGET_CFLAGS) -c $(IDF_MODIFIED_DIR)/newlib/include/sys/idf_reent.c -o $(IDF_MODIFIED_DIR)/newlib/include/sys/idf_reent.o
$(CC) $(TARGET_CFLAGS) -c $(IDF_MODIFIED_DIR)/newlib/include/sys/errno.c -o $(IDF_MODIFIED_DIR)/newlib/include/sys/errno.o
$(CC) $(TARGET_CFLAGS) -c $(IDF_MODIFIED_DIR)/spi_flash/partition.c -o $(IDF_MODIFIED_DIR)/spi_flash/partition.o
$(CC) $(TARGET_CFLAGS) -c $(IDF_MODIFIED_DIR)/vfs/vfs.c -o $(IDF_MODIFIED_DIR)/vfs/vfs.o
$(CXX) $(TARGET_CXXFLAGS) -c $(IDF_MODIFIED_DIR)/wear_levelling/wear_levelling.cpp -o $(IDF_MODIFIED_DIR)/wear_levelling/wear_levelling.o
$(CC) $(TARGET_CFLAGS) -c $(IDF_ORIG_DIR)/fatfs/src/diskio.c -o $(IDF_ORIG_DIR)/fatfs/src/diskio.o
$(CC) $(TARGET_CFLAGS) -c $(IDF_ORIG_DIR)/fatfs/src/diskio_spiflash.c -o $(IDF_ORIG_DIR)/fatfs/src/diskio_spiflash.o
$(CC) $(TARGET_CFLAGS) -c $(IDF_ORIG_DIR)/fatfs/src/option/syscall.c -o $(IDF_ORIG_DIR)/fatfs/src/option/syscall.o
$(CXX) $(TARGET_CXXFLAGS) -c $(IDF_ORIG_DIR)/wear_levelling/crc32.cpp -o $(IDF_ORIG_DIR)/wear_levelling/crc32.o
$(CXX) $(TARGET_CXXFLAGS) -c $(IDF_ORIG_DIR)/wear_levelling/WL_Flash.cpp -o $(IDF_ORIG_DIR)/wear_levelling/WL_Flash.o
$(CXX) $(TARGET_CXXFLAGS) -c $(IDF_ORIG_DIR)/wear_levelling/WL_Ext_Perf.cpp -o $(IDF_ORIG_DIR)/wear_levelling/WL_Ext_Perf.o
$(CXX) $(TARGET_CXXFLAGS) -c $(IDF_ORIG_DIR)/wear_levelling/WL_Ext_Safe.cpp -o $(IDF_ORIG_DIR)/wear_levelling/WL_Ext_Safe.o
$(CXX) $(TARGET_CXXFLAGS) -c main.cpp -o $(BUILD)/main.o
$(CC) $(TARGET_CFLAGS) -c $(IDF_DIR)/errno.c -o $(BUILD)/$(IDF_DIR)/errno.o
$(CC) $(TARGET_CFLAGS) -c $(IDF_DIR)/idf_reent.c -o $(BUILD)/$(IDF_DIR)/idf_reent.o
$(CC) $(TARGET_CFLAGS) -c $(IDF_DIR)/lock.c -o $(BUILD)/$(IDF_DIR)/lock.o
$(CC) $(TARGET_CFLAGS) -c $(IDF_DIR)/freertos/semphr.c -o $(BUILD)/$(IDF_DIR)/freertos/semphr.o
$(CC) $(TARGET_CFLAGS) -c $(FILESYSTEM_DIR)/fatfs/ccsbcs.c -o $(BUILD)/$(FILESYSTEM_DIR)/fatfs/ccsbcs.o
$(CC) $(TARGET_CFLAGS) -c $(FILESYSTEM_DIR)/fatfs/esp_vfs_fat.c -o $(BUILD)/$(FILESYSTEM_DIR)/fatfs/esp_vfs_fat.o
$(CC) $(TARGET_CFLAGS) -c $(FILESYSTEM_DIR)/fatfs/ff.c -o $(BUILD)/$(FILESYSTEM_DIR)/fatfs/ff.o
$(CC) $(TARGET_CFLAGS) -c $(FILESYSTEM_DIR)/fatfs/syscall.c -o $(BUILD)/$(FILESYSTEM_DIR)/fatfs/syscall.o
$(CXX) $(TARGET_CXXFLAGS) -c $(FILESYSTEM_DIR)/diskio/diskio_RAM.cpp -o $(BUILD)/$(FILESYSTEM_DIR)/diskio/diskio_RAM.o
$(CC) $(TARGET_CFLAGS) -c $(FILESYSTEM_DIR)/diskio/diskio.c -o $(BUILD)/$(FILESYSTEM_DIR)/diskio/diskio.o
$(CXX) $(TARGET_CXXFLAGS) -c $(FILESYSTEM_DIR)/diskio/FatPartition.cpp -o $(BUILD)/$(FILESYSTEM_DIR)/diskio/FatPartition.o
$(CC) $(TARGET_CFLAGS) -c $(FILESYSTEM_DIR)/vfs/user_vfs.c -o $(BUILD)/$(FILESYSTEM_DIR)/vfs/user_vfs.o
$(CC) $(TARGET_CFLAGS) -c $(FILESYSTEM_DIR)/vfs/vfs.c -o $(BUILD)/$(FILESYSTEM_DIR)/vfs/vfs.o
$(CXX) $(TARGET_CFLAGS) -o $(TARGET) $(OBJ) $(TARGET_LDFLAGS)



clean:
@rm -f *.o
@rm -f fatfs/*.o
@rm -f $(IDF_MODIFIED_DIR)/fatfs/src/*.o
@rm -f $(IDF_MODIFIED_DIR)/freertos/include/freertos/*.o
@rm -f $(IDF_MODIFIED_DIR)/newlib/include/sys/*.o
@rm -f $(IDF_MODIFIED_DIR)/spi_flash/*.o
@rm -f $(IDF_MODIFIED_DIR)/vfs/*.o
@rm -f $(IDF_MODIFIED_DIR)/wear_levelling/*.o
@rm -f $(IDF_ORIG_DIR)/fatfs/src/*.o
@rm -f $(IDF_ORIG_DIR)/fatfs/src/option/*.o
@rm -f $(IDF_ORIG_DIR)/wear_levelling/*.o
@rm -f $(BUILD)/$(IDF_DIR)/*.o
@rm -f $(BUILD)/$(IDF_DIR)/frertos/*.o
@rm -f $(I$(BUILD)/$(FILESYSTEM_DIR)/fatfs/*.o
@rm -f $(BUILD)/$(FILESYSTEM_DIR)/diskio/*.o
@rm -f $(BUILD)/$(FILESYSTEM_DIR)/vfs/*.o
@rm -f $(TARGET)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extern "C" {
#endif
#define _SYS_ERRNO_H_

#include <sys/idf_reent.h> //MVA was <sys/reent.h>
#include "idf_reent.h" //MVA was <sys/reent.h>

//MVA VVV
/*
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <stdbool.h>
#include <stddef.h>
#include "esp_err.h"
#include "esp_spi_flash.h"
// #include "esp_spi_flash.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -119,7 +119,7 @@ typedef struct {
* Iterator obtained through this function has to be released
* using esp_partition_iterator_release when not used any more.
*/
esp_partition_iterator_t esp_partition_find(esp_partition_type_t type, esp_partition_subtype_t subtype, const char* label);
// esp_partition_iterator_t esp_partition_find(esp_partition_type_t type, esp_partition_subtype_t subtype, const char* label);

/**
* @brief Find first partition based on one or more parameters
Expand All @@ -134,7 +134,7 @@ esp_partition_iterator_t esp_partition_find(esp_partition_type_t type, esp_parti
* @return pointer to esp_partition_t structure, or NULL if no partition is found.
* This pointer is valid for the lifetime of the application.
*/
const esp_partition_t* esp_partition_find_first(esp_partition_type_t type, esp_partition_subtype_t subtype, const char* label);
// const esp_partition_t* esp_partition_find_first(esp_partition_type_t type, esp_partition_subtype_t subtype, const char* label);

/**
* @brief Get esp_partition_t structure for given partition
Expand All @@ -144,7 +144,7 @@ const esp_partition_t* esp_partition_find_first(esp_partition_type_t type, esp_p
* @return pointer to esp_partition_t structure. This pointer is valid for the lifetime
* of the application.
*/
const esp_partition_t* esp_partition_get(esp_partition_iterator_t iterator);
// const esp_partition_t* esp_partition_get(esp_partition_iterator_t iterator);

/**
* @brief Move partition iterator to the next partition found
Expand All @@ -155,15 +155,15 @@ const esp_partition_t* esp_partition_get(esp_partition_iterator_t iterator);
*
* @return NULL if no partition was found, valid esp_partition_iterator_t otherwise.
*/
esp_partition_iterator_t esp_partition_next(esp_partition_iterator_t iterator);
// esp_partition_iterator_t esp_partition_next(esp_partition_iterator_t iterator);

/**
* @brief Release partition iterator
*
* @param iterator Iterator obtained using esp_partition_find. Must be non-NULL.
*
*/
void esp_partition_iterator_release(esp_partition_iterator_t iterator);
// void esp_partition_iterator_release(esp_partition_iterator_t iterator);

/**
* @brief Verify partition data
Expand All @@ -183,7 +183,7 @@ void esp_partition_iterator_release(esp_partition_iterator_t iterator);
* - If partition not found, returns NULL.
* - If found, returns a pointer to the esp_partition_t structure in flash. This pointer is always valid for the lifetime of the application.
*/
const esp_partition_t *esp_partition_verify(const esp_partition_t *partition);
// const esp_partition_t *esp_partition_verify(const esp_partition_t *partition);

/**
* @brief Read data from the partition
Expand All @@ -202,8 +202,8 @@ const esp_partition_t *esp_partition_verify(const esp_partition_t *partition);
* ESP_ERR_INVALID_SIZE, if read would go out of bounds of the partition;
* or one of error codes from lower-level flash driver.
*/
esp_err_t esp_partition_read(const esp_partition_t* partition,
size_t src_offset, void* dst, size_t size);
// esp_err_t esp_partition_read(const esp_partition_t* partition,
// size_t src_offset, void* dst, size_t size);

/**
* @brief Write data to the partition
Expand Down Expand Up @@ -235,8 +235,8 @@ esp_err_t esp_partition_read(const esp_partition_t* partition,
* ESP_ERR_INVALID_SIZE, if write would go out of bounds of the partition;
* or one of error codes from lower-level flash driver.
*/
esp_err_t esp_partition_write(const esp_partition_t* partition,
size_t dst_offset, const void* src, size_t size);
// esp_err_t esp_partition_write(const esp_partition_t* partition,
// size_t dst_offset, const void* src, size_t size);

/**
* @brief Erase part of the partition
Expand All @@ -254,8 +254,8 @@ esp_err_t esp_partition_write(const esp_partition_t* partition,
* ESP_ERR_INVALID_SIZE, if erase would go out of bounds of the partition;
* or one of error codes from lower-level flash driver.
*/
esp_err_t esp_partition_erase_range(const esp_partition_t* partition,
uint32_t start_addr, uint32_t size);
// esp_err_t esp_partition_erase_range(const esp_partition_t* partition,
// uint32_t start_addr, uint32_t size);

/**
* @brief Configure MMU to map partition into data memory
Expand All @@ -282,9 +282,9 @@ esp_err_t esp_partition_erase_range(const esp_partition_t* partition,
*
* @return ESP_OK, if successful
*/
esp_err_t esp_partition_mmap(const esp_partition_t* partition, uint32_t offset, uint32_t size,
spi_flash_mmap_memory_t memory,
const void** out_ptr, spi_flash_mmap_handle_t* out_handle);
// esp_err_t esp_partition_mmap(const esp_partition_t* partition, uint32_t offset, uint32_t size,
// spi_flash_mmap_memory_t memory,
// const void** out_ptr, spi_flash_mmap_handle_t* out_handle);


#ifdef __cplusplus
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
63 changes: 0 additions & 63 deletions fatfs/crc.cpp

This file was deleted.

3 changes: 3 additions & 0 deletions fatfs/FatPartition.cpp → filesystem/diskio/FatPartition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include <cstring> // memset/memcpy
#include "esp_log.h"
#include "FatPartition.h"
#include "sdkconfig.h"

#define SPI_FLASH_SEC_SIZE CONFIG_RAM_SECTOR_SIZE

static const char *TAG = "FatPartition";

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions idf/orig/fatfs/src/diskio.h → filesystem/diskio/diskio.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ extern "C" {
#endif

#include "integer.h"
#include "sdmmc_cmd.h"
#include "driver/sdmmc_host.h"
#include "esp_err.h"
// #include "sdmmc_cmd.h"
// #include "driver/sdmmc_host.h"

/* Status of Disk Functions */
typedef BYTE DSTATUS;
Expand Down Expand Up @@ -77,7 +78,7 @@ void ff_diskio_register(BYTE pdrv, const ff_diskio_impl_t* discio_impl);
* @param pdrv drive number
* @param card pointer to sdmmc_card_t structure describing a card; card should be initialized before calling f_mount.
*/
void ff_diskio_register_sdmmc(BYTE pdrv, sdmmc_card_t* card);
// void ff_diskio_register_sdmmc(BYTE pdrv, sdmmc_card_t* card);

/**
* Get next available drive number
Expand Down

0 comments on commit 8d92aa2

Please sign in to comment.