Skip to content
You Start with one site
Amounts in Start with one site
Embedded Systems & Electronics · Course

STM32 USB-C Four-Layer

Lesson 4 of 9 24 min read
Made with KiCad 10checked November 2026Newer version?
Stays the same
  • Schematic first, then the board
  • Footprints, nets and design rules
  • Ground planes, return paths and clearances
  • Gerbers and a drill file for the maker
May look different
  • Menu places and hotkeys
  • The look of the plugin and library managers
  • Default design rules
  • Dialog fields (KiCad 10 gave rectangles a corner radius)
  • The Python module: SWIG pcbnew is deprecated in favour of kicad-cli and the IPC API

A step looks different? Most commands have a hotkey listed in Help, then the list of hotkeys.

The ideas in this lesson do not depend on the version. Where a click moved, the lesson still names the command.

Found this useful?

This lesson moves from 2-layer to 4-layer PCB design. You will design a Black Pill style development board around the STM32F411CEU6, a 100 MHz Cortex-M4 with floating point unit, paired with a USB-C connector for power and data. The 4-layer stackup gives you dedicated ground and power planes, which are essential for clean power delivery and impedance-controlled USB routing. #KiCad #STM32 #FourLayerPCB

4-Layer PCB StackupLayer 1 (Top):Signal + ComponentsPrepreg~0.2 mmLayer 2 (Inner 1): GND Plane (solid)Core~1.0 mmLayer 3 (Inner 2): Power Plane (3.3V)Prepreg~0.2 mmLayer 4 (Bottom):Signal + ComponentsTotal: ~1.6 mmGND plane directly below signal tracesprovides low-impedance return path andreduces EMI. Via stitching connectstop and bottom ground areas.

What We Are Building

STM32F411 Black Pill Style Board

A compact USB-C development board built around the STM32F411CEU6 in a UFQFPN-48 package. The board features a dedicated ground plane and power plane on the inner layers, USB 2.0 full-speed with impedance-matched differential pairs, and all GPIO broken out to standard 2.54mm headers. Power comes from USB-C through a low-noise 3.3V LDO.

Board specifications:

ParameterValue
MCUSTM32F411CEU6 (UFQFPN-48, 100 MHz Cortex-M4F)
USBUSB-C connector, USB 2.0 Full-Speed (device only)
Clock25 MHz HSE crystal, 32.768 kHz LSE crystal
PowerUSB-C 5V input, ME6211 3.3V LDO (500 mA, low noise)
DebugSWD header (SWDIO, SWCLK, GND, 3V3, NRST)
User I/O1x user LED (PC13), 1x user button (PA0), GPIO headers
Stackup4-layer: Signal / GND / Power / Signal
Size55 x 20 mm

Bill of Materials

RefComponentPackageQtyNotes
U1STM32F411CEU6UFQFPN-48 (7x7mm)1Exposed pad soldered to GND
U2ME6211C33M5GSOT-23-513.3V 500 mA LDO
Y125 MHz3.2x2.5mm SMD1HSE crystal, 10 pF load
Y232.768 kHz2.0x1.2mm SMD1LSE crystal
J1USB-C receptacleUSB-C 16-pin1Mid-mount or top-mount
USB 2.0 Differential Pair RoutingUSB-C connectorSTM32 USB pinsD+PA12 (D+)D-PA11 (D-)= differential pair (matched length)Rules:- 90 ohm differential impedance- Length match within 0.15 mm-Noviasinthepair- Keep 3x trace width clearancefrom other signals- Ground plane unbroken beneath pair
ReferenceValuePackageQtyFunction
J2SWD header1x5 2.54mm1SWDIO, SWCLK, GND, 3V3, NRST
J3, J4GPIO headers1x20 2.54mm2All I/O pins broken out
C1, C210 pF04022HSE crystal load caps
C3, C46.8 pF04022LSE crystal load caps
C5-C9100 nF04025Decoupling per VDD/VDDA pin
C104.7 µF08051Bulk decoupling
C111 µF04021VCAP1 pin
C12, C1310 µF08052LDO input and output
C14100 nF04021LDO output
R1, R25.1 kΩ04022USB-C CC1, CC2 pull-downs
R31.5 kΩ04021USB D+ pull-up (optional, internal available)
R410 kΩ04021NRST pull-up
R510 kΩ04021BOOT0 pull-down
R6330 Ω04021User LED
D1Green LED04021User LED (PC13)
SW1Tactile switchSMD 3x6mm1User button (PA0)
SW2Tactile switchSMD 3x6mm1Reset
F1500 mA polyfuse08051VBUS protection

Why Four Layers?



In Lessons 1 through 3, you worked with 1-layer and 2-layer boards. Those are fine for low-speed microcontrollers with simple power needs. Once you add USB, faster clocks, or denser pin counts, 4-layer boards become the practical choice.

Dedicated ground plane. Layer 2 is a solid, unbroken copper fill connected to GND. Every signal on Layer 1 has a continuous return path directly beneath it. This dramatically reduces electromagnetic interference (EMI) and crosstalk between traces.

Low-impedance power distribution. Layer 3 carries 3.3V as a solid copper fill. Instead of routing power traces across the board, every component connects to the power plane through a short via. Voltage drops across the board become negligible.

