Author Topic: FAT32 getting started  (Read 5711 times)

0 Members and 1 Guest are viewing this topic.

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
FAT32 getting started
« on: October 21, 2020, 03:29:45 pm »
Hi, i like to write a file to a FAT32 SDcard.
To make it simpler i format the card in windows with FAT32.
Now all i want is to write to 1 file in the root.

What do i have to do ?
btw : i am using a 8-bit PIC.
The read/write to SD card is functioning.
I also need to download all the librarys that exist for example, so far i have : sdfat.

thanks
 

Offline ucanel

  • Regular Contributor
  • *
  • Posts: 134
  • Country: tr
Re: FAT32 getting started
« Reply #1 on: October 21, 2020, 03:55:41 pm »
I wrote an sd card library for dspic30f,
fat16 and fat32 supported,
wrote it in assembler, library size was 1k.
I do not recommend you to write your own library
it takes unnecessaryly long time to understand and implement it.

But it is easy to communicate with an sd card
if we do not think about Fat.
So if it is suitable for you there is an workaround about Fat:
You will create a space filled long  txt file with a pc then
using winhex Hxd or similar
you will learn the start address of this  empty file
and at the mcu side
using this address you can easly write and read this file.

There are so many tutorials about physically reaching to sd card.
As a hint you will use SD SPI mode,
and there is SD Card initialisation sequence
after that there is Sd read and Sd write commands you will need.
ELM Chan's site is a very good starting point.
So many mcu manufacturer uses his FatFS library.
http://elm-chan.org/docs/mmc/mmc_e.html

http://elm-chan.org/docs/mmc/i/sdinit.png


And there is one more hint
sd cards has at least  4 or 5 different types
it is hard to support all of them with just one small library.
« Last Edit: October 21, 2020, 03:58:10 pm by ucanel »
 

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: FAT32 getting started
« Reply #2 on: October 22, 2020, 12:45:19 pm »
Yes, i support V1 and V2 SD cards, i focus on SD-HC only.
The SD card is already initialized, thank you.

And yes i am going to write my own FAT32, with only 1 file to write.
 

Offline methods

  • Newbie
  • Posts: 9
  • Country: us
Re: FAT32 getting started
« Reply #3 on: October 23, 2020, 07:08:43 pm »
A bit off topic but my experience has been that the Arduino libraries handle this beautifully.

I have wired the SPI lines directly to a MicroSD card slot and data logged gigs as easy as writing the terminal.

I strongly encourage all engineers to support the Arduino paradigm.  I got my start with pic, specifically the 16f84 and later the 16F877.  This is back when we did everything and pick asm leveraging the true RISC.

Today I find myself struggling to get an stm32 to even do the most basic of tasks. . .  where for the last decade I've used arduino's to great success.

down selection of a microcontroller should be based on how well supported it is by a community. 

...  Unless it's part of a learning program were you actually wanted to be difficult.

-methods
 

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: FAT32 getting started
« Reply #4 on: October 24, 2020, 01:21:41 pm »
Yes i downloaded that code also.
The problem is reading the bootsector "bytes per sector" gives zero.
What can i do ?, is this normal ?
 

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: FAT32 getting started
« Reply #5 on: October 24, 2020, 01:24:43 pm »
...  Unless it's part of a learning program were you actually wanted to be difficult.

I want it to be simple and small, for use with small 8 bitter.
Most important : understandable for myself.
 

Offline ucanel

  • Regular Contributor
  • *
  • Posts: 134
  • Country: tr
Re: FAT32 getting started
« Reply #6 on: October 24, 2020, 04:00:50 pm »
If i remember correctly bytes per sector is 512 bytes standart for FAT32.
I will check my notes and write it again.
 

Offline PlainName

  • Super Contributor
  • ***
  • Posts: 6848
  • Country: va
Re: FAT32 getting started
« Reply #7 on: October 25, 2020, 06:02:47 am »
Quote
down selection of a microcontroller should be based on how well supported it is by a community

Having community support is a useful plus, but surely the selection of a micro (indeed, anything) should be on whether it will do the job better than something else. The availability of a ton of code written by someone else is just one factor, and not necessarily the most important.
 

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: FAT32 getting started
« Reply #8 on: October 25, 2020, 02:09:10 pm »
I attatched a 20x4 LCD, and write hex adress and hex data values 4 in 1 row like this : 00000000 00 00 00 00

