Skip to content

Commit 8e26f75

Browse files
Olson3Rclaude
andcommitted
ZMK generator: fix per-side conf for wired+pio-usb path
Post-review pass on commit 73bac5a. Three real bugs + two QoL gaps: - generateConf treated unibody as central and emitted USB-split configs for non-existent splits. Mirror generateOverlay's split/isCentral semantics so unibody+wired stays out of the split branches entirely (and ZMK_SPLIT/ZMK_SPLIT_WIRED no longer leak into unibody output). - Emit CONFIG_FLASH=n / NVS=n / SETTINGS=n for wired — Zephyr 3.5's RP2040 flash driver is broken in the rainadon-zmk fork; without the override, settings init hangs. The board defconfig sets these to y for when the driver lands; per-shield .conf overrides until then. - Emit CONFIG_USB_DEVICE_PRODUCT/VID/PID per side for the pio-usb path (peripheral product gets a "(peripheral)" suffix). - Emit a CONSOLE/LOG block on the central when enableConsole=true so the CDC ACM port actually surfaces logs (was silent before). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a919145 commit 8e26f75

1 file changed

Lines changed: 34 additions & 5 deletions

File tree

  • src/routes/beta/lib/firmware

src/routes/beta/lib/firmware/zmk.ts

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,15 +426,21 @@ config SHIELD_${options.folderName}_RIGHT
426426

427427
function generateConf(config: FullGeometry, options: ZMKOptions, side: keyof FullGeometry) {
428428
const wired = options.microcontroller === Microcontroller.LemonWired
429-
const usbSplit = wired && options.splitTransport !== SplitTransport.Uart
430-
const isCentral = side === 'unibody' || side === options.centralSide
429+
const split = side !== 'unibody'
430+
const usbSplit = wired && split && options.splitTransport !== SplitTransport.Uart
431+
const isCentral = split && side === options.centralSide
431432
// Phase 1: the wired path doesn't yet ship a working WS2812 driver
432433
// (RP2040 needs a PIO-based ws2812 binding the upstream Zephyr 3.5 doesn't
433434
// have). Force underglow off so the build completes; revisit once the wired
434435
// board overlay grows a working LED strip definition.
435436
const underglow = options.underGlowAtStart && !wired
436437
const hasPointing = Object.values(options.peripherals).some(p => p.pmw3610 || p.cirque)
437438
const hasEncoder = Object.values(options.peripherals).some(p => p.encoder)
439+
// USB device strings. Peripheral re-uses the central PID — the host only
440+
// ever sees the central, so a unique PID on the peripheral has no observer.
441+
// The 16-char limit on ZMK_KEYBOARD_NAME is BLE-specific; USB strings have
442+
// no such cap.
443+
const productName = options.keyboardName + (usbSplit && !isCentral ? ' (peripheral)' : '')
438444
return [
439445
'CONFIG_SPI=y',
440446
'',
@@ -456,24 +462,47 @@ function generateConf(config: FullGeometry, options: ZMKOptions, side: keyof Ful
456462
'CONFIG_PINCTRL=y',
457463
'CONFIG_GPIO=y',
458464
'',
465+
'# Zephyr 3.5 RP2040 flash driver is broken in this fork — non-persistent',
466+
'# settings until that lands. The board defconfig sets these to y; we override.',
467+
'CONFIG_FLASH=n',
468+
'CONFIG_NVS=n',
469+
'CONFIG_SETTINGS=n',
470+
'',
459471
...(usbSplit
460472
? [
461473
'# Pico-PIO-USB split transport: legacy USB device stack on the',
462474
'# native USB-C carries HID (central) / split bulk endpoints (peripheral);',
463475
'# the central also runs Pico-PIO-USB as a UHC on the Link port.',
464476
'CONFIG_USB_DEVICE_STACK=y',
477+
`CONFIG_USB_DEVICE_PRODUCT="${productName}"`,
478+
`CONFIG_USB_DEVICE_VID=${options.vid}`,
479+
`CONFIG_USB_DEVICE_PID=${options.pid}`,
465480
'CONFIG_USB_CDC_ACM=y',
466481
'CONFIG_SERIAL=y',
467482
'CONFIG_UART_INTERRUPT_DRIVEN=y',
468483
'CONFIG_UART_LINE_CTRL=y',
469484
'CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=' + (isCentral ? 'y' : 'n'),
470485
...(isCentral ? ['CONFIG_ZMK_USB=y'] : []),
486+
...(isCentral && options.enableConsole
487+
? [
488+
'',
489+
'# CDC ACM console on the central native USB-C (alongside HID).',
490+
'CONFIG_CONSOLE=y',
491+
'CONFIG_UART_CONSOLE=y',
492+
'CONFIG_LOG=y',
493+
'CONFIG_LOG_PRINTK=y',
494+
'CONFIG_LOG_BACKEND_UART=y',
495+
'CONFIG_LOG_DEFAULT_LEVEL=2',
496+
]
497+
: []),
471498
]
472-
: [
499+
: split
500+
? [
473501
'# Wired-split UART transport on GP0/GP1',
474502
'CONFIG_ZMK_SPLIT_WIRED=y',
475-
]),
476-
'CONFIG_ZMK_SPLIT=y',
503+
]
504+
: []),
505+
...(split ? ['CONFIG_ZMK_SPLIT=y'] : []),
477506
]
478507
: []),
479508
'',

0 commit comments

Comments
 (0)