Shorter return paths. When a signal trace on Layer 1 sits directly above the ground plane on Layer 2, the return current flows on the ground plane surface directly underneath the trace. This tight coupling reduces loop area and radiated emissions.

More routing space. With power and ground handled by inner layers, both outer layers are free for signal routing. You rarely need to sacrifice signal integrity by running a power trace between dense pin groups.

Impedance control. USB 2.0 requires 90 ohm differential impedance. Achieving this requires a known, consistent distance between the signal trace and the reference plane. A 4-layer stackup gives you that controlled geometry: trace on Layer 1, ground plane on Layer 2, separated by a well-defined dielectric thickness.

2-Layer vs 4-Layer Comparison

Aspect2-Layer4-Layer
Ground returnRouted traces, broken return pathsSolid plane, continuous return path
Power distributionTraces with voltage dropsLow-impedance plane
EMI performanceHigher emissions, needs careful layoutLower emissions due to tight coupling
Impedance controlDifficult without controlled stackupStraightforward with known prepreg thickness
Routing densityLimited, traces compete with power/GNDHigher, both outer layers free for signals
Cost (5 boards, 50x20mm)~5~15
When to useSimple, low-speed designsUSB, high-speed clocks, dense MCUs

USB-C Basics for Device Mode



USB-C connectors have 24 pins, but for a USB 2.0 device you only use a small subset. The connector is reversible, so it duplicates the D+ and D- pins on both sides (pins A6/A7 and B6/B7). For a simple device, you can connect both pairs together or use just one pair with the other left unconnected (many budget designs do this and it works for USB 2.0).

Key Signals

Pin(s)SignalPurpose
A4, B9VBUS5V power from host
A1, A12, B1, B12GNDGround connections
A6, A7D+, D-USB 2.0 data pair (side A)
B6, B7D+, D-USB 2.0 data pair (side B)
A5CC1Configuration channel 1
B5CC2Configuration channel 2

CC Resistors

The CC (Configuration Channel) pins tell the host what kind of device is connected. For a UFP (Upstream Facing Port, i.e., a device), you pull both CC1 and CC2 down to GND through 5.1 kOhm resistors. This signals to the host that a device is present and requests the default USB current (500 mA for USB 2.0, up to 1.5 A or 3.0 A if the host advertises higher current through CC voltage levels).

Without these resistors, a USB-C host will not provide power or enumerate your device.

D+ Pull-Up

USB Full-Speed devices must present a 1.5 kOhm pull-up on D+ to signal full-speed capability to the host. The STM32F411 has an internal pull-up that can be enabled in firmware, so the external resistor R3 is optional. If you include it, connect it between D+ and 3.3V through a solder jumper so you can disconnect it if using the internal pull-up.

Connecting Both Orientations

Since USB-C is reversible, the host can plug the cable in either orientation. For USB 2.0 only, the simplest approach is to connect both A6/B6 (D+) together and both A7/B7 (D-) together on the PCB. This way, regardless of cable orientation, the data lines reach the MCU. Some 16-pin USB-C receptacles already tie these internally. Check your connector datasheet to see whether D+ and D- from both sides are brought out separately or combined.

Four-Layer Stackup Design



The standard 4-layer stackup for a 1.6mm board looks like this:

LayerNameThicknessContent
1F.Cu35 µm (1 oz)Signal traces, component pads
-Prepreg~0.2mmDielectric between L1 and L2
2In1.Cu35 µm (1 oz)GND plane (solid, unbroken)
-Core~0.8mmRigid FR4 core
3In2.Cu35 µm (1 oz)+3V3 power plane
-Prepreg~0.2mmDielectric between L3 and L4
4B.Cu35 µm (1 oz)Signal traces, some components

The critical dimension for impedance control is the prepreg thickness between Layer 1 and Layer 2 (approximately 0.2mm). This distance, combined with the trace width and the dielectric constant of FR4 (about 4.3), determines the characteristic impedance of your traces. For a 90 ohm differential pair, you typically need traces around 0.2mm wide with 0.15mm spacing, referenced to a ground plane 0.2mm below. Your fab house can provide the exact stackup dimensions; JLCPCB publishes their standard 4-layer stackup on their capabilities page.

Setting Up 4 Layers in KiCad

  1. Open Board Setup (File > Board Setup, or the gear icon in the PCB editor).

  2. Go to Board > Physical Stackup. Change the layer count from 2 to 4. KiCad adds In1.Cu and In2.Cu between the existing front and back copper layers.

  3. Set layer names for clarity. In Board > Layers, rename In1.Cu to “GND” and In2.Cu to “PWR” if you want descriptive names. The electrical net assignment happens when you fill zones, not here.

  4. Under Physical Stackup, verify the prepreg and core thicknesses match your fab house specs. For JLCPCB’s standard 4-layer process: prepreg 0.2104mm (7628), core 0.8mm.

  5. Go to Design Rules > Net Classes. Create a net class called “USB” with trace width 0.2mm and differential pair gap 0.15mm (adjust based on your fab house impedance calculator). Keep the Default class at 0.25mm trace width.

