@typecad/framework-zephyr 1.0.0-alpha.13 → 1.0.0-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +13 -1
  2. package/dist/chips/controllers.d.ts +28 -8
  3. package/dist/chips/controllers.js +49 -12
  4. package/dist/chips/resolve.js +32 -6
  5. package/dist/chips/types.d.ts +63 -12
  6. package/dist/chips/xiao-ble.js +12 -0
  7. package/dist/dt-config/kconfig.d.ts +11 -0
  8. package/dist/dt-config/kconfig.js +1 -1
  9. package/dist/dt-config/overlay.js +85 -0
  10. package/dist/framework.manifest.d.ts +20 -30
  11. package/dist/framework.manifest.js +12 -3
  12. package/dist/lowering/adc.d.ts +7 -4
  13. package/dist/lowering/adc.js +25 -11
  14. package/dist/lowering/gpio.js +9 -6
  15. package/dist/lowering/mqtt.js +9 -1
  16. package/dist/lowering/pulse.js +7 -7
  17. package/dist/lowering/pwm.d.ts +21 -3
  18. package/dist/lowering/pwm.js +28 -4
  19. package/dist/lowering/spi.js +2 -2
  20. package/dist/lowering/tone.js +3 -2
  21. package/dist/lowering/wifi.js +28 -5
  22. package/dist/strategy.js +56 -4
  23. package/dist/toolchain/debug-config.js +1 -1
  24. package/dist/toolchain/index.d.ts +1 -1
  25. package/dist/toolchain/index.js +83 -8
  26. package/dist/toolchain/scaffold.d.ts +9 -0
  27. package/dist/toolchain/scaffold.js +45 -0
  28. package/dist/toolchain/west-discover.d.ts +4 -1
  29. package/dist/toolchain/west-discover.js +2 -0
  30. package/dist/toolchain/west-spawn.js +17 -5
  31. package/package.json +5 -5
  32. package/src/chips/controllers.ts +61 -12
  33. package/src/chips/resolve.ts +32 -5
  34. package/src/chips/types.ts +63 -12
  35. package/src/chips/xiao-ble.ts +82 -70
  36. package/src/dt-config/kconfig.ts +12 -1
  37. package/src/dt-config/overlay.ts +546 -450
  38. package/src/framework.manifest.ts +12 -3
  39. package/src/lowering/adc.ts +28 -12
  40. package/src/lowering/gpio.ts +9 -6
  41. package/src/lowering/mqtt.ts +9 -1
  42. package/src/lowering/pulse.ts +7 -7
  43. package/src/lowering/pwm.ts +29 -4
  44. package/src/lowering/spi.ts +2 -2
  45. package/src/lowering/tone.ts +3 -3
  46. package/src/lowering/wifi.ts +29 -5
  47. package/src/strategy.ts +52 -4
  48. package/src/toolchain/debug-config.ts +1 -1
  49. package/src/toolchain/index.ts +645 -565
  50. package/src/toolchain/scaffold.ts +43 -0
  51. package/src/toolchain/west-discover.ts +321 -316
  52. package/src/toolchain/west-spawn.ts +17 -5
