skills/baremetal/uart-serial-baremetal/SKILL.md
Bare-metal UART skill for serial console and debug. Use when configuring baud rate, polling or IRQ-driven TX/RX, or integrating DMA with UART. Activates on queries about UART bare-metal, baud BRR, serial printf, or USART interrupt.
npx skillsauth add mohitmishra786/low-level-dev-skills uart-serial-baremetalInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Implement UART/USART for debug console and device communication: baud rate calculation, 8N1 framing, polling and interrupt-driven I/O, overrun handling, and optional DMA basics.
printf/log output on new hardwareBRR = pclk / (16 * baud) /* oversampling by 16 — check RM for USART */
void usart2_init(uint32_t pclk, uint32_t baud) {
RCC->APB1ENR |= RCC_APB1ENR_USART2EN;
/* GPIO PA2/PA3 AF — see gpio-baremetal */
USART2->BRR = pclk / baud; /* simplified — RM has fractional formula */
USART2->CR1 = USART_CR1_TE | USART_CR1_RE | USART_CR1_UE;
}
Verify pclk from actual clock tree (SystemCoreClock, APB prescaler).
void uart_putc(USART_TypeDef *u, char c) {
while (!(u->SR & USART_SR_TXE))
;
u->DR = (uint8_t)c;
}
char uart_getc(USART_TypeDef *u) {
while (!(u->SR & USART_SR_RXNE))
;
return (uint8_t)u->DR;
}
void USART2_IRQHandler(void) {
if (USART2->SR & USART_SR_RXNE) {
uint8_t b = USART2->DR;
rb_push(&rx_rb, b);
}
if (USART2->SR & USART_SR_ORE) {
(void)USART2->DR; /* clear overrun — required on STM32 */
}
}
printf (newlib)int _write(int fd, char *ptr, int len) {
(void)fd;
for (int i = 0; i < len; i++)
uart_putc(USART2, ptr[i]);
return len;
}
Link with --specs=nosys.specs or provide full syscalls.
/uart-serial-baremetal Calculate USART BRR for 115200 at 84 MHz PCLK
| Symptom | Cause | Fix |
|---------|-------|-----|
| Garbage chars | Wrong baud/PCLK | Recompute BRR; check APB divider |
| Lost bytes | ORE not cleared | Read DR on ORE; use IRQ + ringbuf |
| No output | TX pin not AF | GPIO alternate function |
| printf hangs | _write missing | Implement retarget |
skills/baremetal/gpio-baremetal — TX/RX pin muxskills/baremetal/interrupts-and-exceptions-baremetal — USART IRQskills/baremetal/dma-baremetal — UART RX DMAskills/embedded/openocd-jtag — semihosting alternativedevelopment
QEMU/KVM skill for virtualization and kernel development. Use when running qemu-system-x86_64 with KVM, configuring virtio devices, VFIO passthrough, QMP monitor, libvirt, or booting custom kernels. Activates on queries about QEMU, KVM, virtio, VFIO, virsh, virt-install, or -kernel -append.
development
Hardware virtualization internals skill for Intel VT-x and AMD-V. Use when studying VMCS/VMCB, EPT/NPT page tables, VMEXIT handling, APIC virtualization, or building minimal hypervisors. Activates on queries about VMX, SVM, VMCS, EPT, NPT, VMEXIT, or type-1 hypervisor.
testing
Linux containers internals skill for namespaces, cgroups, and OCI. Use when understanding clone/unshare namespaces, cgroups v2 limits, overlayfs, runc, seccomp profiles, capabilities, or escape mitigations. Activates on queries about namespaces, cgroups, overlayfs, runc, seccomp-bpf, OCI spec, or container escape.
tools
Reverse engineering skill for binary analysis. Use when decompiling with Ghidra, analyzing with radare2, scripting RE tools, triaging with strings/file/xxd, or diffing binaries. Activates on queries about Ghidra, radare2, r2, decompiler, Binary Ninja, Diaphora, or stripped binary analysis.