Schematic Capture



Create a new KiCad project named stm32f411-blackpill. Open the schematic editor and work through the following sub-circuits.

Download Schematic PDF

USB-C Connector

  1. Place the USB-C connector. Add USB_C_Receptacle_USB2.0 from the Connector library. This symbol has the minimal pins needed for USB 2.0: VBUS, GND, D+, D-, CC1, CC2, and shield.

  2. Wire the CC resistors. Connect 5.1 kOhm resistors from CC1 and CC2 to GND. Label these R1 and R2.

  3. Wire VBUS. Connect VBUS through polyfuse F1 to a net labeled VBUS_5V. Add a 10 µF decoupling capacitor (C12) near the connector from VBUS_5V to GND.

  4. Wire the data lines. Connect D+ to a net labeled USB_DP and D- to a net labeled USB_DM. These will route to PA12 (D+) and PA11 (D-) on the STM32.

  5. Shield pin. Connect the connector shield to GND through a 0 ohm resistor or directly to GND. Some designers add a 1 nF capacitor in parallel for EMI filtering.

Power Supply

  1. Place the LDO. Add ME6211 (or a generic LDO_3.3V symbol) from the Regulator_Linear library. Input connects to VBUS_5V, output produces +3V3, and the enable pin connects to VBUS_5V (always on when USB is plugged in).

  2. Input capacitor. Place 10 µF (C12) on the input side, close to the LDO VIN pin. If you already placed C12 on VBUS, this same capacitor serves both purposes.

  3. Output capacitors. Place 10 µF (C13) and 100 nF (C14) on the output side, from +3V3 to GND. The ME6211 datasheet recommends at least 1 µF output capacitance; we use 10 µF for extra margin.

  4. Power flags. Add PWR_FLAG symbols on the +3V3 and GND nets if KiCad’s ERC complains about undriven power pins.

STM32F411CEU6

  1. Place the MCU. Add STM32F411CEUx from the MCU_ST_STM32F4 library. This symbol includes all 48 pins plus the exposed thermal pad.

  2. Decoupling capacitors. Place 100 nF capacitors on each VDD pin and on VDDA. The STM32F411 UFQFPN-48 has three VDD pins and one VDDA pin, so you need four 100 nF caps (C5 through C8). Add one more 100 nF (C9) near VDDA with a 1 µF in parallel for analog filtering. Place a 4.7 µF bulk cap (C10) near the MCU as well.

  3. VCAP1 pin. The STM32F411 has one VCAP pin that requires a 1 µF capacitor to GND. This is the internal voltage regulator output; do not connect anything else to this pin.

  4. HSE crystal. Connect a 25 MHz crystal between OSC_IN (PH0) and OSC_OUT (PH1). Place 10 pF load capacitors from each crystal pin to GND. Add a 1 MOhm feedback resistor across the crystal.

  5. LSE crystal. Connect a 32.768 kHz crystal between OSC32_IN (PC14) and OSC32_OUT (PC15). Place 6.8 pF load capacitors from each crystal pin to GND.

  6. Reset circuit. Connect NRST to a 10 kOhm pull-up to 3V3 and a tactile switch (SW2) to GND. Add a 100 nF capacitor from NRST to GND for debouncing.

  7. BOOT0 pin. Connect BOOT0 through a 10 kOhm pull-down to GND. This ensures the MCU boots from flash by default. If you want a BOOT0 button, add a switch to pull it high to 3V3.

  8. USB data lines. Connect PA11 to USB_DM and PA12 to USB_DP. If using the external pull-up, connect the 1.5 kOhm resistor from USB_DP to +3V3.

SWD Header and User I/O

  1. SWD header. Place a 1x5 pin header. Wire pin 1 to +3V3, pin 2 to SWDIO (PA13), pin 3 to SWCLK (PA14), pin 4 to GND, pin 5 to NRST. This is compatible with ST-Link V2 and other SWD debuggers.

  2. User LED. Connect PC13 through a 330 ohm resistor to a green LED, then to +3V3. The LED lights when PC13 is driven low (active-low, same as the Black Pill convention).

  3. User button. Connect PA0 to GND through a tactile switch (SW1). Enable the internal pull-up in firmware, or add an external 10 kOhm pull-up to +3V3.

  4. GPIO headers. Place two 1x20 headers along the board edges. Route all remaining GPIO pins to these headers. Follow the Black Pill pinout convention if you want drop-in compatibility.

ERC and Footprint Assignment

  1. Run ERC. Click Inspect > Electrical Rules Checker. Fix any unconnected pins, conflicting net types, or missing power flags.

  2. Assign footprints. Open Tools > Assign Footprints. Key assignments:

    • STM32F411CEU6: Package_QFP:QFP-48-1EP_7x7mm_P0.5mm_EP5.6x5.6mm (the UFQFPN-48 footprint with exposed pad)
    • USB-C: Select a footprint matching your connector (e.g., USB_C_Receptacle_HRO_TYPE-C-31-M-12)
    • ME6211: Package_TO_SOT_SMD:SOT-23-5
    • 0402 passives: Capacitor_SMD:C_0402_1005Metric and Resistor_SMD:R_0402_1005Metric
    • 0805 bulk caps: Capacitor_SMD:C_0805_2012Metric
  3. Exposed pad. The UFQFPN-48 exposed pad must connect to GND for thermal and electrical performance. In the schematic, the exposed pad pin should already be connected to GND. Verify this in the footprint properties.

