SdFat library not working with Boron

There is a general problem with these symbols in the mesh software.

They are defined in the lwip library and in the standard fcntl.h include file.

The particle version of lwip has these definitions:

#ifndef O_RDONLY
#define O_RDONLY    2
#endif
#ifndef O_WRONLY
#define O_WRONLY    4
#endif
#ifndef O_RDWR
#define O_RDWR      (O_RDONLY|O_WRONLY)
#endif

fcntl.h for the ARM compiler uses the standard POSIX/Linux values.

/*
 * Flag values for open(2) and fcntl(2)
 * The kernel adds 1 to the open modes to turn it into some
 * combination of FREAD and FWRITE.
 */
#define	O_RDONLY	0		/* +1 == FREAD */
#define	O_WRONLY	1		/* +1 == FWRITE */
#define	O_RDWR		2		/* +1 == FREAD|FWRITE */

Unfortunately fcntl.h is not included in lwip so the inconsistent value are defined.

I am modifying SdFat to use the values in fcntl.h I will #undef the symbols if they have the lwip values.

Too many apps use the symbols in other versions of SdFat so I don’t want to change their names.

I will also change the values for these open flags (O_APPEND, O_CREAT, O_TRUNC, O_EXCL, O_SYNC) defined in fcntl.h to avoid future problems.

I am also using these values in the new version of SdFat which supports exFAT.

3 Likes