Skip to content

Commit 8d92aa2

Browse files
committed
去除磨捐赠均衡层
1 parent 7db8819 commit 8d92aa2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+267
-3357
lines changed

Makefile

Lines changed: 44 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
11
#CFLAGS ?= -std=gnu99 -Os -Wall
22
#CXXFLAGS ?= -std=gnu++11 -Os -Wall
3+
BUILD ?= build
4+
IDF_DIR = esp_idf
5+
IDF_INCLUDES += -I $(IDF_DIR)
6+
IDF_INCLUDES += -I $(IDF_DIR)/freertos
37

4-
IDF_MODIFIED_DIR = idf/modified
5-
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)
6-
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)/driver/include
7-
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)/fatfs/src
8-
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)/freertos/include
9-
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)/log/include
10-
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)/newlib/include
11-
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)/vfs/include
12-
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)/vfs/include/sys
13-
IDF_INCLUDES += -I $(IDF_MODIFIED_DIR)/wear_levelling/include
8+
FILESYSTEM_DIR = filesystem
9+
IDF_INCLUDES += -I $(FILESYSTEM_DIR)/diskio
10+
IDF_INCLUDES += -I $(FILESYSTEM_DIR)/fatfs
11+
IDF_INCLUDES += -I $(FILESYSTEM_DIR)/vfs
12+
13+
TCLAP_DIR = tclap
14+
IDF_INCLUDES += -I $(TCLAP_DIR)
1415

15-
IDF_ORIG_DIR = idf/orig
16-
IDF_INCLUDES += -I $(IDF_ORIG_DIR)
17-
IDF_INCLUDES += -I $(IDF_ORIG_DIR)/driver/include
18-
IDF_INCLUDES += -I $(IDF_ORIG_DIR)/driver/include/driver
19-
IDF_INCLUDES += -I $(IDF_ORIG_DIR)/esp32/include
20-
IDF_INCLUDES += -I $(IDF_ORIG_DIR)/fatfs/src
21-
IDF_INCLUDES += -I $(IDF_ORIG_DIR)/sdmmc/include
22-
IDF_INCLUDES += -I $(IDF_ORIG_DIR)/spi_flash/include
23-
IDF_INCLUDES += -I $(IDF_ORIG_DIR)/wear_levelling/private_include
2416
# OS = 1
2517
ifdef OS
2618
ifeq ($(OS),Windows_NT)
@@ -74,28 +66,20 @@ else
7466
TARGET := mkfatfs
7567
endif
7668

77-
OBJ := main.o \
78-
fatfs/fatfs.o \
79-
fatfs/ccsbcs.o \
80-
fatfs/crc.o \
81-
fatfs/FatPartition.o \
82-
$(IDF_MODIFIED_DIR)/fatfs/src/ff.o \
83-
$(IDF_MODIFIED_DIR)/fatfs/src/vfs_fat.o \
84-
$(IDF_MODIFIED_DIR)/freertos/include/freertos/semphr.o \
85-
$(IDF_MODIFIED_DIR)/newlib/include/sys/lock.o \
86-
$(IDF_MODIFIED_DIR)/newlib/include/sys/idf_reent.o \
87-
$(IDF_MODIFIED_DIR)/newlib/include/sys/errno.o \
88-
$(IDF_MODIFIED_DIR)/spi_flash/partition.o \
89-
$(IDF_MODIFIED_DIR)/vfs/vfs.o \
90-
$(IDF_MODIFIED_DIR)/wear_levelling/wear_levelling.o \
91-
$(IDF_ORIG_DIR)/fatfs/src/diskio.o \
92-
$(IDF_ORIG_DIR)/fatfs/src/diskio_spiflash.o \
93-
$(IDF_ORIG_DIR)/fatfs/src/option/syscall.o \
94-
$(IDF_ORIG_DIR)/wear_levelling/crc32.o \
95-
$(IDF_ORIG_DIR)/wear_levelling/WL_Flash.o \
96-
$(IDF_ORIG_DIR)/wear_levelling/WL_Ext_Perf.o \
97-
$(IDF_ORIG_DIR)/wear_levelling/WL_Ext_Safe.o \
98-
69+
OBJ := $(BUILD)/main.o \
70+
$(BUILD)/$(IDF_DIR)/errno.o \
71+
$(BUILD)/$(IDF_DIR)/idf_reent.o \
72+
$(BUILD)/$(IDF_DIR)/lock.o \
73+
$(BUILD)/$(IDF_DIR)/freertos/semphr.o \
74+
$(BUILD)/$(FILESYSTEM_DIR)/fatfs/ccsbcs.o \
75+
$(BUILD)/$(FILESYSTEM_DIR)/fatfs/esp_vfs_fat.o \
76+
$(BUILD)/$(FILESYSTEM_DIR)/fatfs/ff.o \
77+
$(BUILD)/$(FILESYSTEM_DIR)/fatfs/syscall.o \
78+
$(BUILD)/$(FILESYSTEM_DIR)/diskio/diskio_RAM.o \
79+
$(BUILD)/$(FILESYSTEM_DIR)/diskio/diskio.o \
80+
$(BUILD)/$(FILESYSTEM_DIR)/diskio/FatPartition.o \
81+
$(BUILD)/$(FILESYSTEM_DIR)/vfs/user_vfs.o \
82+
$(BUILD)/$(FILESYSTEM_DIR)/vfs/vfs.o \
9983

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

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