PCB Layout



Board Outline and Zones

  1. Draw the board outline. Switch to the Edge.Cuts layer and draw a rectangle 55mm x 20mm. Round the corners with 1mm radius fillets if desired.

  2. Create the GND zone on In1.Cu. Select Add Filled Zone, pick the In1.Cu (GND) layer, and assign it to the GND net. Draw the zone to cover the entire board area. Set the zone priority to 0.

  3. Create the +3V3 zone on In2.Cu. Same process on In2.Cu, assigned to the +3V3 net.

  4. Create GND pour on F.Cu and B.Cu. Add filled zones on both outer layers assigned to GND. These connect to the inner GND plane through vias and help with shielding. Set lower priority than any keep-out zones you add later.

Component Placement

Place the USB-C connector at one short edge of the board. Position the MCU in the center of the board with the exposed pad facing down (front side). Place the LDO and its capacitors between the USB connector and the MCU, keeping the power path short and direct.

Place decoupling capacitors on the back side of the board, directly beneath their corresponding VDD pins on the MCU. This is a major advantage of a 4-layer board: the capacitor pad on B.Cu connects through a via to the GND plane (In1.Cu), and through another via to the +3V3 plane (In2.Cu). The current loop from the power plane, through the via, through the capacitor, and back through the GND via is extremely short.

Place the HSE crystal within 5mm of the OSC_IN/OSC_OUT pins. Place the LSE crystal within 3mm of the OSC32 pins. Keep both crystal areas free of high-speed digital traces.

Place the SWD header at the opposite short edge from USB, or along one of the long edges. Place GPIO headers along both long edges of the board.

Placement priority order:

PriorityComponentReason
1USB-C connectorFixed mechanical position at board edge
2STM32F411Central position, all signals radiate outward
3HSE and LSE crystalsMust be close to MCU oscillator pins
4Decoupling capacitorsDirectly under/beside VDD pins
5LDO and power capsShort path from VBUS to MCU
6SWD headerEdge position for probe access
7GPIO headersBoard edges, last to place

Via Stitching

Via stitching means placing a regular pattern of vias connecting the GND zones on the outer layers to the inner GND plane. This serves multiple purposes: it reduces the impedance of the ground connection, it creates a Faraday cage effect that reduces EMI, and it provides thermal paths from the outer layers to the inner copper.

  1. Add via stitching around the board perimeter. In KiCad, use Place > Via. Set the via net to GND. Place vias every 3 to 5mm around the board edge, inside the ground pour area. Stay at least 0.5mm from the board edge.

  2. Add via stitching near USB traces. Place GND vias on both sides of the USB differential pair, spaced every 2 to 3mm. This shields the USB signals and provides a continuous ground reference.

  3. Add via stitching near the MCU. Place GND vias around the MCU footprint, particularly near the exposed pad area. The exposed pad itself should have a grid of thermal vias (typically 4 to 9 vias in a 2x2 or 3x3 pattern) connecting to the inner GND plane for heat dissipation.

  4. KiCad automatic via stitching. In KiCad 9, you can use Edit > Add Via Stitching to automate this. Set the via diameter to 0.3mm, drill to 0.15mm, and spacing to 3mm. Select the GND net and the target zones, then click OK.

USB Differential Pair Routing

This is the most critical routing on the board. USB 2.0 Full-Speed requires 90 ohm differential impedance.

  1. Assign the USB net class. In Board Setup > Net Classes, verify that USB_DP and USB_DM are assigned to the “USB” net class with the correct trace width and spacing. For JLCPCB’s standard 4-layer stackup (0.21mm prepreg), approximately 0.2mm trace width and 0.15mm gap gives 90 ohm differential impedance. Use your fab house impedance calculator to confirm.

  2. Route the differential pair. Select the Interactive Router and choose “Differential Pair” mode (or press D). Click on one pad of the USB D+/D- pair at the connector, and KiCad routes both traces simultaneously with matched spacing.

  3. Keep traces on one layer. Route the entire USB pair on F.Cu. Avoid vias in the differential pair. Every via introduces an impedance discontinuity, and at USB Full-Speed (12 Mbps) this matters.

  4. Length matching. The D+ and D- traces should be matched within 0.1mm. KiCad’s length tuning tool (accessible from the route menu) lets you add serpentine meanders to the shorter trace. For USB 2.0 Full-Speed, the tolerance is generous, but good practice is to match as closely as possible.

  5. Keep the reference plane intact. Do not route other signals on the inner GND plane (In1.Cu) underneath the USB traces. The ground plane must be continuous under the differential pair for impedance control. If you must cross a signal, cross on In2.Cu (power plane) and add stitching vias nearby.

  6. Termination. USB Full-Speed does not require external series termination resistors in most cases. The STM32’s internal drivers handle this. If you see signal integrity issues, you can add 22 ohm series resistors on D+ and D-.

Decoupling Capacitor Routing

