SD Memory Card Formatter for Linux
sdcard.org
sdcard.org
My world depends on writing TBs of data to micro SD cards in difficult environments right at the limit of write speed. These tools are great but our devices are linux (embedded), so this really is a huge help.
For anyone else out there who needs high performance out of an SD card... fstrim is your friend. Seriously, nothing comes close. Run it regularly when not under load.
mtd is a Linux driver subsystem for accessing raw NAND or NOR flash devices that don't have an SSD's Flash Translation Layer (FTL) in front of them to provide features like wear leveling. It's most commonly encountered in embedded systems.
Thank you for the education.
In some SD cards you can use proprietary magical commands to communicate with the firmware and update it or ask it to mess with the hidden sections for you, but those options aren't exposed to any disk copy tool I know of.
The performance pitfalls are not stated, but I'd guess they're referring to the possibility of using suboptimal file system block sizes or alignment. I wouldn't worry too much about recent tools getting alignment wrong or recent cards being overly sensitive to block sizes.
The official SD tool probably also ensures that it uses the exact filesystem called for by their standards (ie. when to use FAT32 and when to use exFAT), as a guarantee of compatibility with any device that interprets the standards too strictly.
[0]: https://web.archive.org/web/20230405090708/https://3gfp.com/... [1]: https://web.archive.org/web/20230406150117/https://lwn.net/A...
I know someone who worked on a weird SD-Card based "Video Rental" service[1][2] - The idea was that you'd bring your standard consumer SD card to a redbox-like kiosk, load some video onto it, and then be able to play it on their special but standard (integrated into smart tvs by Toshiba et al) video player, which would automatically self-destruct the encryption keys using that secure element.
[1] https://www.engadget.com/2010-12-08-mod-systems-download2go-...
[2] The far more interesting product of this company was all of the weird fraud that their founder was engaged in. https://www.geekwire.com/tag/mod-systems/
Easy to reproduce results is probably what they're going for. If that tool doesn't have much configuration possible, many footguns are prevented.
I don't think they do anything that other formatting tools can't do, but they do make the alignment much easier by defaulting to the right options.
1. NAND in SD cards has page size (minimum writeable piece) something like 4kB or 8KB, or maybe even 64KB. But as per spec SD cards must allow writes at 512 byte granularity. Aligning your file system clusters with these flash pages will allow SIGNIFICANTLY better performance and lower wear. How? Well in the CSD register (accessible using SD commands), the NAND geometry is given, so all it takes is reading that and creating a file system that is properly aligned.
2. Why not just mkfs.vfat? You can, but unless you do some of the above work yourself and some math, you’re unlikely to get the alignment right and will suffer because of it, especially on small or random writes. You CAN do it yourself. Just takes a little work.
3. What about my gopro, my phone, or $DEVICE-X that can format SD cards? Well, most device firmwares DO indeed do this correctly as the SD spec advises to do.
4. Why doesn’t the card just do it in firmware all by itself? Curiously sony memory stick does this. Why not sd? There isn’t a command in the spec for that and adding it now is too late - nobody will use it. Thus we have this tool and ones like it.
5. What is this about the secure area? The tool just says it doesn’t touch it. Almost nobody does. Costs a lot of money to license the SD security stuff. Nobody uses it. It was meant for securing MP3s on cards. Secure area exists on all cards (yes you are paying for flash you cannot use). Luckily it isn’t big. Special commands are used to access it. This tool and basically any device you’ll ever encounter in your everyday life do not use them. Lacking those commands, it is as if the secure area doesn’t exist.
6. Why dont windows/Linux/macOS do it right themselves? My guess? Separation of concerns. The formatting code there only formats a partition. For proper alignment you may need to start the partition on the right block as well. Simple example. Say in your fictional card, we have 4KB pages. That’s 8 512-byte sectors. So we want our first FAT cluster to start at a multiple of 8 (and be a multiple of sectors in size). Say we work out that our various FS Structures need 17 sectors. That means that we need the partition to start at sector 7. Thus we make the MBR do so. Wait! You might say that FAT already has “resevered sectors” value we can use for this. No MBR touching needed. Well, you’d be surprised how many devices/firmwares break with nonstandard values there. Also, what makes you so sure that mkfs.vfat can even find out how many sectors into /dev/sdb, /dev/sdb1 starts, to do the math right? For that matter, what makes you think it would even know to check for SD-card-ness of /dev/sdb?
Is this difficult to obtain (e.g., via ioctl(2)) and parse?
[edit] looks like it's readable from sysfs: https://www.kernel.org/doc/html/latest/driver-api/mmc/mmc-de...
Parsing is another matter. It would be really useful if e.g., parted could read/parse that and then automatically align created partitions!
> SD/SDHC/SDXC Cards have a “Protected Area” for SD Card security purposes. The SD Memory Card Formatter does not format the protected area in the SD/SDHC/SDXC Cards. The protected area shall be formatted by an appropriate PC application or SD host devices that provide SD security function.
[1] Never heard of it and I've erased and recreated partition tables on SD cards multiple times with no "bricking"; maybe it's a feature of cards supplied with "encryption software"?
> Content Protection for Recordable Media (CPRM), the content protection technology used for SD standards, is key to enabling a distribution system for music, video, etc. CPRM provides a high level of protection against illegal copying.
Sounds like someone intended to sell movies on SD cards, replacing DVDs/bluerays.
The "SD Memory Card Formatter for Linux" mentions this non sequitur seemingly to confuse users and cause FUD.
Mod Systems was a Toshiba-funded "Video Rental on SD Cards" startup, whose primary product was a set of bizarre fraud cases.
I'll do the former, as I always have.
By the way, a cool quote from the agreement preceding the download page:
>3. RESTRICTIONS: You agree to NOT: (a) disassemble, reverse engineer, decompile, or otherwise attempt to derive any source code for the SDA Software from executable code;
This should be quite alarming. They insist that we format SD cards with their tool, but they don't want us to know what the tool does.
I will not be the one reversing them, but I checked it is possible to download these through tor, and recommend downloading them that way to prevent potential trouble.
The hashes for the files I obtained are:
SDCardFormatterv1.0.2_Linux_ARM64
MD5: 2CF66295A29C5F496A489074CBC42CFA
SHA1: EE06C0C6834EB9F53E66343A7CFDB95FCCB5FF66
SHA256: 8695A0F441129845136AFEE01D94D6DBCCBE87BA7C904F045F2AF0613F9A1978
SDCardFormatterv1.0.2_Linux_x86_64
MD5: 459A698C3961BACA8103173B3CDA7173
SHA1: C28EFFDF05FF186E56C57476C2794CC7A7AE3AF0
SHA256: 3D961085954ABEB764265184A92C1114AA4CEF9CF12CA3C3337B6B63E0DBE0FB
Depending on where you live, this might have no legal effect. Some jurisdictions allow explicitly for reverse engineering & co. for different purposes (e.g. research, interoperability with other systems, etc.).
Would be an interesting project, I have no idea how you could reprogram them though.
If you want an open source SD card formatter for Linux, you can mkfs.vfat /dev/mmcblk0 all day long, works just fine.
Of course that should apply to all proprietary software accessing SD cards, therefore all phones, all cameras, etc; thankfully, being among the least reliable media out there for carrying files, and less practical than for example a USB connection or dongle, they're often restricted to the same hardware using them, as would be any potential tracking data.
The first SD card I bought just would not work with it no matter what I tried.
Support actually had me download the “SD Memory Card Formatter for Windows” from this site and reformat my card. Did not fix the issue. I ended up just buying a new SD Card which did fix the issue.
At the time it just felt like support was grasping at straws and wasting my time, but sounds like maybe not? Very curious. I have always just formatted my cards with Disk Utility in macOS.
But to download it you have to agree to not do exactly that :(
It would. Most distributions will never ship this, because it is closed source code of questionable usefulness.