Design Your Own Raspberry Pi Compute Module PCB

91,549

268

55

Introduction: Design Your Own Raspberry Pi Compute Module PCB

About: I'm an electronic and computer engineer. Web development and electronics design is what I mostly do, but I do enjoy working on personal projects that involve electronics but also 3D printing. And if it happens…

If you’ve never heard of the Raspberry Pi Compute Module before, it’s basically a fully fledged Linux computer with the form factor a laptop RAM stick!

With it becomes possible to design your own custom boards where the Raspberry Pi is just another component. That gives you an enormous amount of flexibility as it allows you to have access to a much greater amount of IO pins, while the same time you get to choose exactly what hardware you want on your board. The on-board eMMC also eliminates the need for an external micro SD card, which makes the Compute Module perfect for designing Raspberry Pi based products.

Unfortunately, while the Compute Module allows you to do all this it still appears to be lacking in terms of popularity compared to the traditional Raspberry Pi Model A and B. As a result, there aren’t many open source hardware projects out there based on it. And for anyone who might want to get started with designing their own boards the amount of resources they have is rather limited.

When I first got started with the Raspberry Pi Compute Module a few months ago, that was exactly the issue I was faced with. So, I decided to do something about it. I decided to design an open source PCB based on the Compute Module, that is going to have all the basic features that make the Raspberry Pi great. That includes a camera connector, USB host, audio output, HDMI and of course a GPIO header compatible with the regular Raspberry Pi boards.

The goal of this project is to provide an open source design for a Compute Module based board, that anyone will be able to use as a starting point for designing their own custom board. The board was designed on KiCAD, an open source and cross platform EDA software package, in order to allow as many people as possible to take advantage of it.

Simply grab the design files, adapt them to your needs and spin your own custom board for your project.

Step 1: Parts and Tools

To get started with the Raspberry Pi Compute Module you are going to need the following parts:

1 x Raspberry Pi Compute Module 3 - I highly recommend getting the regular version which includes the on-board eMMC and not the Lite version. If you want to use the Lite version in your project you’ll have to make a few changes to the design, and that includes adding a micro SD card connector. Finally, I have only tested the board with the CM3 and I cannot guarantee that it will work with the first CM version that was released back in 2014.

Update 29/1/2019:
It appears that the Foundation has just released the Compute Module 3+ and not only that, but now it also comes with the option for an 8GB, 16GB or 32GB eMMC! According to the datasheet, it appears that the CM3+ is electrical identical to the CM3 which means that it’s basically a drop in replacement for the CM3.

1 x Compute Module IO Board - My design was intended to serve as a starting point for designing your own custom board based on it, not to be replacement for the Compute Module IO board. So, to make your life easier I highly recommend getting your hands to an IO board and use that for development before moving to a custom board. Apart from giving you access to every single pin of the CM plus a variety of connectors, the IO board is also needed for flashing the on-board eMMC. Which is something that you cannot do with my board, unless you do some changes to the design first.

1 x Raspberry Pi Zero Camera Cable or Compute Module Camera Adapter - On my design I’m using a very similar camera connector to the one used by the Compute Module IO Board and the Raspberry Pi Zero. So, in order to attach a camera you're either going to need an adapter cable designed for the Pi Zero or the camera adapter board that comes together with the Compute Module Development Kit. As far as I know, purchasing the adapter board separately is quite expensive. So, if you like me decided to buy your CM and IO Board separately to save some money, I advise you to get the camera adapter cable designed for the Pi Zero instead.

1 x Raspberry Pi Camera Module - I have only tested the board with the original 5MP camera module and not the newer 8MP version. But since the former appears to be working just fine I see no reason the later wouldn’t as it is supposed to be backwards compatible. Either way, the 5MP version can be found for less than 5€ on eBay nowadays which is why I’d recommend getting one.

4 x Female to Female Jumper Wires - You are going to need at least 4 for configuring the camera connector on the IO board, you’ll likely want to get more though. They aren’t needed for the custom board but can be useful if you plan attaching any external hardware via the GPIO header.

1 x HDMI Cable - I decided to use a full size HDMI connector on my board to eliminate the need for adapters. Of course, if you prefer using a mini or even a micro HDMI connector feel free to adapt the design to your needs.

