当前位置:首页>Linux>嵌入式 Linux下SPI NAND Flash可靠读写策略与应用层设计

嵌入式 Linux下SPI NAND Flash可靠读写策略与应用层设计

  • 2026-04-19 07:21:43
嵌入式 Linux下SPI NAND Flash可靠读写策略与应用层设计
Hello,大家好,我是程序媛MM。

本文分析约1500字,这是芯片厂家提供的驱动接口结合项目上使用方法,整理出来的一篇可靠读写SPI NADN Flash的机制

关注公众号, 即可获得与Linux相关的电子书籍以及常用开发工具,文末有文档清单。


在嵌入式 Linux 产品中,配置参数、固件镜像、日志都需要掉电可靠存储。SPI NAND 因成本低、容量大成为首选,但它天生存在坏块、位翻转、只能按块擦除、只能 1→0 写入等物理限制。

一 NAND Flash 核心原理(决定读写策略的根因)


NAND 存储以 Block(块)为最小擦除单元,Page(页)为最小读写单元,SPI NAND 遵循同样规则:

擦除特性:必须先擦除再写入,擦除后全为 0xFF

写入限制:只能把 1 写成 0,不能直接改写

坏块不可避免:出厂坏块 + 磨损坏块,必须跳过

数据易出错:传输干扰、电荷泄漏会导致位翻转

Linux下访问方式:通过 /dev/mtdX 字符设备 + MTD ioctl 操作

代码基于 Linux MTD 子系统封装,是真实嵌入式部署场景的应用体现。

二 安全机制


可靠读写全套策略:

[1]. 坏块管理机制(最核心)

通过 MTD 标准 ioctl 完成坏块检测与标记,读写前先检测,遇到坏块自动跳过;写入校验失败则标记坏块并换块写入,完全遵循 Linux MTD 标准坏块表,不破坏分区。

[2]. 块擦除安全机制

擦除流程严格遵循:先判断是否坏块→再执行块擦除→擦除失败直接跳过该块,完全符合 NAND 擦不死、擦坏即弃原则。

[3]. 数据完整性:头部 + CRC32 双校验

定义块头结构,包含 CRC 校验值、有效魔数标识与保留字段。读取时先校验魔数防止块错位,再用 CRC32 校验数据完整性,自动丢弃无效块,保证数据不篡改、不损坏。

[4]. 写入后强制回读校验(关键可靠性保障)

写入完成后立即回读整块数据,与写入源数据对比。校验不一致则标记坏块并跳过,从根本上保证数据真正写入成功。

[5]. 内存缓冲与边界保护

按块大小动态申请读写缓冲,避免栈溢出;增加地址越界检查、写入长度检查,防止非法操作损坏 Flash。

三 完整读写流程


[1].写入流程:

>>打开 MTD 设备 /dev/mtdX

>>获取 NAND 信息(块大小、页大小、总容量)

>>初始化读写缓冲

>>逐块循环:检查地址越界→跳过坏块→擦除块→再次检查坏块→组包(头部魔数 + 数据 + CRC)→写入块→回读校验→校验失败标记坏块并跳过

>>fsync 刷盘→关闭设备

[2].读取流程:

>>打开 MTD 设备

>>获取 NAND 信息

>>初始化缓冲

>>逐块循环:越界检查→跳过坏块→读取整块→魔数 + CRC 双校验→有效则拷贝用户数据

>>关闭设备

代码片段:

