What changed, and why it matters
This commit is a cleanup and hardening pass on how the Keystone 3 hardware wallet handles camera images, SD card files, and debug/test code. The most user-relevant change is that file-reading functions now refuse to load very large files from the SD card, which closes a path where an oversized file could exhaust device memory. Several debug helpers that could print sensitive file contents or cryptographic hashes over the serial port, plus a leftover firmware-copy routine, are removed. A camera preview buffer is also made safer by freeing it on re-init instead of leaking memory. The commit message is vague ('review data flow') and does not call this a security fix, so the security relevance is inferred from the code changes rather than stated by the vendor.
Treat this as a defensive hardening commit rather than an active vulnerability fix. Review whether MAX_FILE_CONTENT_LEN (1 MB) is appropriate for all legitimate use cases, ensure callers free the buffers returned by FatfsFileRead() and FatfsFileReadBytes(), and confirm that removal of the debug/test commands does not break required manufacturing or support workflows. Consider whether the removed functions existed in released firmware and whether any advisory is warranted for users on older builds.
Security signals we found
Removal of debug functions that printed full file contents or MD5/SHA256 over serial (information disclosure reduction)
Addition of MAX_FILE_CONTENT_LEN size check before reading SD card files (DoS / memory-exhaustion mitigation)
Removal of global g_fileContent buffer in favor of locally allocated, bounded buffers (use-after-free / memory hygiene improvement)
QR preview image buffer now freed on re-initialization (memory leak fix)
Removal of CopyToFlash() and related UART command (firmware-update attack surface reduction)
Removal of unused FileExists() and conversion of FileWrite() to stack buffer (minor cleanup)
Removal of PSBT hex debug print from multisig SD-card flow (sensitive data no longer logged)
Evidence from the diff
The patch reduces attack surface in the QR/camera and FATfs/SD-card subsystems. Key changes: (1) drv_qrdecode.c moves the QR preview LCD buffer from a local static pointer to a module-level static pointer and frees it in QrDecodeInit(), preventing a repeated init leak. (2) sdcard_manager.c removes the unused FileExists() and converts FileWrite() to use a stack buffer, eliminating a small heap path. (3) user_fatfs.c removes dead/debug code: FatfsCatFile, FatfsFileMd5, FatfsFileSha256, CopyToFlash, FatfsMount, and serial listing helpers. It also removes the global g_fileContent buffer and adds a fileSize > MAX_FILE_CONTENT_LEN guard in FatfsFileRead() and FatfsFileReadBytes(), preventing allocation/reads of unbounded size from SD card. (4) gui_multisig_read_sdcard_widgets.c removes a debug hex-dump of PSBT data and frees walletConfig in one path. (5) test_cmd.c removes UART commands that exposed the removed FATfs debug functions. The changes are defensive and remove information-disclosure and DoS vectors, but the commit message does not frame them as a security patch.
Changed components
src/driver/drv_qrdecode.csrc/managers/sdcard_manager.csrc/managers/sdcard_manager.hsrc/tasks/qrdecode_task.csrc/ui/gui_components/gui_attention_hintbox.csrc/ui/gui_widgets/btc_only/multi_sig/gui_import_multisig_wallet_info_widgets.csrc/ui/gui_widgets/btc_only/multi_sig/gui_multisig_read_sdcard_widgets.csrc/user_fatfs.csrc/user_fatfs.htest/test_cmd.cInspect captured patch +39 / −331
diff --git a/src/driver/drv_qrdecode.c b/src/driver/drv_qrdecode.c
index fb0eb59..0f642e7 100644
--- a/src/driver/drv_qrdecode.c
+++ b/src/driver/drv_qrdecode.c
@@ -45,6 +45,8 @@ DecodeConfigTypeDef g_decodeCfg = {0};
LV_FONT_DECLARE(openSans_20);
LV_FONT_DECLARE(openSans_24);
+static uint16_t *g_qrDecodeImageBuffer = NULL;
+
/**
* @brief QR decode init, malloc QRDECODE_BUFF_SIZE byte mem.
* @retval none.
@@ -74,6 +76,11 @@ int32_t QrDecodeInit(uint8_t *pool)
DecodeConfigInit(&g_decodeCfg);
DCMI_NVICConfig();
+ if (g_qrDecodeImageBuffer != NULL) {
+ SRAM_FREE(g_qrDecodeImageBuffer);
+ g_qrDecodeImageBuffer = NULL;
+ }
+
return ret;
}
@@ -155,13 +162,11 @@ int32_t QrDecodeProcess(char *result, uint32_t maxLen, uint8_t progress)
tick = osKernelGetTickCount();
resnum = DecodeStart(&g_decodeCfg, &res);
if (resnum > 0) {
- // printf("ID:%d\tAIMID:%s\n", res.id, res.AIM);
CleanDecodeBuffFlag();
}
g_decodeTick += osKernelGetTickCount() - tick;
return resnum;
- //return 0;
}
#ifdef VIEW_IMAGE_ENABLE
@@ -179,12 +184,11 @@ static void ViewImageOnLcd(void)
{
uint8_t *imgAddr;
- static uint16_t *buffer1 = NULL;
uint8_t *u8Addr;
uint16_t R, G, B;
- if (buffer1 == NULL) {
- buffer1 = SRAM_MALLOC(320 * VIEW_IMAGE_LINE * 2);
+ if (g_qrDecodeImageBuffer == NULL) {
+ g_qrDecodeImageBuffer = SRAM_MALLOC(320 * VIEW_IMAGE_LINE * 2);
}
imgAddr = (uint8_t *)GetImageBuffAddr();
@@ -207,9 +211,7 @@ static void ViewImageOnLcd(void)
}
for (i = 0; i < 320 * VIEW_IMAGE_LINE; i++) {
camPixelIndex = ((320 - y) * 3 / 2 + 80) + (x * 3 / 2) * 640;
- u8Addr = (uint8_t *)&buffer1[i];
- // *u8Addr = (imgAddr[camPixelIndex] & 0xF1) | (imgAddr[camPixelIndex] >> 5);
- // *(u8Addr + 1) = ((imgAddr[camPixelIndex] << 3) & 0xE0) | (imgAddr[camPixelIndex] >> 3);
+ u8Addr = (uint8_t *)&g_qrDecodeImageBuffer[i];
G = imgAddr[camPixelIndex] >> 2;
R = G >> 1;
B = R;
@@ -220,7 +222,7 @@ static void ViewImageOnLcd(void)
y++;
}
}
- LcdDraw(START_SCAN_COL, line, START_SCAN_COL + 320 - 1, line + VIEW_IMAGE_LINE - 1, (uint16_t *)buffer1);
+ LcdDraw(START_SCAN_COL, line, START_SCAN_COL + 320 - 1, line + VIEW_IMAGE_LINE - 1, (uint16_t *)g_qrDecodeImageBuffer);
}
}
diff --git a/src/managers/sdcard_manager.c b/src/managers/sdcard_manager.c
index b3b3d64..1678481 100644
--- a/src/managers/sdcard_manager.c
+++ b/src/managers/sdcard_manager.c
@@ -11,18 +11,9 @@
#define MAX_FILENAME_LEN 128
-bool FileExists(char *filename)
-{
- char *target = SRAM_MALLOC(MAX_FILENAME_LEN);
- snprintf_s(target, MAX_FILENAME_LEN, "%s%s", SD_ROOT, filename);
- return FatfsFileExist(target);
-}
-
int FileWrite(const char *filename, const uint8_t *content, uint32_t len)
{
- char *path = SRAM_MALLOC(MAX_FILENAME_LEN);
+ char path[MAX_FILENAME_LEN] = {0};
snprintf_s(path, MAX_FILENAME_LEN, "%s%s", SD_ROOT, filename);
- int ret = FatfsFileWrite(path, content, len);
- SRAM_FREE(path);
- return ret;
+ return FatfsFileWrite((const char*)path, content, len);
}
diff --git a/src/managers/sdcard_manager.h b/src/managers/sdcard_manager.h
index 9937fe3..ef67ff6 100644
--- a/src/managers/sdcard_manager.h
+++ b/src/managers/sdcard_manager.h
@@ -4,7 +4,6 @@
#include "stdbool.h"
#include "stdint.h"
-bool FileExists(char* filename);
int FileWrite(const char *filename, const uint8_t *content, uint32_t len);
#endif
\ No newline at end of file
diff --git a/src/tasks/qrdecode_task.c b/src/tasks/qrdecode_task.c
index f5de615..ca77a3a 100644
--- a/src/tasks/qrdecode_task.c
+++ b/src/tasks/qrdecode_task.c
@@ -127,7 +127,7 @@ void ProcessQr(uint32_t count)
static bool firstQrFlag = true;
static PtrDecoder decoder = NULL;
static UrViewType_t urViewType = {0, 0};
- static struct URParseResult *urResult;
+ static struct URParseResult *urResult = NULL;
uint32_t retFromRust = 0;
int32_t ret = QrDecodeProcess(qrString, QR_DECODE_STRING_LEN, testProgress);
diff --git a/src/ui/gui_components/gui_attention_hintbox.c b/src/ui/gui_components/gui_attention_hintbox.c
index ec35d07..46c8d41 100644
--- a/src/ui/gui_components/gui_attention_hintbox.c
+++ b/src/ui/gui_components/gui_attention_hintbox.c
@@ -13,8 +13,6 @@ typedef struct {
uint16_t hintboxHeight;
} AttentionHintboxContext;
-
-
typedef struct {
char *title;
char *context;
@@ -24,15 +22,11 @@ typedef struct {
uint16_t hintboxHeight;
} EnableBlindSigningHintboxContext;
-
-
-
static uint16_t g_confirmSign = SIG_SETUP_RSA_PRIVATE_KEY_RECEIVE_CONFIRM;
static AttentionHintboxContext *BuildConfirmationHintboxContext();
static EnableBlindSigningHintboxContext *BuildEnableBlindSigningHintboxContext();
static AttentionHintboxContext *BuildLowPowerHintboxContext();
-static AttentionHintboxContext *HardWareCallInvaildPathHintboxContext();
static void CloseAttentionHandler(lv_event_t *e);
static void ConfirmAttentionHandler(lv_event_t *e);
static void EnableBlindSigningHandler(lv_event_t *e);
diff --git a/src/ui/gui_widgets/btc_only/multi_sig/gui_import_multisig_wallet_info_widgets.c b/src/ui/gui_widgets/btc_only/multi_sig/gui_import_multisig_wallet_info_widgets.c
index ce7d49e..c4188a2 100644
--- a/src/ui/gui_widgets/btc_only/multi_sig/gui_import_multisig_wallet_info_widgets.c
+++ b/src/ui/gui_widgets/btc_only/multi_sig/gui_import_multisig_wallet_info_widgets.c
@@ -202,7 +202,6 @@ static uint32_t prepareWalletBySDCard(char *walletConfig)
static uint32_t processResult(Ptr_Response_MultiSigWallet result)
{
if (result->error_code != 0) {
- printf("%s\r\n", result->error_message);
return result->error_code;
}
g_wallet = result->data;
diff --git a/src/ui/gui_widgets/btc_only/multi_sig/gui_multisig_read_sdcard_widgets.c b/src/ui/gui_widgets/btc_only/multi_sig/gui_multisig_read_sdcard_widgets.c
index 1e3e22b..3996b3e 100644
--- a/src/ui/gui_widgets/btc_only/multi_sig/gui_multisig_read_sdcard_widgets.c
+++ b/src/ui/gui_widgets/btc_only/multi_sig/gui_multisig_read_sdcard_widgets.c
@@ -79,19 +79,12 @@ static void GuiSelectFileHandler(lv_event_t *e)
g_noticeWindow = GuiCreateErrorCodeWindow(ERR_INVALID_FILE, &g_noticeWindow, NULL);
break;
}
+ EXT_FREE(walletConfig);
}
break;
case ONLY_PSBT: {
uint32_t readBytes = 0;
uint8_t *psbtBytes = FatfsFileReadBytes(path, &readBytes);
-
- // for debug
- char *psbtStr = EXT_MALLOC(readBytes * 2 + 1);
- psbtStr[readBytes * 2] = 0;
- ByteArrayToHexStr(psbtBytes, readBytes, psbtStr);
- printf("psbt is %s\n", psbtStr);
- EXT_FREE(psbtStr);
-
GuiSetPsbtStrData(psbtBytes, readBytes);
g_viewType = BtcTx;
GuiModelCheckTransaction(g_viewType);
diff --git a/src/user_fatfs.c b/src/user_fatfs.c
index 197143b..fb041f3 100644
--- a/src/user_fatfs.c
+++ b/src/user_fatfs.c
@@ -15,8 +15,6 @@
#define MAX_FILE_CONTENT_LEN 1000000
#define MAX_FILE_SIZE_LIST (1024 * 256)
-char* g_fileContent = NULL;
-
void FatfsError(FRESULT errNum);
typedef struct FatfsMountParam {
@@ -46,133 +44,6 @@ int FatfsTouchFile(const TCHAR* path)
return RES_OK;
}
-int FatfsCatFile(const TCHAR* path)
-{
- FIL fp;
- uint8_t *fileBuf;
- uint16_t fileSize = 0;
- uint32_t readBytes = 0;
- FRESULT res = f_open(&fp, path, FA_OPEN_EXISTING | FA_READ);
- if (res) {
- FatfsError(res);
- return RES_ERROR;
- }
- fileSize = f_size(&fp);
- fileBuf = EXT_MALLOC(fileSize);
- printf("%s size = %d\n", path, fileSize);
- res = f_read(&fp, (void*)fileBuf, fileSize, &readBytes);
- if (res) {
- FatfsError(res);
- f_close(&fp);
- EXT_FREE(fileBuf);
- return RES_ERROR;
- }
- EXT_FREE(fileBuf);
- for (int i = 0; i < fileSize; i++) {
- printf("%c", fileBuf[i]);
- }
- printf("\n");
- f_close(&fp);
- return RES_OK;
-}
-
-int FatfsFileMd5(const TCHAR* path)
-{
- FIL fp;
- MD5_CTX ctx;
- uint8_t *fileBuf;
- uint32_t fileSize = 0;
- uint32_t readBytes = 0;
- int len, changePercent = 0, percent;
- unsigned char md5[16];
- FRESULT res = f_open(&fp, path, FA_OPEN_EXISTING | FA_READ);
- if (res) {
- FatfsError(res);
- return RES_ERROR;
- }
- fileSize = f_size(&fp);
- int lastLen = fileSize;
- len = lastLen > 1024 ? 1024 : lastLen;
- fileBuf = SRAM_MALLOC(len);
- printf("reading, please wait.\n");
- MD5_Init(&ctx);
- while (lastLen) {
- len = lastLen > 1024 ? 1024 : lastLen;
- res = f_read(&fp, (void*)fileBuf, len, &readBytes);
- if (res) {
- FatfsError(res);
- f_close(&fp);
- SRAM_FREE(fileBuf);
- return RES_ERROR;
- }
- lastLen -= len;
- MD5_Update(&ctx, fileBuf, len);
- percent = (fileSize - lastLen) * 100 / fileSize;
- if (percent != changePercent) {
- changePercent = percent;
- printf("md5 update percent = %d\n", (fileSize - lastLen) * 100 / fileSize);
- }
- }
- MD5_Final(md5, &ctx);
- SRAM_FREE(fileBuf);
- printf("%s md5: ", path);
- for (int i = 0; i < sizeof(md5); i++) {
- printf("%02x", md5[i]);
- }
- printf("\r\n");
-
- return RES_OK;
-}
-
-int FatfsFileSha256(const TCHAR* path, uint8_t *sha256)
-{
- FIL fp;
- struct sha256_ctx ctx;
- sha256_init(&ctx);
- uint8_t *fileBuf;
- uint32_t fileSize = 0;
- uint32_t readBytes = 0;
- int len, changePercent = 0, percent;
- unsigned char hash[32];
- FRESULT res = f_open(&fp, path, FA_OPEN_EXISTING | FA_READ);
- if (res) {
- FatfsError(res);
- return RES_ERROR;
- }
- fileSize = f_size(&fp);
- int lastLen = fileSize;
- len = lastLen > 1024 ? 1024 : lastLen;
- fileBuf = SRAM_MALLOC(len);
- printf("reading, please wait.\n");
- while (lastLen) {
- len = lastLen > 1024 ? 1024 : lastLen;
- res = f_read(&fp, (void*)fileBuf, len, &readBytes);
- if (res) {
- FatfsError(res);
- f_close(&fp);
- SRAM_FREE(fileBuf);
- return RES_ERROR;
- }
- lastLen -= len;
- sha256_update(&ctx, fileBuf, len);
- percent = (fileSize - lastLen) * 100 / fileSize;
- if (percent != changePercent) {
- changePercent = percent;
- printf("sha256 update percent = %d\n", (fileSize - lastLen) * 100 / fileSize);
- }
- }
- sha256_done(&ctx, (struct sha256 *)hash);
- SRAM_FREE(fileBuf);
- printf("%s hash: ", path);
- memcpy(sha256, hash, sizeof(hash));
- for (int i = 0; i < sizeof(hash); i++) {
- printf("%02x", hash[i]);
- }
- printf("\r\n");
-
- return RES_OK;
-}
-
uint32_t FatfsFileGetSize(const TCHAR *path)
{
FRESULT res;
@@ -325,6 +196,7 @@ int FatfsFileCopy(const TCHAR* source, const TCHAR* dest)
return res;
}
+#if 0
void FatfsShowVolumeStatus(char *ptr)
{
FRESULT res;
@@ -404,6 +276,7 @@ void FatfsDirectoryListing(char *ptr)
#endif
f_closedir(&Dir);
}
+#endif
void FatfsGetFileName(const char *path, char *fileName[], uint32_t maxLen, uint32_t *number, const char *contain)
{
@@ -443,43 +316,56 @@ void FatfsGetFileName(const char *path, char *fileName[], uint32_t maxLen, uint3
char *FatfsFileRead(const TCHAR* path)
{
FIL fp;
- uint16_t fileSize = 0;
+ uint32_t fileSize = 0;
uint32_t readBytes = 0;
FRESULT res = f_open(&fp, path, FA_OPEN_EXISTING | FA_READ);
if (res) {
FatfsError(res);
return NULL;
}
- if (g_fileContent) EXT_FREE(g_fileContent);
fileSize = f_size(&fp);
- g_fileContent = EXT_MALLOC(MAX_FILE_CONTENT_LEN);
- memset_s(g_fileContent, MAX_FILE_CONTENT_LEN, 0, MAX_FILE_CONTENT_LEN);
+
+ // Check file size limit
+ if (fileSize > MAX_FILE_CONTENT_LEN) {
+ printf("File too large: %u > %u\n", fileSize, MAX_FILE_CONTENT_LEN);
+ f_close(&fp);
+ return NULL;
+ }
+
+ char *fileContent = EXT_MALLOC(MAX_FILE_CONTENT_LEN);
+ memset_s(fileContent, MAX_FILE_CONTENT_LEN, 0, MAX_FILE_CONTENT_LEN);
printf("%s size = %d\n", path, fileSize);
- res = f_read(&fp, (void*)g_fileContent, fileSize, &readBytes);
+ res = f_read(&fp, (void*)fileContent, fileSize, &readBytes);
if (res) {
FatfsError(res);
f_close(&fp);
- EXT_FREE(g_fileContent);
+ EXT_FREE(fileContent);
return NULL;
}
printf("\n");
f_close(&fp);
- return g_fileContent;
+ return fileContent;
}
uint8_t *FatfsFileReadBytes(const TCHAR* path, uint32_t* readBytes)
{
FIL fp;
uint8_t *fileBuf;
- uint16_t fileSize = 0;
- // uint32_t readBytes = 0;
+ uint32_t fileSize = 0;
FRESULT res = f_open(&fp, path, FA_OPEN_EXISTING | FA_READ);
if (res) {
FatfsError(res);
return NULL;
}
fileSize = f_size(&fp);
+
+ if (fileSize > MAX_FILE_CONTENT_LEN) {
+ printf("File too large: %u > %u\n", fileSize, MAX_FILE_CONTENT_LEN);
+ f_close(&fp);
+ return NULL;
+ }
+
fileBuf = EXT_MALLOC(fileSize);
res = f_read(&fp, (void*)fileBuf, fileSize, readBytes);
printf("%s filesize = %u readSize = %u\n", path, fileSize, *readBytes);
@@ -582,7 +468,6 @@ int MMC_disk_read(
}
}
- // printf("disk readblock state %d\r\n", SD_state);
return status;
}
@@ -669,41 +554,11 @@ int USB_disk_write(
return RES_OK;
}
-int FatfsMount(void)
-{
- FRESULT res;
- FatfsMountParam_t *fs;
- for (uint8_t i = 0; i < NUMBER_OF_ARRAYS(g_fsMountParamArray); i++) {
- fs = &g_fsMountParamArray[i];
- res = f_mount(fs->fs, fs->volume, fs->opt);
- // if (res == FR_NO_FILESYSTEM) {
- // BYTE work[FF_MAX_SS];
- // f_mkfs(fs->volume, 0, work, sizeof work);
- // f_mount(NULL, fs->volume, fs->opt);
- // res = f_mount(fs->fs, fs->volume, fs->opt);
- // printf("%s:", fs->name);
- // FatfsError(res);
- // }
- printf("%s:", fs->name);
- FatfsError(res);
- }
- return res;
-}
-
int MountUsbFatfs(void)
{
FRESULT res;
FatfsMountParam_t *fs = &g_fsMountParamArray[DEV_USB];
res = f_mount(fs->fs, fs->volume, fs->opt);
- // if (res == FR_NO_FILESYSTEM) {
- // BYTE work[FF_MAX_SS];
- // f_mkfs(fs->volume, 0, work, sizeof work);
- // f_mount(NULL, fs->volume, fs->opt);
- // res = f_mount(fs->fs, fs->volume, fs->opt);
- // printf("%s:", fs->name);
- // FatfsError(res);
- // }
- printf("%s:", fs->name);
FatfsError(res);
return res;
}
@@ -716,15 +571,6 @@ int MountSdFatfs(void)
if (res != FR_OK) {
res = f_mount(fs->fs, fs->volume, fs->opt);
}
- // if (res == FR_NO_FILESYSTEM) {
- // BYTE work[FF_MAX_SS];
- // f_mkfs(fs->volume, 0, work, sizeof work);
- // f_mount(NULL, fs->volume, fs->opt);
- // res = f_mount(fs->fs, fs->volume, fs->opt);
- // printf("%s:", fs->name);
- // FatfsError(res);
- // }
- printf("%s:", fs->name);
FatfsError(res);
return res;
}
@@ -743,53 +589,6 @@ int UnMountSdFatfs(void)
return res;
}
-void CopyToFlash(void)
-{
-#define COPY_TO_FLASH_PAGE_SIZE (1024)
- const char *srcPath = "0:/pillar.bin";
- const char *destPath = "1:/pillar.bin";
- FIL srcFp, destFp;
- uint8_t *fileBuf = SRAM_MALLOC(COPY_TO_FLASH_PAGE_SIZE);
- uint32_t fileSize = 0;
- uint32_t readBytes = 0, writeBytes = 0;
- FRESULT res = f_open(&srcFp, srcPath, FA_OPEN_EXISTING | FA_READ);
- if (res) {
- FatfsError(res);
- return;
- }
- fileSize = f_size(&srcFp);
- printf("%s size = %d\n", srcPath, fileSize);
- res = f_open(&destFp, destPath, FA_CREATE_ALWAYS | FA_WRITE);
- if (res) {
- FatfsError(res);
- return;
- }
- while (1) {
- uint32_t len = fileSize > COPY_TO_FLASH_PAGE_SIZE ? COPY_TO_FLASH_PAGE_SIZE : fileSize;
- fileSize -= len;
- printf("fileSize = %d\n", fileSize);
- res = f_read(&srcFp, (void*)fileBuf, len, &readBytes);
- if (res) {
- FatfsError(res);
- f_close(&srcFp);
- EXT_FREE(fileBuf);
- return;
- }
- res = f_write(&destFp, (void*)fileBuf, readBytes, &writeBytes);
- if (res) {
- FatfsError(res);
- return;
- }
- memset_s(fileBuf, COPY_TO_FLASH_PAGE_SIZE, 0, COPY_TO_FLASH_PAGE_SIZE);
- if (fileSize == 0) {
- break;
- }
- }
- f_close(&srcFp);
- f_close(&destFp);
- SRAM_FREE(fileBuf);
-}
-
int FormatSdFatfs(void)
{
FRESULT res;
diff --git a/src/user_fatfs.h b/src/user_fatfs.h
index b17ae8d..a52e4d8 100644
--- a/src/user_fatfs.h
+++ b/src/user_fatfs.h
@@ -29,15 +29,11 @@ int USB_disk_write(
UINT count /* Number of sectors to write */
);
-int FatfsMount(void);
int MountUsbFatfs(void);
int MountSdFatfs(void);
int UnMountSdFatfs(void);
void FatfsShowVolumeStatus(char *ptr);
void FatfsDirectoryListing(char *ptr);
-void CopyToFlash(void);
-int FatfsCatFile(const TCHAR* path);
-int FatfsFileMd5(const TCHAR* path);
int FatfsFileWrite(const TCHAR* path, const uint8_t *data, uint32_t len);
int FatfsFileCreate(const TCHAR* path);
int FatfsFileAppend(const TCHAR* path, const uint8_t *data, uint32_t len);
@@ -47,7 +43,6 @@ uint32_t FatfsFileGetSize(const TCHAR *path);
int FormatSdFatfs(void);
void FatfsError(FRESULT errNum);
uint32_t FatfsGetSize(const char *path);
-int FatfsFileSha256(const TCHAR* path, uint8_t *sha256);
bool FatfsFileExist(const char *path);
char *FatfsFileRead(const TCHAR* path);
void FatfsGetFileName(const char *path, char *fileName[], uint32_t maxLen, uint32_t *number, const char *contain);
diff --git a/test/test_cmd.c b/test/test_cmd.c
index 230132e..be37c29 100644
--- a/test/test_cmd.c
+++ b/test/test_cmd.c
@@ -83,14 +83,6 @@ static void Gd25FlashOperateFunc(int argc, char *argv[]);
static void Sha256TestFunc(int argc, char *argv[]);
static void Sha256HmacFunc(int argc, char *argv[]);
static void Ds28s60TestFunc(int argc, char *argv[]);
-static void FatfsLsFunc(int argc, char *argv[]);
-static void FatfsCatFunc(int argc, char *argv[]);
-static void FatfsFileWriteFunc(int argc, char *argv[]);
-static void FatfsFileDeleteFunc(int argc, char *argv[]);
-static void FatfsFileMd5Func(int argc, char *argv[]);
-static void FatfsFileSha256Func(int argc, char *argv[]);
-static void FatfsFileCopyFunc(int argc, char *argv[]);
-static void FatfsCopyFunc(int argc, char *argv[]);
static void ReadAddrFunc(int argc, char *argv[]);
static void GetCurrentTimeFunc(int argc, char *argv[]);
static void SetCurrentTimeFunc(int argc, char *argv[]);
@@ -231,14 +223,6 @@ const static UartTestCmdItem_t g_uartTestCmdTable[] = {
{"sha256 test", Sha256TestFunc},
{"sha256 hmac:", Sha256HmacFunc},
{"ds28s60 test:", Ds28s60TestFunc},
- {"ls:", FatfsLsFunc},
- {"cat:", FatfsCatFunc},
- {"write:", FatfsFileWriteFunc},
- {"rm:", FatfsFileDeleteFunc},
- {"md5:", FatfsFileMd5Func},
- {"sha256:", FatfsFileSha256Func},
- {"copy:", FatfsFileCopyFunc},
- {"copy ota", FatfsCopyFunc},
{"read addr:", ReadAddrFunc},
{"get time", GetCurrentTimeFunc},
{"set time:", SetCurrentTimeFunc},
@@ -722,54 +706,6 @@ static void Ds28s60TestFunc(int argc, char *argv[])
DS28S60_Test(argc, argv);
}
-static void FatfsLsFunc(int argc, char *argv[])
-{
- VALUE_CHECK(argc, 1);
- FatfsDirectoryListing(argv[0]);
-}
-
-static void FatfsCopyFunc(int argc, char *argv[])
-{
- CopyToFlash();
-}
-
-static void FatfsCatFunc(int argc, char *argv[])
-{
- VALUE_CHECK(argc, 1);
- FatfsCatFile(argv[0]);
-}
-
-static void FatfsFileMd5Func(int argc, char *argv[])
-{
- VALUE_CHECK(argc, 1);
- FatfsFileMd5(argv[0]);
-}
-
-static void FatfsFileSha256Func(int argc, char *argv[])
-{
- VALUE_CHECK(argc, 1);
- uint8_t sha256[32];
- FatfsFileSha256(argv[0], sha256);
-}
-
-static void FatfsFileWriteFunc(int argc, char *argv[])
-{
- VALUE_CHECK(argc, 2);
- FatfsFileWrite(argv[0], (const uint8_t *)argv[1], strnlen_s(argv[1], DEFAULT_TEST_BUFF_LEN));
-}
-
-static void FatfsFileDeleteFunc(int argc, char *argv[])
-{
- VALUE_CHECK(argc, 1);
- FatfsFileDelete(argv[0]);
-}
-
-static void FatfsFileCopyFunc(int argc, char *argv[])
-{
- VALUE_CHECK(argc, 2);
- FatfsFileCopy(argv[0], argv[1]);
-}
-
static void BpkPrintFunc(int argc, char *argv[])
{
VALUE_CHECK(argc, 1);
Why this scored 45/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.