10690
$(TARGET):
10791
@echo "Building mkfatfs ..."
108-
$(CXX) $(TARGET_CXXFLAGS) -c main.cpp -o main.o
109-
$(CC) $(TARGET_CFLAGS) -c fatfs/fatfs.c -o fatfs/fatfs.o
110-
$(CC) $(TARGET_CFLAGS) -c fatfs/ccsbcs.c -o fatfs/ccsbcs.o
111-
$(CXX) $(TARGET_CXXFLAGS) -c fatfs/crc.cpp -o fatfs/crc.o
112-
$(CXX) $(TARGET_CXXFLAGS) -c fatfs/FatPartition.cpp -o fatfs/FatPartition.o
113-
$(CC) $(TARGET_CFLAGS) -c $(IDF_MODIFIED_DIR)/fatfs/src/ff.c -o $(IDF_MODIFIED_DIR)/fatfs/src/ff.o
114-
$(CC) $(TARGET_CFLAGS) -c $(IDF_MODIFIED_DIR)/fatfs/src/vfs_fat.c -o $(IDF_MODIFIED_DIR)/fatfs/src/vfs_fat.o
115-
$(CC) $(TARGET_CFLAGS) -c $(IDF_MODIFIED_DIR)/freertos/include/freertos/semphr.c -o $(IDF_MODIFIED_DIR)/freertos/include/freertos/semphr.o
116-
$(CC) $(TARGET_CFLAGS) -c $(IDF_MODIFIED_DIR)/newlib/include/sys/lock.c -o $(IDF_MODIFIED_DIR)/newlib/include/sys/lock.o
117-
$(CC) $(TARGET_CFLAGS) -c $(IDF_MODIFIED_DIR)/newlib/include/sys/idf_reent.c -o $(IDF_MODIFIED_DIR)/newlib/include/sys/idf_reent.o
118-
$(CC) $(TARGET_CFLAGS) -c $(IDF_MODIFIED_DIR)/newlib/include/sys/errno.c -o $(IDF_MODIFIED_DIR)/newlib/include/sys/errno.o
119-
$(CC) $(TARGET_CFLAGS) -c $(IDF_MODIFIED_DIR)/spi_flash/partition.c -o $(IDF_MODIFIED_DIR)/spi_flash/partition.o
120-
$(CC) $(TARGET_CFLAGS) -c $(IDF_MODIFIED_DIR)/vfs/vfs.c -o $(IDF_MODIFIED_DIR)/vfs/vfs.o
121-
$(CXX) $(TARGET_CXXFLAGS) -c $(IDF_MODIFIED_DIR)/wear_levelling/wear_levelling.cpp -o $(IDF_MODIFIED_DIR)/wear_levelling/wear_levelling.o
122-
$(CC) $(TARGET_CFLAGS) -c $(IDF_ORIG_DIR)/fatfs/src/diskio.c -o $(IDF_ORIG_DIR)/fatfs/src/diskio.o
123-
$(CC) $(TARGET_CFLAGS) -c $(IDF_ORIG_DIR)/fatfs/src/diskio_spiflash.c -o $(IDF_ORIG_DIR)/fatfs/src/diskio_spiflash.o
124-
$(CC) $(TARGET_CFLAGS) -c $(IDF_ORIG_DIR)/fatfs/src/option/syscall.c -o $(IDF_ORIG_DIR)/fatfs/src/option/syscall.o
125-
$(CXX) $(TARGET_CXXFLAGS) -c $(IDF_ORIG_DIR)/wear_levelling/crc32.cpp -o $(IDF_ORIG_DIR)/wear_levelling/crc32.o
126-
$(CXX) $(TARGET_CXXFLAGS) -c $(IDF_ORIG_DIR)/wear_levelling/WL_Flash.cpp -o $(IDF_ORIG_DIR)/wear_levelling/WL_Flash.o
127-
$(CXX) $(TARGET_CXXFLAGS) -c $(IDF_ORIG_DIR)/wear_levelling/WL_Ext_Perf.cpp -o $(IDF_ORIG_DIR)/wear_levelling/WL_Ext_Perf.o
128-
$(CXX) $(TARGET_CXXFLAGS) -c $(IDF_ORIG_DIR)/wear_levelling/WL_Ext_Safe.cpp -o $(IDF_ORIG_DIR)/wear_levelling/WL_Ext_Safe.o
92+
$(CXX) $(TARGET_CXXFLAGS) -c main.cpp -o $(BUILD)/main.o
93+
$(CC) $(TARGET_CFLAGS) -c $(IDF_DIR)/errno.c -o $(BUILD)/$(IDF_DIR)/errno.o
94+
$(CC) $(TARGET_CFLAGS) -c $(IDF_DIR)/idf_reent.c -o $(BUILD)/$(IDF_DIR)/idf_reent.o
95+
$(CC) $(TARGET_CFLAGS) -c $(IDF_DIR)/lock.c -o $(BUILD)/$(IDF_DIR)/lock.o
96+
$(CC) $(TARGET_CFLAGS) -c $(IDF_DIR)/freertos/semphr.c -o $(BUILD)/$(IDF_DIR)/freertos/semphr.o
97+
$(CC) $(TARGET_CFLAGS) -c $(FILESYSTEM_DIR)/fatfs/ccsbcs.c -o $(BUILD)/$(FILESYSTEM_DIR)/fatfs/ccsbcs.o
98+
$(CC) $(TARGET_CFLAGS) -c $(FILESYSTEM_DIR)/fatfs/esp_vfs_fat.c -o $(BUILD)/$(FILESYSTEM_DIR)/fatfs/esp_vfs_fat.o
99+
$(CC) $(TARGET_CFLAGS) -c $(FILESYSTEM_DIR)/fatfs/ff.c -o $(BUILD)/$(FILESYSTEM_DIR)/fatfs/ff.o
100+
$(CC) $(TARGET_CFLAGS) -c $(FILESYSTEM_DIR)/fatfs/syscall.c -o $(BUILD)/$(FILESYSTEM_DIR)/fatfs/syscall.o
101+
$(CXX) $(TARGET_CXXFLAGS) -c $(FILESYSTEM_DIR)/diskio/diskio_RAM.cpp -o $(BUILD)/$(FILESYSTEM_DIR)/diskio/diskio_RAM.o
102+
$(CC) $(TARGET_CFLAGS) -c $(FILESYSTEM_DIR)/diskio/diskio.c -o $(BUILD)/$(FILESYSTEM_DIR)/diskio/diskio.o
103+
$(CXX) $(TARGET_CXXFLAGS) -c $(FILESYSTEM_DIR)/diskio/FatPartition.cpp -o $(BUILD)/$(FILESYSTEM_DIR)/diskio/FatPartition.o
104+
$(CC) $(TARGET_CFLAGS) -c $(FILESYSTEM_DIR)/vfs/user_vfs.c -o $(BUILD)/$(FILESYSTEM_DIR)/vfs/user_vfs.o
105+
$(CC) $(TARGET_CFLAGS) -c $(FILESYSTEM_DIR)/vfs/vfs.c -o $(BUILD)/$(FILESYSTEM_DIR)/vfs/vfs.o
129106
$(CXX) $(TARGET_CFLAGS) -o $(TARGET) $(OBJ) $(TARGET_LDFLAGS)
130-
131-
132107

