I'm building some code to read the SD Card on an MCB2300. I'm using the RL-FlashFS library.
I have configured CCLK to 48MHZ and PCLK_MCI to CCLK, and changed the #defines in MCI_LPC23xx.c to read:
#define __MCLK 48000000 #define __CPUCLK 48000000
My code to initialise the card reads:
uint32_t retv = finit(NULL);
The SD LED on the MCB2300 board comes on when the call is made and then there's a *long* pause and eventually the function returns a value of 2.
I'm using 4.74 of the library and uVision 5
Help please, I am totally baffled.
Thanks, David
The code is busy waiting in the ReadBlock function in source file MCI_LPC23xx.c:
static BOOL ReadBlock (U32 bl, U8 *buf, U32 cnt) { /* Read one or more 512 byte blocks from Flash Card. */ U32 i; /* Set MCI Transfer registers. */ MCI_DATA_TMR = DATA_RD_TOUT_VALUE; MCI_DATA_LEN = cnt * 512; /* Start DMA Peripheral to Memory transfer. */ DmaStart (DMA_READ, buf); MCI_DATA_CTRL = 0x9B; for (i = DMA_TOUT; i; i--) { if (GPDMA_RAW_INT_TCSTAT & 0x01) { /* Data transfer finished. */ return (__TRUE); } } /* DMA Transfer timeout. */ return (__FALSE); }
After 10M iterations it gives up and returns FALSE.
Surely I'm not the first to hit this issue?
D.
Hello David,
I assume you are using MDK v 5.38, and on this page:developer.arm.com/.../Use-MDK-Version-4-Projects
...under "Legacy Pack Download" you download and installed "Arm7, Arm9, Cortex-R" (MDK79525.EXE) into the C:\Keil_v5 folder.
Once you do that, you will find pre-made Flash FS examples in the folder:C:\Keil_v5\ARM\Boards\Keil\MCB2300\RL\FlashFS\SD_File\SD_File.uvproj
==============
You can use this project as a reference. Does that example work for you? If not, some additional questions.
- What SD card are you using on the MCB2300 board?
- What Device is on your MCB2300 board? Is it a LPC2370?
- Are you using COM1 for serial communication, in order to control the SD example
See more in the RL-FlashFS manualwww.keil.com/.../rlarm_fs_flashfs.htm
Thanks for your reply.
I copied the SD_File project to a work area, and built it (after changing the location of FS_ARM_L.lib to specify C:\Keil_V5). My MCB2300 has an LPC2388 not an LPC2378, so I changed the project setting for that.
I've tried a few SD cards - all about 1GB in size.When I tried to debug it I got an error popup saying:Memory mismatch! Address: 0x00000058 Value = 0x90 Expected = 0xFCI don't have a serial port on my PC - it's way too recent for that, so I'll just have to run under the debugger as far as I can (once I get past this issue)PS One BIG difference from my project that I see it this one is building for Thumb mode and using FS_ARM_L.lib while I am building for ARM mode and using FS_ARM_LA.lib. Don't know how critical that is?
Thanks again, David
I ran a manual flash of the build and was able to get into the debugger.
I had changed this code to let me debug the finit call:
static void init_card (void) { U32 retv = finit (NULL); char buffer[16] = {0}; if (0== retv) return; else { sprintf(buffer, "%d", retv); } }
For the avoidance of doubt I am trying to build/use the sample from directory:C:\Keil_v5\ARM\Boards\Keil\MCB2300\RL\FlashFS\SD_Filethat was installed by MDK79525. This has version V4.51 of MCI_LPC23xx.c and File_Config.c as distinct from the version in the downloadable sample which is V3.21.
Of course the V3.21 code won't compile:
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin' Build target 'MCB2300' compiling File_Config.c... File_Config.c(150): error: #77-D: this declaration has no storage class or type specifier DEVCONF const FlashDev [1] = {0,0}; File_Config.c(150): error: #65: expected a ";" DEVCONF const FlashDev [1] = {0,0}; File_Config.c(169): error: #77-D: this declaration has no storage class or type specifier DEVCONF const SpiDev [1] = {0,0}; File_Config.c(169): error: #65: expected a ";" DEVCONF const SpiDev [1] = {0,0}; File_Config.c(211): error: #77-D: this declaration has no storage class or type specifier DEVCONF const RamDev [1] = {0,0}; File_Config.c(211): error: #65: expected a ";" DEVCONF const RamDev [1] = {0,0}; File_Config.c: 0 warnings, 6 errors compiling Getline.c... compiling Serial.c... compiling MCI_LPC23xx.c... MCI_LPC23xx.c(96): error: #20: identifier "CARD_NONE" is undefined CardType = CARD_NONE; MCI_LPC23xx.c(101): error: #20: identifier "CARD_MMC" is undefined CardType = CARD_MMC; MCI_LPC23xx.c(115): error: #20: identifier "CARD_SD" is undefined CardType = CARD_SD; MCI_LPC23xx.c(135): error: #20: identifier "CARD_MMC" is undefined if (CardType == CARD_MMC) { MCI_LPC23xx.c(146): error: #20: identifier "CARD_SD" is undefined if (CardType == CARD_SD) { MCI_LPC23xx.c(211): error: #20: identifier "CARD_SD" is undefined if (CardType == CARD_SD) { MCI_LPC23xx.c(230): error: #20: identifier "CARD_MMC" is undefined if (CardType == CARD_MMC) { MCI_LPC23xx.c(257): error: #20: identifier "CARD_SD" is undefined if (CardType == CARD_SD) { MCI_LPC23xx.c(280): error: #20: identifier "CARD_SD" is undefined if (CardType == CARD_SD) { MCI_LPC23xx.c(388): error: #20: identifier "CARD_SD" is undefined if (CardType == CARD_SD) { MCI_LPC23xx.c(654): error: #20: identifier "MMCFG" is undefined BOOL mci_read_config (MMCFG *cfg) { MCI_LPC23xx.c(669): error: #20: identifier "CARD_SD" is undefined if (CardType == CARD_SD) { MCI_LPC23xx.c: 0 warnings, 12 errors
David
Some comments from my side:
Perdrix said:Memory mismatch! Address: 0x00000058 Value = 0x90 Expected = 0xFC
The µVision option 'Update Target before Debugging' in the dialog 'Options for Target - Utilities' did not exist in early versions of µVision 4 and therefore this option is also not set when you work with µVision 5. With these old projects, you always need to download the generated code manually after you build it and before you start a debug session.
Perdrix said:I don't have a serial port on my PC - it's way too recent for that, so I'll just have to run under the debugger as far as I can (once I get past this issue)
Sure, you can run it in the debugger as well, but you could also use a USB to RS232 converter. These devices are a available for a few Euro/Dollar.
Perdrix said:When I debugged through that I got retv of 2 as previously.
How did you format the SD Card? Only FAT is supported, no ExFAT or NTFS or others. Please see the description of the error codes in the manual:
https://www.keil.com/support/man/docs/rlarm/rlarm_finit.htm
Perdrix said:Of course the V3.21 code won't compile:
Old versions of configuration files are often incompatible. Please use the one that came with the example and adapt it if necessary.
Perdrix said:PS One BIG difference from my project that I see it this one is building for Thumb mode and using FS_ARM_L.lib while I am building for ARM mode and using FS_ARM_LA.lib. Don't know how critical that is?
If your application is built in Arm mode, you should also use libraries built in Arm mode. Here is a complete listing of RL-ARM library files:
www.keil.com/.../rlarm_lib_files.htm
Its formatted as FAT - and yes I understand the difference between ARM and Thumb mode - I was merely pointing out that difference.The problem is VERY clearly that data xfer IS NOT taking place to the read_block times out.