f_read doesn't respond in large files



  • Hi All,

    I am tying to read a large file ( ~300kb) from sd card , I am using FreeRTOS sdk, but it doesn't respond properly . I have tried to read in 1000 bytes blocks but after couple of readings it's halted. I should mention that I've tested the same code in Kendryte_standalone_sdk and it works fine ( I was able to read 65535 bytes in each reading while in FreeRtos it doean't work even with 5000 bytes) . After some readings f_read it's halted (stays in f_read).


  • Global Moderator |  Mod

    Hi,
    I can't reproduce this issue. Would you please download the lastest kendryte-freertos-sdk, kendryte-freertos-demo and toolchain and try again. My test environment is ubuntu(not windows), I want to know your test environment.

    Thanks.


  • Global Moderator |  Mod

    This post is deleted!


  • @hukai Thanks for testing but it doesn't work for me, here is the code. I am getting "runtime_error" , I've attached the screenshot of the error.

    int main()
    {
    printf("Hello sd\n");
    int size = 65535;

    char *msg = NULL ;//="k233333333333333333";
    msg = (char *) malloc(size);
    if (!msg) printf("errorrrrr\n");
    else {
      memset(msg,'A',size);
      *(msg+size-1) = NULL;
    

    ![alt text](![image url](![image url](image url)))
    handle_t sd0 = install_sdcard();
    configASSERT(sd0);
    configASSERT(filesystem_mount("/fs/0/", sd0) == 0);
    io_close(sd0);

    /************************* test syscalls ************************************/
    FILE *stream;

      if((stream=fopen("/fs/0/test_syscalls.txt","wb"))==NULL)
      {
          fprintf(stderr,"Can not open file.\n");
          exit(-1);
      }
    

    printf("fwrite\n");
    fwrite(msg, 1, size, stream);
    fclose(stream);
    printf("done\n");
    }
    0_1555007619106_440db1fd-c0a9-4ddd-a723-72487c798fff-image.png


  • Global Moderator |  Mod

    Hi,

    1. I have download kendryte-freertos-sdk and kendryte-freertos-demo;

    2. copied kendryte-freertos-demo/sdcard_filesystem to kendryte-freertos-sdk/src;

    3. changed sdcard_filesystem/main.c
      ++char msg[65536];
      ++char buffer[65536];
      int main()
      {
      printf("Hello sd\n");
      ++memset(msg,'A',65535);
      ++memset(buffer,'A',65535);
      --//char msg[]="k233333333333333333";
      --//char buffer[32];

    4. I tested this case and everything is OK.



  • Hi @hukai
    When did you test it? If you have tested with the latest FreeRTOS existing is develop branch, it's ok now. I've seen this issue with the previous one but it's been almost two weeks the branch has been updated and problem is resolved , however, writing in sd_card still has problem and for big files you have to break down it in smaller blocks( 512bytes).
    I should mention that I wan't able to use fwrite even with breaking down to small blocks , However f_write can store the large files if it's broken down to 512bytes block.


  • Global Moderator |  Mod

    Hi , I have use FreeRTOS and tested sdcard, but it's OK. Could you please provide your test code? Thanks.