1 x 5V Micro USB Power Supply - Your phone charger should probably do just fine for most cases as long as it can provide at least 1A. Keep in mind that this is just a general value, your actually power requirements are going to depend on the hardware you decide to include on your custom board.

1 x USB Ethernet Adapter - If you plan installing or updating pretty much any package on your system, you’re going to need at least temporary Internet access. A 2-in-1 Ethernet adapter plus USB hub is probably a good combo as you only have one USB port available. Personally I use the Edimax EU-4208 which works out of the box with the Pi and doesn't require external power, but it doesn't have a USB hub built in. If you are looking into buying a USB Ethernet adapter here you can find a list with ones that have been tested with the Raspberry Pi.

If you want to add more USB ports and even Etherent directly on your custom board, I’d suggest having a look at the LAN9512 from Microchip. It is the same chip used by the original Raspberry Pi Model B and is going to give you 2 USB ports and 1 Ethernet port. Alternatively, if you need 4 USB ports consider having a look at its cousin LAN9514.

1 x DDR2 SODIMM RAM Connector - This is probably the most important component of the entire board and likely the only one that can't be easily substituted. To save you from the trouble the part that you should get is the TE CONNECTIVITY 1473005-4. It is available from most major suppliers including TME, Mouser and Digikey, so you should have no problem finding it. Be very careful though, double check and make sure that the part you’re ordering is in fact the 1473005-4. Don’t make the same mistake I did and get the mirrored version, these connectors aren’t cheap.

For the rest of the parts that I choose to include on the board you can take a look at the BOM to get more information, I tried to include links to the datasheets for most of them.

Soldering Equipment - The smallest components on the board are the 0402 decoupling capacitors, but the HDMI as well as the camera and the SODIMM connectors can also be a bit challenging without any kind of magnification. If you have good experience with SMD soldering thought it shouldn’t be a big issue. Either way, if you happen to have access to a microscope I highly recommend it.

Step 2: Flashing the EMMC

First thing you need to do before you start using your Compute Module is flashing the latest Raspbian Lite image on the eMMC. The official Raspberry Pi documentation is very well written and describes the whole process in great detail for both Linux and Windows. For that reason I’m only going to describe the steps you need to take very briefly on Linux, so they can serve as a quick reference.

First of all, you need to make sure that you have your IO board set to programming mode and the Compute Module is inserted to the SODIMM connector. To set the board to programming mode move the J4 jumper to the EN position.

Next, you are going to need to build the rpiboot tool on your system so you can use it to obtain access to the eMMC. To do so, you need a copy of the usbboot repository which can be obtained easily using git as follows,

git clone --depth=1 https://github.com/raspberrypi/usbboot && cd usbboot

Now, in order to build rpiboot you need to make sure that both libusb-1.0-0-dev and make packages are installed on your system. So, assuming you’re on a Debian based distro such as Ubuntu run,

sudo apt update && sudo apt install libusb-1.0-0-dev make

If you don't use a Debian based distro the name of the libusb-1.0.0-dev package might be different, so make sure to find how it is called in your case. Once the build dependencies are installed you can build the rpiboot binary simply by running,

make

After the built is complete run rpiboot as root and it will start to wait for a connection,

sudo ./rpiboot

Now plug the IO board to your computer by connecting a micro USB cable to its USB SLAVE port and then apply power to the POWER IN port. After a few seconds the rpiboot should be able to detect the Compute Module and allow you access to the eMMC. That should result to a new block device appearing under /dev. You can use the fdisk program to help you find the name of the device,

sudo fdisk -l
Disk /dev/sdi: 3.7 GiB, 3909091328 bytes, 7634944 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x8e3a9721</p><p>Device     Boot  Start     End Sectors  Size Id Type
/dev/sdi1         8192  137215  129024   63M  c W95 FAT32 (LBA)
/dev/sdi2       137216 7634943 7497728  3.6G 83 Linux

In my case it was /dev/sdi as I have quite a few drives already attached on my system, but yours will most definitely vary.

After you’ve been absolutely sure you have found the correct device name, you can use dd in order to burn the Raspbian Lite image to the eMMC. Before doing that though, make sure that there aren’t any partition of the eMMC already mounted on your system.

df -h