If i read the bootsector ( 512 bytes ), it has only some values at the end, it has the 0x55 and 0xAA, and before that some more.
The rest all zeros.

The size in use after formatting is 2K, i overwritten 4 blocks and the card is still working in windows.
btw : i dont know if it matters, i format it with the SD to USB converter from my 3D-printer.

It is formatted FAT32, if i look in those library codes, it gives "invalid card" if the "bytes per sector" reads zero.
« Last Edit: October 25, 2020, 02:14:15 pm by Jan Audio »
 

Online Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6266
  • Country: fi
    • My home page and email address
Re: FAT32 getting started
« Reply #9 on: October 25, 2020, 03:06:20 pm »
Apologies for inserting Linux in this discussion, but if one just writes data to the SD card sequentially without any file system, it is rather easy to read in Linux: you can treat the block device as a file, and read it directly.  All you need to do is make sure you have the necessary privileges to do so.  (I can show a privileged "opener" written in C, though, that simply verifies the first 512 bytes have an acceptable fingerprint, and if so, pass the descriptor (file handle) back to a normal, unprivileged program, so they can treat the entire device as a single file.  This is safe, and only requires that you leave the first write block intact, containing a fingerprint that does not match any existing filesystem or partition table structure.  (I recommend some initial and final bytes, plus the rest as ASCII text explaining the format.)  It can be used in conjunction with e.g. Graphical User Interface written in Python3 and Qt5, for portability.)

Unfortunately, I do not know of any way to do the equivalent in Windows.

For Linux users, it means you do not need the overhead of any file system, as long as you have a way to determine the beginning and ending of data.  One method I have used, is to have a 64-bit monotonically increasing generation counter in every block (whatever block size you use to write to the device), and use the blocks on the device in sequential order.  In general, it does mean you need to "initialize" the device to all zeroes, unless it is already sufficiently initialized (all counters zeros – it can be easily, albeit slowly, verified).

On a device with N blocks, you then only need to read 2 + log2 N or so blocks, to find the most recent or oldest block.  On a 8 GB SD card with 512 byte sectors/blocks, or 16,777,216 sectors, this means you only need to read 26 sectors to find the oldest or newest block; and when oldest and newest blocks are known, all other blocks are directly accessible without searching.  So, it is quite fast and efficient, too.  All this is easily written in library form – especially if you have a fixed structure for each block, say containing fixed-size records, or variable-sized records that do not cross a block boundary –, much easier than any filesystem driver.
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 6783
  • Country: pl
Re: FAT32 getting started
« Reply #10 on: October 25, 2020, 03:38:15 pm »
You optimally "initialize" an SD card by erasing it with a special command, though I'm not sure if it's guaranteed whether the result will be all 0x00 or all 0xff or perhaps something else. It tends to be all 0x00 IME.
 

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: FAT32 getting started
« Reply #11 on: October 25, 2020, 03:49:20 pm »
I need those "bytes per sector".
 

Online Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6266
  • Country: fi
    • My home page and email address
Re: FAT32 getting started
« Reply #12 on: October 25, 2020, 03:54:34 pm »
You optimally "initialize" an SD card by erasing it with a special command, though I'm not sure if it's guaranteed whether the result will be all 0x00 or all 0xff or perhaps something else. It tends to be all 0x00 IME.
Yeah, CMD38, but issuing it is nontrivial. All zeros or all ones works fine, as long as both 0 and 264-1 are considered invalid generation numbers.  A mix (0xFF00..) is technically not allowed, but one can fiddle a bit with the generation counter to avoid any of the eight bytes ever having zero or one.  It makes the math a bit slower on 8-bit MCUs, though.  So, just writing all zeros to the SD card is easier, but takes a while.  One can optimize that a bit by only clearing sectors whose eight first bytes are nonzero or non-264-1.

I need those "bytes per sector".
What do you mean?  Using a generation counter per block written is at most 1.5625% overhead (8 bytes out of every 512 byte sector; 0.2% at 8 bytes per 4096 byte block), which is definitely less than using any filesystem.
 

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: FAT32 getting started
« Reply #13 on: October 25, 2020, 04:30:58 pm »
What do you mean?  Using a generation counter per block written is at most 1.5625% overhead (8 bytes out of every 512 byte sector; 0.2% at 8 bytes per 4096 byte block), which is definitely less than using any filesystem.

