Petit FatFs - pf_opendir undefined reference

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've just started to experiment with the library:

#define F_CPU 1000000UL

#include <avr/io.h>
#include "pff.h"
#include "diskio.h"

FATFS fs;	 // file system object
DIR dir;	 // directory object
FILINFO fno; // file information

int8_t temp = -5;

int main(void)
{
	disk_initialize();
	pf_mount (&fs);

	pf_opendir (&dir, "");

    while (1)
    {
		//temp =  pf_readdir (&dir, &fno);
	}

}

Didn't make it too far as Atmel Studio says pf_opendir is an undefined reference although pf_mount is fine and they are both declared in pff.h which is included. What is going on?

 

------ Build started: Project: The Button, Configuration: Debug AVR ------
Build started.
Project "The Button.cproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Compiler.targets" from project "C:\Button\code\The Button\The Button\The Button.cproj" (target "Build" depends on it):
    Task "RunCompilerTask"
        Shell Utils Path C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils
        C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils\make.exe all --jobs 4 --output-sync 
        Building target: The Button.elf
        Invoking: AVR/GNU Linker : 5.4.0
        "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe" -o "The Button.elf"  diskio.o main.o pff.o   -Wl,-Map="The Button.map" -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mmcu=atmega328p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.3.300\gcc\dev\atmega328p"  
C:\Button\code\The Button\The Button\Debug\Makefile(130,1): error: recipe for target 'The Button.elf' failed
        main.o: In function `main':
C:\Button\code\The Button\The Button\main.c(27,1): error: undefined reference to `pf_opendir'
collect2.exe(0,0): error: ld returned 1 exit status
        make: *** [The Button.elf] Error 1
        The command exited with code 2.
    Done executing task "RunCompilerTask" -- FAILED.
Done building target "CoreBuild" in project "The Button.cproj" -- FAILED.
Done building project "The Button.cproj" -- FAILED.

Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

This topic has a solution.
Last Edited: Tue. Nov 12, 2019 - 01:29 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

http://elm-chan.org/fsw/ff/pf/ap...

 

See 'module size reduction'

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

http://elm-chan.org/fsw/ff/pf/ap...

 

See 'module size reduction'

 

 

Oh, right!

So by default you can't open a directory. Assuming I'm using an SD card with an unknown # of files, with unknown names and an unknown # of directories with an unknown # of files in them and so on... I really must enable this function right? I want to use it to get a listing of the root dir for starters.

Last Edited: Tue. Nov 12, 2019 - 01:33 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You've answered your own question - you want it - you turn it on!   It's the opposite at McDonalds - the quarter pounder has everything, so I need to deselect options like pickles etc (over here in Australia, McD's have large touch screens to order from - you select what you want and there are options like more cheese/less cheese etc). Each time they upgrade the code, there's defects and even retrograde steps.

 

It's interesting that Chan has this configuration - I would've thought most compilers/tool chains these days would strip out unused code. Whilst I've investigated IAR and it is quite agressive at doing this, I've not looked at gcc. Comments anyone?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why are you using "Petit" on a 328? It has plenty enough resources to run the full copy of FatFs with all the advantages it brings.

Kartman wrote:
It's interesting that Chan has this configuration - I would've thought most compilers/tool chains these days would strip out unused code.
But these config options don't necessarily turn of whole functions (as linker garbage collection would) but also sequences in the rest of the code that are there only to support such functions - the linker would not know this.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

Why are you using "Petit" on a 328? It has plenty enough resources to run the full copy of FatFs with all the advantages it brings

 

I'm only developing on this model, when final project size will be determined I'll switch over to a smaller device.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

slow_rider wrote:
I'm only developing on this model, when final project size will be determined I'll switch over to a smaller device.
Ah OK, makes sense. As long as it's a read-only application then Petit should be fine even if the fact that it does not buffer 512 sectors means it can be hugely inefficient.