@@ -1,70 +1,82 @@
1
- // ---------------------------------------------------------------------------
2
- // Seeed Studio XIAO nRF52840 — Zephyr board descriptor
3
- //
4
- // Board target: `xiao_ble` (mainline Zephyr, boards/seeed/xiao_ble).
5
- // The onboard user LED is active-low and exposed as the DT alias `led0`.
6
- // ---------------------------------------------------------------------------
7
-
8
- import type { ZephyrChipDescriptor } from './types.js';
9
-
10
- export const XIAO_BLE: ZephyrChipDescriptor = {
11
- id: 'xiao_ble',
12
- soc: 'nrf52840',
13
- gpioController: 'gpio0',
14
- gpio: {
15
- dtSpecs: [
16
- // Onboard RGB LEDs active-low (GPIO_ACTIVE_LOW in xiao_ble_common.dtsi).
17
- // Verified against the board's `aliases { led0 = &led0; led1 = &led1; led2 = &led2; }`.
18
- { pin: 26, dtSpec: 'led0' }, // Red (P0.26)
19
- { pin: 30, dtSpec: 'led1' }, // Green (P0.30)
20
- { pin: 6, dtSpec: 'led2' }, // Blue (P0.06)
21
- ],
22
- // The XIAO nRF52840 has a user button on P0.04, but mainline Zephyr's
23
- // xiao_ble board (verified against Zephyr 4.3.99) does NOT expose it as a
24
- // DT `sw0` alias there is no gpio-keys node in xiao_ble.dts. Emitting
25
- // GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios) therefore fails to compile
26
- // ('DT_N_ALIAS_sw0_... was not declared'). Until a button node + alias is
27
- // added (via an overlay or an upstream board update), interruptPins stays
28
- // empty: attachInterrupt on this board lowers to the no-DT-spec comment
29
- // fallback rather than a hard compile error.
30
- interruptPins: [],
31
- },
32
- // The XIAO connector wiring (from seeed_xiao_connector.dtsi + xiao_ble-pinctrl.dtsi):
33
- // xiao_i2c → i2c1 (SDA P0.04/D4, SCL P0.05/D5)
34
- // xiao_spi → spi2 (SCK P1.13/D8, MOSI P1.15/D10, MISO P1.14/D9)
35
- // xiao_serial → uart0 (TX P1.11/D6, RX P1.12/D7)
36
- // The board DTS leaves i2c0/spi0/spi1 disabled (shared instances).
37
- i2c: {
38
- controllers: [{ nodeLabel: 'i2c1' }],
39
- },
40
- spi: {
41
- controllers: [{ nodeLabel: 'spi2' }],
42
- },
43
- uart: {
44
- controllers: [{ nodeLabel: 'uart0' }],
45
- },
46
- pwm: {
47
- // pwm-led0 drives the board PWM LED (PWM_OUT0 on P0.17, inverted).
48
- specs: [{ pin: 17, dtSpec: 'pwm-led0' }],
49
- },
50
- adc: {
51
- // SAADC node is `adc`; no pre-declared channels. XIAO D0–D3 = AIN0–AIN3
52
- // (P0.02/P0.03/P0.28/P0.29). Internal VREF ~0.6V with VDD/4 gain ⇒ 3000mV.
53
- nodeLabel: 'adc',
54
- resolution: 12,
55
- vrefMv: 3000,
56
- channels: [
57
- { pin: 2, channel: 0 }, // P0.02 / D0 / AIN0
58
- { pin: 3, channel: 1 }, // P0.03 / D1 / AIN1
59
- { pin: 28, channel: 2 }, // P0.28 / D2 / AIN2
60
- { pin: 29, channel: 3 }, // P0.29 / D3 / AIN3
61
- ],
62
- },
63
- wdt: { nodeLabel: 'wdt0' },
64
- // Hardware timer: nRF RTC1 is the free counter (RTC0 is kernel-owned by the
65
- // softdevice/clock driver). The hwtimer lowering drives it as a Zephyr
66
- // counter device (counter_start/stop + a top-value alarm for set_frequency).
67
- // Verified against the nRF52840 SoC dtsi (rtc0/rtc1 nodes). The kernel uses
68
- // RTC0 for the system tick; RTC1 is available for application use.
69
- hwtimer: { controllers: [{ nodeLabel: 'rtc1' }] },
70
- };
1
+ // ---------------------------------------------------------------------------
2
+ // Seeed Studio XIAO nRF52840 — Zephyr board descriptor
3
+ //
4
+ // Board target: `xiao_ble` (mainline Zephyr, boards/seeed/xiao_ble).
5
+ // The onboard user LED is active-low and exposed as the DT alias `led0`.
6
+ // ---------------------------------------------------------------------------
7
+
8
+ import type { ZephyrChipDescriptor } from './types.js';
9
+
10
+ export const XIAO_BLE: ZephyrChipDescriptor = {
11
+ id: 'xiao_ble',
12
+ soc: 'nrf52840',
13
+ gpioController: 'gpio0',
14
+ // GPIO is split across two devicetree controllers: gpio0 (P0.00–P0.31)
15
+ // and gpio1 (P1.00–P1.15, HAL pins 32–47). Declaring the split makes the
16
+ // raw path emit the port-relative index against gpio1 (P1.11 = raw 11),
17
+ // which NRF_GPIO_PIN_MAP(1, 11) resolves to absolute pin 43 the same
18
+ // physical pin the old single-controller form reached only by accident:
19
+ // gpio0 + global 43 also maps to 43 (MAP(0, 43) = 43), but that form
20
+ // trips the generic layer's port_pin_mask __ASSERT ("Unsupported pin",
21
+ // gpio0's mask covers 0–31) on any assert-enabled build.
22
+ gpioControllers: [
23
+ { nodelabel: 'gpio0', minPin: 0, maxPin: 31 },
24
+ { nodelabel: 'gpio1', minPin: 32, maxPin: 47 },
25
+ ],
26
+ gpio: {
27
+ dtSpecs: [
28
+ // Onboard RGB LEDs active-low (GPIO_ACTIVE_LOW in xiao_ble_common.dtsi).
29
+ // Verified against the board's `aliases { led0 = &led0; led1 = &led1; led2 = &led2; }`.
30
+ { pin: 26, dtSpec: 'led0' }, // Red (P0.26)
31
+ { pin: 30, dtSpec: 'led1' }, // Green (P0.30)
32
+ { pin: 6, dtSpec: 'led2' }, // Blue (P0.06)
33
+ ],
34
+ // The XIAO nRF52840 has a user button on P0.04, but mainline Zephyr's
35
+ // xiao_ble board (verified against Zephyr 4.3.99) does NOT expose it as a
36
+ // DT `sw0` alias there is no gpio-keys node in xiao_ble.dts. Emitting
37
+ // GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios) therefore fails to compile
38
+ // ('DT_N_ALIAS_sw0_... was not declared'). Until a button node + alias is
39
+ // added (via an overlay or an upstream board update), interruptPins stays
40
+ // empty: attachInterrupt on this board lowers to the no-DT-spec comment
41
+ // fallback rather than a hard compile error.
42
+ interruptPins: [],
43
+ },
44
+ // The XIAO connector wiring (from seeed_xiao_connector.dtsi + xiao_ble-pinctrl.dtsi):
45
+ // xiao_i2c → i2c1 (SDA P0.04/D4, SCL P0.05/D5)
46
+ // xiao_spi → spi2 (SCK P1.13/D8, MOSI P1.15/D10, MISO P1.14/D9)
47
+ // xiao_serial → uart0 (TX P1.11/D6, RX P1.12/D7)
48
+ // The board DTS leaves i2c0/spi0/spi1 disabled (shared instances).
49
+ i2c: {
50
+ controllers: [{ nodeLabel: 'i2c1' }],
51
+ },
52
+ spi: {
53
+ controllers: [{ nodeLabel: 'spi2' }],
54
+ },
55
+ uart: {
56
+ controllers: [{ nodeLabel: 'uart0' }],
57
+ },
58
+ pwm: {
59
+ // pwm-led0 drives the board PWM LED (PWM_OUT0 on P0.17, inverted).
60
+ specs: [{ pin: 17, dtSpec: 'pwm-led0' }],
61
+ },
62
+ adc: {
63
+ // SAADC node is `adc`; no pre-declared channels. XIAO D0–D3 = AIN0–AIN3
64
+ // (P0.02/P0.03/P0.28/P0.29). Internal VREF ~0.6V with VDD/4 gain 3000mV.
65
+ nodeLabel: 'adc',
66
+ resolution: 12,
67
+ vrefMv: 3000,
68
+ channels: [
69
+ { pin: 2, channel: 0 }, // P0.02 / D0 / AIN0
70
+ { pin: 3, channel: 1 }, // P0.03 / D1 / AIN1
71
+ { pin: 28, channel: 2 }, // P0.28 / D2 / AIN2
72
+ { pin: 29, channel: 3 }, // P0.29 / D3 / AIN3
73
+ ],
74
+ },
75
+ wdt: { nodeLabel: 'wdt0' },
76
+ // Hardware timer: nRF RTC1 is the free counter (RTC0 is kernel-owned by the
77
+ // softdevice/clock driver). The hwtimer lowering drives it as a Zephyr
78
+ // counter device (counter_start/stop + a top-value alarm for set_frequency).
79
+ // Verified against the nRF52840 SoC dtsi (rtc0/rtc1 nodes). The kernel uses
80
+ // RTC0 for the system tick; RTC1 is available for application use.
81
+ hwtimer: { controllers: [{ nodeLabel: 'rtc1' }] },
82
+ };
@@ -35,6 +35,17 @@ export interface KconfigUsage {
35
35
  /** PSRAM type ('opi' | 'quad') when the target board has PSRAM. Emits the
36
36
  * CONFIG_SPIRAM symbols so the ESP heap serves PSRAM for canvas allocations. */
37
37
  psram?: 'opi' | 'quad';
38
+ /** HAL pin numbers the program reads with adc.* — scanned from the emitted
39
+ * `__tc_adc<N>_setup()` calls at compile time. Only the overlay generator
40
+ * consumes this (to rewrite the ADC node's pinctrl-0 to the used channels
41
+ * on SoCs that need pad muxing, e.g. STM32); prj.conf ignores it. */
42
+ adcReadPins?: readonly number[];
43
+ /** HAL pin numbers the program drives with pwm.* — scanned from the
44
+ * emitted `__tc_pwm_*` spec references at compile time. Only the overlay
45
+ * generator consumes this (synthesized pwm-leds consumers + aliases are
46
+ * emitted per used pin, so the DT carries no dead channels); prj.conf
47
+ * ignores it. */
48
+ pwmUsedPins?: readonly number[];
38
49
  }
39
50
 
40
51
  /**
@@ -123,7 +134,7 @@ export function resolveKconfigFragments(
123
134
  // (without it, Kconfig silently forces them all to n).
124
135
  m.set('CONFIG_NETWORKING', 'y');
125
136
  m.set('CONFIG_WIFI', 'y');
126
- m.set('CONFIG_WIFI_ESP32', 'y'); // ESP32-specific driver (sole WiFi target)
137
+ m.set('CONFIG_WIFI_ESP32', 'y'); // family-wide ESP32 driver (esp32/s3/c3/c6)
127
138
  m.set('CONFIG_NET_L2_ETHERNET', 'y');
128
139
  m.set('CONFIG_NET_IPV4', 'y');
129
140
  m.set('CONFIG_NET_UDP', 'y'); // transitive dep of NET_DHCPV4