Talk about What do you mean?, now you got me confused.
Should i ignore the bytespersector and use 512 ?
Should i ignore the whole bootsector and only validate 0x55 and 0xAA ?
I dont think it works.
 

Online Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6266
  • Country: fi
    • My home page and email address
Re: FAT32 getting started
« Reply #14 on: October 25, 2020, 05:59:37 pm »
Talk about What do you mean?, now you got me confused.
Since you didn't quote the message you answered, I assumed you were responding to me.

I now see you were continuing your previous post, i.e.
I attatched a 20x4 LCD, and write hex adress and hex data values 4 in 1 row like this : 00000000 00 00 00 00

If i read the bootsector ( 512 bytes ), it has only some values at the end, it has the 0x55 and 0xAA, and before that some more.
The rest all zeros.

The size in use after formatting is 2K, i overwritten 4 blocks and the card is still working in windows.
btw : i dont know if it matters, i format it with the SD to USB converter from my 3D-printer.

It is formatted FAT32, if i look in those library codes, it gives "invalid card" if the "bytes per sector" reads zero.
I need those "bytes per sector".

There are two layers here.  One is the physical layer at which the SecureDigital card works.  The other is the filesystem layer, FAT32 in your case.

At the hardware level, when writing to a SD cards, you write in 512-byte aligned blocks.  This is often called a physical sector, because back when storage media had spinning disks, the smallest unit they could read and write was a physical sector (or more properly, a circular arc on the rotating media), usually also 512 bytes.  (Nowadays hard drives with 4096 byte sectors are common, though; and on solid-state media like Flash, things are more complicated.)

At the filesystem level, FAT32 specifies a logical sector size.  This is is a power of two, and at least 512.
FAT32 also specifies a cluster size.  This is a power of two multiple of the logical sector size.

The typical logical sector sizes are 512 and 4096.  The cluster size varies, but 32768 is most common.  You can set either or both when formatting the filesystem, or let the utility implement some heuristic.  Either way, these two numbers are described in the file system boot sector.

I don't know about Windows tools, but in Linux, if I want to find them out, I connect the media (via an USB card reader for SD cards), and then run sudo umount /dev/partition && sudo fsck.ext -nv /dev/partition, which tells me stuff like
Code: [Select]
fsck.fat 4.1 (2017-01-24)
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "MSDOS5.0"
Media byte 0xf8 (hard disk)
       512 bytes per logical sector
     16384 bytes per cluster
     16448 reserved sectors
First FAT starts at byte 8421376 (sector 16448)
         2 FATs, 32 bit entries
   7577600 bytes per FAT (= 14800 sectors)
Root directory start at cluster 2 (arbitrary size)
Data area starts at byte 23576576 (sector 46048)
   1892901 data clusters (31013289984 bytes)
128 sectors/track, 63 heads
      8064 hidden sectors
  60618880 sectors total
Checking for unused clusters.
Checking free cluster summary.
/dev/sda1: 1064 files, 57794/1892901 clusters
which tells me that this is FAT32 with 512 bytes per logical sector, and 32768 bytes (64 logical sectors) per cluster.  The smallest block this FAT32 filesystem uses is therefore 32768 bytes; even a 1-byte file will reserve 32768 bytes on the media.

Hope this clarifies things a bit.
 

Online Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6266
  • Country: fi
    • My home page and email address
Re: FAT32 getting started
« Reply #15 on: October 25, 2020, 06:12:09 pm »
What I was telling above, was that when the SD card data is collated using a Linux machine, it is easy to not have any kind of filesystem on it at all, as in Linux you can read the entire SD card as if it was a single continuous file.

Of course, it won't mount, so you won't be able to see its contents on the desktop, but you can write simple tools in C, C++, Python, etc. that let the user examine and export the data to ordinary files – XML and CSV formats are very common.  There are Python modules for exporting the data in other file formats, like Excel or OpenOffice/LibreOffice, or PDF.  Essentially, this moves the complexity from the microcontroller to the management utilities on a computer.

The only "issue" in Linux (and *BSDs) is the permission model.  Ordinary users do not normally have direct access to the block devices, mounted or not.  For this, I have developed a privileged, secure C helper, that examines the underlying block device, and if it looks (has initial/final sector contents matching specific pattern which is not a normal filesystem or partition table, i.e. specifically designed for use with microcontrollers), passes the open file descriptor, file handle, back to the unprivileged ordinary program.  This relies on Unix domain sockets, and passing file descriptors over such a socket, as specified in the POSIX.1 standard.  Basically all except Windows is enough POSIXy today so that the basic idea works.