133108
clean:
134109
@rm -f *.o
135-
@rm -f fatfs/*.o
136-
@rm -f $(IDF_MODIFIED_DIR)/fatfs/src/*.o
137-
@rm -f $(IDF_MODIFIED_DIR)/freertos/include/freertos/*.o
138-
@rm -f $(IDF_MODIFIED_DIR)/newlib/include/sys/*.o
139-
@rm -f $(IDF_MODIFIED_DIR)/spi_flash/*.o
140-
@rm -f $(IDF_MODIFIED_DIR)/vfs/*.o
141-
@rm -f $(IDF_MODIFIED_DIR)/wear_levelling/*.o
142-
@rm -f $(IDF_ORIG_DIR)/fatfs/src/*.o
143-
@rm -f $(IDF_ORIG_DIR)/fatfs/src/option/*.o
144-
@rm -f $(IDF_ORIG_DIR)/wear_levelling/*.o
110+
@rm -f $(BUILD)/$(IDF_DIR)/*.o
111+
@rm -f $(BUILD)/$(IDF_DIR)/frertos/*.o
112+
@rm -f $(I$(BUILD)/$(FILESYSTEM_DIR)/fatfs/*.o
113+
@rm -f $(BUILD)/$(FILESYSTEM_DIR)/diskio/*.o
114+
@rm -f $(BUILD)/$(FILESYSTEM_DIR)/vfs/*.o
145115
@rm -f $(TARGET)
File renamed without changes.

idf/modified/newlib/include/sys/errno.h renamed to esp_idf/errno.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern "C" {
88
#endif
99
#define _SYS_ERRNO_H_
1010

11-
#include <sys/idf_reent.h> //MVA was <sys/reent.h>
11+
#include "idf_reent.h" //MVA was <sys/reent.h>
1212

1313
//MVA VVV
1414
/*
File renamed without changes.
File renamed without changes.

idf/orig/spi_flash/include/esp_partition.h renamed to esp_idf/esp_partition.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <stdbool.h>
2020
#include <stddef.h>
2121
#include "esp_err.h"
22-
#include "esp_spi_flash.h"
22+
// #include "esp_spi_flash.h"
2323

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

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

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

149149
/**
150150
* @brief Move partition iterator to the next partition found
@@ -155,15 +155,15 @@ const esp_partition_t* esp_partition_get(esp_partition_iterator_t iterator);
155155
*
156156
* @return NULL if no partition was found, valid esp_partition_iterator_t otherwise.
157157
*/
158-
esp_partition_iterator_t esp_partition_next(esp_partition_iterator_t iterator);
158+
// esp_partition_iterator_t esp_partition_next(esp_partition_iterator_t iterator);
159159