If you find any unmount them as follows,

sudo umount /dev/sdXY

Now be extremely careful, using the wrong device name with dd can potentially destroy your system and cause data loss. Do not proceed with the next step unless you’re completely sure that you know what you’re doing. If you need any more information please have a look at the documentation regarding this.

sudo dd if=<date>-raspbian-stretch-lite.img of=/dev/sdX bs=4M && sync

Once the dd and sync commands finish, you should be able to unplug the IO board from your computer. Finally, don’t forget to move the J4 jumper back to the DIS position and your Compute Module should be ready for its first boot.

Step 3: First Boot

Before booting for the first time make sure to plug a USB keyboard and an HDMI monitor to your IO board. If everything goes as expected and your Pi finishes booting, having them attached will allow you to interact with it.

When you’re prompted to login use "pi" for the username and "raspberry" for the password as these are the default login credentials. You can now run some commands to make sure that everything is working as expected as you’d normally do on any Raspberry Pi, but don’t attempt installing anything yet as you still don’t have an Internet connection.

An important thing you need to do before shutting your Pi down is enabling SSH, so you can connect to it from your computer after the next boot. You can do that very easily using the raspi-config command,

sudo raspi-config

To enable SSH go to Interfacing Options, select SSH, choose YES, OK and Finish. In case you’re asked if you want to reboot decline. After you are done shutdown your Pi and once it finishes remove the power.

sudo shutdown -h now

Next, you need to establish an Internet connection using the USB Ethernet adapter that you should already have. If your adapter also features a USB hub you can use it to plug your keyboard if you like, otherwise you can just connect to your Pi over SSH. Either way, keep the HDMI monitor plugged at least for now, to make sure that the boot process finishes as expected.

Also, near the end it should also show you the IP address that your Pi got from the DHCP server. Try using this to connect to your Pi via SSH.

ssh pi@<ip-address-of-pi>

After successfully connecting to your Pi over SSH you no longer need the monitor and the keyboard plugged in, so feel free to unplug them if you like. At this point you should also have access to the Internet from your Pi, you can try pinging something like google.com to verify it. After making sure that you have access to the Internet it’s a good idea to update the system by running,

sudo apt update && sudo apt upgrade

Step 4: Configuring the Camera

The biggest difference between a regular Raspberry Pi board and the Compute Module is that in the case of the later apart from just enabling the camera by using raspi-config, you also need a custom device tree file.

You can find more information regarding the configuration of the Compute Module for use with a camera in the documentation. But in general, the camera connector among the others also features 4 control pins, which need to be connected to 4 GPIO pins on the Compute Module, and it is up to you to decide which ones while designing your custom board.

In my case, while designing the board I choose CD1_SDA to go to GPIO28, CD1_SCL to GPIO29, CAM1_IO1 to GPIO30 and CAM1_IO0 to GPIO31. I choose these particular GPIO pins as I wanted to have a 40 pin GPIO header on my board, that also maintains compatibility with the GPIO connector of the regular Raspberry Pi boards. And for that reason I had to make sure that the GPIO pins I’m using for the camera don’t also appear in GPIO header.

So, unless you decide to make changes on the wiring of the camera connector, you need a /boot/dt-blob.bin that tells your Pi to configure GPIO28-31 as described above. And in order to generate a dt-blob.bin, which is a binary file, you need a dt-blob.dts to compile. To make things easy I’m going to provide my own dt-blob.dts for you to use which you can then adapt to your needs if you have to.

To compile the device tree file use the device tree compiler as follows,

dtc -I dts -O dtb -o dt-blob.bin dt-blob.dts

I'm not sure why but the above should result to quite a few warnings, but as long as the dt-blob.bin has been generated successfully everything should be fine. Now, move the dt-blob.bin you just generated to /boot by executing,

sudo mv dt-blob.bin /boot/dt-blob.bin

The above will probably give you the following warning,

mv: failed to preserve ownership for '/boot/dt-blob.bin': Operation not permitted

This is just mv complaining that it can’t preserve the file ownership as /boot is a FAT partition which is to be expected. You may have noticed that /boot/dt-blob.bin doesn’t exist by default, this is because the Pi uses a built in device tree instead. Adding your own inside /boot though overrides the built in one and allows you to configure the function of its pin the way you like. You can find more about the device tree in the documentation.

