This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

I cannot create subfolders in FATFS

Hi, I'm trying to create subfolders with loop. My partly code looks like:

So, it creates new dir but after that my app is crashing and rebooting, and it works fine if all dirs and subdirs are created (if dirA, dirB, dirC already exist) What I do wrong? Thanks in advanced

Parents
  • Hi IllyaM, 

     

    We currently have limited staff due to Easter holidays. We will try to have a look at your case as soon as possible when the team coming back next week. 

Reply
  • Hi IllyaM, 

     

    We currently have limited staff due to Easter holidays. We will try to have a look at your case as soon as possible when the team coming back next week. 

Children
  • Ok, have a nice holidays)

  • Simply change:

    char *str = "dirA/dirB/dirC/file.txt";

    to:

    char str[] = "dirA/dirB/dirC/file.txt";

    and you shall be fine

  • Jakub, thanks for your reply! Could you please explain why char array should work instead of pointer? Cause printf works fine and I see all my subdirs

  • Hi,

    As I read it is basically not recommended to use strtok function due to some drawbacks. If possible you should use strtok_r.

    One of the drawbacks of strtok is that this function is modyfing its first argument. When you are trying to modify text pointed by char * str, most likely you are trying modify const variable (written in Flash).

    When you will use an array you will not have this problem as string will be in RAM.