160160
/**
161161
* @brief Release partition iterator
162162
*
163163
* @param iterator Iterator obtained using esp_partition_find. Must be non-NULL.
164164
*
165165
*/
166-
void esp_partition_iterator_release(esp_partition_iterator_t iterator);
166+
// void esp_partition_iterator_release(esp_partition_iterator_t iterator);
167167

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

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

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

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

260260
/**
261261
* @brief Configure MMU to map partition into data memory
@@ -282,9 +282,9 @@ esp_err_t esp_partition_erase_range(const esp_partition_t* partition,
282282
*
283283
* @return ESP_OK, if successful
284284
*/
285-
esp_err_t esp_partition_mmap(const esp_partition_t* partition, uint32_t offset, uint32_t size,
286-
spi_flash_mmap_memory_t memory,
287-
const void** out_ptr, spi_flash_mmap_handle_t* out_handle);
285+
// esp_err_t esp_partition_mmap(const esp_partition_t* partition, uint32_t offset, uint32_t size,
286+
// spi_flash_mmap_memory_t memory,
287+
// const void** out_ptr, spi_flash_mmap_handle_t* out_handle);
288288

289289

290290
#ifdef __cplusplus
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

fatfs/crc.cpp

Lines changed: 0 additions & 63 deletions
This file was deleted.

fatfs/FatPartition.cpp renamed to filesystem/diskio/FatPartition.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
#include <cstring> // memset/memcpy
1515
#include "esp_log.h"
1616
#include "FatPartition.h"
17+
#include "sdkconfig.h"
18+
19+
#define SPI_FLASH_SEC_SIZE CONFIG_RAM_SECTOR_SIZE
1720

1821
static const char *TAG = "FatPartition";
1922

File renamed without changes.
File renamed without changes.

idf/orig/fatfs/src/diskio.h renamed to filesystem/diskio/diskio.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ extern "C" {
1010
#endif
1111

1212
#include "integer.h"
13-
#include "sdmmc_cmd.h"
14-
#include "driver/sdmmc_host.h"
13+
#include "esp_err.h"
14+
// #include "sdmmc_cmd.h"
15+
// #include "driver/sdmmc_host.h"
1516

1617
/* Status of Disk Functions */
1718
typedef BYTE DSTATUS;
@@ -77,7 +78,7 @@ void ff_diskio_register(BYTE pdrv, const ff_diskio_impl_t* discio_impl);
7778
* @param pdrv drive number
7879
* @param card pointer to sdmmc_card_t structure describing a card; card should be initialized before calling f_mount.
7980
*/
80-
void ff_diskio_register_sdmmc(BYTE pdrv, sdmmc_card_t* card);
81+
// void ff_diskio_register_sdmmc(BYTE pdrv, sdmmc_card_t* card);
8182

8283
/**
8384
* Get next available drive number

0 commit comments

Comments
 (0)