After that is done you need to enable the camera,

sudo raspi-config

Go to Interfacing Options, select Camera, choose YES, OK and Finish. In case you’re asked if you want to reboot decline. Now, shutdown your Pi and remove the power.

After the power has been removed from the IO board, using 4 female to female jumper wires connect the pins for GPIO28 to CD1_SDA, GPIO29 to CD1_SCL, GPIO30 to CAM1_IO1 and GPIO31 to CAM1_IO0. Finally, attach your camera module to the CAM1 connector using the camera adapter board or a camera cable designed for the Raspberry Pi Zero and apply power.

If everything worked as expected after the Pi boots you should be able to utilize the camera. To try to take a picture after connecting to your Pi via SSH run,

raspistill -o test.jpeg

If the command finishes with no errors and a test.jpeg gets created it means that it worked. If you want to have a look at the picture you just took you can connect to your Pi via SFTP and trasfer it to your computer.

sftp pi@<ip-address-of-pi>
sftp> get test.jpeg
sftp> exit

Step 5: Moving From the IO Board to a Custom PCB

Now that you are done with all the basic configuration you can move to designing your own custom board based on the Compute Module. Since this is going to be your first project, I highly encourage you to grab my design and extend it to include any additional hardware you like.

The back of the board has plenty of space for adding your own components and for relatively small projects you likely don’t even have to increase the dimensions of the board. Also, in case this is a standalone project and you don’t need a physical GPIO header on your board, you can easily get rid of it and save some space on the top side of the PCB. The GPIO header is also the only component that is routed through the second inner layer and removing it frees it up completely.

I should point out that I have successfully assembled and tested one of the boards myself, and I have verified that everything including the camera and the HDMI output appears to be working as expected. So, as long as you don’t make any huge changes to the way I’ve routed everything you shouldn’t have any issues.

In case you have to do some big layout changes though, keep in mind that most of the traces that go to the HDMI and camera connectors are routed as 100 Ohm differential pairs. This means that you have to take this into account in case you have to move them around the board. Also, it means that even if you drop the GPIO header from your design, which means that now the internal layers won’t contain any traces, you still need a 4 layer PCB in order to achieve a differential impedance close to 100 Ohm. If you are not going to make use of the HDMI output and the camera though, you should be able to go with a 2 layer board by getting rid of them and cut down the cost of the boards a bit.

Just for reference, the boards were ordered from ALLPCB with a total thickness of 1.6mm and I didn’t ask for impedance control, as it would likely raise the cost quite a bit and I also wanted to see if it would matter. I also selected immersion gold finish to make hand soldering of the connectors easier as it guarantees that all pads are going to be nice and flat.

PCB Contest

Participated in the
PCB Contest

