Author Topic: FAT32 getting started  (Read 6633 times)

0 Members and 1 Guest are viewing this topic.

Offline vinayak

  • Newbie
  • Posts: 4
  • Country: in
    • NA
Re: FAT32 getting started
« Reply #25 on: January 18, 2024, 09:06:30 am »
Hi darkspr1te,

 I dont know exactly i just need some idea how i can implement the FAT32 file system IP without kernel involved

Regards,
Vinayak
« Last Edit: January 31, 2024, 07:09:40 am by vinayak »
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10086
  • Country: nz
Re: FAT32 getting started
« Reply #26 on: January 18, 2024, 09:12:58 am »
Do you mean you want to do it all with DMA?
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline vinayak

  • Newbie
  • Posts: 4
  • Country: in
    • NA
Re: FAT32 getting started
« Reply #27 on: January 18, 2024, 09:24:27 am »
 yes DMA only
why is that not possible?
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3991
  • Country: nl
Re: FAT32 getting started
« Reply #28 on: January 18, 2024, 10:52:50 am »
just something like DMA won't cut it. Why, because it is a file system you want to setup, and that means making decisions based on what is already on the disk (card). It would require an intricate state machine to get it working.

If you want to know about FAT32 and how it works you should checkout the already mentioned FATFS code. http://elm-chan.org/fsw/ff/

Offline vinayak

  • Newbie
  • Posts: 4
  • Country: in
    • NA
Re: FAT32 getting started
« Reply #29 on: January 18, 2024, 10:58:32 am »
Ok... Thanks for replying :)
 

Offline 5U4GB

  • Frequent Contributor
  • **
  • Posts: 424
  • Country: au
Re: FAT32 getting started
« Reply #30 on: January 19, 2024, 06:29:41 am »
Now all i want is to write to 1 file in the root.

If you're only going to write 1 file to the root then format the card and write the file on the system of your choice, record which blocks on the card correspond to that file, and then overwrite only those blocks from the PIC code with the data you're saving.  The PIC code doesn't need to know anything about FAT, just which blocks to write to.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10086
  • Country: nz
Re: FAT32 getting started
« Reply #31 on: January 19, 2024, 09:49:23 am »
Now all i want is to write to 1 file in the root.

If you're only going to write 1 file to the root then format the card and write the file on the system of your choice, record which blocks on the card correspond to that file, and then overwrite only those blocks from the PIC code with the data you're saving.  The PIC code doesn't need to know anything about FAT, just which blocks to write to.

+1 for this being a simple solution.

Another options is to consider if you actually need a FS on the card.  If you need to remove the card and access it in a PC then you obviously do.
But sometimes you can simply think of the card as permanent memory for your device and just write wherever you want to, basically you roll your own super simple file system on the card for your use case and give up on it ever being readable in a PC.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 4018
  • Country: gb
Re: FAT32 getting started
« Reply #32 on: January 19, 2024, 09:51:29 am »
Don't bother writing your own FAT implementation. I've used this one in several projects:
elm-chan

It can be tailored to include more or less features depending on what you need versus the amount of flash space you have.

People simply don't care, for me the Elm-Chan's FAT is very poor code quality.

The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3991
  • Country: nl
Re: FAT32 getting started
« Reply #33 on: January 19, 2024, 10:21:13 am »
People simply don't care, for me the Elm-Chan's FAT is very poor code quality.

I agree, but it works. Used it in the FNIRSI 1013D firmware and noticed that it allowed NULL pointers to be passed for output buffers.  :palm:

But judging on some of the responses people seem to miss that this is a 4 year old thread revived by vinayak to ask for the code. The OP has not been back since February 2022, so the change of him reading the posts are slim.

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10086
  • Country: nz
Re: FAT32 getting started
« Reply #34 on: January 19, 2024, 10:59:02 am »
sigh,  it would be nice if SMF would color old threads different or something.
Or maybe a cobweb background image for any old thread that suddenly got revived. That would be cool.
Greek letter 'Psi' (not Pounds per Square Inch)
 
The following users thanked this post: 5U4GB

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14873
  • Country: fr