typedef struct blockHeader{int crc;int headImage;char rsv[24];}blockHeader_T;static char* pWriteBlockBuf = NULL;static char* pReadBlockBuf = NULL;#define PRINT_DEBUG#ifdef PRINT_DEBUG#define  PRINT_LOG_DBG(format,arg...)			\	printf(format,## arg)#else#define  PRINT_LOG_DBG(format,arg...)#endif#define  PRINT_LOG_INFO(format,arg...)			\	printf(format,## arg)unsignedlongsimple_strtoul(constchar *cp, char **endp,unsigned int base){unsigned long result = 0;unsigned long value;if (*cp == '0') {		cp++;if ((*cp == 'x') && isxdigit(cp[1])) {			base = 16;			cp++;		}if (!base)			base = 8;	}if (!base)		base = 10;while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)	    ? toupper(*cp) : *cp)-'A'+10) < base) {		result = result*base + value;		cp++;	}if (endp)		*endp = (char *)cp;return result;}staticintcompare_buf(char *buf0, char *buf1, int len){int i;/* dump_buf(0,16,buf0); *//* dump_buf(0,16,buf1); */for(i = 0; i < len; i++)	{if(buf0[i] != buf1[i])return 1;	}return 0;}staticintnand_rwblockbuf_init(int block_size){if(pWriteBlockBuf == NULL)	{		pWriteBlockBuf = (char*)malloc(block_size);if(pWriteBlockBuf == NULL)		{printf("nand_rwbuf_init: malloc pWriteBlockBuf failed!\n");return -1;		}	}if(pReadBlockBuf == NULL)	{		pReadBlockBuf = (char*)malloc(block_size);if(pReadBlockBuf == NULL)		{printf("nand_rwbuf_init: malloc pReadBlockBuf failed!\n");return -1;		}	}return 0;}staticintnand_mark_badblock(int fd, loff_t offs){    int ret;	ret = ioctl(fd, MEMSETBADBLOCK, &offs);    if (ret < 0) {        PRINT_LOG_DBG("[%s][%d] Failed to set bad block\n",__func__, __LINE__);    }return ret;}staticintnand_is_badblock(int fd, loff_t offs){int ret;	ret = ioctl(fd, MEMGETBADBLOCK, &offs);    if (ret < 0) {        PRINT_LOG_DBG("[%s][%d] Failed get badblock\n",__func__, __LINE__);    }return ret;}staticintnand_erase_block(int fd, struct erase_info_user erase_info){int ret;	ret = ioctl(fd, MEMERASE, &erase_info);    if (ret < 0) {        PRINT_LOG_DBG("[%s][%d] Failed erase block\n",__func__, __LINE__);    }return ret;}staticintnand_is_invaliddata(char *data, int dataLen){//check nand every block data is validunsigned int pkg_crc_block = 0;int blockCrc = 0;int blockDataLen = 0;if(data == NULL || dataLen <= 0)	{return 1;	}if (*(uint32_t *)(data + CRC_LEN) != HEADIMAGE) {//PRINT_LOG_INFO("Invalid block header, %x %x error headLen:%d\n", *(uint32_t *)(data+CRC_LEN), HEADIMAGE, headLen);return 1;	}	blockCrc = *(unsigned int*)data;	blockDataLen = dataLen - CRC_LEN;crc_32_fun(data + CRC_LEN, blockDataLen, &pkg_crc_block);if(blockCrc != pkg_crc_block)	{PRINT_LOG_INFO("The block data is invalid, blockCrc:%x pkg_crc_block:%x blockDataLen:%d\n", blockCrc, pkg_crc_block, blockDataLen);return 1;	}PRINT_LOG_INFO("The block data is ok, blockCrc:%x pkg_crc_block:%x\n", blockCrc, pkg_crc_block);return 0;}intnand_read(char* nand_device, char *read_buffer, int read_size, int max_available_size, int offset){int fd = -1;int ret = -1;int len = 0;struct mtd_info_user mtd_info;loff_t offs = (loff_t)offset;int dataErr = -1;if(nand_device == NULL || read_buffer == NULL)	{        printf("inf_nand_read:nand_device or read_buffer is NULL\n");        return -1;	}//open nand device    fd = open(nand_device, O_RDWR);    if (fd < 0) {        perror("inf_nand_read: Failed to open NAND device");        return -1;    }    //get nand device info    ret = ioctl(fd, MEMGETINFO, &mtd_info);    if (ret < 0) {        perror("inf_nand_read: Failed to get MTD info");        close(fd);        return ret;    }#if 0PRINT_LOG_DBG("read nand info:\n");PRINT_LOG_DBG("mtd size: 0x%x\n",mtd_info.size);PRINT_LOG_DBG("nand erasesize: 0x%x\n",mtd_info.erasesize);PRINT_LOG_DBG("nand writesize: 0x%x\n",mtd_info.writesize);PRINT_LOG_DBG("nand oobsize: 0x%x\n",mtd_info.oobsize);#endifif(nand_rwblockbuf_init(mtd_info.erasesize) < 0)	{return -1;	}	len = read_size;lseek(fd, offs, SEEK_SET);while(len > 0) {if(offs >=  (loff_t)max_available_size)		{//PRINT_LOG_DBG("inf_nand_read: offs(0x%x) is bigger than offset + max_available_size(0x%x)\n", offs, (loff_t)(offset + max_available_size));close(fd);return dataErr;		}		ret = nand_is_badblock(fd,offs);if(ret) {PRINT_LOG_DBG("inf_nand_read: skiping bad block, addr %llx ret %d\n",offs, ret);			offs += mtd_info.erasesize;lseek(fd, offs, SEEK_SET);continue;else			;memset(pReadBlockBuf, 0x0, mtd_info.erasesize);if (read(fd, pReadBlockBuf, mtd_info.erasesize) != mtd_info.erasesize) {perror("inf_nand_read: Failed to read from NAND device");PRINT_LOG_DBG("inf_nand read: block addr %llx read failed, len = 0x%x\n",offs, len);close(fd);return dataErr;		}		ret = nand_is_invaliddata(pReadBlockBuf, mtd_info.erasesize);if(ret)		{//PRINT_LOG_DBG("inf_nand_read: check data is invalid, skiping the block, addr %llx ret %d\n",offs, ret);			offs += mtd_info.erasesize;lseek(fd, offs, SEEK_SET);continue;else			;PRINT_LOG_DBG("inf_nand read: block addr %llx read ok, len = 0x%x\n",offs, len);		offs += mtd_info.erasesize;memcpy(read_buffer, pReadBlockBuf + sizeof(blockHeader_T), mtd_info.erasesize - sizeof(blockHeader_T));		read_buffer += mtd_info.erasesize - sizeof(blockHeader_T);		len -= mtd_info.erasesize - sizeof(blockHeader_T);		dataErr = 0;	}close(fd);return dataErr;}intnand_write(char* nand_device, char *write_buffer, int write_size, int max_available_size, int offset){int fd = -1;int ret = -1;unsigned int crcnum = 0;int blockDataLen = 0;int blockHeadLen = sizeof(blockHeader_T);int remainDataSize = 0;struct mtd_info_user mtd_info;struct erase_info_user erase_info;loff_t offs = (loff_t)offset;if(nand_device == NULL || write_buffer == NULL)	{        printf("inf_nand_write: nand_device is NULL\n");        return -1;	}//open nand device    fd = open(nand_device, O_RDWR);    if (fd < 0) {        perror("inf_nand_write: Failed to open NAND device");        return -1;    }    //get nand device info    ret = ioctl(fd, MEMGETINFO, &mtd_info);    if (ret < 0) {        perror("inf_nand_write: Failed to get MTD info");        close(fd);        return ret;    }#if 0PRINT_LOG_DBG("read nand info:\n");PRINT_LOG_DBG("mtd size: 0x%x\n",mtd_info.size);PRINT_LOG_DBG("nand erasesize: 0x%x\n",mtd_info.erasesize);PRINT_LOG_DBG("nand writesize: 0x%x\n",mtd_info.writesize);PRINT_LOG_DBG("nand oobsize: 0x%x\n",mtd_info.oobsize);#endifif(nand_rwblockbuf_init(mtd_info.erasesize) < 0)	{return -1;	}//mark badblock for testing//nand_mark_badblock(fd, offs);//printf("nand_mark_badblock: set nand bad,  0x%llx \n", offs);if(write_size > CONFIG_SIZE - mtd_info.erasesize)	{return -1;	}	remainDataSize = write_size;printf("inf_nand_write: write_size:%d offset:0x%x\n", write_size, offset);lseek(fd, offs, SEEK_SET);while(remainDataSize > 0) {if(offs >= (loff_t)max_available_size)		{PRINT_LOG_INFO("inf_nand_write: offs(0x%x) is bigger than max_available_size(0x%x)", offs, max_available_size);close(fd);return -1;		}//check if it is bad fast. If so, skip this block and write it to the next block		ret = nand_is_badblock(fd,offs);if(ret) {PRINT_LOG_INFO("inf_nand_write: 1 skiping bad block, addr %llx ret %d len: %d\n",offs, ret, remainDataSize);			offs += mtd_info.erasesize;lseek(fd, offs, SEEK_SET);continue;else			;/* write_crc = crc32(0, write_buffer, mtd_info.erasesize); *///Before writing, erase the block first		erase_info.start = (__u32)offs;		erase_info.length = mtd_info.erasesize;		ret = nand_erase_block(fd,erase_info);if(ret) {PRINT_LOG_INFO("inf_nand_write: erase failed, skiping the block, addr %llx ret %d\n", offs, ret);			offs += mtd_info.erasesize;lseek(fd, offs, SEEK_SET);continue;else			;//check if it is bad fast. If so, skip this block and write it to the next block		ret = nand_is_badblock(fd,offs);if(ret) {PRINT_LOG_INFO("inf_nand_write: 2 skiping bad block, addr %llx ret %d remainDataSize: %d\n",offs, ret, remainDataSize);			offs += mtd_info.erasesize;lseek(fd, offs, SEEK_SET);continue;else			;//handle block header dataif(remainDataSize <= mtd_info.erasesize - blockHeadLen)		{			blockDataLen = remainDataSize;		}else		{			blockDataLen = mtd_info.erasesize - blockHeadLen;		}bzero(pReadBlockBuf, mtd_info.erasesize);bzero(pWriteBlockBuf, mtd_info.erasesize);		*(int*)(pWriteBlockBuf + CRC_LEN) = HEADIMAGE;memcpy(pWriteBlockBuf + blockHeadLen, write_buffer, blockDataLen);crc_32_fun(pWriteBlockBuf + CRC_LEN, mtd_info.erasesize - CRC_LEN, &crcnum);PRINT_LOG_INFO("crcnum:0x%x blockDataLen:%d \n", crcnum, mtd_info.erasesize - CRC_LEN);		*(int*)pWriteBlockBuf = crcnum;lseek(fd, offs, SEEK_SET);//write dataif (write(fd, pWriteBlockBuf, mtd_info.erasesize) != mtd_info.erasesize) {perror("inf_nand_write: Failed to read from NAND device");close(fd);return -1;		}//Read data for verification (sample is just a simple comparison, actual use can use CRC verification, which is more efficient)//If the data is abnormal (you can retry reading a few more times here); Mark the block as a block, skip the block and write it onto a blocklseek(fd, offs, SEEK_SET);if (read(fd, pReadBlockBuf, mtd_info.erasesize) != mtd_info.erasesize) {perror("inf_nand_write: Failed to read from NAND device");close(fd);return -1;		}/* read_crc = crc32(0, read_buffer, mtd_info.erasesize); *//* if(write_crc != read_crc) { */if(compare_buf(pReadBlockBuf, pWriteBlockBuf, mtd_info.erasesize)) {PRINT_LOG_INFO("inf_nand_write: block addr %llx, write data error,mark badblock, remainDataSize:%d\n",offs, remainDataSize);			offs += mtd_info.erasesize;lseek(fd, offs, SEEK_SET);continue;		}PRINT_LOG_DBG("inf_nand_write: block addr %llx write ok, len = 0x%x\n",offs, remainDataSize);		offs += mtd_info.erasesize;		write_buffer += mtd_info.erasesize - blockHeadLen;lseek(fd, offs, SEEK_SET);		remainDataSize -= blockDataLen;	}fsync(fd);close(fd);return 0;}#endif