Be the First to Share

    Recommendations

    • Battery Powered Contest

      Battery Powered Contest
    • Plywood Challenge

      Plywood Challenge
    • Plastic Contest

      Plastic Contest

    55 Discussions

    0
    achevezguard
    achevezguard

    2 months ago

    @magkopian, This is a great article! Thank you. Could you provide advice regarding the following questions:

    1. Soldering the SODIMM connector manually is not recommended for its small-size pins. I was looking at JLCPCB to assemble the PCB but they do not have the RAM and the camera/display connectors. Which vendor did you use for assembling it?

    2. I want to include a TFT LCD screen driver on the design, I was thinking of using the "TFP401 HDMI/DVI Decoder to 40-pin TTL" from Adafruit, but I am not sure if there is another better open-source 1280x800 7" TFT screen driver PCB design? Do you have any experience with these ICs, any you could recommend?

    3. I want to include a LIPO charger/boost but I am not able to find a good schematic that can provide an output of 3A@5V to cover the board, screen's power demand, provide overvoltage and other protections. I can only find designs using the TP4056 with an output of 1A@5V. Do you have an idea of how to implement it?

    0
    magkopian
    magkopian

    Reply 2 months ago

    1. As I also explained in the instructable I didn’t send the board to a PCB manufacture to be assembled, I handsoldered everything myself including the SODIMM connector. I do however have quite a few years of experience with SMD soldering, as well as a proper stereo microscope. In the past I have used the assembly services of ALLPCB for different projects at work but not for this. From my experience with that as long as you provide the parts to the company that assembles your boards there should be no issue. And honestly if you want my advice for a commercial product I wouldn’t trust the PCB manufacturer for supplying the parts themselves.

    2. I don’t, but as long as we are talking about something with an HDMI interface I don’t think you would have any problems.

    3. The problem is that you are approaching the issue from the wrong angle, you are looking for a schematic when what should be actually looking is which part you want to use. You need a power output of 5V at 3A which will come from a LiPo battery and you also need the ability to charge the battery. So, you need two things a battery charging IC and a switching regulator. One switching regulator I found from a quick search was TPS61232DRC, you can look the datasheet for an example circuit. Now for the battery charger IC you have plenty of options, and it mostly depends to the maximum charge current you want to have. I think that something like the MCP73833 should be good enough for your project.

    Sorry for the late reply, but I was a bit busy the last few days.

    0
    dragonxtamer596
    dragonxtamer596

    Question 4 months ago

    I know nothing to very little about PCB design, I would however like to learn. Where would I start? Where should I go to get to a point where I can edit this design or make my own? I just want the GPIO, 3.3v pad, ground pad, data + & - two sets if possible.

    0
    magkopian
    magkopian

    Answer 4 months ago

    Well, probably you should start by installing KiCAD and watching a few video tutorials. Start by designing something simple like an LED blinking circuit. Then after you feel confident enough, try designing something useful involving a microcontroller such as an ESP8266 or an ATmega328 and get your board fabricated.

    Truth be told something involving a Raspberry Pi Compute Module isn't exactly a beginner friendly project, but if you keep working on different projects involving custom boards you will get there eventually.

    0
    dragonxtamer596
    dragonxtamer596

    Reply 4 months ago

    Thank you for the advise.

    0
    AmyW174
    AmyW174

    Question 10 months ago

    Hi, for your linear voltage regulators did you use the maximum output of 800mA or 1A? Also, on your PCB why is pin 1 for the camera on the right side instead of the left?

    1
    magkopian
    magkopian

    Answer 10 months ago

    No, the LDOs are not being maxed out. I don’t remember exactly what the worst case was, but I did make some measurements under 100% load when I first built the board and it looked pretty good. Of course depending your application you may wish to replace them with something that can supply more current and/or has better efficiency like a switching regulator.

    If you want an all-in-one solution you may want to have a look at the PAM2306AYPKE which is also used by the Raspberry Pi 3 for generating the 3.3V and 1.8V power rail voltages. Look at the partial schematics for the Pi 3 here for reference. Just keep in mind that the IC is only available in a DFN package, if you decide to use it.

    Regarding your question about the camera connector it’s pretty simple, when I started working on the schematic I wanted the labels of the P3 connector to come out from the right side rather than the left so I mirrored it. As a result, in order for the physical pins to match the pins of the schematic I had to go from the bottom upwards, so when it was the time to create the footprint I had to number the pins from right to left. Eventually I realized this but I had already designed the footprint and didn’t really feel like going back and changing everything.

    0
    zontar902
    zontar902

    Reply 7 months ago

    Hi Magkopian. You did an excellent work, thank you for sharing. I am building a small portable device based on the Pi and I was in doubt wether to pass to the COmpute Module or not. Your work tilted the balance. It's a big step for me, I've even learnt a bit of Kicad just for this, but I think the end result will be more compact and stable. Basically I am just using it so to have a different camera connector and not the unreliable one found on the piZero :)

    Regarding this topic, you are warning a reader that a component is DFN. Have you got any experience with hand soldering these package forms? And generally, did you solder the compos on your PCB all by yourself or did you outsource soldering to ALLPCB? I am worried about small pitch compos, for example a small HDMI connector (in the end I did it but it was a pain) and the 200 pin SODIMM especially..

    Thanks

    0
    magkopian
    magkopian

    Reply 6 months ago

    Sorry for the later reply. There are no DFN packages on the board I designed, PAM2306AYPKE which comes on a DFN package is just a switching regulator that I suggested using if you need an all-in-one solution for generating the power rail voltages. In the board that I designed I'm using LDOs instead which have their own pros and cons but they are pretty easy to solder.

    As for the rest of the components these I had no problem handsoldering, but I do have a proper stereo microscope. I do have quite a few years for experience with SMD soldering so maybe I would be able to solder them with naked eye but the SODIMM connectors aren't exactly cheap so I wasn't gonna risk it.

    0
    roshan7505
    roshan7505

    7 months ago

    Hi magkopian first of all thank you so much for the content. I did not had a idea of customizable raspberry pi.
    I have a question that how can I integrate wifi here

    1
    magkopian
    magkopian

    Reply 7 months ago

    Hi, for adding WiFi you have two options either you include a WiFi module on the design or you use an external USB adapter. If you decide to go for the WiFi module probably the easiest one is using an ESP8266.

    0
    roshan7505
    roshan7505

    Reply 7 months ago

    Thank you for the suggestion. As I wanted smaller modules I'm thinking of ESP-01F or RTL8723BS. But I did not find the libraries/drivers for that yet. If I find it I'll upload it. :)

    0
    janostonda
    janostonda

    Reply 7 months ago

    I would be interested as well but couldn't find detailed information about it. If you go for it, I would be super happy to get the files... Thanks!

    0
    onilx
    onilx

    Question 7 months ago

    Sorry for the Narage of questions. I was wondering if there was any secret sauce to turning the CM3 on other than applying the right voltages to the correct pins. I’m trying to comb through the official documentation and it looks like I’m supposed to engage and then drop the Enable pin... if I just had a bench supply with 5v 3v3 and 1v8, (and an SD card hooked up) could I just get this thing running? (Also with those 4 pull down resistors on the GPIO that need it for some reason)

    0
    magkopian
    magkopian

    Answer 7 months ago

    If you have all the supply voltages come on simultaneously like I do you shouldn't have any problems, it's when you can't do that where you need to take special care with the supply sequencing.

    As for EMMC_DISABLE_N you need to have this pulled high unless you are booting for USB. Here is a the schematic for the official IO board https://www.raspberrypi.org/documentation/hardware..., have on what it says under "MODULE BOOT OPTIONS".

    0
    rgrthtrgr
    rgrthtrgr

    Question 8 months ago

    Hi, this is awesome, thanks for taking the time. I am using your schematics as reference, at this stage im just working on powering the compute module via usb-c. I notice our schematic for the dimm slot is labelled slightly differently, I have pins labelled 2v5 where yours are VDAC (pins 189 and 190), and are connected to 3.3v, could you please explain why? Thanks

    0
    magkopian
    magkopian

    Answer 8 months ago

    If you have a look at the last paragraph of section 9.6 on page 19 of the datasheet for the CM3, it says that when the TVDAC output is not used VDAC can be connected to 3.3V. And since on my design I don't make use of it I did exactly that so I won't have to include an additional 2.5V regulator. Now, if in your design you need the TVDAC output you of course need to connect VDAC to 2.5V.

    0
    rgrthtrgr
    rgrthtrgr

    Reply 8 months ago

    I was not expecting a response so quickly, thanks! I am planning to use an lcd display, but I intend to use a rgb display that I already have, that connects to a regular pi via a 50p ribbon cable to the gpio pins. In this case I don't believe I need TVDAC. Does that sound right to you? (I am a noob).

    Thanks.

    0
    magkopian
    magkopian

    Reply 8 months ago

    Yeah, doesn't sound like you need the TVDAC output. That's if you want to have something like an RCA connector on your board like the original Raspberry Pi Model B had for connecting a TV or something.

    0
    rgrthtrgr
    rgrthtrgr

    Reply 8 months ago

    Hi, I am making a lot of progress, thanks to your help. There are a couple of questions I still have though, if you don't mind.

    1. I am a little confused with usb ports. If I have a single usb port, I can connect the D+ and D- pins directly to the USB_DP and USB_DM port of the pi right? I only need a usb switch (like in the official schematics) if I wanted to use the data pins of two ports? (image attached of my schematic related to usb ports, the image shows a mini-usb wired only for power, and a usb-a port with all pins wired, so I can plug a keyboard in for example). The traces for the data pins must be the same length if I understand correctly?

    2. If I want to force the pi to only boot from an sd card, I apply 3.3v to emmc_disable_N?


    USBPCB.PNG