elehobica / pico_fatfs Goto Github PK
View Code? Open in Web Editor NEWFatFs library for Raspberry Pi Pico
License: BSD 2-Clause "Simplified" License
FatFs library for Raspberry Pi Pico
License: BSD 2-Clause "Simplified" License
Hi all,
I can't issue a proper pull request at the moment, but it's a really simple patch for tf_card.c so I'll just put it here for now:
DWORD get_fattime (void)
{
datetime_t t;
if (rtc_get_datetime(&t))
{
return (((t.year - 1980) << 25) + (t.month << 21) + (t.day << 16) + (t.hour << 11) + (t.min << 5) + (t.sec >> 1));
}
else
{
// Quoting the FatFs documentation, see http://elm-chan.org/fsw/ff/doc/fattime.html :
// "The get_fattime function shall return any valid time even if the system does not support
// a real time clock. If a zero is returned, the file will not have a valid timestamp."
return (((2024 - 1980) << 25) + (1 << 21) + (1 << 16)); // -> 2024, January 1, 00:00:00
}
}
...plus the associated Pico SDK #include and target_link_library for hardware_rtc elsewhere of course.
Thanks,
BR//Karl @xoblite
In tf_card.c around line 49 the CLK_FAST speed is set to 50MHz. I believe this is unrealistic for most SD cards in SPI mode (~20MHz is max?). It was too fast to function on my wired test setup, I changed it to 100KHz and all my bugs went away.
Ahoy!
Thank you for putting together this project- you seem to have done the legwork that's otherwise missing to get SD-card support compatible with the Pico SDK.
In lieu of reinventing the wheel I'd like to re-use your tf_card.c
and tf_card.h
files, building them and FatFS into libraries as part of our collection of Pico examples/drivers. Could you clarify the license, please?
I've put together an example based around this for serving files from SD card over a wireless network (using an ESP32 pack for the Pico). See: pimoroni/pimoroni-pico@24fa369
(I noticed your Pico Wav Player is BSD 2-Clause and includes a possibly more up-to-date version of this code!)
In tf_card.c in disk_initialize around line 285 CS is taken LOW before sending the 80 dummy clocks. Everything I've read says CS should be high during init. I commented out CS_LOW().
Hello,
Firstly many thanks for developing the library.
I seem to have found an issue to get the SD card to mount without error. I'd assumed this was due to my poor wiring or pin selection. However having tried an alternate pico-fatfs library this works without issue, writing Hello World
to the SD card (viewable on another device). This is currently setup on a breadboard with a mess of wires, so expect poor signaling but attempting to lower CLK_FAST to as low as 1 MHZ has not helped. I've tried switch SPI lanes and pins to no avail either. The SD card reader used is this and is hooked up-to the 5v rail for power.
Any ideas how to debug a mount error 3
?
Doubt it would change anything, but I've set the example code test/main.cpp
to use USB serial out for debugging.
The project currently depends on SPI0. I changed this to a define because I'm using SPI1. Not a big issue, but I'm now out of sync with the master branch. I'd suggest a SPIx neutral naming convention with a define for the spi unit used.
I see this quite frequently on the web, but I think this is not strictly the case. I believe a pull up is only needed on MISO (RX), the spec is 100k to 50k (or similar, see the fatfs docs). During the low speed initialization the SD card DO pin is in open drain mode. This needs the pull up to provide the HIGH level. After initialization though it goes into push pull mode and the pull up is no longer needed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.