[HN Gopher] Petit Fat File System Module
       ___________________________________________________________________
        
       Petit Fat File System Module
        
       Author : elvis70
       Score  : 85 points
       Date   : 2020-10-13 15:27 UTC (7 hours ago)
        
 (HTM) web link (elm-chan.org)
 (TXT) w3m dump (elm-chan.org)
        
       | halayli wrote:
       | Been checking elm-chan since 1999/2000 when I implemented his mp3
       | player using atmel.
       | 
       | I admire his consistency.
        
       | andyjpb wrote:
       | I've been using this recently and, because it doesn't ever modify
       | the file system structures, you don't have to worry about
       | unmounting the volume cleanly.
       | 
       | It can write to files, but it can't create or resize them. For
       | that (and more), you want FatFs, the full featured version:
       | http://elm-chan.org/fsw/ff/00index_e.html
       | 
       | elm-chan has also written an AVR bootloader that can update the
       | flash from, for example, an SDCard. It uses this Petit FAT File
       | System Module and requires a 4K bootloader section (so mostly of
       | use on the ATMega1284).
        
       | howerj wrote:
       | I have noticed there are quite a few FAT-32 implementations out
       | there, but none that do what I want. Ideally what I want is
       | something that would do the following; allow the creation of a
       | new FAT-32 image file of a specified length given a target
       | directory.
       | 
       | The program (or programs/scripts) must be command line driven and
       | run under both Windows and Linux (so they can be integrated into
       | our build system).
       | 
       | The use case is the following; the creation of a single binary
       | image containing some firmware and a (per-unit) custom FAT-32
       | partition, both of which would effectively concatenated together.
       | 
       | Does anyone have any ideas? Otherwise I might have to make
       | something myself.
        
         | a1369209993 wrote:
         | > allow the creation of a new FAT-32 image file _of a specified
         | length_ given a target directory [emphasis added]
         | 
         | I think that's your problem: file systems are supposed to go
         | onto a preexisting block device, which you'll need to create
         | seperately. For example, on my system:                 dd
         | if=/dev/zero of=/tmp/foo.dos bs=512 count=128K       mkdosfs -F
         | 32 /tmp/foo.dos
         | 
         | Once you've created the filesystem, fill it with:
         | mkdir /tmp/foo/       sudo mount -t msdos -o loop /tmp/foo.dos
         | /tmp/foo/       # dump stuff into /tmp/foo/       sudo umount
         | /tmp/foo.dos # or /tmp/foo/       # filesystem is in
         | /tmp/foo.dos
        
         | ptspts wrote:
         | mtools, containing the mformat and mcopy tools.
        
           | any1 wrote:
           | There's also genimage [1] which uses mtools for FAT, but it
           | can also do ext2 and more.
           | 
           | [1] https://github.com/pengutronix/genimage
        
           | howerj wrote:
           | That looks like it might work, thank you. My search did not
           | find this.
        
           | jaclaz wrote:
           | +1
           | 
           | The mtools/mformat are not AFAIK released pre-built for
           | Windows, in case of need here is a build:
           | 
           | http://reboot.pro/topic/14354-buidlingmodifying-floppy-
           | image...
           | 
           | Syntax/option for mformat are a bit complex, again in case of
           | need here is a small batch that hopefuly makes commands
           | clearer:
           | 
           | http://reboot.pro/topic/21664-makeiso/page-4#entry205455
        
         | koolba wrote:
         | I can't speak for Windows, but on any *nix OS you can do this
         | with a loop back device. You'd have to determining in advance
         | and likely round up a bit. But it's a literally a couple line
         | shell script.
        
           | shawnz wrote:
           | On Windows you could create and mount a VHD file and format
           | it as FAT32 by using the diskpart utility, with the commands
           | "create vdisk", "attach vdisk", and "format"
        
           | howerj wrote:
           | Yeah, it is easy to do, but only on Unixen, the dev
           | environment I am working on is primarily run under Windows
           | (and also maybe Linux in the future).
        
             | m463 wrote:
             | WSL / WSL2 might be one answer
        
         | kevin_thibedeau wrote:
         | You can adapt FatFS to do this. You just have to implement a
         | few low level I/O routines to work using an conventional file
         | as a fake block device.
        
       | morio wrote:
       | Why does the author not just put it on github/gitlab/... instead
       | of only offering a .zip? It's 2020 last time I checked.
        
         | panic wrote:
         | If it's that onerous to download the zip, maybe we should build
         | a tool to browse .zip/.tgz source links instead of pressuring
         | everyone to centralize all source code on the planet into just
         | two web sites.
        
           | tom_ wrote:
           | Wait, what's the other one that isn't GitHub? Sounds like we
           | need to start working on the people still putting their stuff
           | there!
        
         | SahAssar wrote:
         | Not everyone wants to work that way, and having a public git as
         | a requirement is ridiculous. The software is FOSS, why are you
         | complaining?
        
           | morio wrote:
           | Never said it should be a requirement. But downloading a .zip
           | file from a site which does not have a valid SSL certificate
           | nor supports SSL in the first place does not instill
           | confidence. Software security is a thing.
        
             | SahAssar wrote:
             | Agreed about the SSL/TLS, but the comment sounded more like
             | not having a public git was the complaint.
        
       | cbluth wrote:
       | this link doesnt work
        
         | theamk wrote:
         | Works for me?
         | 
         | > Petit FatFs is a sub-set of FatFs module for tiny 8-bit
         | microcontrollers. It is written in compliance with ANSI C and
         | completely separated from the disk I/O layer. It can be
         | incorporated into the tiny microcontrollers with limited memory
         | even if the RAM size is less than sector size.
        
         | vosper wrote:
         | Works fine for me - maybe it has intermittent errors?
        
         | morio wrote:
         | The site does not have a valid SSL certificate. Some browsers
         | will block it.
        
         | hinkley wrote:
         | If it wasn't hugged to death before, it definitely is now. 403
         | errors for this path and for /
        
         | grawprog wrote:
         | Works fine for me.
         | 
         | >Petit FatFs is a sub-set of FatFs module for tiny 8-bit
         | microcontrollers. It is written in compliance with ANSI C and
         | completely separated from the disk I/O layer. It can be
         | incorporated into the tiny microcontrollers with limited memory
         | even if the RAM size is less than sector size. Also full
         | featured FAT file system module is available here.
         | 
         | http://elm-chan.org/fsw/ff/00index_e.html
         | 
         | >Features Very small RAM consumption (44 bytes work area +
         | certain stack). Very small code size (2K-4K bytes). FAT12,
         | FAT16 and FAT32. Single volume and Single file. Streaming file
         | read. File write function with some restrictions.
        
       | arcadian33 wrote:
       | PetitFatFS was handy in a recent build. I was creating a box that
       | could be placed on marine equipment to collect vibrations data,
       | but to capture the modes of interest it had to read accelerometer
       | data and write it to a microSD card at >=660[Hz]. I don't have a
       | programming background and thus had trouble creating code which
       | fit onto the tiny memory of the microcontroller being used.
       | PetitFatFS worked beautifully, and saved a ton of headache on my
       | end. It added the step of creating the storage files on the
       | microSD card prior to inserting it, but that was acceptable for
       | this project.
        
       | sgtnoodle wrote:
       | I recently did a search for embedded fat implementations, and
       | this one stood out well above the rest.
        
       | nom wrote:
       | Ah ELM. I always try to urge everyone interested in low-level
       | embedded systems engineering to browse elm-chan.org, it's such a
       | treasure trove.
       | 
       | He describes himself as "Mediocre embedded system engineer" but
       | he is way too humble, the skill he shows is so incredible that I
       | often find myself speechless whenever I look at his projects.
       | 
       | Go there, look around and recommend it to everyone. You will not
       | regret it.
        
         | rkagerer wrote:
         | Agreed. Anyone know how to get in touch with him? I used his
         | audio player code, found some bugs, and want to give him the
         | fixes. Tried the email listed on his Profile page, but never
         | heard back.
         | 
         | ChaN, if you're out there:
         | 
         | https://i.imgur.com/E8Z29VE.png
         | 
         | The original code fails to load WAV's containing metadata -
         | even though an intent to tolerate them appears written into
         | some of the handlers (DISP, LIST FCC, etc). I can provide files
         | from Audacity which reproduce the issue.
         | 
         | Moved remaining details here to avoid boring the HN audience:
         | https://pastebin.com/raw/XdneQ8xh
        
       ___________________________________________________________________
       (page generated 2020-10-13 23:00 UTC)