The goal is to minimize the current loop area between each VDD pin, its decoupling capacitor, and GND. With 4-layer boards, the technique is straightforward: place the capacitor on the back side directly under the VDD pin, connect the capacitor’s power pad through a via to the +3V3 plane (In2.Cu), and connect its ground pad through a via to the GND plane (In1.Cu). The loop area becomes the distance between the two vias times the board thickness, which is extremely small.

Do not route long traces from decoupling caps to VDD pins. The via-to-plane connection should be the primary path. If the capacitor cannot sit directly below the VDD pin, keep the trace as short as possible and still use vias to both inner planes.

Design Rules for JLCPCB 4-Layer

Set these minimum design rules in Board Setup > Design Rules > Constraints:

ParameterMinimumRecommended
Trace width0.09 mm0.15 mm (0.2 mm for USB)
Trace spacing0.09 mm0.15 mm
Via drill0.15 mm0.2 mm
Via diameter0.35 mm0.45 mm
Annular ring0.075 mm0.1 mm
Copper to edge0.2 mm0.3 mm

These are slightly tighter than 2-layer rules because JLCPCB uses a different process for 4-layer boards. Always check the latest capabilities page before finalizing your design.

Running DRC

  1. Fill all zones (Edit > Fill All Zones, or press B).

  2. Open Inspect > Design Rules Checker.

  3. Fix any clearance violations, unconnected nets, or minimum width violations.

  4. Pay special attention to the inner planes. Look for unintended splits in the GND plane caused by traces routed on In1.Cu. The GND plane should be solid; remove any traces accidentally placed on it.

Manufacturing



The Gerber and drill file export process is the same as Lesson 3. This section covers 4-layer specifics.

4-Layer Options at JLCPCB

When ordering, select “4” for the layer count. JLCPCB offers a standard 4-layer stackup (JLC04161H-7628) at a reasonable price premium. For a board this size (55x20mm), expect to pay roughly 2x to 3x the cost of an equivalent 2-layer order (approximately 15 for 5 boards versus 5 for 2-layer). The cost difference decreases as board size increases because the per-board price for 4-layer has a higher fixed component but similar per-area scaling.

Impedance Control

If you need guaranteed impedance (rather than relying on typical stackup values), select “Yes” for impedance control in the JLCPCB order form. This adds cost (roughly 40 extra) but the fab house will adjust their process to hit your target impedance within a tighter tolerance (typically plus or minus 10%). For USB 2.0 Full-Speed, the standard stackup is usually close enough, so impedance control is optional.

Gerber Export Checklist

Make sure your Gerber export includes all six copper-related files:

FileKiCad Layer
F.Cu.gtlF.Cu (Layer 1, top signals)
In1.Cu.g2In1.Cu (Layer 2, GND plane)
In2.Cu.g3In2.Cu (Layer 3, power plane)
B.Cu.gblB.Cu (Layer 4, bottom signals)
F.Mask, B.MaskSolder masks
F.SilkS, B.SilkSSilkscreen
Edge.CutsBoard outline

Zip all Gerbers and drill files together. Upload to JLCPCB and verify the layer order in the Gerber viewer before placing the order.

Firmware: USB CDC Virtual COM Port



Once the board is assembled, verify it works by sending serial data over USB. The STM32F411 supports USB 2.0 Full-Speed natively on PA11/PA12.

STM32CubeMX Configuration

  1. Open STM32CubeMX and create a new project for the STM32F411CEU6.

  2. Under System Core > RCC, set High Speed Clock (HSE) to “Crystal/Ceramic Resonator” and Low Speed Clock (LSE) to “Crystal/Ceramic Resonator”.

  3. Under Connectivity > USB_OTG_FS, set Mode to “Device_Only”.

  4. Under Middleware > USB_DEVICE, set Class to “Communication Device Class (Virtual Port Com)”.

  5. In the Clock Configuration tab, set the system clock to 96 MHz using the PLL with HSE as the source. The USB peripheral requires exactly 48 MHz, which the PLL can derive from a 25 MHz HSE crystal.

  6. Generate the project code for your preferred toolchain (STM32CubeIDE, Makefile, or CMake).

Sending Data Over USB

In the generated project, open usbd_cdc_if.c. The function CDC_Transmit_FS() sends data to the host. Add a simple test in main.c:

/* main.c (inside the while(1) loop in main()) */
#include "usbd_cdc_if.h"
/* In main(), after MX_USB_DEVICE_Init() */
uint8_t msg[] = "STM32F411 Black Pill alive\r\n";
uint32_t tick = 0;
while (1)
{
if (HAL_GetTick() - tick >= 1000)
{
tick = HAL_GetTick();
CDC_Transmit_FS(msg, sizeof(msg) - 1);
}
}

Flash the firmware via SWD using an ST-Link or J-Link. Connect the board to a computer over USB-C. A virtual COM port should appear. Open a serial terminal at any baud rate (CDC ignores baud rate settings) and you should see:

STM32F411 Black Pill alive
STM32F411 Black Pill alive
STM32F411 Black Pill alive

On Linux, the device appears as /dev/ttyACM0. On Windows, it appears as a COM port in Device Manager. On macOS, look for /dev/tty.usbmodemXXXX.

