ALTERA_SDCARD(4)

πŸ’– ALTERA_SDCARD πŸ’–

okay bestie, welcome to the altera_sdcard page from the Kernel Interfaces Manual (that's the manual name btw, it's giving Very Serious Kernel Business ✨). sit down, grab a snack, we're talking about a driver for the Altera University Program Secure Data Card IP Core. yes that's a whole mouthful. we'll get through it together 🫢


✨ NAME ✨

altera_sdcard β€” driver for the Altera University Program Secure Data Card IP Core

no cap, that's literally it. the whole vibe. πŸ’…


🌸 SYNOPSIS 🌸

device altera_sdcard

and in /boot/device.hints:

hint.altera_sdcardc.0.at="nexus0"
hint.altera_sdcardc.0.maddr=0x7f008000
hint.altera_sdcardc.0.msize=0x400

so that's the kernel config line and the three hint lines, copied exactly, don't you dare typo them πŸ™ˆ


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so the altera_sdcard device driver provides support for the Altera University Program Secure Data Card (SD Card) IP Core device. it's a whole thing.

a controller device, altera_sdcardcX, will be attached during boot. iconic behaviour honestly.

inserted disks are presented as disk(9) devices, altera_sdcardX, corresponding to the controller number. so like, controller number goes in, disk number comes out, that's the math πŸ’«


πŸ”₯ HARDWARE πŸ”₯

the current version of the altera_sdcard driver supports the SD Card IP core as described in the August 2011 version of Altera's documentation. (yes, the August 2011 version, we're being specific here.)

the core supports only cards up to 2G (CSD 0). larger cards, or cards using newer CSD versions, will not be detected. so if you're out here with a big card wondering why nothing's happening... that's why bestie, it's not you, it's the CSD version 😭

the IP core has two key limitations, and I need you to sit with both of them:

  1. a lack of interrupt support, requiring timer-driven polling to detect I/O completion
  2. support for only single 512-byte block read and write operations at a time

the combined effect of those two limits is that the system clock rate, HZ, must be set to at least 200 in order to accomplish the maximum 100KB/s data rate supported by the IP core. periodt. don't fight the math. πŸ’…


πŸ’œ SEE ALSO πŸ’œ

  • disk(9)
  • Altera University Program Secure Data Card IP Core, Altera Corporation - University Program, ftp://ftp.altera.com/up/pub/Altera_Material/11.0/University_Program_IP_Cores/Memory/SD_Card_Interface_for_SoPC_Builder.pdf, August 2011.

that PDF link is real and it's long, copy it carefully, iykyk πŸ“„βœ¨


🌈 HISTORY 🌈

the altera_sdcard device driver first appeared in FreeBSD 10.0. a debut era, honestly πŸ‘‘


πŸŽ€ AUTHORS πŸŽ€

the altera_sdcard device driver and this manual page were developed by SRI International and the University of Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) (β€œCTSRD”), as part of the DARPA CRASH research programme.

this device driver was written by Robert N. M. Watson.

shoutout to the whole research programme, we love a collaborative slay 🫢


πŸ’€ BUGS πŸ’€

okay this is the part where we get real. altera_sdcard contains a number of work-arounds for IP core bugs. like, several. buckle up.

perhaps most critically, altera_sdcard ignores the CRC error bit returned in the RR1 register, which appears to be unexpectedly set by the IP core. yeah. we're just... ignoring it. on purpose. because the core is being weird about it πŸ™ˆ

altera_sdcard uses fixed polling intervals are used for card insertion/removal and I/O completion detection β€” an adaptive strategy might improve performance by reducing the latency to detecting completed I/O. however, in our experiments, using polling rates greater than 200 times a second did not improve performance. so like, we tried, bestie. we really did. πŸ“‰

altera_sdcard supports only a nexus bus attachment, which is appropriate for system-on-chip busses such as Altera's Avalon bus. if the IP core is configured off of another bus type, then additional bus attachments will be required. not a bug so much as a "you're gonna have to build more stuff" situation πŸ’…

real talk though: that CRC error bit thing? it's a work-around, not a flex. the driver is choosing to ignore it because the IP core sets it when it shouldn't. don't read this as "CRC errors are fine," read it as "the hardware is lying to us and we've made peace with that." 😭

and that's the whole page bestie!! this was the ALTERA_SDCARD(4) page, straight out of the Debian-flavoured Kernel Interfaces Manual, dated August 18, 2012 (yes, a whole 2012 moment πŸ•°οΈβœ¨). go forth and slay your SoC bus attachments, mwah πŸ’–πŸ’…πŸ¦‹

πŸ“¦ where this page comes from