Note that this is also secure: the unprivileged program does not have privileged access to anything else.  It has access only to the verified-safe-to-access SD card or USB memory stick or whatever media has the correct "signature".

Unfortunately, I have no idea how you would do anything like this in Windows.  I know it is possible in Macs, but I am not familiar enough with Mac OS access restrictions to say for sure whether my C program would work there as well as it does in Linux, or whether it would need some Mac-specific additions; I'd need to check it on a Mac development machine first.  I also have no idea whether Microsoft WSL supports such access at all, because I haven't used Windows in over a decade.  I just don't know.
« Last Edit: October 25, 2020, 06:14:04 pm by Nominal Animal »
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26907
  • Country: nl
    • NCT Developments
Re: FAT32 getting started
« Reply #16 on: October 25, 2020, 11:38:05 pm »
Don't bother writing your own FAT implementation. I've used this one in several projects:
http://elm-chan.org/fsw/ff/00index_e.html

It can be tailored to include more or less features depending on what you need versus the amount of flash space you have.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 
The following users thanked this post: PlainName

Offline ucanel

  • Regular Contributor
  • *
  • Posts: 134
  • Country: tr
Re: FAT32 getting started
« Reply #17 on: October 26, 2020, 10:33:40 am »
Can you open sd card with pc Winhex Hxd and add the screenshot of boot sector,
so we may check it for you.
Maybe you are doing something wrong,
BPS information is two bytes long and located at boot sector 0x0C,0x0B
 

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: FAT32 getting started
« Reply #18 on: October 26, 2020, 02:28:12 pm »
All the sudden it works.
I wrote all zeros to the card, then formatted,
after formatting i found a valid boot sector.

Now i can get started with the fun part.

Don't bother writing your own FAT implementation. I've used this one in several projects:
http://elm-chan.org/fsw/ff/00index_e.html

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

Yes i have that and i find it unreadable.
I be using that for inspiration a bit if i,m stuck.
 

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: FAT32 getting started
« Reply #19 on: October 26, 2020, 02:33:07 pm »
My version allows block to write smaller then 512 ( useless with only 1 SPI port, only i plan reading parallel data )
End of the week i be writing my file, else i be posting here.
 

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: FAT32 getting started
« Reply #20 on: October 28, 2020, 02:26:46 pm »
I found the root folder, that was easy.
Now i have the file.

All i have to do now is search for how it handles free clusters, my file is bigger then 1 cluster.
 

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: FAT32 getting started
« Reply #21 on: October 31, 2020, 03:38:38 pm »
All done, it was really simple, i took a few shortcuts.

Read boot-sector.
Find fatsize.
Find root-directory.
I filled a file text with the ammount of bytes i am writing.
Then look up in the FAT for the next cluster in the file.
 

Online coppercone2

  • Super Contributor
  • ***
  • Posts: 9467
  • Country: us
  • $
Re: FAT32 getting started
« Reply #22 on: January 18, 2024, 05:29:19 am »
is it possible to make a fat128?

I don't like how they make these marketing names like ORANGE and HAMMER2 that have nothing to do with computer things
« Last Edit: January 18, 2024, 05:33:57 am by coppercone2 »
 

Offline vinayak

  • Newbie
  • Posts: 4
  • Country: in
    • NA
Re: FAT32 getting started
« Reply #23 on: January 18, 2024, 05:38:26 am »
hi Jan audio,

Could you please provide the code which you have written for implementing the FAT32.

Regards,
Vinayak
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 290
  • Country: zm
Re: FAT32 getting started
« Reply #24 on: January 18, 2024, 08:55:40 am »
You didnt really say exactly which pic you are using , but maybe this will help
https://simple-circuit.com/pic18f46k22-sd-card-fat32-mikroc/


darkspr1te
« Last Edit: January 23, 2024, 06:23:54 am by darkspr1te »
 

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: 9954
  • 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: 3712
  • 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: 391
  • 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: 9954
  • 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: 3915
  • 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: 3712
  • 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: 9954
  • 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

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14489
  • 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: 391
  • 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: 3915
  • 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

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14489
  • 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: 21698
  • 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: 6848
  • 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: 3915
  • 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: 6848
  • 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