Troubleshooting USB Enumeration

If the device does not appear on the host:

  • Check CC resistors. Without the 5.1 kOhm pull-downs on CC1 and CC2, the host will not supply VBUS power. Measure the voltage on VBUS; it should be 5V when the cable is connected.
  • Check the D+ pull-up. The host detects a Full-Speed device by seeing D+ pulled high. If using the internal pull-up, make sure the USB peripheral is initialized before the cable is connected (or add a short delay before USB init).
  • Verify the 48 MHz clock. USB requires exactly 48 MHz on the USB peripheral clock. If the PLL is misconfigured, the USB peripheral will not function. Double-check the CubeMX clock tree.
  • Check VCAP capacitor. A missing or wrong-value capacitor on the VCAP pin can cause the internal regulator to be unstable, leading to erratic behavior including USB failures.
  • Try a different cable. Some USB-C cables are charge-only and do not connect the data lines.

What You Have Learned



Lesson 4 Complete

KiCad skills:

  • Set up a 4-layer PCB stackup with inner ground and power planes
  • Routed USB 2.0 differential pairs with impedance-aware trace width and spacing
  • Used KiCad’s differential pair router for matched-length routing
  • Applied via stitching for ground plane integrity and EMI reduction
  • Placed decoupling capacitors on back side with via connections to inner planes

Electronics skills:

  • USB-C connector wiring for device mode (CC pull-downs, VBUS, data lines)
  • 4-layer stackup design and its benefits for signal integrity
  • Impedance-controlled routing concepts (90 ohm differential for USB)
  • LDO power regulation with proper input/output capacitor selection
  • STM32F411 power supply design (VDD decoupling, VCAP, VDDA filtering)

Manufacturing skills:

  • 4-layer Gerber export with inner layer files
  • JLCPCB 4-layer ordering options and cost considerations
  • Impedance control option at the fab house

Firmware skills:

  • STM32CubeMX USB Device CDC configuration
  • USB virtual COM port communication from STM32

Comments

Loading comments...


© 2021-2026 SiliconWit®. All rights reserved.
Predict first

A fast signal travels along a bent track on the top layer of a board. The layer below is a whole sheet of ground copper. The current must return to its source through that sheet. Where in the sheet does it flow?

See it: what sets the impedance of a pair of tracks

Pair, D+ to D-
One track alone
Against the USB range

The drawing is to scale. The impedance is the IPC-2141 estimate given above, for FR4 with a relative permittivity of 4.3 and copper 0.035 mm thick. Against an exact field calculation for bare tracks, the estimate is between 9% low and 12% high over the range of these sliders. Solder mask lowers the real value by a further 3 to 13 Ω. So the figure shows which way each dimension moves the impedance and by about how much. It does not replace the factory's calculator, and it does not judge a value near an edge of the USB range.

Check yourself

Three questions. Each wrong choice is a mistake people really make, so read the note after you answer.

1. Your USB pair is 0.2 mm wide with a 0.15 mm gap, drawn for a stack-up with 0.21 mm of prepreg, where it is about 100 Ω. To save money you order a stack-up with 0.10 mm of prepreg and change nothing in the layout. What is the impedance of the pair now?

2. A finished board works from a computer through a cable with a USB-A plug at one end and USB-C at the other. From a USB-C charger, through a cable with USB-C at both ends, it stays dead: 0 V on VBUS. What do you examine first?

3. To finish a crowded layout, a colleague routes one 30 mm signal track on In1.Cu, the ground plane layer. It passes under the USB pair at a right angle. The design rules check reports nothing. What has changed for the USB pair?

two layersfour layers outinoutin ground plane under it all large loop: noisytiny loop: quiet
90 Ω trackthe rest goes on part comes backa via, a slot, a new width
Watch it build: what four layers give
0.2 mm 0.2 mm L1L2L3L4 signalsignal GND 3.3 V 1.6 mm, four copper layers return current: under the track a via reaches the 3.3 V sheet both outer faces free USB pair at 0.2 mm: 90 Ω 5 boards: 8 to 15 USD(2 layers: 2 to 5)
  1. Four copper layers in a 1.6 mm board: L1 and L4 outside, L2 and L3 inside.
  2. L2 is a whole GND plane. The return current flows in it, 0.2 mm under the track.
  3. L3 is a sheet of 3.3 V. A via beside each pin reaches it, with no long track.
  4. Power and ground are inside, so L1 and L4 are both free for signals.
  5. The small, fixed 0.2 mm height lets tracks of normal width reach 90 Ω.
  6. The price: five boards cost about 8 to 15 USD on four layers, 2 to 5 USD on two.
Watch it build: the USB pair
In1 GND USB-C MCU B.Cu D+D− USB class:0.2 mm, gap 0.15 mm drawn as one pair,the gap held F.Cu only,no vias bends on D+:equal within 0.15 mm plane wholeunder the pair no series resistors(22 Ω if it rings)
  1. D+ and D- go in the USB net class: 0.2 mm tracks with a 0.15 mm gap, to start.
  2. Route Differential Pair draws both tracks at once and holds the gap between them.
  3. The whole pair stays on F.Cu, with no via to change its impedance.
  4. D- is the outer track of the bend, so small bends lengthen D+ until both match.
  5. The In1.Cu plane stays whole under the pair. A signal that must cross goes on B.Cu.
  6. The STM32 driver needs no series resistors. Add 22 Ω only if the signal rings.
