This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

fopen problem

Hi!!

I have problem with fopen funciton. I'm using MCB2300 (lpc2378). When I use SD_File examle its work's fine. Now I'm doing my project, I have proglem. I could incialize SD card, but I can't open file (fopen returns error). I have set IRAM2 to addres 0x7FD00000 and size 0x2000, RTLFS.lib (code/cons: default; Zero Initialized Data: IRAM2, Other data: Default)

Default: IRAM1 0x40000000 0x8000
         IRAM2 0x7FD00000 0x2000 (USB)
         RAM1  0x7FE00000 0x4000 (ethernet)

In project I have also included: ETHERNET, DHCP, TELNET, TCP/IP, UDP, TFTP, serial and kernal (from example Http)

I even tried this and don't work:

int main (void) {
   /* Start with 'init' task. */

   FILE *fin;

init_serial();
init_card ();

   fin = fopen ("Test.txt","w");
   if (fin == NULL) {
      send_text ("File not found!\n");
   }
   else {
      // process file content
      fclose (fin);
      send_text ("File OK!\n");
   }
   //os_sys_init(init);
   while(1);
}


Any idea where could be a problem?

Best regard
Peter

  • Hi Peter,

    I'm using the Flashfilesystem with the SD Card in combination with the the MCB2300 successfully. So I assume there is a simply configuration error.

    Here my ideas what to check:
    I configured RTLFS.lib configured like this:
    (code/cons: default; Zero Initialized Data: IRAM2, Other data: IRAM2)

    I used the MCI_LPC23xx.c found as example to the board as lowlevel driver for the flashfilesystem. You must configure this modul to run in the same RAM configuration like RTLFS.lib.

    Did you check the return code of the finit() function? In my case the initialisation sometimes failes. At the moment I solve this issue by a short removal of the SD card. Didn't had time to have a close look, yet.

    Hope the hints gonna solve your problems

  • I find a problem. I had flag in flash configuration/target - use microlib. I experimently removed. Now can I use SD card, but RAM don't work.

    I also using MCI_LPC23xx.c.

    Anybody find some good tutorial how (and whay like this) to set configurations, that manipulating with file works (in ram, SD card and flash)?

  • As you are using the MCB2300, you should have a look to the example projects of the MCB2300, especially to the TFTP_demo. It's using the RAM disk feature of the RL-ARM. So you can take this as an example.

    You can find it in the Keil folder in the following path:
    ..Keil\ARM\Boards\Keil\MCB2300\RL\TCPnet\TFTP_demo

    Rainer

  • I started with this example. I find a problem.

    First problem was, that I didn't inicialize defoult mamory. Now I fixed that, but I have problem with RAM size. It's not enough of them. I tried to seperate 32k ram on two parts, one for general prpose (default) other for RAM drive. The minimum od RAM drive is 16k, but other 16k ram is not enough for zero initialized data (just net_config.c needs cca 19k).

    At first I would to like learn mora about Memory areas.
    What is:
    - code/const
    - zero initialized data
    - other data

    where must be placed (ROM, RAM) and which part od some function or c file present some area. For example where is put global veriable, ...
    Have anybody some tutorial? I looked in Kiel help, but I didn't find nothing usefull.

    What about using function fread? I know, that you have to correctly set code generation (ARM mode ot Thumb mode) and file Retarget.c. Slowly I understanding how it's work.

    Thanke you for your help