四 嵌入式应用层如何设计可靠读写(最关键)


[1].应用层设计原则:

固定分区:配置、固件、日志分开放

固定入口:统一调用 nand_read /nand_write

缓冲对齐:读写缓冲必须和块大小对齐

失败重试:1~3 次,避免偶发干扰

掉电安全:先写备份区,再写主区

版本管理:头部加版本,支持回滚

应用层宏定义:

// 配置分区路径(Linux 下 SPI NAND 对应 mtdX)#define CONFIG_FILE_PATH "/dev/mtd5"// 配置区最大可用空间#define CONFIG_MAX_SIZE (1024 * 1024 * 1)// 配置存储偏移地址#define CONFIG_INFO_OFFSET 0x00000000// 块头魔数#define HEADIMAGE 0xAA55AA55#define CRC_LEN 4

[2].应用层可靠写入示例

// 全局或静态缓冲(必须足够大,>= 块大小)char pWriteBuf [64 * 1024] = {0};int savedDataLen = 0;// 1. 填充待写入数据memcpy (pWriteBuf, &app_config, sizeof (app_config));savedDataLen = sizeof (app_config);// 2. 调用封装好的标准接口写入int ret = nand_write (CONFIG_FILE_PATH, pWriteBuf, savedDataLen, CONFIG_MAX_SIZE, CONFIG_INFO_OFFSET);// 3. 结果判断if (ret < 0){    print("nand write config info failed\n");// 可重试 1~2 次}else{    printf("nand write config info success\n");}