Re: FAT32 getting started
« Reply #35 on: January 19, 2024, 10:38:34 pm »
FatFs "works" and is used by many, but similarly, when I had to use FAT in a project, I rejected it eventually and wrote my own implementation. I only needed FAT32 and exFAT as well, so didn't bother to implement FAT16 or FAT12, which are supported by FatFs.

"Very poor code quality" may be a bit harsh, but it's definitely not very good - and one of the main reasons, beyond that, that made me reject it, was that it only implemented blocking calls for all operations, which turns out very inconvenient if you're not using some kind of preemptive OS.
 

Offline 5U4GB

  • Frequent Contributor
  • **
  • Posts: 424
  • Country: au
Re: FAT32 getting started
« Reply #36 on: January 20, 2024, 12:55:33 am »
But judging on some of the responses people seem to miss that this is a 4 year old thread revived by vinayak to ask for the code. The OP has not been back since February 2022, so the change of him reading the posts are slim.

Even if the OP never reads it, it's still here as a reference for anyone else who ends up here, and there's valuable advice in the postings.
 

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 4018
  • Country: gb
Re: FAT32 getting started
« Reply #37 on: January 20, 2024, 02:02:40 pm »
I rejected it eventually and wrote my own implementation

"very poor code quality" may seem very cynical, however ...

Years ago, I designed and implemented a filesystem for a job request. A few months earlier, the two super project managers had asked to find a solution, some of us started thinking about it and "ran for office" (to get the task), bringing a solution.

I broght a personal project I had started at university, cleaned it up in order to present it as a "candidate project". It had nice featues, everything was B+tree based, and the whole module it could easily be written to run as userspace service (microkernel approach).

I presented a demo, running it on the top of the XINU uckernel on a Sequoia PowerPC board.

The code quality was for sure more than decent as it was already passing MISRA and DO178B-level D. However, being a personal project of mine, started during my university days, rewritten several years after graduation and carried out only in moments of free time, it needed some revision and modification. Nothing serious, I had estimated less than 3 weeks of work, allocating two people full time.

So, I presented it with a list of "Pros and Cons" and ... got then rejected because
  • an experimental filesystem design? Sounds too high complexity and too exspensive!
  • people (who?!?) want to use a Windows laptop

Then a colleague of mine showed up, who had downloaded the code from the Elm-Chan FAT website, and ... I really don't understand how this happened, but the two project managers thought it was exactly the right solution and ordered us to use that code, which I had then to split into 4 parts in order to have 4 teams work in parallel to be able to clean and make it "decent" for an avionics allocation that passed at least DO178B level C.

... and ... it was a massacre, a damn bloody bloodbath.

Did it make sense? ...

... well, in the end, if you consider the consumed "human power" of 4 teams of 3 dudes each, 8h/24 for 3 months, it costed more than 4x times the cost I had estimated for myfs, but hey? "people want to use a Windows Laptop to copy GPS flight maps from a folder on the Desktop to the SD card/USB-stick that goes into the flight module on the airplane or helicopter" - said one of the two project manager ...

Computer science is sometime *VERY* frustrating :-//
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 
The following users thanked this post: cfbsoftware

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14873
  • Country: fr
Re: FAT32 getting started
« Reply #38 on: January 20, 2024, 09:33:40 pm »
It's pretty much always the same thing: managers usually favor solutions that look "well established", because they appear as the path of least resistance.
What seems to matter in the end is not the end result, but how people have perceived it.
If choosing a well known (or one that appears a bit 'de facto') solution, managers will rarely get the blame, even if the project takes ages to complete with a lot of hiccups.
FAT has been around for decades now, and FatFs is rather popular, so it's definitely in the 'de facto' category.

If choosing an alternative, new or "obscure" solution, managers will often get the blame even just for the project being one week late. I've seen this endlessly.
That's unfortunately how it works. Humans need conformity. And while it has probably had many evolutionary benefits in our distant past, this is also what is currently dragging us down IMHO. End of rant. :horse:
 
The following users thanked this post: cfbsoftware, DiTBho

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21966
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: FAT32 getting started
« Reply #39 on: January 21, 2024, 06:55:57 am »
Did it make sense? ...

