Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years ago.
filesystem.mount() error codes ?
Hi there. So I have this code on a FRDM-K66F:
SDBlockDevice sd( PTE3, PTE1, PTE2, PTE4 ); MBRBlockDevice part1( &sd, 3 ); FATFileSystem fs( "fs", &part1 ); ... int main() { int errCode = NOERR; int err = fs.mount( &sd ); if ( err != 0 ) { pc.printf( "fs.mount failed: err = %d.\n\r", err ); // other stuff as needed } ...
In my diagnostic output, I see that it's returning an error code of "-5." Where do I find out what this return values means? It would go far toward figuring out why the mount isn't working.
Edited for code formatting.
1 Answer
5 years ago.
Hi Aaron,
The filesystem uses POSIX error codes. You can find the full list of error codes here:
https://github.com/ARMmbed/mbed-os/blob/8b6a7aacc5d2b90ba40d89c8eeb680ebee81ea18/platform/mbed_retarget.h#L132-L393
You can also use the strerror function to get a human readable string describing the error. However, this comes with a code size cost, so you should remove it if you are tight on space.
5 is EIO, which indicates an IO error. Most likely something is going wrong with the block device. If you call sd.init() before the mount, it should return a more descriptive error.
Also, are you meaning to pass "sd" to the filesystem and not the "part1"? Are you using partitions?
Ah, thank you kindly. I'm using a 32G microSD card - it was handy; nothing more - that has been formatted for FAT - yes, using partitions - and it's recognized on Mac and Linux, but seems to be problematic for the K66. I'm trying to avoid having to initialize it under mbed so I can bring in existing files for a particular application. I want the files to be used on both a Mac and the mbed app I'm developing. Maybe due to the SD size, requiring the extended partitions, that might be the problem. I'll see if I can find a 2G SD card that just uses the 4 primary partitions.
posted by 28 Feb 2018