应用层可靠读取示例:

char pReadBuf[64 * 1024] = {0};int read_len = sizeof(app_config);int ret = nand_read(CONFIG_FILE_PATH, pReadBuf, read_len, CONFIG_MAX_SIZE, CONFIG_INFO_OFFSET);if (ret < 0){    printf("nand read config fail\n");}else{// 读取成功,恢复配置    memcpy (&app_config, pReadBuf, sizeof (app_config));}

五 增强策略:掉电安全写入


在原有代码基础上,应用层可简单封装双区备份,彻底防止断电损坏:

示例代码:

int read_nand_check_crc(char* wr_buf, int* wr_buf_len, int offset){//check config and bak config crc is valid	unsigned int pkg_crc_config = 0;int configCrc = 0;int i = 0;int dataLen = 0;int validFileNum = 0;	fileDescrible_T *pBuffer = NULL;	fileDescrible_T fileInfo;int oneFileInfoLen = sizeof(fileDescrible_T);int headImageLen = sizeof(int);int headFileNumLen = sizeof(int);int totalHeadLen = 0;if(wr_buf_len == NULL || *wr_buf_len <= 0)	{return -1;	}	memset(wr_buf, 0, *wr_buf_len);	inf_nand_read(CONFIG_FILE_PATH, wr_buf, *wr_buf_len, CONFIG_MAX_SIZE+offset, offset);	char* pConfigInfo =  (offset == 0) ? "config data" : "bak config data";if (*(uint32_t *)(wr_buf+CRC_LEN) != HEADIMAGE) {printf("Invalid config header, %s error\n", pConfigInfo);return -1;	}	totalHeadLen = CRC_LEN+headImageLen;	validFileNum = *(uint32_t *)(wr_buf + totalHeadLen);	pBuffer = (fileDescrible_T*)(wr_buf + totalHeadLen + headFileNumLen);for(i = 0; i < validFileNum; i++)	{		memset(&fileInfo, 0, oneFileInfoLen);		memcpy(&fileInfo, pBuffer+i, oneFileInfoLen);		dataLen += fileInfo.fileLen;//printf("=====i : %d fileName:%s fileInfo.fileLen:%d\n", i, fileInfo.fileName, fileInfo.fileLen);	}	dataLen += totalHeadLen + headFileNumLen + oneFileInfoLen*validFileNum;	configCrc = *(unsigned int*)(wr_buf);	crc_32_fun(wr_buf+CRC_LEN, dataLen -CRC_LEN, &pkg_crc_config);if((configCrc != pkg_crc_config)||(validFileNum == 0))	{printf("%s is invalid, configCrc:%x pkg_crc_config:%x config data len:%d validFileNum:%d\n", pConfigInfo, configCrc, pkg_crc_config, dataLen, validFileNum);return -1;	}printf("%s is ok, configCrc:%x pkg_crc_config:%x config data len:%d validFileNum:%d\n", pConfigInfo, configCrc, pkg_crc_config,  dataLen, validFileNum);	*wr_buf_len = dataLen;return 0;}
if(read_nand_check_crc(wr_buf, &wr_buf_len, CONFIG_INFO_OFFSET) < 0){if(read_nand_check_crc(bak_wr_buf, &bak_wr_buf_len, BAK_CONFIG_INFO_OFFSET) >= 0)	{//copy bak config to configinf_nand_write(CONFIG_FILE_PATH, (uint8_t*)bak_wr_buf, bak_wr_buf_len,CONFIG_MAX_SIZE, CONFIG_INFO_OFFSET);memcpy(wr_buf, bak_wr_buf, bak_wr_buf_len);	}else	{printf("config and bak config data are both error!\n");goto exitGet;	}}else{if(read_nand_check_crc(bak_wr_buf, &bak_wr_buf_len, BAK_CONFIG_INFO_OFFSET) < 0)	{//copy config to bak configinf_nand_write(CONFIG_FILE_PATH, (uint8_t*)wr_buf, wr_buf_len,BAK_CONFIG_INFO_OFFSET+CONFIG_MAX_SIZE, BAK_CONFIG_INFO_OFFSET);memcpy(bak_wr_buf, wr_buf, wr_buf_len);	}}

六 嵌入式开发必知注意事项


MTD 设备必须是原始字符设备 /dev/mtdX,不要用 /dev/mtdblockX(块设备会被文件系统缓存)

缓冲必须大于等于 NAND 块大小,常见 64KB/128KB,代码已自动 malloc

禁止跨块乱写、禁止部分写,代码已按整块管理,从根源避免

ECC 建议开启,内核 MTD 驱动默认打开硬件 ECC,可纠正 1~4 位错误

高可靠场景建议双备份 + 版本号,配置参数至少 2 块备份

调试看日志,打开 PRINT_DEBUG 可看到:坏块、CRC、地址、长度

七 总结


这套设计逻辑包含:

[1].标准 Linux MTD 接口

[2].坏块检测 / 跳过 / 标记

[3].块擦除安全流程

[4].头部魔数 + CRC32 双校验

[5].写入后回读校验

[6].越界保护、缓冲管理

应用层只需要做三件事:

[1].定义好分区路径与大小

[2].准备对齐的读写缓冲

[3].调用封装好的读和写接口

这套方案能满足很多嵌入式产品的掉电可靠存储需求。

以上为全文内容。

往期文章(欢迎订阅技术分享栏目全部文章):

【从零开始撸内核驱动源码】:以ttyserial(串口驱动)为例,串联字符设备驱动基础知识点的学习计划
Linux内核源码顶层 Makefile分析并单独编译调试内核自带的驱动
【从零开始撸内核驱动源码】:ttynull驱动
Linux内核驱动安装失败问题调试及解决方法
Linux内核驱动源码走读之编译内核及外部驱动实操指南

谢谢你看到这里

这里是女程序员的笔记本

 15年+嵌入式软件工程师兼二胎宝妈

分享读书心得、工作经验,自我成长和生活方式。

希望我的文字能对你有所帮助

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-04-19 17:20:56 HTTP/2.0 GET : https://f.mffb.com.cn/a/485202.html
  2. 运行时间 : 0.127533s [ 吞吐率:7.84req/s ] 内存消耗:4,522.59kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=f1aecdc1108ff4cd3248b583e3be7b5c
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000576s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000582s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000305s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.005157s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000656s ]
  6. SELECT * FROM `set` [ RunTime:0.000221s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000561s ]
  8. SELECT * FROM `article` WHERE `id` = 485202 LIMIT 1 [ RunTime:0.001213s ]
  9. UPDATE `article` SET `lasttime` = 1776590456 WHERE `id` = 485202 [ RunTime:0.004367s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 67 LIMIT 1 [ RunTime:0.000270s ]
  11. SELECT * FROM `article` WHERE `id` < 485202 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000489s ]
  12. SELECT * FROM `article` WHERE `id` > 485202 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000510s ]
  13. SELECT * FROM `article` WHERE `id` < 485202 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.000861s ]
  14. SELECT * FROM `article` WHERE `id` < 485202 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.002118s ]
  15. SELECT * FROM `article` WHERE `id` < 485202 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.000794s ]
0.129002s