Layer 1 F.Cu signals and parts, 35 µm prepreg about 0.2 mm (0.2104 mm, 7628) Layer 2 In1.Cu GND plane, whole sheet, 17.5 µm core about 1.0 mm (1.065 mm) Layer 3 In2.Cu +3V3 plane, 17.5 µm prepreg about 0.2 mm (0.2104 mm, 7628) Layer 4 B.Cu signals and parts, 35 µm Total thickness: about 1.6 mm (1.59 mm with these values). Heights to scale.
D+ and D- as one differential pair, same length 3 x track width clear of other signals ground plane unbroken beneath the pair USB-C D+ D- STM32 USB pins PA12 (D+) PA11 (D-) Rules 90 Ω between the two tracks Lengths equal within 0.15 mm No vias in the pair 3 x track width clear of other signals Ground plane unbroken beneath the pair Track width 0.2 mm, gap 0.15 mm and clearance 0.6 mm to scale; the parts are not.
The finished board in 3D, seen from above: a long green board with a 20-pin header along each long edge and a five-pin header across the right end. At the left the USB-C socket, then the small six-legged protection chip and the square STM32F411 with its two crystals beside it, then three small buttons, the regulator, the capacitors and a tiny LED.
The board you will make (55 × 20 mm, four layers), made in KiCad 10.
STM32F411CEU6 UFQFPN-48, 7 x 7 mm, pins 0.5 mm apart USB-C 16 pins USBLC6-2SC6 SOT-23-6 ME6211 SOT-23-5 25 MHz 3.2 x 2.5 mm 32.768 kHz 2.0 x 1.2 mm Button PTS810, 4.2 x 3.2 mm 0402 1.0 x 0.5 mm 5 mm. All drawn at the same scale, copper pads from the KiCad 10 footprints.
The parts at true scale. The STM32F411's 48 contacts and its big centre pad are underneath: it needs paste and hot air, or the factory. The holes in the centre pad are its vias to the ground plane.
Coming here first?

This board uses skills taught on the earlier boards. Each one is here, at the part that teaches it:

Words used here, each with a five-minute page:

What the finished board changes, and why
  • The USB tracks are 0.25 mm wide, 0.15 mm apart. On this stack-up that gives about 90 Ω (91.8 Ω by the estimate below, 92.6 Ω by an exact field calculation). The 0.2 mm of the steps gives about 101 to 103 Ω: inside the range, but at its top.
  • The USBLC6-2SC6 is fitted (U3), as the static protection step advises. D+ and D- run straight through it: in at pins 6 and 4, out at 1 and 3.
  • A BOOT0 button (SW3). Hold it and press RESET: the STM32F411's built-in loader starts and takes a program over USB (DFU), with no ST-Link.
  • PB2 has 10 kΩ to GND (R7). PB2 is BOOT1: the loader needs it low.
  • The LED resistor is 1 kΩ (R6), not 330 Ω. PC13 sinks 3 mA at most (DS10314). With a 2 V LED, 330 Ω gives 3.9 mA; 1 kΩ gives 1.3 mA.
  • R3 is left out. The F411 has the 1.5 kΩ D+ pull-up inside.
  • Parts the text names now have references: C9 (1 µF at VDDA), C15 (100 nF at VBAT), C16 (100 nF on NRST), R7 (BOOT1). C10 and C11, the two 4.7 µF, are 0603.
  • All parts on the top, for one-sided assembly. Each decoupling capacitor sits beside its pin, and each GND and 3.3 V pad has its own via to its plane.
  • Header pins left open: VB, C14 and C15 (the 32.768 kHz crystal), A11 and A12 (the USB pair). A header wire would load the weak oscillator, or hang a branch on the pair. Each row keeps the Black Pill's order of pins. The B12 row starts at the USB end; the VB row starts at the far end, so that no track from the chip must cross another on its way to the header (along an edge, the chip's pins are numbered the other way). Check the rows against your Black Pill before you put this board in its place.
  • The SWD header has pin 1 (3.3 V) at the bottom corner, so it reads 3V3, SWDIO, SWCLK, GND, NRST from the bottom edge up. SWDIO and SWCLK reach it along the bottom edge, under the header row, and NRST comes in at the top. Check the order on your probe's cable.
  • SW1, SW2 and SW3 are the C&K PTS810 (4.2 × 3.2 mm); the "3 × 6 mm" in the table is another switch.

stm32f411-blackpill-bom.csv is the full list.

This board's pair, worked out two ways

JLC04161H-7628: prepreg 0.2104 mm, εr 4.4; outer copper 0.041 mm after plating; solder mask εr 3.8 (JLCPCB's impedance guide).

Width / gapEstimate (IPC-2141)Field calculation
0.20 / 0.15 mm102.0 Ω100.8 Ω
0.25 / 0.15 mm91.8 Ω92.6 Ω
0.30 / 0.15 mm83.2 Ω86.0 Ω

The field calculation solves the field over the cross-section, with the mask over and between the tracks. Against a result JLCPCB's calculator gave for this stack-up (85 Ω for 0.205 mm tracks 0.102 mm apart) it reads 88 Ω: about 3% high. So 0.25 / 0.15 mm lands near 89 to 92 Ω. Read your own value from the factory's calculator before you order.

The finished project has this stack-up in Board Setup > Physical Stackup: 0.035 mm outer copper, 0.2104 mm prepreg (7628, εr 4.4), 0.0152 mm inner copper, 1.065 mm core, 1.59 mm in all. Net classes: Default 0.15 mm, Power 0.4 mm (+5V, VBUS), USB 0.25 mm with a 0.15 mm pair gap (/USB_D*). Vias 0.45 mm with a 0.2 mm hole.

Check it

The finished schematic, in KiCad 10.0.8: ERC 0 errors, 0 warnings. Nine titled boxes, joined by net labels. PWR_FLAG sits on VBUS, +5V and GND: only passive pins feed them (the socket, the fuse).

The MCU footprint is QFN-48-1EP_7x7mm_P0.5mm_EP5.6x5.6mm_ThermalVias: the same pads with the via grid already in the exposed pad. Each GND pin (VSS 23, 35, 47, VSSA 8) is joined to the exposed pad by a short track on the top.

The whole schematic on one A3 sheet in nine titled boxes joined by net labels: USB-C in with the two 5.1 k CC resistors, the polyfuse and the USBLC6 protection; the ME6211 3.3 V regulator; the two crystals with their load capacitors; reset and boot with three buttons; the STM32F411 with VCAP1; SWD; the user LED and button; the decoupling capacitors; and the two GPIO headers.
The schematic as a PDF.
The board from above as its printed outlines show it: the header rows along both long edges and the SWD header across the right end; between them from the left the USB-C socket, the fuse and the CC resistors, the protection chip, the MCU with its capacitors round it, the two crystals at its right side, the three buttons, the LED and the regulator.
The finished placement. Check: DRC reports no Courtyards overlap.

The steps put the decoupling capacitors on the back. This board keeps every part on the top: the factory then assembles one side only, which costs less. Each capacitor sits beside its pin, with its own via to each plane.

This board's vias are 0.45 mm with a 0.2 mm hole: JLCPCB's four-layer table accepts holes down to 0.15 mm, but a 0.2 mm hole costs more only when the via is under 0.45 mm across, so this is the smallest via at the standard price.

KiCad 10 has no via stitching command either. Create Array works as the last step says. A stitching zone is being added for the next major version.

On the finished board: 92 vias join the ground pours of both faces to the GND plane, most of them at the GND pad they serve; the MCU's exposed pad has its own grid of vias in the footprint.

Check it: the four copper layers
Layer 1, the top copper: the USB pair from the socket through the protection chip to the MCU, short tracks from the MCU pins, and ground pour in the spaces.
F.Cu, layer 1: signals and pads
Layer 2: one whole sheet of ground copper with small round holes where vias of other nets pass, and no slot anywhere.
In1.Cu, layer 2: the GND plane
Layer 3: one whole sheet of 3.3 V copper with small round holes where the ground and signal vias pass.
In2.Cu, layer 3: the 3.3 V plane
Layer 4, the bottom copper seen from above: the tracks that cross under others, the 5 V track, and ground pour.
B.Cu, layer 4, seen from above

DRC in KiCad 10.0.8, with schematic parity and every severity: 0 errors, 0 unconnected items, 0 parity issues, and 5 warnings (5 silkscreen clipped by board edge: the outlines of the USB-C socket, whose mouth stands past the edge, and of the SWD header at the far end reach the edge; the factory trims them).

The USB pair runs on F.Cu from the socket through U3 to PA11 and PA12, with no via: D- 10.63 mm, D+ 10.67 mm, 0.04 mm apart in length (the rule: 0.15 mm). Under it, the GND plane is whole. 158 vias in all: 17 to the 3.3 V plane, 92 to ground. No track runs on the two inner layers.

Ours, to compare
  • stm32f411-blackpill-gerbers.zip: 11 .gbr files, -NPTH.drl, -PTH.drl and a .gbrjob. With Use Protel filename extensions off, the four copper files end -F_Cu.gbr, -In1_Cu.gbr, -In2_Cu.gbr and -B_Cu.gbr; the factory reads the layer from inside each file.
  • stm32f411-blackpill-bom-jlcpcb.csv, columns Comment, Designator, Footprint, LCSC. The LCSC column is empty: choose each part on the order page and check its stock.
  • stm32f411-blackpill-cpl-jlcpcb.csv, columns Designator, Mid X, Mid Y, Rotation, Layer, from the bottom left corner. U1 is at 20.55, 9.95 mm, rotation 180: in the factory's preview its pin 1 dot must be at the bottom right.
The finished board from below in 3D: ground pour over most of the back, the header and SWD holes, the via grid under the MCU and the text siliconwit.com.
Check it. From below: the ground pour, joined to the plane by its vias.
Found this useful?

Discussion

    Comments show your name. Be kind, stay on the topic.