M.2 For Hackers – Expand Your Laptop

You’ve seen M.2 cards in modern laptops already. If you’re buying an SSD today, it’s most likely an M.2 one. Many of our laptops contain M.2 WiFi cards, the consumer-oriented WWAN cards now come in M.2, and every now and then we see M.2 cards that defy our expectations. Nowadays, using M.2 is one of the most viable ways for adding new features to your laptop. I have found that the M.2 standard is quite accessible and also very hackable, and I would like to demonstrate that to you.

If you ever searched the Web trying to understand what makes M.2 tick, you might’ve found one of the many confusing articles which just transcribe stuff out of the M.2 specification PDF, and make things look more complicated than they actually are. Let’s instead look at M.2 real-world use. Today, I’ll show you the M.2 devices you will encounter in the wild, and teach you what you need to know to make use of them. In part 2, I will show you how to build your own M.2 cards and card-accepting devices, too!

Well Thought-Out, Mostly

You can genuinely appreciate the M.2 standard once you start looking into it, especially if you have worked with mPCIe devices for some amount of time. mPCIe is what we’ve been using for all these years, and it gradually became a mish-mash of hardly-compatible pinouts. As manufacturers thought up all kinds of devices they could embed, you’d find hacks like mSATA and WWAN coexistence extensions, and the lack of standardization is noticeable in things like mPCIe WWAN modems as soon as you need something like UART or PCM. The M.2 specification, thankfully, accounted for all of these lessons.

The M.2 standard is designed with real-world usecases in mind and defines as many pins as possible, making sure that same-purpose cards from different manufacturers can be substituted for one another. It’s split into different keyings that each serve a purpose – like storage-oriented, WWAN, WiFi and other purpose keyings. Each keying defines a pinout for a group of interfaces like PCIe, USB 2.0 or 3.0, SATA, I2C, DisplayPort and so on. Most of these interfaces are, naturally, quite tasty for a hacker.

Neither a card nor a socket is required to support all interfaces defined in the keying’s pinout, or any particular interface. This makes sense if you design systems – a lot of interfaces defined are situational or expensive. However, of course, it can cause confusion of the “it fits, but doesn’t work” kind. For instance, a B+M key SATA SSD will not work in some NVMe-only M-key sockets, and some proprietary standards like CNVi throw a wrench into the “any M.2 WiFi card will work with your laptop” concept.

Some M.2 cards might look flippable, but they’re not

However, in real-world use, there’s anchors you can rely on – if you see a M-key, A-key or E-key slot, it has PCIe, if you see a B-key slot, A-key or E-key slot, it has USB 2.0; and if you have schematics or a few M.2 devices on hand, you can quickly test compatibility of any particular slot. There’s also I2C SDA and SCL pins defined in all keyings, but whether they’re connected to anything at all is a 50/50 chance, apparently dependent on the phase of the moon of the exact day when your laptop mainboard was designed.

B+M? The M.2 standard allows combining keys on cards, letting a card fit into two different types of socket and increasing compatibility of your card. There are two combinations you will see – B+M and A+E, used for SSDs and WiFi cards respectively, and the B, M, A and E key pinouts are designed around these two combinations being possible. You lose on some of the optional features, but the crucial stuff like PCIe remains accessible. As an aside, while it might feel like you can insert a B+M SSD flipped upside down if you apply enough force, or push an M-key card into a B-key socket, not only it will not work, you will reverse the input voltage polarity and there might be fiery consequences. Even given these few hiccups, M.2 is way more reasonable and powerful than mPCIe ever could be.

A Stick Of Solid-State

Two B+M SSDs – one SATA and one NVMe through 2x PCIe link

Undoubtably most popular are M.2 SSDs. They’re either SATA, or NVMe – the latter is a storage interface using PCIe as its physical layer. We’ve talked about NVMe internals in depth, feel free to check that out. SATA SSDs usually use B+M keying – some are B-key only, but it’s rare. NVMe SSDs usually use M-key, some using a combination of B+M and thus being limited to 2 PCIe lanes, you’ll see it with cheaper SSDs.

An SSD can only support one of these standards – never both. It might be hard to figure out which one, so if there’s no NVMe or SATA logo on the label, look the model number up. If you have the SSD in hand or got some higher-resolution pictures, look at the number of differential pairs. If there’s only two of them, it’s SATA; if there’s three, five or nine of them, it’s NVMe. Statistically, you’re way more likely to see NVMe SSDs, as they’re getting more and more abundant.

An M-key or B-key port might support either both of them or only one of them. On the B and M pinouts, there’s a pin defined to distinguish between PCIe and SATA SSDs, and if a host supports both standards, it will switch between them automatically. With some laptops, it might be hard to tell if an M.2 SATA SSD would be supported – in contrast, NVMe is a safe bet, as it’s is hardly ever non-supported. And, if you have a simple external adapter that has only a PCIe connector or a SATA connector, it will only support that type of SSD.

All The Ways To Do WiFi

M.2 WiFi uses A or E keyings – most WiFi cards you will see will use a combined A+E keying, and sockets used to be A-key but nowadays E-key is the rule. You get an 1x PCIe link and USB 2.0 , with former used for actual WiFi and latter used for Bluetooth. On both A and E keys, you can get a second PCIe 1x link – not lane, link! – but it’s rare to see sockets that wire it up, hence it’s hard to find hosts for cards like this Google Coral Dual TPU Accelerator. Compared to mPCIe, the antenna connectors are no longer uFL – they’re MHF3, also known as wFL, so it might be that you’ll need some new antenna hardware.

Not all embedded WiFi cards run PCIe, of course – the E-key pinout also accounts for SDIO WiFi cards. SDIO is an embeddable interface used mostly for SD cards and WiFi chip connections – for instance, on boards like the Raspberry Pi. A few cards and adapters have been seen out there using E-key, having the yet-uninitiated hackers raise eyebrows. Given how easy it is to design your own M.2 cards, hopefully we could see M.2 SDIO WiFi cards become more popular one day – maybe then, Pine64 will no longer design weird WiFi modules.

half-sized WiFi card on top, 1216 M.2 WiFi module on the bottom

It’s rare to see pure E-key or A-key cards – one of the exceptions, CNVi, uses E-key, and it’s not the good kind of exception. It’s an Intel-only proprietary M.2-derived interface that lets the chipset do most of the WiFi work that used to be done on the PCIe WiFi cards. Not only do these cursed M.2 WiFi cards not work with AMD processors or older laptops, there are two versions of CNVi and they have neither backwards nor forwards compatibility, resulting in user confusion, extra expenses, and e-waste. There’s one tentative upside – slots usually wire up both CNVi and PCIe+USB2, so you can theoretically use a CNVi card, then get yourself extra internal PCIe and USB links for your hacking purposes.

There are two somewhat wacky WiFi card form-factors you might encounter. First of all, there’s this fun-sized E-key WiFi card – made possible because large portion of the pinout is unused by default. Going even more fun-sized but not necessarily as fun, you might’ve seen these small shielded soldered-on modules in ultrabooks. This, too, is M.2 form-factor, called 1216. It’s solderable and hence not as easily upgradeable, but with a pre-defined pinout all the same. Sadly, these modules also come in CNVi variety – on the upside, it’s not like you’re going to be swapping these cards often.

Go Worldwide With B-Key

Project-ready USB 4G modems for cheap

If you need a cheap USB-connected 4G modem with decent Linux support in your project, you won’t go wrong with getting a used M.2 B-key modem, typically coming in 3042 form-factorm, so 30 mm wide. A lot of these cards got manufactured for laptops with WWAN connectivity, and the second-hand market has them for ultra low prices. Most of them are USB 2.0, with some USB 3.0 cards available – for either, you can find USB-plug-equipped breakouts online, and there’s some homebrew open-source breakouts out there as well.

These go into B-key slots on laptops – out of all M.2 slots available, these are the most “wild west” ones, in that you can only really rely on USB 2.0 being present – everything else highly varies. The standard defines quite a few other features – some B-key slots have extra SATA, some have extra PCIe, some have both SATA and PCIe switchable by the same PCIe/SATA config pin M-key SSDs use. Sometimes there’s USB 3.0 too, but no guarantee. You will definitely have USB 2.0 for your modem, but for any other devices like SSDs, you’ll have to google your laptop’s model number with “can I put SSD in B-key slot” inquiries.

Sadly, if your laptop didn’t actually come with a WWAN option, not only the WWAN antennas might be absent, but the on-mainboard B-key socket might not be soldered either – it’s a bizarre and frustrating assembly choice to face and it hampers upgradability, but it’s nothing we haven’t seen done with mPCIe, I guess. On the upside, if you do have a B-key slot, you don’t have to limit yourself by SSDs and WWAN cards – for instance, here’s an open-source USB 2.0-connected RP2040-based M.2 expansion card by [Timonsku], likely to be a fun upgrade for your laptop!

M.2: Evolving, Ever-Present, Here To Stay

Some parts of the M.2 standard are fading into obscurity, and are no longer accessible on laptops out there – if they’ve ever been in the first place. If you want to go down a rabbithole, the M.2 Electromechanical Specification Rev1.0 document can be found online, and you can learn a lot from its 201 pages. For instance, you will find that the F-key is reserved for some obscure thing called Future Memory Interface, no doubt a shelved Intel project only described on some Blogspot page that’s not even indexed by Google anymore.

For more real-world but no less fun parts, there was a standard called WiGig, and some ThinkPads exposed a DisplayPort link on the A-key WiFi slot for that – along with actually making use of the second PCIe link on the A-key I mentioned above. Apparently, you could have wireless laptop docks, with DisplayPort and USB3.0 connectivity bringing you a ton of devices without a cable in sight. There’s some interesting pictures of WiGig dock internals out there – the in-dock receiver hardware is actually a M.2 G-key card itself. You can even find the in-dock cards on eBay, as a piece of somewhat recent computing peripheral history.

You will find M.2 basically everywhere. It has plenty of hidden potential, and if we ever need to tap into that, it helps that you learn how it’s used out there in the wild. Even if you’re never going to design a M.2 card, now you know how to tell SATA and NVMe M.2 SSDs apart, and why pushing a B-key 4G card into your M-key SSD slot will not result in anything good. In the next article, I’ll show you how to design a M.2 card or put a M.2 socket on your own board, too!

55 thoughts on “M.2 For Hackers – Expand Your Laptop

  1. I find myself somewhat unfortunate that I have a thinkpad from the generation when the m2 slots were the most neutered ever.
    Not only is it one generation too early for DP in the m2 slot, they also removed sata from the wwan slot, which was available in the previous generations.

    1. I got that T-400 which seeeeeems to have 3 slots, one for wifi, one for intel turbomem if equipped and one for cellular modem…. but haven’t found much about using anything else in them. Some say it’s not enough lines hooked up, some say it’s BIOS whitelist problems.

      1. I had a MPC Transport T2500 (rebranded Samsung X65). It had a Turbo Memory slot for that useless module, but the slot also had USB 2.0 so I got an adapter and plugged in a very small 128 gig USB 2.0 thumb drive to have a bit more internal storage.

        The laptop was very nice, quite high end. But for some reason Samsung chose to give it a CardBus slot instead of ExpressCard – in 2008! I would have kept that laptop quite a while longer if I’d been able to plug a USB 3.0 card in.

      2. IIRC the third slot was supposed to be for USB Wireless, but that one never gained traction. Some Thinkpads of that era don’t even have the 3rd mPCIe socket soldered on the system board.

        The BIOS whitelist can be removed, allowing you to install other cards–WiFi AC, etc.

    2. I’m on the T460 myself, I found that there is a NVMe x2 link in the “SATA” connector and a sled from a t470 that can attach a normal m.2 NVMe drive. Its been working well for me.

      I don’t think it is U.2 compatible, I think I tried an adapter for that. But the idea is similar, more pins on a SATA socket for PCIe lanes.

      Also rumour of an unsoldered m.2 header on the backside of the t560 that may work if populated and some resistors for the PCIe link pairs.

    3. 01HY319 is the T470 ‘SATA’ to m.2 sled part number

      DC02C007K20 is the ‘SATA’ cable that supports PCIe links.

      1.6G/s throughput. Better than SATA and lets you use cheaper storage units. $12 for a 256gb Kioxia BG40 is my record.

        1. correct, however its not an electrical or software limitation, its a physical proximity issue to the charge regulator (which gets very hot)

          a double sided M2 comes into direct contact with said regulator, and prevents it from cooling.

          1. I will check again, but the charge regulator interferes with extra long 42mm NVMe drives. Not 30mm as it is supplied with. The Wifi solution is under the m.2 slot. I am not sure if it interferes with double side drives.

        2. It really looks like they wanted to leave steamdeck removable controllers or the option for a console version on the table with the design.

          Otherwise they could have flipped the drive out off the end of the board like many laptops do, out into the right handgrip area. May have been enough room for 2242 2260 and 2280 drives. Although I’m not sure if an extension adapter couldn’t enable that as well.

    1. They’ve had a noticeably huge hole that Jim used to fill, for a few years now, regarding computer technology.

      I know Dan tries, really. But his reporting is almost always on security issues and vulnerabilities, not enough about computer technology itself. In his articles, he often comes across like a frustrated Windows-only user who just copies what he reads, and does not truly understand what he’s read, instead of digesting it, then presenting a clear explanation of what’s going on to the reader. Like Jim used to do. He WAY over-uses the terms “hacker” (in a negative way, ALWAYS) and “malicious actor” in his articles. He often leaves it to commenters to figure out: who does this affect, what should system admins and/or users do, what software/hardware does this affect, etc.? All usually figured and spelled out by the intelligent commenters, thankfully still present on Ars.

      Sometimes the other staff have to chip in, and write the articles that Jim would’ve written, and they do about as well as you’d expect a substitute writer: passable once or twice, but not the type of writing you want to see consistently.

      If you’re out there Jim, some of us sorely miss you. <3

    1. Do you just need to mount a socket to the pcb footprint?

      I added an nvme socket to a crappy chromebook that I bought that came without it. (Lenovo 14w)
      I had to buy an unbranded connector from Taobao through some reseller, and soldering was… interesting… but I was able to install a 32gb optane drive and add an entry to boot from NVME without issue.

      It will likely not get much more than a new drive because the CPU is painfully slow for much beyond web browsing but it has been working great for 2 years now.

  2. Indeed, I like M.2 on paper at least. The chip shortage shelved all the projects I had in mind that would have used M.2 interfaces but it seems like a good dense pin array that specs pretty much every contemporary and actually occurring in the real world IO style in some keying or other. And perhaps more importantly lots of devices with M.2 keying are starting to be available, along with the adapter board to turn it into just another PCIe etc for those devices that don’t.

    Not sold it will really endure the way PCIe spec has done with great backwards compatibility, though as currently almost everything you may wish to interface is available with USB or PCIe and both signals exist on M.2 maybe it does have a great deal of legs.

      1. I got a ThinkMod NVMe to expresscard with an SD card reader for Clover bootloader. I know its only x1 PCIe, but I can swap my drive from my x230 to my P71, and T430, T530 etc etc. Its pretty nice. I might even try my Core2 ‘toughbook’ that sports expresscard and PC card, (and a HDD heater ;)

        1. I do so love a toughbook, but more importantly thanks to telling me something exists I didn’t know about – I had no idea anybody had made express card NVMe converters. I may just have to get one for my toughbooks (maybe two) – I traded in the tiny SSD my best Toughbook came with for a more high capacity 2.5″ as I really needed the space. Being able to get an SSD for the boot disk as well is going to be great – not like machine of that age are going to notice the lack of extra PCI-e lanes, its still faster than their original disk most likely, at the very least comparable throughput with much faster seek..

  3. was an early adopter of m.2. mostly because i was getting fed up with sata cables randomly deciding to stop working. boot and your drives are missing. and usually the fix is to reseat or replace the cable. once is acceptable, once a month is not. i tried high quality cables but that didn’t improve the situation much. then one day i was shopping for computer parts and a new connector appears. and henceforth i was able to banish all drives and drive cabling from my builds. now the only drives i own reside in the nas and was able to adopt small form factor cases.

    the early days were confusing but i think the nvme standard catalyzed the final form to the point where you dont really have think about keying when you buy a drive. you do have to check the mobo manual to figure out if an m.2 slot has any pcie lanes or not and what gen they are. my current mobo has a gen3 and 4 slot, so i use the fast drive for boot/software and the slower one for data.

  4. Take care with PCIe to NVME adapters! I had two HP T5745 thin clients killed by them. I installed the PCIe expansion chassis, which worked perfectly with a PCIe x1 eSATA card and a 500 gig external drive.

    I wanted to change to an NVME 1TB internal so I bought a generic PCIe x4 adapter, installed it, hit the power and… nothing. Call the computer coroner, it’s dead. I tried the x4 adapter in an older desktop, an MPC ClientPro. It refused to boot with the adapter installed, with or without the SSD.

    I’d also bought an x1 adapter, tried it in the T5745. Not working. Tried the x1 adapter in the ClientPro. It works.

    So I tossed the x4 adapter out and bought another T5745. I tested it alone, with the Apacer SATA DOM, RAM etc. Working fine. Installed the PCIe expansion. Still fine.

    Plugged in the x1 NVME adapter and *poof*. Exactly as dead as the other one. The x1 adapter still works in other PCs.

    To head off any dumb remarks… I DID NOT PLUG THE PCIe ADAPTERS DIRECTLY INTO THE T5745’S EXPANSION SLOT ON ITS MAINBOARD. Every time I’ve posted about this somewhere, some numpty who refuses to *read every word* pops off with that. The expansion kit comes with a choice of a 32bit PCI slot or an x16 PCIe slot that’s only connected up as x4.

    So how can a garden variety PCie device that works fine in other PCs insta-kill a specific model of HP thin client, that works with other garden variety PCIe devices without dying?

    I’ve been looking for someone in the USA to ship the lot off to, to investigate how/why this model of thin client is deathly allergic to PCIe NVME adapters, and possibly fix and keep the two plus the one expansion kit.

    So I gave up on having a T5745 with 1TB internal SSD for an Open Media Vault 5 server and got a 2011 Mac Mini into which I installed a dual hard drive kit. The only issue with that was OMV’s power management settings were unable to stop the thing from going to sleep, so a configuration change at the terminal was required to disable sleep in Debian. Didn’t have that issue with the T5745. The Mac Mini is overkill for simply serving HEVC video files via DLNA for client devices to play using their own software.

  5. i was excited to read this article but found it far too jargony to enjoy. in such articles, a little effort must be expended to define terms, even simple ones like “keys” and what the various letter names of the keys signify. otherwise it comes across as a big useless wank. sorry, but that’s my take

    1. I recommend you ask specifically about the things you didn’t get! A connector “key” is a widespread term – it’s a piece of plastic that only lets the connector be inserted in a certain way, and M.2 defines a bunch of different positions that the key could be in – referred to as “keying”, with the aforementioned group of interfaces available and a pinout, and the very first picture in the intro demonstrates how a key looks. The letter names are just, letters from one side of the connector to the other side, as the consequent picture demonstrates.

  6. Documenting this standard is cool (though I am not sure if this text was really that clear…), but I can’t really see and application when it comes to laptops. As general interface between cards possibly, but to insert it as extension into a laptop, which would have to be permanently, as you need to undo so many screws, I don’t really see where that would come in handy.

    One a tower PC it makes more sense since you have room to fit things into it, and maybe could add more external sockets, such as to make your own soundcard. But with a laptop it would have to be a selfcontained system, so mostly about compute.

    I can’t see anything I would like to fit inside there permanently that is just about compute, as it’s unlikely I can make anything as powerful as will be done with an ASIC.

    Or maybe you could make your own fake drive, based on a simple FPGA that connects over USB/M.2, a drive that gets wiped again, each time you power off, to give other users a temporary space if they want to use your laptop.

    Or something for a VM. Yes, you could add a credit card sized computer, like a raspberry pi zero, and then switch to it for banking or other security relevant purposes.

    Integration would make sense, as you could use virtualization to assign reroute signals maybe to the screen. Not sure exactly how this could be done, but virtualization techniques may make it possible.

    So it would be really your computer in a computer, in a way, your very own private and under your control computer. As opposed to IME or TPM and all those other systems that can take over control over your computer.

    If anybody has cool ideas, I am open to hear them, because currently I can’t see many (especially ones reasonably easy to realize).

    1. The other thing I could see is to use M.2 as an alternative to the compute module connectors of the Raspberry Pi compute modules/breakout boards for the CMs.

      But so far the Raspi standard seems to be more established for hackers.

      1. Since I can’t edit the comment, Hackaday has posted about the compute module in the past ( 2020/10/19/new-raspberry-pi-4-compute-module-so-long-so-dimm-hello-pcie/ ). The connector that works mechanically similar to M.2 (at least in laptops) was SO-DIMM (like for RAM).

        The new connectors of the CM 4 are: Hirose DF40C-100DS-0.4V, which are essentially high density and high speed connector, which allow to stack boards similar to how hats (raspberry pi)/shields(arduino) work mechanically.

        So M.2 would be a more standardized approach of the SO-DIMM connector trick.

  7. Good to mention that M.2 isn’t just limited to SSDs and WiFi cards. I’ve got a tiny HDMI capture card from Magewell that captures 2 channels of 1080p60 video. I installed it in an Asrock Deskmini Mini-STX computer, and made the cutest streaming capable machine.

  8. This may be slightly off-topic, but I figured it might be the right place to ask: I’m trying to figure out a way to convert a male microPCIe to a male M.2 M-Key, which is basically the reverse of what the adapter pictured on the very top in the title-image of this article does – anyone got any lead? Is it even possible?

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.