We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi!
I already wrote to the support and described my problem, but I didn't get a reaction yet. Maybe someone of you can help me.
I use the RL-RTX kernel and the RL-TCPnet library on a AT91SAM7X256 device. This works well, but now I tried to implement the RL-FlashFS library to store the network configuration on the internal flash. I included the File_Config.c and RTLFS.lib and adapted the FS_FlashDev.h and FlashPrg.c. Then I tried to build the project and get a linker error. After a lot of searching I found out, that I have to retarget the stdio functions. I tried this with the Retarget.c found in ...\Keil\ARM\RV30\RTL\FlashFS\SRC. After that I got no linker error and the application seemed to work. I add the finit() and fcheck() function to the project and it seemed to work. Then I tried to open a file witch fopen(). Now the application jumps into the retargeted _sys_exit() just after the branch command in the startup file.
; Enter the C code IMPORT __main LDR R0, =__main BX R0 --> after this command the application jumps into the _sys_exit function
Best Regards,
Karsten Loof
File System needs a heap. Check your heap size in the startup file. Typical setting is 0x800, however you may try to reduce it.
Franc
Thank you for the hint. Now the described problem is gone, but there are new ones. I initialize the file system with finit() and then i perform a check with fcheck(). This works without failure. Then I try to open a file and get an abort. But this happens only if I run to a breakpoint after the open call. When I put a breakpoint into the fs_ProgramPage function and code execution stops there is no abort and I get a valid Pointer from the fopen function.
fs_ProgramPage, fs_EraseSector, fs_Init are relocated into RAM. fs_ProgramPage calls a swi which calls the flash programming routine. The abort occurs somewhere after the return from fs_ProgrammPage. Here is the code:
int __swi(8) program_page (U32 adr, U32 sz, U8 *buf); int __SWI_8 (U32 adr, U32 sz, U8 *buf) { unsigned long page; unsigned long * Flash; Flash = (unsigned long *)adr; page = (adr - FLASH_BASE_ADDRESS) / FLASH_PAGE_SIZE_BYTE; // Unlock Page Command AT91C_BASE_MC->MC_FCR = AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_UNLOCK | (AT91C_MC_PAGEN & (page << 8)); // Wait until the end of Command while ((AT91C_BASE_MC->MC_FSR & AT91C_MC_FRDY) != AT91C_MC_FRDY); // Copy to the Write Buffer for (sz = (sz + 3) & ~3; sz; sz -= 4, buf += 4) { *Flash++ = *((unsigned long *)buf); } //* Start Programming Command AT91C_BASE_MC->MC_FCR = AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_START_PROG | (AT91C_MC_PAGEN & (page << 8)); // Wait until the end of Command while ((AT91C_BASE_MC->MC_FSR & AT91C_MC_FRDY) != AT91C_MC_FRDY); // Check for Errors if (AT91C_BASE_MC->MC_FSR & (AT91C_MC_PROGE | AT91C_MC_LOCKE)) return 1; return 0; } /*--------------------------- fs_Init ---------------------------------------*/ int fs_Init (U32 adr, U32 clk) { /* Library default fs_Init function. */ unsigned long clkus; // Calculate Flash Microsecond Cycle Number - Approximate (no Library Code) // clkus = (1074*(clk >> 10)) >> 20; // Master Clock Cycles in 1.0us clkus = (1611*(clk >> 10)) >> 20; // Master Clock Cycles in 1.5us // Set Flash Microsecond Cycle Number // Set Flash Waite State to max. (Single Cycle Access at Up to 30 MHz) AT91C_BASE_MC->MC_FMR = ((AT91C_MC_FMCN) & (clkus << 16)) | AT91C_MC_FWS_3FWS; return (0); } /*--------------------------- fs_EraseSector --------------------------------*/ int fs_EraseSector (U32 adr) { /* Library default fs_EraseSector function. */ return (0); // Automatic Erase during Program Cycle } /*--------------------------- fs_ProgramPage --------------------------------*/ /* * Program Page in Flash Memory * Parameter: adr: Page Start Address * sz: Page Size * buf: Page Data * Return Value: 0 - OK, 1 - Failed */ int fs_ProgramPage (U32 adr, U32 sz, U8 *buf) { /* Library default fs_ProgramPage function. */ unsigned int ret; ret = program_page(adr,sz,buf); return ret; }
I don't understand what happens and how I can find out what happens. I am just starting to work with arm based controllers.
Best regards Karsten Loof
Maybe you are returning from program_page() too early. If the flash programming has not finished yet, you might get abort in the return. This also explains why it works if you set a breakpoint into this function where you wait and then single step.