lpc4337+fatfs+spifi 文件系统变量被修改的问题
最近在调试LPC4337+FATFS,FLASH用的是MX25L512,但是读写一直不成功。通过Debug监视一个局部变量,发现FATFS文件系统其在一个毫不相干的判断语句后,其值被修改了。
if (fp->flag & FA__ERROR) return FR_INT_ERR;
上面的代码就是执行后被监视的局部变量值发生变化的语句。在注释后发现其下一条语句依然会把监视的值改掉。
是栈出了问题么?
部分MAP文件:Memory Map of the image
Image Entry point : 0x1a000115
Load Region LR_IROM1 (Base: 0x1a000000, Size: 0x00008150, Max: 0x00080000, ABSOLUTE, COMPRESSED[0x0000802c])
Execution Region RW_IRAM1 (Base: 0x10000000, Size: 0x00000c00, Max: 0x00008000, ABSOLUTE)
Base Addr Size Type Attr Idx E Section Name Object
0x10000000 0x00000c00 Zero RW 8448 .bss endpoint.o
Execution Region RW_RAM3 (Base: 0x10080000, Size: 0x00003200, Max: 0x0000a000, ABSOLUTE)
Base Addr Size Type Attr Idx E Section Name Object
0x10080000 0x00003200 Zero RW 1524 .bss board_keil_mcb_18574357.o
Execution Region ER_IROM1 (Base: 0x1a000000, Size: 0x00008000, Max: 0x00080000, ABSOLUTE)
Base Addr Size Type Attr Idx E Section Name Object
。。。。。
Execution Region RW_IRAM2 (Base: 0x20000000, Size: 0x00008cc8, Max: 0x00010000, ABSOLUTE, COMPRESSED[0x0000002c])
Base Addr Size Type Attr Idx E Section Name Object
0x20000000 0x00000018 Data RW 421 .data generichid.o
0x20000018 0x00000010 Data RW 1117 .data drv_lpc43xx.o
0x20000028 0x00000081 Data RW 1526 .data board_keil_mcb_18574357.o
0x200000a9 0x00000003 PAD
0x200000ac 0x0000003c Data RW 5262 .data tasks.o
0x200000e8 0x0000000e Data RW 8211 .data usbtask.o
0x200000f6 0x00000003 Data RW 8382 .data devicestandardreq.o
0x200000f9 0x00000003 PAD
0x200000fc 0x00000034 Data RW 8449 .data endpoint.o
0x20000130 0x00000003 Data RW 8627 .data usbcontroller.o
0x20000133 0x00000002 Data RW 8682 .data hal_lpc18xx.o
0x20000135 0x00000001 PAD
0x20000136 0x00000011 Data RW 9109 .data mrfi.o
0x20000147 0x00000001 PAD
0x20000148 0x00000006 Data RW 9594 .data ff.o
0x2000014e 0x00000002 PAD
0x20000150 0x0000003f Zero RW 420 .bss generichid.o
0x2000018f 0x00000001 PAD
0x20000190 0x000000fc Zero RW 5261 .bss tasks.o
0x2000028c 0x0000026c Zero RW 7880 .bss lpc18xx_43xx_emac.o
0x200004f8 0x00000308 PAD
0x20000800 0x000012b0 Zero RW 8825 .bss endpoint_lpc18xx.o
0x20001ab0 0x00000014 Zero RW 8989 .bss mx25l1606edrv.o
0x20001ac4 0x00000203 Zero RW 9107 .bss mrfi.o
0x20001cc7 0x00000001 PAD
0x20001cc8 0x00007000 Zero RW 1404 STACK keil_freertos_startup_lpc18xx43xx.o
Load Region LR_IROM2 (Base: 0x1b000000, Size: 0x0002acc8, Max: 0x00080000, ABSOLUTE)
Execution Region ER_IROM2 (Base: 0x1b000000, Size: 0x0002acc8, Max: 0x00080000, ABSOLUTE)
Base Addr Size Type Attr Idx E Section Name Object
0x1b000000 0x0002acc8 Data RO 9844 .constdata cc936.o
Code (inc. data) RO Data RW Data ZI Data Debug Library Member Name
92 0 0 0 0 0 __dczerorl2.o
0 0 0 0 0 0 entry.o
0 0 0 0 0 0 entry10a.o
0 0 0 0 0 0 entry11a.o
8 4 0 0 0 0 entry2.o
4 0 0 0 0 0 entry5.o
0 0 0 0 0 0 entry7b.o
0 0 0 0 0 0 entry8b.o
8 4 0 0 0 0 entry9a.o
30 0 0 0 0 0 handlers.o
36 8 0 0 0 68 init.o
30 0 0 0 0 68 llshl.o
32 0 0 0 0 68 llushr.o
36 0 0 0 0 68 memcpya.o
36 0 0 0 0 108 memseta.o
1150 54 0 0 0 352 printf8.o
98 0 0 0 0 92 uldiv.o
160 26 0 0 0 92 amic.o
276 24 64 0 0 96 atmel.o
220 26 0 0 0 88 chi.o
184 12 0 0 0 96 eon.o
188 24 0 0 0 96 esmt.o
352 44 0 0 0 232 falcon_details.o
176 20 0 0 0 96 giga.o
404 28 130 0 0 92 macronix.o
376 40 0 0 0 184 numonyx.o
236 24 0 0 0 112 spansion.o
4848 116 84 0 0 1148 spifi_rom_api.o
184 26 120 0 0 88 sst.o
252 20 0 0 0 172 winbond.o
----------------------------------------------------------------------
9418 500 400 0 0 3416 Library Totals
2 0 2 0 0 0 (incl. Padding)
----------------------------------------------------------------------
Code (inc. data) RO Data RW Data ZI Data Debug Library Name
1560 70 0 0 0 824 mc_w.l
7856 430 398 0 0 2592 spifi_drv_M4.lib
----------------------------------------------------------------------
9418 500 400 0 0 3416 Library Totals
----------------------------------------------------------------------
==============================================================================
Code (inc. data) RO Data RW Data ZI Data Debug
31100 1804 176972 336 51576 423473 Grand Totals
31100 1804 176972 44 51576 423473 ELF Image Totals (compressed)
31100 1804 176972 44 0 0 ROM Totals
==============================================================================
Total RO Size (Code + RO Data) 208072 ( 203.20kB)
Total RW Size (RW Data + ZI Data) 51912 ( 50.70kB)
Total ROM Size (Code + RO Data + RW Data) 208116 ( 203.24kB)
============================================================================== 文件系统 局部变量 flash
[解决办法]
FR_INT_ERR 由于一个错误的FAT结构或一个内部错误,而导致该函数失败
和SD卡有关