Nội dung liên quan
#STM32
Finishing a Real HID Keyboard, from Keypress to Release
Turning key press and release events into HID reports and sending them to the host, plus what to watch out for with Boot Protocol and tap-style null reports.
Firmware Log với USB CDC Debug Channel
Triển khai CDC debug channel trên STM32G0: descriptor CDC, ring buffer, ISR-safe logging và tránh xung đột DTR khi host mở COM port.
Composite Debug Tool: GUI test tổng hợp cho STM32 USB
GUI Python gộp CDC log, vendor command và RAM dump vào một màn hình: pattern queue-poll thống nhất trong tkinter, và vì sao viết GUI mới không đụng vào phần USB đã có.
Hoàn thành HID keyboard thật từ sự kiện nhấn thả phím
Chuyển sự kiện nhấn thả phím thành HID report rồi gửi đến host kèm theo các lưu ý về Boot Protocol hay tap-style null report.
Vendor Request và Bulk IN trên STM32G0
EP0 vendor command và Bulk IN RAM dump trên STM32G0: pending log flag, tại sao không dùng ZLP, Zadig cho Windows, và output thật từ vendor_test.py.
CubeMX USB pitfalls thường gặp
Những điểm CubeMX không làm đúng khi generate USB code: HID mouse descriptor thay vì keyboard, NVIC không bật, Sof_enable DISABLE, USBD_static_malloc sai kích thước.
USB Bulk Transfer cho debug dump là gì?
Bulk IN cho RAM dump trên STM32G0: state machine chunk 64 byte, DataIn callback pipeline, tại sao không dùng ZLP, Zadig cho Windows và throughput thực đo.
USB CDC ACM là gì?
CDC ACM trên STM32: tại sao giống UART về trải nghiệm nhưng khác về implementation, SET_CONTROL_LINE_STATE, DTR và điểm dễ nhầm khi dùng với terminal.
USB Vendor Request qua EP0 là gì?
EP0 Vendor Request trên STM32: bmRequestType 0xC0, dispatch trong Composite_Setup, tại sao không được gọi CdcLog_Printf trong handler và pattern pending log flag.
What Is a USB Descriptor?
The concept and structure of USB descriptors, explained with real examples. Includes a look at how Boot Protocol fits into the Configuration Descriptor.
Designing the Input Pipeline Before the USB Layer
How input flows from a keypad through scanning, debounce, key policy, and an event queue, and the tradeoffs made before an HID report ever gets built.
USB Descriptor là gì?
Giải thích khái niệm và cấu trúc của USB Descriptor kèm ví dụ. Lưu ý về Boot Protocol trong Configuration Descriptor
Thiết kế input pipeline trước tầng USB
Giải thích thiết kế tạo input từ keypad qua các tầng scan, debounce, key policy, event queue và những đánh đổi trước khi tạo HID report.
STM32G0 USB Lab: Composite Device
USB composite device trên STM32G0B1RE: HID Keyboard + CDC log + EP0 Vendor Request + Vendor Bulk IN. Một codebase phát triển từ HID đơn đến debug tool hoàn chỉnh qua commit/tag.
STM32G0 USB Lab: Host Debug Tool
Python tool giao tiếp với USB composite device STM32G0: CLI smoke test 4 vendor commands qua EP0 và GUI test tổng hợp HID, CDC log, vendor bulk dump trên một màn hình.
STM32G0 USB Lab: Key Input Pipeline
Keypad 4x4 matrix trên STM32G0B1RE: quét bằng BSRR/IDR trực tiếp, TIM6 5ms, debounce 2 mẫu, event queue và chính sách simultaneous-error cho ma trận không diode.
Series tổng hợp kiến thức về STM32 Firmware thực chiến
Từ những vấn đề thật trong firmware POS đến thiết kế thật: logger non-blocking, FreeRTOS architecture, Flash EEPROM emulation và dual-slot bootloader trên STM32G0.
What Is STM32 GPIO Register Access?
Accessing GPIO through BSRR and IDR instead of HAL_GPIO_WritePin/ReadPin: why, when it's worth it, and how it applies to row-by-row matrix scanning on STM32.
STM32 GPIO Register Access là gì?
Truy cập GPIO bằng BSRR và IDR thay vì HAL_GPIO_WritePin/ReadPin: tại sao, khi nào phù hợp, và cách áp dụng cho matrix scan row-by-row trên STM32.
Clock Configuration for USB FS là gì?
USB Full-speed cần clock 48 MHz chính xác. Các nguồn clock khả dụng trên STM32, trade-off giữa HSI48+CRS và HSE+PLL, và checklist kiểm tra trước khi debug enumeration.
USB Enumeration Debugging là gì?
Cách debug USB enumeration fail từ tool đến log: USBView trên Windows, Wireshark USB capture, sysfs trên Linux và cách đọc lỗi enumeration theo từng bước.
What Is a Debounce Algorithm?
Why mechanical keys bounce, and how to handle it with counter-based debounce, timestamp debounce, scan buffers, and a state machine in firmware.
What Is the HID Keyboard Report Format?
The 8-byte structure of an HID keyboard report: the modifier byte, the reserved byte, and 6 keycode slots. How to send a report from STM32 middleware.
What Are HID Usage Tables?
Usage Page and Usage in HID, explained. A full lookup table for the Keyboard/Keypad Page 0x07: letters, digits, punctuation, numpad, lock keys, F-keys.
What Is a USB Descriptor Overview?
The hierarchical structure of USB descriptors: Device, Configuration, Interface, Endpoint - wTotalLength, bDescriptorType, and what commonly breaks enumeration.
What Is the USB Enumeration Process?
A sequence of requests over Endpoint 0, from device plug-in to the host assigning an address and picking a configuration - 7 steps, where things fail, and how to debug bottom-up.
Debounce Algorithm là gì?
Tại sao phím cơ học bounce và cách xử lý bằng counter-based debounce, timestamp debounce, scan buffer và state machine trong firmware.
HID Keyboard Report Format là gì?
Cấu trúc 8 byte của HID keyboard report: modifier byte, reserved byte, 6 keycode slot. Cách gửi report từ STM32 middleware.
HID Report Descriptor là gì?
HID Report Descriptor mô tả cấu trúc và ý nghĩa từng byte trong HID report. Usage Page, Usage, Collection, Input/Output — ngữ pháp tối thiểu cần biết để viết HID firmware.
HID Usage Tables là gì?
Giải thích Usage Page và Usage trong HID. Bảng tra đầy đủ Keyboard/Keypad Page 0x07 (chữ, số, dấu câu, numpad, phím khoá, F-key).
Keyboard Matrix Fundamentals là gì?
Tại sao bàn phím dùng matrix thay vì một dây mỗi phím. Cách quét hàng/cột, GPIO setup, active-low convention, ghosting và khi nào thực sự cần diode.
STM32 HAL USB Device Architecture là gì?
Kiến trúc STM32 USB Device Library: PCD driver, USBD core, class layer và callback flow. Firmware cần implement gì, middleware xử lý gì và cách debug đúng tầng.
USB Descriptor Overview là gì?
Cấu trúc phân cấp USB descriptor: Device → Configuration → Interface → Endpoint. wTotalLength, bDescriptorType, cách host đọc từng bước và điểm dễ gây enumeration fail.
USB Enumeration Process là gì?
Chuỗi hỏi–đáp qua Endpoint 0 từ lúc device cắm vào đến khi host giao address và chọn configuration. 7 bước, điểm nào dễ fail và cách debug từ dưới lên.
USB Transfer Types là gì?
So sánh Control, Interrupt, Bulk và Isochronous transfer: dùng ở đâu, đảm bảo gì, và dễ debug sai ở điểm nào — đặc biệt là cách bInterval thực sự hoạt động trên Windows.
GNU ld warning: LOAD segment with RWX permissions là gì?
Giải thích warning LOAD segment with RWX permissions khi build STM32 bằng GNU ld, vì sao nó xuất hiện, có nguy hiểm không, và cách xử lý bằng linker script PHDRS.
VMA và LMA trong linker script STM32 là gì?
Giải thích sự khác nhau giữa VMA và LMA trong linker script STM32, vì sao .data chạy ở RAM nhưng lại được lưu trong Flash, và vai trò của các symbol như _sidata, _sdata, _edata.
STM32 Dual-Slot UART OTA Bootloader
Case study xây dựng bootloader A/B cho STM32G0B1RE, hỗ trợ cập nhật firmware qua UART, xác thực packet CRC32, metadata pending/confirmed và rollback.
Tạo file BIN từ ELF trong STM32CubeIDE
Quick note về cách export file .bin từ .elf trong STM32CubeIDE bằng objcopy, post-build command, và cách kiểm tra file BIN đã tạo đúng chưa.
ELF, BIN, HEX và little-endian trên STM32
Giải thích sự khác nhau giữa ELF, BIN, HEX khi build firmware STM32, vì sao bootloader thường nhận file BIN, và cách đọc vector table theo little-endian.
STM32 Flash EEPROM Emulation
Project EEPROM emulation trên STM32G0B1RE dùng Flash Bank 2, append-only record, two-page transfer, CRC và fault injection bằng software reset.
STM32 FreeRTOS Firmware Skeleton
Project thực nghiệm FreeRTOS skeleton trên STM32G0B1RE, kiểm tra task timing 10 ms/100 ms, event queue, UART log mutex, monitor task và queue full policy bằng log thật.
The Four Transfer Types, from a Firmware Point of View
When do you use Interrupt, Bulk, Control, or Isochronous? The role of bInterval and SOF timing, and how they shape USB Device firmware design.
Bốn loại Transfer dưới góc nhìn firmware
Khi nào dùng Interrupt, Bulk, Control hay Isochronous? Vai trò và ảnh hưởng của bInterval, SOF timing đến việc thiết kế USB Device.
STM32 Non-Blocking UART Logger
Project thực nghiệm UART logger non-blocking trên STM32G0B1RE, so sánh blocking transmit với UART DMA + Ring Buffer và drop counter.
Starting a series on USB Device on STM32
A journey through USB knowledge, from theory to a real project on STM32G0: from protocol fundamentals to a working composite device firmware.
Mở đầu series về USB Device trên STM32
Hành trình tổng hợp lại kiến thức USB từ lý thuyết cho đến thực hành với project thực tế trên STM32G0.
Thiết kế firmware STM32 với FreeRTOS: task ownership, signaling và HAL wrapper
Từ demo nhiều task sang kiến trúc firmware thật: cách tổ chức task ownership, chọn đúng primitive signal, tránh race condition và viết HAL wrapper để dễ port.
FreeRTOS on STM32: Tasks, Queues, Mutexes, and How to Organize Firmware into Modules
Building a FreeRTOS skeleton on STM32: tasks, queues, mutexes, and how to split firmware into independent modules.
FreeRTOS trên STM32: Task, Queue, Mutex và cách tổ chức firmware theo module
Triển khai FreeRTOS skeleton trên STM32: task, queue, mutex, và cách chia firmware thành các module độc lập.
Non-Blocking UART Logger on STM32 with DMA + Ring Buffer
Designing a non-blocking UART debug logger for STM32: avoiding printf blocking, handling lost logs with DMA, and using a ring buffer with DMA callbacks.
UART non-blocking logger trên STM32 với DMA + Ring Buffer
Thiết kế debug UART non-blocking cho STM32: tránh printf blocking, xử lý mất log với DMA, dùng ring buffer và DMA callback.
What Is a Ring Buffer in Embedded C?
Ring buffers in embedded C, explained: head/tail, full/empty, ISR producers, task consumers, DMA circular buffers, overflow, and debugging dropped bytes.
DMA Normal vs Circular Mode trong STM32 là gì?
Giải thích DMA Normal và Circular Mode trong STM32: luồng truyền, buffer, half/full callback, UART/ADC, ring buffer và debug mất dữ liệu.
FreeRTOS ISR Mutex là gì?
Giải thích vì sao không dùng mutex trong ISR với FreeRTOS: interrupt context, FromISR API, queue/semaphore, priority và debug deadlock.
GCC Dead Code Elimination là gì?
Giải thích GCC Dead Code Elimination trong embedded C: tối ưu loại code, linker garbage collection, section, KEEP, volatile và debug hàm bị mất.
HAL_BUSY UART DMA là gì?
Giải thích HAL_BUSY khi dùng UART DMA trong STM32: HAL state, DMA callback, gState/RxState, race condition, timeout và debug không gửi được.
Producer Consumer Logging trong STM32 là gì?
Giải thích Producer Consumer Logging trong STM32: ISR/task producer, log queue, UART DMA consumer, ring buffer, drop policy và debug mất log.
Production Debug Log Macro trong STM32 là gì?
Giải thích Production Debug Log Macro trong STM32: log level, compile-time filter, module tag, zero-cost log, ISR-safe và debug release build.
STM32 printf _write redirect là gì?
Giải thích redirect printf qua _write trong STM32: syscall, UART blocking, DMA/ring buffer, reentrancy, FreeRTOS và debug log bị treo.
UART Baudrate Time Calculation là gì?
Giải thích cách tính thời gian truyền UART từ baudrate: bit time, frame format, start/stop/parity, throughput, timeout và debug mất log.
UART Transmit Blocking là gì?
Giải thích UART Transmit Blocking trong STM32: HAL_UART_Transmit, baudrate timing, timeout, ISR/RTOS impact, printf blocking và debug treo log.
Flash, EEPROM và RAM trong STM32 khác nhau thế nào?
Giải thích Flash, EEPROM và RAM trong STM32: vùng nhớ, dữ liệu mất hay giữ sau reset, EEPROM emulation, linker script và debug lỗi lưu cấu hình.
Flash Operations trong STM32 là gì?
Giải thích thao tác Flash trong STM32: unlock, erase, program, verify, lock, page/sector, alignment, HAL error và debug ghi Flash an toàn.
Linker Script STM32 là gì?
Giải thích linker script STM32: memory regions, sections .text/.data/.bss, stack heap, Flash data area, bootloader offset và debug map file.
Reset Vector và Bootloader trong STM32 là gì?
Quick note ngắn gọn về Reset Vector, vector table, Initial MSP, Reset_Handler, VTOR và flow bootloader jump vào application trên STM32/Cortex-M.
Ring Buffer trong Embedded C là gì?
Giải thích Ring Buffer trong Embedded C: head/tail, full/empty, ISR producer, task consumer, DMA circular, overflow và debug mất byte.
Startup Code STM32 là gì?
Giải thích Startup Code trong STM32: vector table, Reset_Handler, copy .data, clear .bss, SystemInit, main và debug lỗi trước main.
STM32G0 Dual Bank là gì?
Giải thích STM32G0 Dual Bank Flash: bank layout, page erase, read-while-write, boot bank, firmware update, EEPROM emulation và debug sai bank.