... well, in the end, if you consider the consumed "human power" of 4 teams of 3 dudes each, 8h/24 for 3 months, it costed more than 4x times the cost I had estimated for myfs, but hey? "people want to use a Windows Laptop to copy GPS flight maps from a folder on the Desktop to the SD card/USB-stick that goes into the flight module on the airplane or helicopter" - said one of the two project manager ...

Computer science is sometime *VERY* frustrating :-//

Part of it I think is the lack of scientific knowledge, going on feel rather than fact.  Many times have I presented an idea, including potential pros and cons, in the interest of making a more informed decision about it; many times, alternative ideas have been given as just basic ideas without the cons, and probably the impression of simplicity plus lack of explicit cons wins out in the decision maker's mind.  It's bad psychology, it's dumb psychology, but human psychology it is.

Or maybe it's me being a 'sperg and that's the bigger turn-off in general, not so much my ideas necessarily.  That's always a possibility.

But real ideas are complex, real solutions have up and down sides, real projects are difficult to talk about not only in complexity but in the feelings we ascribe to them, feelings we create in lieu of having a strong enough factual basis; that is, out of ignorance of the total scope of the project (and, again, ignorance isn't a bad thing, it's literally not knowing, if you knew the complete solution you wouldn't be asking me to engineer it for you, right?!), we fall back on statistics, feelings of likelihood, and of optimism or apathy towards one approach or another.  And above some level of complexity, ignorance is a necessity, many systems are simply too complex for any one person to fully understand, and so we will always apply heuristics and emotions while operating on them.

And it's not to say we should avoid feelings.  It's unavoidable, of course.  At least at scale -- whether in terms of a given sufficiently-complex problem, or in terms of the number of people that can maintain a complete understanding within their heads (of any given topic).  Just, to avoid making rash decisions, with little buy-in from stakeholders, and avoid committing sunk-cost and gamblers' fallacies (among many others) along the way.

Back on topic, for my part -- I gave this a try,
http://www.roland-riegel.de/sd-reader/
which seemed to go just fine.  I haven't used it for writing, I haven't tested it in any meaningful way at all, but it seems capable of reading a file from root in SPI mode, and that's all that I cared about at the time.

Tim
« Last Edit: January 21, 2024, 06:57:45 am by T3sl4co1l »
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 
The following users thanked this post: DiTBho

Offline PlainName

  • Super Contributor
  • ***
  • Posts: 7031
  • Country: va
Re: FAT32 getting started
« Reply #40 on: January 21, 2024, 08:56:26 am »
Quote
"people want to use a Windows Laptop to copy GPS flight maps from a folder on the Desktop to the SD card/USB-stick that goes into the flight module on the airplane or helicopter"

Do they, or would they?
 

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 4018
  • Country: gb
Re: FAT32 getting started
« Reply #41 on: January 21, 2024, 01:54:08 pm »
Quote
"people want to use a Windows Laptop to copy GPS flight maps from a folder on the Desktop to the SD card/USB-stick that goes into the flight module on the airplane or helicopter"

Do they, or would they?

I don't know, last time I was in Japan, I spoken to a couple of managers of CASIO, and asked why they removed the physical SD-card support from their graphing calculators (e.g. FX-9860GIISD), and replaced it with FAT32 internal flash support in the last line of products (e.g. FX-9860GIII).

Why not an other prettier filesystem? Why still FAT32?

The answer was something like because most people, especially in the educational field, college and university, use Windows, so they are used to have FAT32 on their SD cards.

I don't know  :-//
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline PlainName

  • Super Contributor
  • ***
  • Posts: 7031
  • Country: va
Re: FAT32 getting started
« Reply #42 on: January 21, 2024, 02:26:31 pm »
Well perhaps the management had a point, then. It's all very well have a super-FS which is ultra-robust, fast and uses 2K of memory, but give your average user the choice of an SD card to shove in their PC/phone/whatever and have it Just Work, or minimally having to install a special driver (where's the Mac version? What about XP?) or, worse, a custom dongle and I know why they will choose every time.

Without knowing details, it seems to me that the problem wasn't the management choosing FAT32 but the shitty implementation of it.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf