When we think of an m.2 slot in our laptop or similar, it’s usually in the context of its PCI connectivity for high-speed applications such as solid state disks. It’s a connector that offers much more than that interface though, making it suitable for some unexpected add-ons. As an example [MagicWolfi] has produced an m.2 card which contains the equivalent of a Raspberry Pi Pico.
The board itself has the familiar m.2 edge connector at the bottom, and the RP2040 GPIO lines as postage-stamp indentations round the edges. On the m.2 front is uses the USB interface as well as a UART and the I2C lines, as well as some of the interfaces we’re less familiar with such as ALERT, WAKE, DISABLE1/2, LED 1/2, and VENDOR_DEFINED.
On one level this provides a handy internal microcontroller card with which you can do all the things you’d expect from a Pi Pico, but on another it provides the fascinating possibility of the Pico performing a watchdog or other function for the host device. We would be genuinely interested to hear more about the use of the m.2 slot in this way.
If you’d like to know more about m.2, we’ve taken a look at it in more depth.
The M.2 connector has an issue that is becoming increasingly more common.
It started with USB in a small way, then PCI, USB-C expanded it and M.2 inherited it somewhat.
What is it, what device can I plug in there?
With USB you had the 2.0/3.0 issue, with USB-C you have an issue of is that a master or slave device, if it’s for power only what voltage and current rating is it? PCI you might have what looks like a PCIe4x16 slot only to find it offers x8 or PCIe3.0x4.
Now M.2 is the worst offender. A, B, M, E, B+M, A + E.
I often have no idea if an M.2 device will work with an M.2 connector hosting device because of all this.
I know the situation was not much better with parrallel ports, but it does appear to be getting worse.
Case in point, the Coral Tensor M.2 accelerator can be purchased with A+E keying or B+M….
M.2 is vastly better than USB-C as it at least has a keying that identifies when there is a major difference in connectivity offered, and I’ve never seen a device that doesn’t tell you clearly what keying it offers when they are not pre-populated.
You do need to know which keying you have but once you do two compatible devices will plug into each other, and almost certainly work. Where USB-C it will always plug in, but after that…
Specific big issue: SSDs
Now every adapter has to specify whether they support sata or NVMe, and almost none support both, because the protocols and requirements for what the USB bridge chip must implement are completely different.
Really this should have been solved by never having M.2 SATA. For desktops nobody bought the more expensive M.2 SATA drives, and for space constrained laptops mSATA would have been absolutely fine if for some reason the slot couldn’t possibly be wired to support NVMe.
We apparently can’t just have clean breaks between electrical protocols indicated by a connector change anymore, we have to have a compatible physical change and then at some point in the future mysteriously drop compatibility with the old stuff.
Imagine if the early PCIe slots also supported PCI 32-bit 33MHz signalling, just over the PCIe connector. It would have been absurd. You lose compatibility with your old cards by the physical change and the electrical compatibility doesn’t really even help you, it just means any of your cards might potentially be using a crap old protocol. That’s pretty much the M.2 SSD situation.
USB has something similar, but it at least has a valid reason for electrical compatibility because you can use a dongle and keep your old devices. That makes it worth it.
Fortunately the M.2 SSD thing is mostly resolved now since NVMe is so widely adopted. I made it easier on myself by never ever buying a M.2 SATA drive, just NVMe.
It seems like there was an attempt to cleanly key M.2 SSDs, and it failed
So, M key is NVMe
M+B Key is SATA
except, NVMe with PCIe x2 lanes uses M+B Key
WHY???
M-key is supposed to provide 4 lanes of PCIe; M+B only specifies 2.
If M+B were actually smaller; the way it is with the full size PCIe edge connectors, the existence of a separate keying for 2-lane would probably make a lot more sense.
As it is, I have to grudgingly prefer(as long as they at least document it somewhere) the vendors who just M-key everything even if they are providing less than 4 lanes. At least then it all fits; and it seems to be the fairly rare PCIe device that will literally fall over and refuse to work if given fewer lanes than it wants. Devices that are actually bottlenecked on the PCIe side will certainly work slower if you cut their lane count; but, especially if you are on some kind of budget, a lot of SSDs will basically only show you your PCIe speed for a moment while the cache fills and then fall off pretty sharply; so I’d rather have everything just fit than have an M+B that I am forever forbidden from using an M-key in even if I’m OK with taking the hit on bandwidth.
Big freaking deal… this is hackaday and you are complaining that you haven’t even bothered to read the manual to determine which drives your devices ports support.
We got a mad lad here. The information is ALWAYS handed to you on a silver platter about this things and yet you still complain?
Also you must be dealing with some old devices if you have SATA only ports because that’s pretty rare these days on Mobos or laptops. Anything new is usually NVMe capable.
If nothing else you’d surely agree that colour coding M.2 would help? Maybe A – white, E – green and A+E checkerboard of white and green? Etc.
Huh? The most common ~10gbit usb m.2 enclosures use controller chips that definitely support both – the RTL9210B for instance is here https://www.realtek.com/Product/Index?id=4075
I’ve got an enclosure that has either that or a similar chip, and as far as I remember the 16G sata drive I got for testing did work in it.
It could be different with the thunderbolt or usb4 ones, maybe?
There are definitely some M.2 slots that lie(M-key that isn’t actually 4 PCIe lanes seems to be a really common one; and often a helpful one since 4 lane PCIe devices will almost always fall back gracefully to 1 or 2 lanes, while if they use B+M to honestly express that you are only getting two lanes your M-key SSD will be mechanically incompatible); but the can-muddle-through is aided be the fact that power isn’t really on the table(it’s always ‘not much’ and explicitly for powering the card rather than the host device) and there’s no aux mode behavior: it’s much closer to the non-C USBs where there are several variously ugly connectors; but if it fits you’ll find at least USB 1.1 on the 4 pins and at least somewhat oversubscribed 5Gb/s USB3 on the additional pins if present; along with some bus power. No assurances whatsoever about things like UASP or ‘USB3.2 Gen2’ or the like.
That said, part of the ‘standardization’ of the standard seems to have been achieved by neglect. A-key mentions 4x DP among its provided interfaces. I can only assume that someone had a pet use case involving M.2 GPUs or video processing; I’ve not been able to find a whisper of such a thing in the wild.
E-key includes some stuff(UART, PCM, SDIO) that sounds like they were to accommodate the CDC/softmodem daughter cards of that future where we still connected laptops to copper telephone lines; instead we mostly seem to have A+E; with wifi on either PCIe or CNVio because intel just won’t give it a rest with their dodgy alternate networking expansion things; and bluetooth on USB).
SATA was far less obscure; so there are plenty of historical examples; but it’s becoming much less relevant whether a specific board is actually providing a SATA port to every B, M, and B+M slot(as well as more likely that any lies will now be SATA-free PCIe slots rather than PCIe-less SATA-only slots; and SATA 2280s are mostly historical at this point).
I don’t even know what “Future Memory Interface” is, aside from references to M.2 keyings that indicate the F-key was supposed to indicate it.
If M.2 was actually supposed to be everything to everyone(particularly if more use cases demanded standardization of signals from the daughtercard to be routed outward(like A-key’s DP; which nobody ever seemed to actually try) rather than running RF and whatever little pigtails from the daughtercard directly) I suspect that it would turn into a bit of a mess; but as it is it’s mostly converged into “that cellular one that can talk to a SIM slot on the motherboard somewhere”, “the wifi and bluetooth one with PCIe and USB” and “4xPCIe but smaller”; which, means that you just don’t run into most of the complexity most of the time.
I did say ‘almost certainly work’ with that PCIe element in mind when I said it. Still a vast improvement on USB-C where the result is almost certainly WILL NOT work (at least when you are actually using anything beyond USB2 only stuff).
And didn’t say it was a perfect standard by any stretch – but the keying is almost always used correctly as far as I can see, and thus nearly always means if it looks like it it actually is compatible, at least enough to function – way way better than USB-C where everything looks identical, but not every port can do every function the device should do, no ports are ever labelled, and even when you have the right ports on both end it still won’t work as the cables are frequently incapable as well…
No disagreement here. My point was not to argue with you; just to emphasize how the development of M.2 seems to have followed the path of becoming less confused over time; while USB went the opposite way.
M.2 vs the nonsense of mini-PCIe and ‘mSATA’ doing totally different things electrically was a clear improvement; and (if only because of territorial considerations vs. the datacenter guys, not necessarily because of good sense; some things that might have been awkwardly rammed into M.2 were handled in U.2, EDSFF, or OCP NIC form factors) and then the actual market implementation of M.2 has mostly followed a path toward less complexity since. A-key could have led to some real weirdness; but I’ve not been able to find a single reference to an actual A-key device. Pure E-key softmodems were clearly intended, based on PCM audio and UART support along with CNVio on the same keying; but that was more or less a legacy requirement by the time it was codified; and all the actual networking cards seem to be A+E.
There were a few obnoxious abuses of M and B+M back when SATA SSDs were still contenders(not super common; but I ran into at least a handful of cases where they only ran SATA to a connector, back when SATA connections were still easier to come by than PCIe lanes; plus some, less irksome now that PCIe NVMe is priced as well or better, that didn’t run SATA to some ports that theoretically had it); but that’s quickly aging out of relevance. Hopefully B+M will just be replaced by M key entirely; since even half-populated M-key is at least the mechanically more versatile one; and PCIe devices are pretty good at working on fewer lanes if they have to.
USB, by contrast, basically never saw a use case it didn’t want to pick up. It wasn’t necessarily the most elegant thing going; but hard to hate back when it was gunning for all the various random mouse and keyboard interfaces and so on. Then USB2 gave it useful-enough speed for basic mass storage stuff while basically retaining the other features. Then USB 3 was a totally different signaling mechanism, over different wiring, just sort of awkwardly bolted on in parallel; Then type-C, which is a trifle on the delicate side but not as fugly as some of the USB3 connectors; but now a single port can be anything from USB2 and a trickle of power to 40Gb/s of something that isn’t even USB, plus USB sideband, plus 230w of power in either direction; and you just can’t be all things to all people when some of the things include features like “cheap” and “simple”.
I’m not sure if it’s a matter of being an internal bus that helped; if M.2 had the ‘Enterprise’ guys carefully pushing back on anything that seemed too ambitious because they wanted it for a server standard; or if the PCIe SIG and the USB IF just have markedly different senses of taste.
Don’t forget that m.2 is Inside a device as well. Aka, if you are going to open up and add anything in there, you should probably check first what the thing is and what your goals are by adding stuff. There are some cases where you already have stuff but mostly you will be buying the thing you want to add.
But USB-c otoh.. is external. You are not buying a thing to fit just that contact, you most likely have the thing and want it to also work with that contact!
i don’t think i’ve had this problem with usb yet, though obviously in the world of power delivery there is tremendous variety (i don’t mind fallback-mode phone charging, i guess).
with m.2 though, i do the same thing as with DVI. i look at the picture of what i’m buying and compare the notches :)
Doesn’t work with USB-C though, and sadly that is becoming the only port many devices come with. As USB-C is full of a billion alt-modes, lots of devices that will require voltages and currents not everything supplies to work, many of the alternate uses are not available on every port, and for good measure it comes in a bonkers array of connection speeds now. Which then all leads to needing extra special cables to hand the data speeds and charge rates. But for all of it the connectors and cables look identical…
I’m slightly confused by the caselated edges on 3 sides – Aren’t m2 slots usually internal, or only exposing the opposite edge to the connector? Am I missing something? Or is this intended to be used in some kind of extension cable like a dev board?
The project page says:
“Externally, +3.3 V, GND, the SWD interface and 16 IOs are accessible on castellated pins. A footprint for a QWIIC connector is on the top side of the board, not populated to have the board as low profile as possible.”
Looks like a fairly pragmatic response to M.2s being forced into two mostly different niches at this point. If you actually want one to fit in a laptop you need to stick fairly close to the spec and verify any excursions you do wish to make happen to work in your case; while you often see M.2 slots with comparatively enormous amounts of clearance on the Z axis, and at least some on either side, on desktop boards.
It would be a pity to just bury all the I/O that doesn’t correspond to M.2 pins or which can’t be easily broken out onto connectors within the confines of the actually-fits-in-laptops-expecting-spec-compliance board size and height limits; but the shipping configuration appears to have been designed to make taking advantage of the extra space for more stuff if you have it relatively simple; should you be doing a desktop board or an internally cavernous laptop.
the specific project i was envisioning for my pico is an hdmi cec interface for my nuc. the nuc itself happens to have an exposed header for the CEC serial line. so i was going to have the pico like taped to the back of the nuc using an external usb connector, with a wire going inside to connect to that header. but if i had this device, i think i might be able to replace the (unused) m2 wifi board with the pico, and just solder a wire from this castellated board edge to that header.
just depends on how much extra space there is inside your laptop..
so anyways it seemed useful right off to me :)
(my project didn’t happen for 3 different reasons)
Sparkfun have a whole range of M2 products, the MicroMod series:
https://www.sparkfun.com/micromod
They produced a specification for the pin out so that third party vendors can produce boards compatible with their range of carriers.
That appears to be something using the m.2 connector, not something compatible with the m.2 standards
100%. I got very excited by that product line, then very sad.
Okay, I’ve got an empty M.2 slot in my laptop which should have USB on it (2, I assume). If I want to develop an M.2 card for it, I have a few concerns. For one, this is a device I am going to embed into my laptop–I’m not keen on removing the bottom lid and removing it or pressing a button from time to time. So, the board must be completely controllable from the host.
To that end, I would think a good power controlling hub would be a good start. That would allow me to power cycle any devices attached to it. The target uC would be one port on the hub. A USB<>serial would be another as that’s almost always needed. Another port for whatever programmer the target uses (it may be possible to combine this with other ports). Finally a simple uC for GPIO which can interact with and control the target device.
For example, the target could need reset while powered on (in case you wouldn’t want to use the USB hub to power cycle the target) you could use the other micro’s GPIO. The micros could be connected together with similar ports to test the targets ability to use the ports.
Clearly I’m thinking for of a ‘bring up a new micro’ rather than something like an arduino where the tasks are more “do something with the micro itself”.
This is sounding like a fun project.
It looks like there’s some platform-specific behavior(the wonderful world of PCIe resets looks particularly muddy); but at least in some cases the host should be able to just reset the peripheral in software.
Wouldn’t surprise me to find a laptop where someone saved 2 cents by just not including the power switching and protection that external ports are supposed to get on an internal one that was only ever intended to support the factory-installed wifi/BT card; or implemented power control through some wacky vendor specific nonsense that ACPI-quirks may or may not be aware of since they thought of it as being the airplane mode/RF disable key combo rather than a standardized but not terribly user-visible bus level function; but in principle it looks like there’s some bus-level ability to reset peripherals without taking down the entire computer; especially for USB where things getting hotplugged or jostled and ending up in some horrible brownout state the first boot or two is pretty normal.
That’s one of the reasons I would want a good hub on the board that supports power control–because I don’t trust the host to be able to power down the whole thing in case that’s needed.
can’t you power cycle it by suspending your laptop :)
I work in secure areas, so the WiFi card must be removed from any laptop. This left an M.2 slot empty.
Sadly, the only thing I can think of for the slot, is a floating point coprocessor.
Using decimal64 / decimal128 notation.
And to implement THAT in hardware, I’d need an FPGA rather than a Pi Pico.
DSP.
SATA ssds were needed back when Win 7 was around. It didn’t have NVME support in its install.
Depending on the capabilities it could be used as a secondary AV device for the system that monitored and backed up the UEFI and other critical system partitions. If it had the capability.
I’d like to see a raspberry pi with an edge connector. With the usb and stuff slotting on to that to provide io
Don’t need external connections? don’t add them, want a slimline form factor? only have 2 usb. Want a different case, route the usb where you want. Want usb3 ? Just add it (maybe? Don’t know if it’s just mechanical differences)
Also seems like you could unify the compute module with the raspi proper.
It would add some cost to a default raspi board setup. But it could be reused if you have multiple boards. And who has just one raspi?
How about an M.2 board that provides a lights-out management platform for a NUC with a spare E-keyed slot. I’d love to have something that can power the host on/off and provide a KVM interface via IP.
A lot of hacking happen at the network interface level via UDP/TCP payloads. I wonder if the attention gets to these “internal” interfaces and more friendly way of accessing them appear, what would researchers uncover…
Kind of scary IMHO.
One issue to be aware of with M.2 style sockets is that the connectors typically have low (less than 50) mating cycles. This can be problematic if you need to frequently re-socket the board. It’s also problematic in production if you need to program and test a lot of m.2 boards.